[llvm] Refine the examples in the debug info document (PR #86272)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 12:33:46 PDT 2024


================
@@ -91,8 +91,12 @@ misattributed to a block containing one of the instructions-to-be-merged.
 
 Examples of transformations that should follow this rule include:
 
-* Merging identical loads/stores which occur on both sides of a CFG diamond
-  (see the ``MergedLoadStoreMotion`` pass).
+* Hoisting identical instructions from successors of a conditional branch or
----------------
dwblaikie wrote:

> Actually, the merging updater (eg., applyMergedLocation) will drop the specific row or column number in the debug location when merging different DebugLocs, only keeping their common scope. As a result, the merged debug location would not provide "extra coverage".

If both merged locations were the same (perhaps they came from a macro in the source code) - you can end up with bonus coverage if you hoist them, preserve the location (because merging identical locations produces that identical location) but the hoisted path doesn't always lead to at least one of the original paths (eg: because there's a third path the hoisted path can take that skips the merged paths), or came from the same inlined function but are different locations (merging would find the nearest common scope, the inlined function) again, the code would be attributed to the function even though the function may not be reachable.

I figure there might be cases where we could hoist some conditional code into an unconditional path, especially for some code size optimizations - but I don't know of a concrete example. I'll ask around.

https://github.com/llvm/llvm-project/pull/86272


More information about the llvm-commits mailing list