Skip to content

Commit 16e6055

Browse files
Revert "[SelectionDAG] Salvage debuginfo when combining load and sext… (#171745)
… instrs. (#169779)" This reverts commit 2b958b9. I might have broken the sanitizer-x86_64-linux bot /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cpp clang++: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:248: const T &llvm::ArrayRef<llvm::DbgValueLocEntry>::operator[](size_t) const [T = llvm::DbgValueLocEntry]: Assertion `Index < Length && "Invalid index!"' failed.
1 parent 62aaa3a commit 16e6055

File tree

3 files changed

+2
-170
lines changed

3 files changed

+2
-170
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#include "llvm/IR/Attributes.h"
5252
#include "llvm/IR/Constant.h"
5353
#include "llvm/IR/DataLayout.h"
54-
#include "llvm/IR/DebugInfoMetadata.h"
5554
#include "llvm/IR/DerivedTypes.h"
5655
#include "llvm/IR/Function.h"
5756
#include "llvm/IR/Metadata.h"
@@ -79,7 +78,6 @@
7978
#include <variant>
8079

8180
#include "MatchContext.h"
82-
#include "SDNodeDbgValue.h"
8381

8482
using namespace llvm;
8583
using namespace llvm::SDPatternMatch;
@@ -14467,52 +14465,17 @@ static SDValue tryToFoldExtOfLoad(SelectionDAG &DAG, DAGCombiner &Combiner,
1446714465
LN0->getBasePtr(), N0.getValueType(),
1446814466
LN0->getMemOperand());
1446914467
Combiner.ExtendSetCCUses(SetCCs, N0, ExtLoad, ExtOpc);
14470-
unsigned Opcode = N->getOpcode();
14471-
bool IsSigned = Opcode == ISD::SIGN_EXTEND;
1447214468
// If the load value is used only by N, replace it via CombineTo N.
14473-
SDValue OldLoadVal(LN0, 0);
14474-
SDValue OldExtValue(N, 0);
14475-
bool NoReplaceTrunc = OldLoadVal.hasOneUse();
14476-
14477-
// Because we are replacing a load and a s|z ext with a load-s|z ext
14478-
// instruction, the dbg_value attached to the load will be of a smaller bit
14479-
// width, and we have to add a DW_OP_LLVM_convert expression to get the
14480-
// correct size.
14481-
auto SalvageToOldLoadSize = [&](SDValue From, SDValue To, bool IsSigned) {
14482-
for (SDDbgValue *Dbg : DAG.GetDbgValues(From.getNode())) {
14483-
unsigned VarBitsFrom = From->getValueSizeInBits(0);
14484-
unsigned VarBitsTo = To->getValueSizeInBits(0);
14485-
14486-
// Build a convert expression for the s|z extend.
14487-
const DIExpression *OldE = Dbg->getExpression();
14488-
auto *NewE =
14489-
DIExpression::appendExt(OldE, VarBitsFrom, VarBitsTo, IsSigned);
14490-
14491-
// Create a new SDDbgValue that points at the widened node with the
14492-
// fragment.
14493-
Dbg->setIsInvalidated();
14494-
Dbg->setIsEmitted();
14495-
SDDbgValue *NewDV = DAG.getDbgValue(
14496-
Dbg->getVariable(), NewE, To.getNode(), To.getResNo(),
14497-
Dbg->isIndirect(), Dbg->getDebugLoc(), Dbg->getOrder());
14498-
DAG.AddDbgValue(NewDV, /*isParametet*/ false);
14499-
}
14500-
};
14501-
14469+
bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse();
14470+
Combiner.CombineTo(N, ExtLoad);
1450214471
if (NoReplaceTrunc) {
14503-
if (LN0->getHasDebugValue())
14504-
SalvageToOldLoadSize(OldLoadVal, ExtLoad, IsSigned);
14505-
14506-
if (N->getHasDebugValue())
14507-
DAG.transferDbgValues(OldExtValue, ExtLoad);
1450814472
DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1));
1450914473
Combiner.recursivelyDeleteUnusedNodes(LN0);
1451014474
} else {
1451114475
SDValue Trunc =
1451214476
DAG.getNode(ISD::TRUNCATE, SDLoc(N0), N0.getValueType(), ExtLoad);
1451314477
Combiner.CombineTo(LN0, Trunc, ExtLoad.getValue(1));
1451414478
}
14515-
Combiner.CombineTo(N, ExtLoad);
1451614479
return SDValue(N, 0); // Return N so it doesn't get rechecked!
1451714480
}
1451814481

llvm/test/DebugInfo/X86/selectionDAG-load-sext-trunc.ll

Lines changed: 0 additions & 70 deletions
This file was deleted.

llvm/test/DebugInfo/X86/selectionDAG-load-sext.ll

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)