llvm.org GIT mirror llvm / c22f794
Revert Add debug location verification for !llvm.loop attachments. This reverts r363725 (git commit 8ff822d61dacf5a9466755eedafd3eeb54abc00d) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363728 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 5 months ago
2 changed file(s) with 28 addition(s) and 64 deletion(s). Raw diff Collapse all Expand all
23412341 // FIXME: Check this incrementally while visiting !dbg attachments.
23422342 // FIXME: Only check when N is the canonical subprogram for F.
23432343 SmallPtrSet Seen;
2344 auto VisitDebugLoc = [&](const Instruction &I, const MDNode *Node) {
2345 // Be careful about using DILocation here since we might be dealing with
2346 // broken code (this is the Verifier after all).
2347 const DILocation *DL = dyn_cast_or_null(Node);
2348 if (!DL)
2349 return;
2350 if (!Seen.insert(DL).second)
2351 return;
2352
2353 Metadata *Parent = DL->getRawScope();
2354 AssertDI(Parent && isa(Parent),
2355 "DILocation's scope must be a DILocalScope", N, &F, &I, DL,
2356 Parent);
2357 DILocalScope *Scope = DL->getInlinedAtScope();
2358 if (Scope && !Seen.insert(Scope).second)
2359 return;
2360
2361 DISubprogram *SP = Scope ? Scope->getSubprogram() : nullptr;
2362
2363 // Scope and SP could be the same MDNode and we don't want to skip
2364 // validation in that case
2365 if (SP && ((Scope != SP) && !Seen.insert(SP).second))
2366 return;
2367
2368 // FIXME: Once N is canonical, check "SP == &N".
2369 AssertDI(SP->describes(&F),
2370 "!dbg attachment points at wrong subprogram for function", N, &F,
2371 &I, DL, Scope, SP);
2372 };
23732344 for (auto &BB : F)
23742345 for (auto &I : BB) {
2375 VisitDebugLoc(I, I.getDebugLoc().getAsMDNode());
2376 // The llvm.loop annotations also contain two DILocations.
2377 if (auto MD = I.getMetadata(LLVMContext::MD_loop))
2378 for (unsigned i = 1; i < MD->getNumOperands(); ++i)
2379 VisitDebugLoc(I, dyn_cast_or_null(MD->getOperand(i)));
2380 if (BrokenDebugInfo)
2381 return;
2346 // Be careful about using DILocation here since we might be dealing with
2347 // broken code (this is the Verifier after all).
2348 DILocation *DL =
2349 dyn_cast_or_null(I.getDebugLoc().getAsMDNode());
2350 if (!DL)
2351 continue;
2352 if (!Seen.insert(DL).second)
2353 continue;
2354
2355 Metadata *Parent = DL->getRawScope();
2356 AssertDI(Parent && isa(Parent),
2357 "DILocation's scope must be a DILocalScope", N, &F, &I, DL,
2358 Parent);
2359 DILocalScope *Scope = DL->getInlinedAtScope();
2360 if (Scope && !Seen.insert(Scope).second)
2361 continue;
2362
2363 DISubprogram *SP = Scope ? Scope->getSubprogram() : nullptr;
2364
2365 // Scope and SP could be the same MDNode and we don't want to skip
2366 // validation in that case
2367 if (SP && ((Scope != SP) && !Seen.insert(SP).second))
2368 continue;
2369
2370 // FIXME: Once N is canonical, check "SP == &N".
2371 AssertDI(SP->describes(&F),
2372 "!dbg attachment points at wrong subprogram for function", N, &F,
2373 &I, DL, Scope, SP);
23822374 }
23832375 }
23842376
+0
-28
test/Verifier/llvm.loop.ll less more
None ; RUN: llvm-as -disable-output < %s -o /dev/null 2>&1 | FileCheck %s
1
2 define i32 @foo() !dbg !4 {
3 entry:
4 ret i32 0, !dbg !6
5 }
6
7 define i32 @bar() !dbg !5 {
8 entry:
9 ; CHECK: !dbg attachment points at wrong subprogram for function
10 ret i32 0, !dbg !10, !llvm.loop !9
11 }
12
13 ; CHECK: warning: ignoring invalid debug info
14 !llvm.dbg.cu = !{!0}
15 !llvm.module.flags = !{!7, !8}
16
17 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
18 !1 = !DIFile(filename: "dwarf-test.c", directory: "test")
19 !2 = !{}
20 !4 = distinct !DISubprogram(name: "foo", scope: !0, isDefinition: true, unit: !0)
21 !5 = distinct !DISubprogram(name: "bar", scope: !0, isDefinition: true, unit: !0)
22 !6 = !DILocation(line: 7, scope: !4)
23 !7 = !{i32 2, !"Dwarf Version", i32 3}
24 !8 = !{i32 1, !"Debug Info Version", i32 3}
25 !9 = !{!9, !10, !11}
26 !10 = !DILocation(line: 1, scope: !5)
27 !11 = !DILocation(line: 1, scope: !4)