1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[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!").

llvm-svn: 325036
This commit is contained in:
Vedant Kumar 2018-02-13 18:15:27 +00:00
parent b3b12b2293
commit 9e0cea2637
2 changed files with 8 additions and 2 deletions

View File

@ -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:.*]]}

View File

@ -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) {