Prevent calls to __jit_debug_register_code from being optimized out.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 16 Jan 2014 04:50:58 +0000 (04:50 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 16 Jan 2014 04:50:58 +0000 (04:50 +0000)
Patch by Andrew MacPherson. I just tweaked the comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199350 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp

index 603c526d06e3c6df586d203880f36ae298ee5e20..60adc9b383d0d510b393362cb11d0e5535da2568 100644 (file)
@@ -47,7 +47,11 @@ extern "C" {
   struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 };
 
   // Debuggers puts a breakpoint in this function.
-  LLVM_ATTRIBUTE_NOINLINE void __jit_debug_register_code() { }
+  LLVM_ATTRIBUTE_NOINLINE void __jit_debug_register_code() {
+    // The noinline and the asm prevent calls to this function from being
+    // optimized out.
+    asm volatile("":::"memory");
+  }
 
 }