Skip to content

Commit

Permalink
[FastISel][NFC] Remove repeated calls to get{Variable,Expr}
Browse files Browse the repository at this point in the history
This will make it easy to reuse these values in subsequent commits.

Depends on D151331

Differential Revision: https://reviews.llvm.org/D151332
  • Loading branch information
felipepiovezan committed May 26, 2023
1 parent 96ec1be commit c23b35a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,48 +1272,49 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
const DbgValueInst *DI = cast<DbgValueInst>(II);
const MCInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE);
const Value *V = DI->getValue();
assert(DI->getVariable()->isValidLocationForIntrinsic(MIMD.getDL()) &&
DIExpression *Expr = DI->getExpression();
DILocalVariable *Var = DI->getVariable();
assert(Var->isValidLocationForIntrinsic(MIMD.getDL()) &&
"Expected inlined-at fields to agree");
if (!V || isa<UndefValue>(V) || DI->hasArgList()) {
// DI is either undef or cannot produce a valid DBG_VALUE, so produce an
// undef DBG_VALUE to terminate any prior location.
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD.getDL(), II, false, 0U,
DI->getVariable(), DI->getExpression());
Var, Expr);
return true;
}
if (const auto *CI = dyn_cast<ConstantInt>(V)) {
// See if there's an expression to constant-fold.
DIExpression *Expr = DI->getExpression();
if (Expr)
std::tie(Expr, CI) = Expr->constantFold(CI);
if (CI->getBitWidth() > 64)
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, II)
.addCImm(CI)
.addImm(0U)
.addMetadata(DI->getVariable())
.addMetadata(Var)
.addMetadata(Expr);
else
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, II)
.addImm(CI->getZExtValue())
.addImm(0U)
.addMetadata(DI->getVariable())
.addMetadata(Var)
.addMetadata(Expr);
return true;
}
if (const auto *CF = dyn_cast<ConstantFP>(V)) {
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, II)
.addFPImm(CF)
.addImm(0U)
.addMetadata(DI->getVariable())
.addMetadata(DI->getExpression());
.addMetadata(Var)
.addMetadata(Expr);
return true;
}
if (Register Reg = lookUpRegForValue(V)) {
// FIXME: This does not handle register-indirect values at offset 0.
if (!FuncInfo.MF->useDebugInstrRef()) {
bool IsIndirect = false;
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD.getDL(), II, IsIndirect,
Reg, DI->getVariable(), DI->getExpression());
Reg, Var, Expr);
return true;
}
// If using instruction referencing, produce this as a DBG_INSTR_REF,
Expand All @@ -1324,10 +1325,10 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
/* isUndef */ false, /* isEarlyClobber */ false,
/* SubReg */ 0, /* isDebug */ true)});
SmallVector<uint64_t, 2> Ops({dwarf::DW_OP_LLVM_arg, 0});
auto *NewExpr = DIExpression::prependOpcodes(DI->getExpression(), Ops);
auto *NewExpr = DIExpression::prependOpcodes(Expr, Ops);
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD.getDL(),
TII.get(TargetOpcode::DBG_INSTR_REF), /*IsIndirect*/ false, MOs,
DI->getVariable(), NewExpr);
Var, NewExpr);
return true;
}
// We don't know how to handle other cases, so we drop.
Expand Down

0 comments on commit c23b35a

Please sign in to comment.