test: fix test under ASAN and MSAN
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 28 Aug 2016 18:16:00 +0000 (18:16 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 28 Aug 2016 18:16:00 +0000 (18:16 +0000)
When we're running tests under ASAN or MSAN, they're compiled with -O1, which
enables tail call elimination. This causes backtrace_test to fail: the compiler
performs tail call elimination for call3_nothrow, but it can't for call3_throw,
leading to a mismatched frame count. Disable tail call elimination (and
inlining, just to be explicit) to avoid this.

Patch by Shoaib Meenai!

llvm-svn: 279935

libcxxabi/test/backtrace_test.pass.cpp

index 9954e8b..80346c0 100644 (file)
@@ -21,6 +21,7 @@ trace_function(struct _Unwind_Context* context, void* ntraced) {
   return _URC_NO_REASON;
 }
 
+__attribute__ ((__noinline__))
 void call3_throw(size_t* ntraced) {
   try {
     _Unwind_Backtrace(trace_function, ntraced);
@@ -29,10 +30,12 @@ void call3_throw(size_t* ntraced) {
   }
 }
 
+__attribute__ ((__noinline__, __disable_tail_calls__))
 void call3_nothrow(size_t* ntraced) {
   _Unwind_Backtrace(trace_function, ntraced);
 }
 
+__attribute__ ((__noinline__, __disable_tail_calls__))
 void call2(size_t* ntraced, bool do_throw) {
   if (do_throw) {
     call3_throw(ntraced);
@@ -41,6 +44,7 @@ void call2(size_t* ntraced, bool do_throw) {
   }
 }
 
+__attribute__ ((__noinline__, __disable_tail_calls__))
 void call1(size_t* ntraced, bool do_throw) {
   call2(ntraced, do_throw);
 }