This is an archive of the discontinued LLVM Phabricator instance.

[WIP] Experimental Debug Location Verifier.
Needs ReviewPublic

Authored by aprantl on Aug 28 2020, 11:43 AM.

Details

Reviewers
vsk
davide
Summary

This is an experimental debug location verifier that ensures the following condition: If an instruction has a source location, then all occurrences of each operand's source location must dominate this instruction or be in the same BB as the instruction.

Diff Detail

Event Timeline

aprantl created this revision.Aug 28 2020, 11:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2020, 11:43 AM
aprantl requested review of this revision.Aug 28 2020, 11:43 AM
aprantl edited the summary of this revision. (Show Details)

For example:

... o -MF lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o.d -o lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o -c /Volumes/Data/llvm-project/llvm/lib/Demangle/ItaniumDemangle.cpp
Occurence of source location from an operand does not dominate instruction.
  br label %cond.end26, !dbg !2571
!2571 = !DILocation(line: 355, column: 10, scope: !2491)
  %cond = phi i8* [ %21, %cond.true24 ], [ null, %cond.false25 ], !dbg !2571
vsk added a comment.Aug 28 2020, 11:54 AM

Very cool. Does this fire at all in an -O0 stage2 build?

llvm/lib/IR/Verifier.cpp
4213

s/all occurrences/the first occurrence in any block/? Or do we mean to check the 'all' condition?

4216

Is I.getOperand(i) guaranteed to be an Instruction? What about constants?

Yes, triggers a similar error in debug mode:

lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o -c /Volumes/Data/llvm-project/llvm/lib/Support/CommandLine.cpp
Occurence of source location from an operand does not dominate instruction.
  %25 = phi i1 [ false, %while.cond12 ], [ %lnot17, %land.rhs14 ], !dbg !18832
!18832 = !DILocation(line: 0, scope: !18830)
  %16 = phi i1 [ false, %while.cond ], [ %call5, %land.rhs3 ], !dbg !18832

Ah! I got to remove line: 0 locations.

aprantl updated this revision to Diff 288679.Aug 28 2020, 12:50 PM

Ignore line 0.

Now:

ttyStackTrace.cpp.o -c /Volumes/Data/llvm-project/llvm/lib/Support/PrettyStackTrace.cpp
Occurence of source location from an operand does not dominate instruction.
  br label %cond.end, !dbg !2018
!2018 = !DILocation(line: 107, column: 29, scope: !2010)
  %cond = phi i64 [ %call, %cond.true ], [ 0, %cond.false ], !dbg !2018
fatal error: error in backend: Broken module found, compilation aborted!