From 7f1c389c71c673874b77a4e85f9a67cf357dbf3c Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Thu, 20 Mar 2014 11:16:34 +0000 Subject: [PATCH] [ASan] Add -asan-module to the ASan .ll tests. After the -asan pass had been split into -asan (function-level) and -asan-module (module-level) some of the tests have silently stopped working, because they didn't instrument the globals anymore. We've decided to have every test using both passes, irrespective of the presence of globals in it. llvm-svn: 204335 --- .../Instrumentation/AddressSanitizer/X86/bug_11395.ll | 2 +- test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll | 2 +- test/Instrumentation/AddressSanitizer/basic.ll | 2 +- test/Instrumentation/AddressSanitizer/coverage.ll | 4 ++-- .../do-not-instrument-internal-globals.ll | 2 +- .../AddressSanitizer/do-not-touch-odr-global.ll | 11 ++++++++--- .../AddressSanitizer/do-not-touch-threadlocal.ll | 4 ++-- test/Instrumentation/AddressSanitizer/freebsd.ll | 4 ++-- .../AddressSanitizer/instrument-no-return.ll | 2 +- .../AddressSanitizer/instrument_load_then_store.ll | 4 ++-- .../AddressSanitizer/keep-instrumented_functions.ll | 2 +- test/Instrumentation/AddressSanitizer/lifetime-uar.ll | 2 +- test/Instrumentation/AddressSanitizer/lifetime.ll | 2 +- .../AddressSanitizer/stack-poisoning.ll | 4 ++-- test/Instrumentation/AddressSanitizer/stack_layout.ll | 2 +- test/Instrumentation/AddressSanitizer/test64.ll | 2 +- 16 files changed, 28 insertions(+), 23 deletions(-) diff --git a/test/Instrumentation/AddressSanitizer/X86/bug_11395.ll b/test/Instrumentation/AddressSanitizer/X86/bug_11395.ll index 2c4d82eb1ae..63477aacd8f 100644 --- a/test/Instrumentation/AddressSanitizer/X86/bug_11395.ll +++ b/test/Instrumentation/AddressSanitizer/X86/bug_11395.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -asan -S | llc -o /dev/null +; RUN: opt < %s -asan -asan-module -S | llc -o /dev/null ; The bug manifests as a reg alloc failure: ; error: ran out of registers during register allocation ; ModuleID = 'z.o' diff --git a/test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll b/test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll index 1087c9a58ff..75adf4061c0 100644 --- a/test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll +++ b/test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -asan -S | FileCheck %s +; RUN: opt < %s -basicaa -gvn -asan -asan-module -S | FileCheck %s ; ASAN conflicts with load widening iff the widened load accesses data out of bounds ; (while the original unwidened loads do not). ; http://code.google.com/p/address-sanitizer/issues/detail?id=20#c1 diff --git a/test/Instrumentation/AddressSanitizer/basic.ll b/test/Instrumentation/AddressSanitizer/basic.ll index fb32e704af8..4863a3dea96 100644 --- a/test/Instrumentation/AddressSanitizer/basic.ll +++ b/test/Instrumentation/AddressSanitizer/basic.ll @@ -1,6 +1,6 @@ ; Test basic address sanitizer instrumentation. ; -; RUN: opt < %s -asan -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Instrumentation/AddressSanitizer/coverage.ll b/test/Instrumentation/AddressSanitizer/coverage.ll index 6697f4b0f24..06701325db8 100644 --- a/test/Instrumentation/AddressSanitizer/coverage.ll +++ b/test/Instrumentation/AddressSanitizer/coverage.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -asan -asan-coverage=1 -S | FileCheck %s --check-prefix=CHECK1 -; RUN: opt < %s -asan -asan-coverage=2 -S | FileCheck %s --check-prefix=CHECK2 +; RUN: opt < %s -asan -asan-module -asan-coverage=1 -S | FileCheck %s --check-prefix=CHECK1 +; RUN: opt < %s -asan -asan-module -asan-coverage=2 -S | FileCheck %s --check-prefix=CHECK2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" define void @foo(i32* %a) sanitize_address { diff --git a/test/Instrumentation/AddressSanitizer/do-not-instrument-internal-globals.ll b/test/Instrumentation/AddressSanitizer/do-not-instrument-internal-globals.ll index 0928c494154..cff83ab718b 100644 --- a/test/Instrumentation/AddressSanitizer/do-not-instrument-internal-globals.ll +++ b/test/Instrumentation/AddressSanitizer/do-not-instrument-internal-globals.ll @@ -1,6 +1,6 @@ ; This test checks that we are not instrumenting globals ; that we created ourselves. -; RUN: opt < %s -asan -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Instrumentation/AddressSanitizer/do-not-touch-odr-global.ll b/test/Instrumentation/AddressSanitizer/do-not-touch-odr-global.ll index 1687877849c..97752612297 100644 --- a/test/Instrumentation/AddressSanitizer/do-not-touch-odr-global.ll +++ b/test/Instrumentation/AddressSanitizer/do-not-touch-odr-global.ll @@ -1,6 +1,11 @@ -; RUN: opt < %s -asan -S | FileCheck %s +; This test checks that we instrument regular globals, but do not touch +; the linkonce_odr ones. +; RUN: opt < %s -asan -asan-module -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" ; no action should be taken for these globals -@v1 = linkonce_odr constant i8 1 -; CHECK-NOT: __asan_register_globals +@global_noinst = linkonce_odr constant [2 x i8] [i8 1, i8 2] +@global_inst = private constant [2 x i8] [i8 1, i8 2] +; CHECK-NOT: {{asan_gen.*global_noinst}} +; CHECK: {{asan_gen.*global_inst}} +; CHECK: @asan.module_ctor diff --git a/test/Instrumentation/AddressSanitizer/do-not-touch-threadlocal.ll b/test/Instrumentation/AddressSanitizer/do-not-touch-threadlocal.ll index 89644d4a943..f863f44d512 100644 --- a/test/Instrumentation/AddressSanitizer/do-not-touch-threadlocal.ll +++ b/test/Instrumentation/AddressSanitizer/do-not-touch-threadlocal.ll @@ -1,6 +1,6 @@ -; RUN: opt < %s -asan -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" ; no action should be taken for thread locals @xxx = thread_local global i32 0, align 4 -; CHECK-NOT: __asan_register_globals +; CHECK-NOT: {{call.*__asan_register_globals}} diff --git a/test/Instrumentation/AddressSanitizer/freebsd.ll b/test/Instrumentation/AddressSanitizer/freebsd.ll index 26fee787d9a..359529fc8fc 100644 --- a/test/Instrumentation/AddressSanitizer/freebsd.ll +++ b/test/Instrumentation/AddressSanitizer/freebsd.ll @@ -1,9 +1,9 @@ -; RUN: opt < %s -asan -S \ +; RUN: opt < %s -asan -asan-module -S \ ; RUN: -mtriple=i386-unknown-freebsd \ ; RUN: -default-data-layout="e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" | \ ; RUN: FileCheck --check-prefix=CHECK-32 %s -; RUN: opt < %s -asan -S \ +; RUN: opt < %s -asan -asan-module -S \ ; RUN: -mtriple=x86_64-unknown-freebsd \ ; RUN: -default-data-layout="e-m:e-i64:64-f80:128-n8:16:32:64-S128" | \ ; RUN: FileCheck --check-prefix=CHECK-64 %s diff --git a/test/Instrumentation/AddressSanitizer/instrument-no-return.ll b/test/Instrumentation/AddressSanitizer/instrument-no-return.ll index 2d835a34080..5d5c592c3f4 100644 --- a/test/Instrumentation/AddressSanitizer/instrument-no-return.ll +++ b/test/Instrumentation/AddressSanitizer/instrument-no-return.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -asan -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -S | FileCheck %s ; AddressSanitizer must insert __asan_handle_no_return ; before every noreturn call or invoke. diff --git a/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll b/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll index 23cf6d28ec6..195785ff5e3 100644 --- a/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll +++ b/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll @@ -1,6 +1,6 @@ ; Test that AddressSanitizer instruments "(*a)++" only once. -; RUN: opt < %s -asan -S -asan-opt=1 | FileCheck %s -check-prefix=OPT1 -; RUN: opt < %s -asan -S -asan-opt=0 | FileCheck %s -check-prefix=OPT0 +; RUN: opt < %s -asan -asan-module -S -asan-opt=1 | FileCheck %s -check-prefix=OPT1 +; RUN: opt < %s -asan -asan-module -S -asan-opt=0 | FileCheck %s -check-prefix=OPT0 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Instrumentation/AddressSanitizer/keep-instrumented_functions.ll b/test/Instrumentation/AddressSanitizer/keep-instrumented_functions.ll index ff3bbb047ff..8726b8e5f9c 100644 --- a/test/Instrumentation/AddressSanitizer/keep-instrumented_functions.ll +++ b/test/Instrumentation/AddressSanitizer/keep-instrumented_functions.ll @@ -1,5 +1,5 @@ ; Test the -asan-keep-uninstrumented-functions flag: FOO should get cloned -; RUN: opt < %s -asan -asan-keep-uninstrumented-functions -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -asan-keep-uninstrumented-functions -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Instrumentation/AddressSanitizer/lifetime-uar.ll b/test/Instrumentation/AddressSanitizer/lifetime-uar.ll index 21eaf7f1541..25577de445b 100644 --- a/test/Instrumentation/AddressSanitizer/lifetime-uar.ll +++ b/test/Instrumentation/AddressSanitizer/lifetime-uar.ll @@ -1,5 +1,5 @@ ; Test handling of llvm.lifetime intrinsics in UAR mode. -; RUN: opt < %s -asan -asan-use-after-return -asan-check-lifetime -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -asan-use-after-return -asan-check-lifetime -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" diff --git a/test/Instrumentation/AddressSanitizer/lifetime.ll b/test/Instrumentation/AddressSanitizer/lifetime.ll index d80331e3872..1961997dc01 100644 --- a/test/Instrumentation/AddressSanitizer/lifetime.ll +++ b/test/Instrumentation/AddressSanitizer/lifetime.ll @@ -1,5 +1,5 @@ ; Test hanlding of llvm.lifetime intrinsics. -; RUN: opt < %s -asan -asan-check-lifetime -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -asan-check-lifetime -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Instrumentation/AddressSanitizer/stack-poisoning.ll b/test/Instrumentation/AddressSanitizer/stack-poisoning.ll index 2d69879925b..6919e5353f2 100644 --- a/test/Instrumentation/AddressSanitizer/stack-poisoning.ll +++ b/test/Instrumentation/AddressSanitizer/stack-poisoning.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -asan -asan-use-after-return -S | FileCheck --check-prefix=CHECK-UAR %s -; RUN: opt < %s -asan -S | FileCheck --check-prefix=CHECK-PLAIN %s +; RUN: opt < %s -asan -asan-module -asan-use-after-return -S | FileCheck --check-prefix=CHECK-UAR %s +; RUN: opt < %s -asan -asan-module -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" diff --git a/test/Instrumentation/AddressSanitizer/stack_layout.ll b/test/Instrumentation/AddressSanitizer/stack_layout.ll index 6fa3cfc9df2..c027acf3e4f 100644 --- a/test/Instrumentation/AddressSanitizer/stack_layout.ll +++ b/test/Instrumentation/AddressSanitizer/stack_layout.ll @@ -1,6 +1,6 @@ ; Test the ASan's stack layout. ; More tests in tests/Transforms/Utils/ASanStackFrameLayoutTest.cpp -; RUN: opt < %s -asan -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Instrumentation/AddressSanitizer/test64.ll b/test/Instrumentation/AddressSanitizer/test64.ll index 6390644422c..4f3ed5b478c 100644 --- a/test/Instrumentation/AddressSanitizer/test64.ll +++ b/test/Instrumentation/AddressSanitizer/test64.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -asan -S | FileCheck %s +; RUN: opt < %s -asan -asan-module -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" define i32 @read_4_bytes(i32* %a) sanitize_address {