2016-11-01 02:51:58 +08:00
|
|
|
; This test checks that instrumented global C (null terminated) strings are put into a special section on Darwin.
|
[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 -passes='asan-pipeline' -S | FileCheck %s
|
2016-11-01 02:51:58 +08:00
|
|
|
|
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-apple-macosx10.10.0"
|
|
|
|
|
|
|
|
; Should be put into __asan_cstring section:
|
|
|
|
@.str.1 = private unnamed_addr constant [13 x i8] c"Hello world.\00", align 1
|
|
|
|
@.str.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
|
|
|
|
|
2021-05-20 10:18:49 +08:00
|
|
|
; CHECK: @.str.1 = internal constant { [13 x i8], [19 x i8] } { [13 x i8] c"Hello world.\00", [19 x i8] zeroinitializer }, section "__TEXT,__asan_cstring,regular", align 32
|
|
|
|
; CHECK: @.str.2 = internal constant { [4 x i8], [28 x i8] } { [4 x i8] c"%s\0A\00", [28 x i8] zeroinitializer }, section "__TEXT,__asan_cstring,regular", align 32
|
2016-11-01 02:51:58 +08:00
|
|
|
|
|
|
|
; Shouldn't be put into special section:
|
|
|
|
@.str.3 = private unnamed_addr constant [4 x i8] c"\00\01\02\03", align 1
|
|
|
|
@.str.4 = private unnamed_addr global [7 x i8] c"Hello.\00", align 1
|
|
|
|
@.str.5 = private unnamed_addr constant [8 x i8] c"Hello.\00\00", align 1
|
|
|
|
|
2021-05-20 10:18:49 +08:00
|
|
|
; CHECK: @.str.3 = internal constant { [4 x i8], [28 x i8] } { [4 x i8] c"\00\01\02\03", [28 x i8] zeroinitializer }, align 32
|
|
|
|
; CHECK: @.str.4 = private global { [7 x i8], [25 x i8] } { [7 x i8] c"Hello.\00", [25 x i8] zeroinitializer }, align 32
|
|
|
|
; CHECK: @.str.5 = internal constant { [8 x i8], [24 x i8] } { [8 x i8] c"Hello.\00\00", [24 x i8] zeroinitializer }, align 32
|