[PATCH] D43687: Improve merging of debug locations (fixes PR 36410)
Ulrich Weigand via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 11:02:40 PST 2018
uweigand created this revision.
uweigand added reviewers: aprantl, dblaikie, vsk.
Herald added subscribers: llvm-commits, eraman.
PR 36410 describes a problem where as a result of hoisting common code from "then" and "else" branches of a condition to before the "if", we get a llvm.dbg.value intrinsic with an invalid location. For those intrinsics, the scope indicated in the !dbg location must be identical with the scope of the variable tracked by the intrinsics, or else the module verifier will abort. This constraint can be violated by the current algorithm of getMergedLocation.
To fix this problem, this patch re-implements the algorithm used in getMergedLocation as follows (for the case of merging call instructions):
- First, we determine a merged scope. This is closest common scope of the two locations. If this does not exist, use the current function as scope. Note that in the special case of debug intrinsics for the same variable, the scopes must be identical, and therefore this algorithm will always return the same scope as well.
- If both original locations were inline, we need to return an inline location as well. To determine the inlined-at location, we use the closest common location in the inlined-at chain of both locations. If none exist, use a compiler-generated location in the current function.
This should handle the following cases:
- Same location (inlined or non-inlined): return that location
- Locations in the same scope (non-inlined): return a compiler-generated location in that scope
- Locations in different but nested scopes (non-inlined): return a compiler-generated location in the outer scope
- Locations in the same scope or nested scopes, inlined directly at the same location: return the outer scope, using the original (shared) inlined-at chain
- Locations in the same scope or nested scopes, inlined indirectly at the same location: return the outer scope, using the longest common part of the two original inlined-at chains
- Locations in the same scope or nested scopes, inlined at different locations of the same function: return the outer scope, using an inlined-at pointing to a compiler-generated location in that function.
Repository:
rL LLVM
https://reviews.llvm.org/D43687
Files:
lib/IR/DebugInfoMetadata.cpp
test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll
unittests/IR/MetadataTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43687.135663.patch
Type: text/x-patch
Size: 8359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180223/13413e00/attachment.bin>
More information about the llvm-commits
mailing list