2016-05-06 18:25:22 +08:00
|
|
|
; Test that the scale (-asan-mapping-scale) and offset (-asan-mapping-offset) command-line options work as expected
|
|
|
|
;
|
[NewPM][ASan] Make ASan tests work under NPM
Under NPM, the asan-globals-md analysis is required but cannot be run
within the asan function pass due to module analyses not being able to
run from a function pass. So this pins all tests using "-asan" to the
legacy PM and adds a corresponding RUN line with
-passes='require<asan-globals-md>,function(asan)'.
Now all tests in Instrumentation/AddressSanitizer pass when
-enable-new-pm is by default on.
Tests were automatically converted using the following python script and
failures were manually fixed up.
import sys
for i in sys.argv:
with open(i, 'r') as f:
s = f.read()
with open(i, 'w') as f:
for l in s.splitlines():
if "RUN:" in l and ' -asan -asan-module ' in l and '\\' not in l:
f.write(l.replace(' -asan -asan-module ', ' -asan -asan-module -enable-new-pm=0 '))
f.write('\n')
f.write(l.replace(' -asan -asan-module ', " -passes='require<asan-globals-md>,function(asan),module(asan-module)' "))
f.write('\n')
elif "RUN:" in l and ' -asan ' in l and '\\' not in l:
f.write(l.replace(' -asan ', ' -asan -enable-new-pm=0 '))
f.write('\n')
f.write(l.replace(' -asan ', " -passes='require<asan-globals-md>,function(asan)' "))
f.write('\n')
else:
f.write(l)
f.write('\n')
See https://bugs.llvm.org/show_bug.cgi?id=46611.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D83921
2020-07-18 08:49:46 +08:00
|
|
|
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-mapping-offset 0xdeadbeef -S | FileCheck --check-prefix=CHECK-OFFSET %s
|
|
|
|
; RUN: opt < %s -passes='asan-pipeline' -asan-mapping-offset 0xdeadbeef -S | FileCheck --check-prefix=CHECK-OFFSET %s
|
|
|
|
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-mapping-scale 1 -S | FileCheck --check-prefix=CHECK-SCALE %s
|
|
|
|
; RUN: opt < %s -passes='asan-pipeline' -asan-mapping-scale 1 -S | FileCheck --check-prefix=CHECK-SCALE %s
|
|
|
|
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-mapping-offset 0xc0ffee -asan-mapping-scale 0 -S | FileCheck --check-prefix=CHECK-BOTH %s
|
|
|
|
; RUN: opt < %s -passes='asan-pipeline' -asan-mapping-offset 0xc0ffee -asan-mapping-scale 0 -S | FileCheck --check-prefix=CHECK-BOTH %s
|
2016-05-06 18:25:22 +08:00
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
define i32 @read_offset(i32* %a) sanitize_address {
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i32, i32* %a, align 4
|
|
|
|
ret i32 %tmp1
|
|
|
|
}
|
|
|
|
; CHECK-OFFSET-LABEL: @read_offset
|
|
|
|
; CHECK-OFFSET-NOT: ret
|
|
|
|
; CHECK-OFFSET: lshr {{.*}} 3
|
|
|
|
; CHECK-OFFSET-NEXT: add{{.*}}3735928559
|
|
|
|
; CHECK-OFFSET: ret
|
|
|
|
|
|
|
|
define i32 @read_scale(i32* %a) sanitize_address {
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i32, i32* %a, align 4
|
|
|
|
ret i32 %tmp1
|
|
|
|
}
|
|
|
|
; CHECK-SCALE-LABEL: @read_scale
|
|
|
|
; CHECK-SCALE-NOT: ret
|
|
|
|
; CHECK-SCALE: lshr {{.*}} 1
|
|
|
|
; CHECK-SCALE-NEXT: add{{.*}}
|
|
|
|
; CHECK-SCALE: ret
|
|
|
|
|
|
|
|
define i32 @read_both(i32* %a) sanitize_address {
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i32, i32* %a, align 4
|
|
|
|
ret i32 %tmp1
|
|
|
|
}
|
|
|
|
; CHECK-BOTH-LABEL: @read_both
|
|
|
|
; CHECK-BOTH-NOT: ret
|
|
|
|
; CHECK-BOTH: lshr {{.*}} 0
|
|
|
|
; CHECK-BOTH-NEXT: add{{.*}}12648430
|
|
|
|
; CHECK-BOTH: ret
|