mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
92a77f4b5e
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
43 lines
1.8 KiB
LLVM
43 lines
1.8 KiB
LLVM
; Test that global metadata is placed in a separate section on Mach-O platforms,
|
|
; allowing dead stripping to be performed, and that the appropriate runtime
|
|
; routines are invoked.
|
|
|
|
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=1 -S | FileCheck %s
|
|
; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=1 -S | FileCheck %s
|
|
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-apple-macosx10.11.0"
|
|
|
|
@global = global [1 x i32] zeroinitializer, align 4
|
|
|
|
!llvm.asan.globals = !{!0}
|
|
|
|
!0 = !{[1 x i32]* @global, !1, !"global", i1 false, i1 false}
|
|
!1 = !{!"test-globals.c", i32 1, i32 5}
|
|
|
|
|
|
; Find the metadata for @global:
|
|
; CHECK: [[METADATA:@.+]] = internal global {{.*}} @global {{.*}} section "__DATA,__asan_globals,regular"
|
|
|
|
; Find the liveness binder for @global and its metadata:
|
|
; CHECK: @__asan_binder_global = internal global {{.*}} @global {{.*}} [[METADATA]] {{.*}} section "__DATA,__asan_liveness,regular,live_support"
|
|
|
|
; The binder has to be inserted to llvm.compiler.used to avoid being stripped
|
|
; during LTO.
|
|
; CHECK: @llvm.compiler.used {{.*}} @__asan_binder_global {{.*}} section "llvm.metadata"
|
|
|
|
; Test that there is the flag global variable:
|
|
; CHECK: @___asan_globals_registered = common hidden global i64 0
|
|
|
|
; Test that __asan_register_image_globals is invoked from the constructor:
|
|
; CHECK-LABEL: define internal void @asan.module_ctor
|
|
; CHECK-NOT: ret
|
|
; CHECK: call void @__asan_register_image_globals(i64 ptrtoint (i64* @___asan_globals_registered to i64))
|
|
; CHECK: ret
|
|
|
|
; Test that __asan_unregister_image_globals is invoked from the destructor:
|
|
; CHECK-LABEL: define internal void @asan.module_dtor
|
|
; CHECK-NOT: ret
|
|
; CHECK: call void @__asan_unregister_image_globals(i64 ptrtoint (i64* @___asan_globals_registered to i64))
|
|
; CHECK: ret
|