brunodefraine updated this revision to Diff 353949.
brunodefraine added a comment.
Fix issues from Windows/clang-format buildbot. Fix mistake in code comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104777/new/
https://reviews.llvm.org/D104777
Files:
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGen/attr-nodebug2.cpp
Index: clang/test/CodeGen/attr-nodebug2.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/attr-nodebug2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -debug-info-kind=limited
-debugger-tuning=gdb -dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o -
%s | FileCheck %s
+
+void t1();
+
+void use() { t1(); }
+
+__attribute__((nodebug)) void t1() {
+ int a = 10;
+ a++;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z3usev()
+// CHECK-SAME: !dbg
+// CHECK-SAME: {
+// CHECK: !dbg
+// CHECK: }
+
+// PR50767 Function __attribute__((nodebug)) inconsistency causes crash
+// illegal (non-distinct) !dbg metadata was being added to _Z2t1v definition
+
+// CHECK-LABEL: define{{.*}} void @_Z2t1v()
+// CHECK-NOT: !dbg
+// CHECK-SAME: {
+// CHECK-NOT: !dbg
+// CHECK: }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1300,8 +1300,14 @@
QualType ResTy = BuildFunctionArgList(GD, Args);
// Check if we should generate debug info for this function.
- if (FD->hasAttr<NoDebugAttr>())
- DebugInfo = nullptr; // disable debug info indefinitely for this function
+ if (FD->hasAttr<NoDebugAttr>()) {
+ // Clear non-distinct debug info that was possibly attached to the function
+ // due to an earlier declaration without the nodebug attribute
+ if (Fn)
+ Fn->setSubprogram(nullptr);
+ // Disable debug info indefinitely for this function
+ DebugInfo = nullptr;
+ }
// The function might not have a body if we're generating thunks for a
// function declaration.
Index: clang/test/CodeGen/attr-nodebug2.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/attr-nodebug2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -debug-info-kind=limited -debugger-tuning=gdb -dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+
+void t1();
+
+void use() { t1(); }
+
+__attribute__((nodebug)) void t1() {
+ int a = 10;
+ a++;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z3usev()
+// CHECK-SAME: !dbg
+// CHECK-SAME: {
+// CHECK: !dbg
+// CHECK: }
+
+// PR50767 Function __attribute__((nodebug)) inconsistency causes crash
+// illegal (non-distinct) !dbg metadata was being added to _Z2t1v definition
+
+// CHECK-LABEL: define{{.*}} void @_Z2t1v()
+// CHECK-NOT: !dbg
+// CHECK-SAME: {
+// CHECK-NOT: !dbg
+// CHECK: }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1300,8 +1300,14 @@
QualType ResTy = BuildFunctionArgList(GD, Args);
// Check if we should generate debug info for this function.
- if (FD->hasAttr<NoDebugAttr>())
- DebugInfo = nullptr; // disable debug info indefinitely for this function
+ if (FD->hasAttr<NoDebugAttr>()) {
+ // Clear non-distinct debug info that was possibly attached to the function
+ // due to an earlier declaration without the nodebug attribute
+ if (Fn)
+ Fn->setSubprogram(nullptr);
+ // Disable debug info indefinitely for this function
+ DebugInfo = nullptr;
+ }
// The function might not have a body if we're generating thunks for a
// function declaration.
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits