Skip to content

Commit ead0e97

Browse files
authored
[DebugInfo][Mem2Reg] Assign uninitialized values with annotated locs (#157716)
In PromoteMem2Reg, we perform a DFS over the CFG and track, for each alloca, its incoming value and its associated incoming DebugLoc, both of which are taken from stores to that alloca; these values and DebugLocs are propagated to PHI nodes when new blocks are reached. In the event that for one incoming edge no store instruction has been seen, we propagate an UndefValue and an empty DebugLoc to the PHI. This is a perfectly valid occurrence, and assigning an empty DebugLoc to the PHI is the correct course of action; therefore, we should pass an annotated DebugLoc instead, so that in DebugLoc coverage tracking we correctly do not expect a valid DebugLoc to be present; we generally mark allocas as having CompilerGenerated locations, so I've chosen to use the same annotation to represent the uninitialized value of that alloca. This change is NFC outside of DebugLoc coverage tracking builds.
1 parent e03fcce commit ead0e97

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,12 @@ void PromoteMem2Reg::run() {
849849
for (unsigned i = 0, e = Allocas.size(); i != e; ++i)
850850
IncomingVals.init(i, UndefValue::get(Allocas[i]->getAllocatedType()));
851851

852-
// When handling debug info, treat all incoming values as if they have unknown
853-
// locations until proven otherwise.
852+
// When handling debug info, treat all incoming values as if they have
853+
// compiler-generated (empty) locations, representing the uninitialized
854+
// alloca, until proven otherwise.
854855
IncomingLocs.resize(Allocas.size());
856+
for (unsigned i = 0, e = Allocas.size(); i != e; ++i)
857+
IncomingLocs.init(i, DebugLoc::getCompilerGenerated());
855858

856859
// The renamer uses the Visited set to avoid infinite loops.
857860
Visited.resize(F.getMaxBlockNumber(), false);

0 commit comments

Comments
 (0)