Skip to content

Commit 43cc6ea

Browse files
committed
[DebugInfo] Fix LoadableByAddress losing debug info
LoadableByAddress was losing debug info, including at -Onone. When converting a load-store pair to a copy_addr, the debug info attached to the load was not salvaged. Additionally, the wrong scope was being attached to other debug values.
1 parent f6232a9 commit 43cc6ea

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "swift/SILOptimizer/Analysis/DeadEndBlocksAnalysis.h"
3434
#include "swift/SILOptimizer/PassManager/Transforms.h"
3535
#include "swift/SILOptimizer/Utils/BasicBlockOptUtils.h"
36+
#include "swift/SILOptimizer/Utils/DebugOptUtils.h"
3637
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
3738
#include "swift/SILOptimizer/Utils/StackNesting.h"
3839
#include "llvm/ADT/MapVector.h"
@@ -1778,7 +1779,7 @@ static void rewriteUsesOfSscalar(StructLoweringState &pass,
17781779
createOutlinedCopyCall(copyBuilder, address, dest, pass);
17791780
storeUser->eraseFromParent();
17801781
} else if (auto *dbgInst = dyn_cast<DebugValueInst>(user)) {
1781-
SILBuilderWithScope dbgBuilder(dbgInst);
1782+
SILBuilder dbgBuilder(dbgInst, dbgInst->getDebugScope());
17821783
// Rewrite the debug_value to point to the variable in the alloca.
17831784
dbgBuilder.createDebugValueAddr(dbgInst->getLoc(), address,
17841785
*dbgInst->getVarInfo());
@@ -2151,9 +2152,8 @@ static void rewriteFunction(StructLoweringState &pass,
21512152
} else {
21522153
assert(currOperand->getType().isAddress() &&
21532154
"Expected an address type");
2154-
SILBuilderWithScope debugBuilder(instr);
21552155
// SILBuilderWithScope skips over metainstructions.
2156-
debugBuilder.setCurrentDebugScope(instr->getDebugScope());
2156+
SILBuilder debugBuilder(instr, instr->getDebugScope());
21572157
debugBuilder.createDebugValueAddr(instr->getLoc(), currOperand,
21582158
*instr->getVarInfo());
21592159
instr->getParent()->erase(instr);
@@ -3655,6 +3655,7 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
36553655

36563656
builder.createCopyAddr(load->getLoc(), load->getOperand(), addr, IsTake,
36573657
IsInitialization);
3658+
swift::salvageLoadDebugInfo(load);
36583659
assignment.markForDeletion(load);
36593660
}
36603661

0 commit comments

Comments
 (0)