[llvm] r325036 - [Debugify] Avoid verifier failure on non-definition subprograms
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 10:15:27 PST 2018
Author: vedantk
Date: Tue Feb 13 10:15:27 2018
New Revision: 325036
URL: http://llvm.org/viewvc/llvm-project?rev=325036&view=rev
Log:
[Debugify] Avoid verifier failure on non-definition subprograms
If a function doesn't have an exact definition, don't apply debugify
metadata as it triggers a DIVerifier failure.
The issue is that it's invalid to have DILocations inside a DISubprogram
which isn't a definition ("scope points into the type hierarchy!").
Modified:
llvm/trunk/test/DebugInfo/debugify.ll
llvm/trunk/tools/opt/Debugify.cpp
Modified: llvm/trunk/test/DebugInfo/debugify.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debugify.ll?rev=325036&r1=325035&r2=325036&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/debugify.ll (original)
+++ llvm/trunk/test/DebugInfo/debugify.ll Tue Feb 13 10:15:27 2018
@@ -30,6 +30,12 @@ define i32 @bar() {
ret i32 0
}
+; CHECK-LABEL: define weak_odr zeroext i1 @baz
+define weak_odr zeroext i1 @baz() {
+; CHECK-NOT: !dbg
+ ret i1 false
+}
+
; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=325036&r1=325035&r2=325036&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Tue Feb 13 10:15:27 2018
@@ -66,14 +66,14 @@ bool applyDebugifyMetadata(Module &M) {
// Visit each instruction.
for (Function &F : M) {
- if (F.isDeclaration())
+ if (F.isDeclaration() || !F.hasExactDefinition())
continue;
auto SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
bool IsLocalToUnit = F.hasPrivateLinkage() || F.hasInternalLinkage();
auto SP =
DIB.createFunction(CU, F.getName(), F.getName(), File, NextLine, SPType,
- IsLocalToUnit, F.hasExactDefinition(), NextLine,
+ IsLocalToUnit, /*isDefinition=*/true, NextLine,
DINode::FlagZero, /*isOptimized=*/true);
F.setSubprogram(SP);
for (BasicBlock &BB : F) {
More information about the llvm-commits
mailing list