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
61 lines
2.1 KiB
LLVM
61 lines
2.1 KiB
LLVM
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-after-return -S | FileCheck --check-prefix=CHECK-UAR %s
|
|
; RUN: opt < %s -passes='asan-pipeline' -asan-use-after-return -S | FileCheck --check-prefix=CHECK-UAR %s
|
|
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-after-return=0 -S | FileCheck --check-prefix=CHECK-PLAIN %s
|
|
; RUN: opt < %s -passes='asan-pipeline' -asan-use-after-return=0 -S | FileCheck --check-prefix=CHECK-PLAIN %s
|
|
target datalayout = "e-i64:64-f80:128-s:64-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
declare void @Foo(i8*)
|
|
|
|
define void @Bar() uwtable sanitize_address {
|
|
entry:
|
|
; CHECK-PLAIN-LABEL: Bar
|
|
; CHECK-PLAIN-NOT: label
|
|
; CHECK-PLAIN: ret void
|
|
|
|
; CHECK-UAR-LABEL: Bar
|
|
; CHECK-UAR: load i32, i32* @__asan_option_detect_stack_use_after_return
|
|
; CHECK-UAR: label
|
|
; CHECK-UAR: call i64 @__asan_stack_malloc_4
|
|
; CHECK-UAR: label
|
|
; Poison red zones.
|
|
; CHECK-UAR: store i64 -1007680412564983311
|
|
; CHECK-UAR: store i64 72057598113936114
|
|
; CHECK-UAR: store i32 -218959118
|
|
; CHECK-UAR: store i64 -868082074056920316
|
|
; CHECK-UAR: store i16 -3085
|
|
; CHECK-UAR: call void @Foo
|
|
; CHECK-UAR: call void @Foo
|
|
; CHECK-UAR: call void @Foo
|
|
; If LocalStackBase != OrigStackBase
|
|
; CHECK-UAR: label
|
|
; Then Block: poison the entire frame.
|
|
; CHECK-UAR: call void @__asan_set_shadow_f5(i64 %{{[0-9]+}}, i64 128)
|
|
; CHECK-UAR-NOT: store i64
|
|
; CHECK-UAR: label
|
|
; Else Block: no UAR frame. Only unpoison the redzones.
|
|
; CHECK-UAR: store i64 0
|
|
; CHECK-UAR: store i64 0
|
|
; CHECK-UAR: store i32 0
|
|
; CHECK-UAR: store i64 0
|
|
; CHECK-UAR: store i16 0
|
|
; CHECK-UAR-NOT: store
|
|
; CHECK-UAR: label
|
|
; Done, no more stores.
|
|
; CHECK-UAR-NOT: store
|
|
; CHECK-UAR: ret void
|
|
|
|
%x = alloca [20 x i8], align 16
|
|
%y = alloca [25 x i8], align 1
|
|
%z = alloca [500 x i8], align 1
|
|
%xx = getelementptr inbounds [20 x i8], [20 x i8]* %x, i64 0, i64 0
|
|
call void @Foo(i8* %xx)
|
|
%yy = getelementptr inbounds [25 x i8], [25 x i8]* %y, i64 0, i64 0
|
|
call void @Foo(i8* %yy)
|
|
%zz = getelementptr inbounds [500 x i8], [500 x i8]* %z, i64 0, i64 0
|
|
call void @Foo(i8* %zz)
|
|
ret void
|
|
}
|
|
|
|
|