r367269 - [DebugInfo] Don't emit incorrect descriptions of thunk params (PR42627)
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 29 15:49:55 PDT 2019
Author: vedantk
Date: Mon Jul 29 15:49:55 2019
New Revision: 367269
URL: http://llvm.org/viewvc/llvm-project?rev=367269&view=rev
Log:
[DebugInfo] Don't emit incorrect descriptions of thunk params (PR42627)
The `this` parameter of a thunk requires adjustment. Stop emitting an
incorrect dbg.declare pointing to the unadjusted pointer.
We could describe the adjusted value instead, but there may not be much
benefit in doing so as users tend not to debug thunks.
Robert O'Callahan reports that this matches gcc's behavior.
Fixes PR42627.
Differential Revision: https://reviews.llvm.org/D65035
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCXX/thunks.cpp
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=367269&r1=367268&r2=367269&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Mon Jul 29 15:49:55 2019
@@ -2496,10 +2496,11 @@ void CodeGenFunction::EmitParmDecl(const
setAddrOfLocalVar(&D, DeclPtr);
- // Emit debug info for param declaration.
+ // Emit debug info for param declarations in non-thunk functions.
if (CGDebugInfo *DI = getDebugInfo()) {
if (CGM.getCodeGenOpts().getDebugInfo() >=
- codegenoptions::LimitedDebugInfo) {
+ codegenoptions::LimitedDebugInfo &&
+ !CurFuncIsThunk) {
DI->EmitDeclareOfArgVariable(&D, DeclPtr.getPointer(), ArgNo, Builder);
}
}
Modified: cfe/trunk/test/CodeGenCXX/thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/thunks.cpp?rev=367269&r1=367268&r2=367269&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/thunks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/thunks.cpp Mon Jul 29 15:49:55 2019
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NONOPT %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -debug-info-kind=standalone -dwarf-version=5 -munwind-tables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NONOPT --check-prefix=CHECK-DBG %s
// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - -O1 -disable-llvm-passes | FileCheck --check-prefix=CHECK --check-prefix=CHECK-OPT %s
namespace Test1 {
@@ -20,6 +21,8 @@ struct C : A, B {
};
// CHECK-LABEL: define void @_ZThn8_N5Test11C1fEv(
+// CHECK-DBG-NOT: dbg.declare
+// CHECK: ret void
void C::f() { }
}
@@ -38,6 +41,8 @@ struct B : virtual A {
};
// CHECK-LABEL: define void @_ZTv0_n24_N5Test21B1fEv(
+// CHECK-DBG-NOT: dbg.declare
+// CHECK: ret void
void B::f() { }
}
@@ -83,6 +88,8 @@ struct __attribute__((visibility("protec
};
// CHECK-LABEL: define protected void @_ZThn8_N5Test41C1fEv(
+// CHECK-DBG-NOT: dbg.declare
+// CHECK: ret void
void C::f() { }
}
@@ -166,6 +173,7 @@ namespace Test6 {
};
// CHECK-LABEL: define void @_ZThn16_N5Test66Thunks1fEv
+ // CHECK-DBG-NOT: dbg.declare
// CHECK-NOT: memcpy
// CHECK: {{call void @_ZN5Test66Thunks1fEv.*sret}}
// CHECK: ret void
@@ -212,6 +220,7 @@ namespace Test7 {
void D::baz(X, X&, _Complex float, Small, Small&, Large) { }
// CHECK-LABEL: define void @_ZThn8_N5Test71D3bazENS_1XERS1_CfNS_5SmallERS4_NS_5LargeE(
+ // CHECK-DBG-NOT: dbg.declare
// CHECK-NOT: memcpy
// CHECK: ret void
void testD() { D d; }
@@ -227,6 +236,7 @@ namespace Test8 {
void C::helper(NonPOD var) {}
// CHECK-LABEL: define void @_ZThn8_N5Test81C3barENS_6NonPODE(
+ // CHECK-DBG-NOT: dbg.declare
// CHECK-NOT: load [[NONPODTYPE]], [[NONPODTYPE]]*
// CHECK-NOT: memcpy
// CHECK: ret void
@@ -269,10 +279,14 @@ namespace Test11 {
// The this-adjustment and return-adjustment thunk required when
// C::f appears in a vtable where A is at a nonzero offset from C.
// CHECK: define {{.*}} @_ZTcv0_n24_v0_n32_N6Test111C1fEv(
+ // CHECK-DBG-NOT: dbg.declare
+ // CHECK: ret
// The return-adjustment thunk required when C::f appears in a vtable
// where A is at a zero offset from C.
// CHECK: define {{.*}} @_ZTch0_v0_n32_N6Test111C1fEv(
+ // CHECK-DBG-NOT: dbg.declare
+ // CHECK: ret
}
// Varargs thunk test.
@@ -295,6 +309,7 @@ namespace Test12 {
// Varargs thunk; check that both the this and covariant adjustments
// are generated.
// CHECK: define {{.*}} @_ZTchn8_h8_N6Test121C1fEiz
+ // CHECK-DBG-NOT: dbg.declare
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -8
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 8
}
@@ -318,6 +333,7 @@ namespace Test13 {
return *this;
}
// CHECK: define {{.*}} @_ZTcvn8_n32_v8_n24_N6Test131D4foo1Ev
+ // CHECK-DBG-NOT: dbg.declare
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -8
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -32
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -24
@@ -338,6 +354,8 @@ namespace Test14 {
void C::f() {
}
// CHECK: define void @_ZThn8_N6Test141C1fEv({{.*}}) unnamed_addr [[NUW:#[0-9]+]]
+ // CHECK-DBG-NOT: dbg.declare
+ // CHECK: ret void
}
// Varargs non-covariant thunk test.
@@ -376,6 +394,8 @@ struct D : public C {
};
D::~D() {}
// CHECK: define linkonce_odr void @_ZThn8_N6Test161C3fooEv({{.*}}) {{.*}} comdat
+// CHECK-DBG-NOT: dbg.declare
+// CHECK: ret void
}
/**** The following has to go at the end of the file ****/
More information about the cfe-commits
mailing list