[compiler-rt][asan] Add noinline to use-after-scope testcases
authorJinsong Ji <jji@us.ibm.com>
Wed, 27 May 2020 03:39:59 +0000 (03:39 +0000)
committerJinsong Ji <jji@us.ibm.com>
Wed, 27 May 2020 14:05:02 +0000 (14:05 +0000)
Some testcases are unexpectedly passing with NPM.
This is because the target functions are inlined in NPM.

I think we should add noinline attribute to keep these test points.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D79648

compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp
compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp
compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp

index 8d4f772..43c1710 100644 (file)
@@ -5,7 +5,7 @@
 
 struct IntHolder {
   explicit IntHolder(int *val = 0) : val_(val) { }
-  ~IntHolder() {
+  __attribute__((noinline)) ~IntHolder() {
     printf("Value: %d\n", *val_);  // BOOM
     // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
     // CHECK:  #0 0x{{.*}} in IntHolder::~IntHolder{{.*}}.cpp:[[@LINE-2]]
index b97f312..2cfc7ce 100644 (file)
@@ -8,7 +8,7 @@ struct IntHolder {
 
 const IntHolder *saved;
 
-void save(const IntHolder &holder) {
+__attribute__((noinline)) void save(const IntHolder &holder) {
   saved = &holder;
 }
 
index 99e4f25..3e6f52a 100644 (file)
@@ -3,7 +3,7 @@
 
 
 struct IntHolder {
-  const IntHolder& Self() const {
+  __attribute__((noinline)) const IntHolder &Self() const {
     return *this;
   }
   int val = 3;