[pkg-d-commits] [ldc] 204/211: Fix -finstrument-functions. The wrong return address was used.

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.1.0
in repository ldc.

commit a601ec6e724b8c5374e34a4adb93187ff617dfa6
Author: Johan Engelen <jbc.engelen at gmail.com>
Date:   Sun Jan 8 22:30:38 2017 +0100

    Fix -finstrument-functions. The wrong return address was used.
---
 gen/runtime.cpp                 |  2 +-
 tests/codegen/instrumentation.d | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gen/runtime.cpp b/gen/runtime.cpp
index 73ff0b7..2bcf641 100644
--- a/gen/runtime.cpp
+++ b/gen/runtime.cpp
@@ -773,7 +773,7 @@ static void emitInstrumentationFn(const char *name) {
 
   // Grab the address of the calling function
   auto *caller =
-      gIR->ir->CreateCall(GET_INTRINSIC_DECL(returnaddress), DtoConstInt(1));
+      gIR->ir->CreateCall(GET_INTRINSIC_DECL(returnaddress), DtoConstInt(0));
   auto callee = DtoBitCast(gIR->topfunc(), getVoidPtrType());
 
 #if LDC_LLVM_VER >= 307
diff --git a/tests/codegen/instrumentation.d b/tests/codegen/instrumentation.d
index a5b85ca..b594335 100644
--- a/tests/codegen/instrumentation.d
+++ b/tests/codegen/instrumentation.d
@@ -2,8 +2,10 @@
 
 void fun0 () {
   // CHECK-LABEL: define{{.*}} @{{.*}}4fun0FZv
-  // CHECK: call void @__cyg_profile_func_enter
-  // CHECK: call void @__cyg_profile_func_exit
+  // CHECK: [[RET1:%[0-9]]] = call i8* @llvm.returnaddress(i32 0)
+  // CHECK: call void @__cyg_profile_func_enter{{.*}}4fun0FZv{{.*}}[[RET1]]
+  // CHECK: [[RET2:%[0-9]]] = call i8* @llvm.returnaddress(i32 0)
+  // CHECK: call void @__cyg_profile_func_exit{{.*}}4fun0FZv{{.*}}[[RET2]]
   // CHECK-NEXT: ret
   return;
 }
@@ -11,8 +13,8 @@ void fun0 () {
 pragma(LDC_profile_instr, false)
 int fun1 (int x) {
   // CHECK-LABEL: define{{.*}} @{{.*}}4fun1FiZi
-  // CHECK-NOT: call void @__cyg_profile_func_enter
-  // CHECK-NOT: call void @__cyg_profile_func_exit
+  // CHECK-NOT: __cyg_profile_func_enter
+  // CHECK-NOT: __cyg_profile_func_exit
   return 42;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list