1*7c3d14c8STreehugger Robot // Check that a stack unwinding algorithm works corretly even with the assembly 2*7c3d14c8STreehugger Robot // instrumentation. 3*7c3d14c8STreehugger Robot 4*7c3d14c8STreehugger Robot // REQUIRES: x86_64-target-arch 5*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -g -O1 %s -fno-inline-functions -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mllvm -asan-instrument-assembly -o %t && not %run %t 2>&1 | FileCheck %s 6*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -g -O1 %s -fno-inline-functions -fomit-frame-pointer -momit-leaf-frame-pointer -mllvm -asan-instrument-assembly -o %t && not %run %t 2>&1 | FileCheck %s 7*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -g0 -O1 %s -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -fno-inline-functions -fomit-frame-pointer -momit-leaf-frame-pointer -mllvm -asan-instrument-assembly -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-nounwind 8*7c3d14c8STreehugger Robot 9*7c3d14c8STreehugger Robot #include <cstddef> 10*7c3d14c8STreehugger Robot 11*7c3d14c8STreehugger Robot // CHECK: READ of size 4 12*7c3d14c8STreehugger Robot // CHECK-NEXT: {{#0 0x[0-9a-fA-F]+ in foo}} 13*7c3d14c8STreehugger Robot // CHECK-NEXT: {{#1 0x[0-9a-fA-F]+ in main}} 14*7c3d14c8STreehugger Robot 15*7c3d14c8STreehugger Robot // CHECK-nounwind: READ of size 4 16*7c3d14c8STreehugger Robot // CHECK-nounwind-NEXT: {{#0 0x[0-9a-fA-F]+ in foo}} 17*7c3d14c8STreehugger Robot foo(size_t n,int * buffer)18*7c3d14c8STreehugger Robot__attribute__((noinline)) int foo(size_t n, int *buffer) { 19*7c3d14c8STreehugger Robot int r; 20*7c3d14c8STreehugger Robot __asm__("movl (%[buffer], %[n], 4), %[r] \n\t" 21*7c3d14c8STreehugger Robot : [r] "=r"(r) 22*7c3d14c8STreehugger Robot : [buffer] "r"(buffer), [n] "r"(n) 23*7c3d14c8STreehugger Robot : "memory"); 24*7c3d14c8STreehugger Robot return r; 25*7c3d14c8STreehugger Robot } 26*7c3d14c8STreehugger Robot main()27*7c3d14c8STreehugger Robotint main() { 28*7c3d14c8STreehugger Robot const size_t n = 16; 29*7c3d14c8STreehugger Robot int *buffer = new int[n]; 30*7c3d14c8STreehugger Robot foo(n, buffer); 31*7c3d14c8STreehugger Robot delete[] buffer; 32*7c3d14c8STreehugger Robot return 0; 33*7c3d14c8STreehugger Robot } 34