Skip to content

Commit

Permalink
[IRTranslator][NFC] Refactor if/else chain into early returns
Browse files Browse the repository at this point in the history
This will make it easier to add more cases in a subsequent commit and also
better conforms to the coding guidelines.

Differential Revision: https://reviews.llvm.org/D151328
  • Loading branch information
felipepiovezan committed May 25, 2023
1 parent a1c4f42 commit b5983a3
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,11 +2026,14 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
// DI cannot produce a valid DBG_VALUE, so produce an undef DBG_VALUE to
// terminate any prior location.
MIRBuilder.buildIndirectDbgValue(0, DI.getVariable(), DI.getExpression());
} else if (const auto *CI = dyn_cast<Constant>(V)) {
return true;
}
if (const auto *CI = dyn_cast<Constant>(V)) {
MIRBuilder.buildConstDbgValue(*CI, DI.getVariable(), DI.getExpression());
} else if (auto *AI = dyn_cast<AllocaInst>(V);
AI && AI->isStaticAlloca() &&
DI.getExpression()->startsWithDeref()) {
return true;
}
if (auto *AI = dyn_cast<AllocaInst>(V);
AI && AI->isStaticAlloca() && DI.getExpression()->startsWithDeref()) {
// If the value is an alloca and the expression starts with a
// dereference, track a stack slot instead of a register, as registers
// may be clobbered.
Expand All @@ -2039,14 +2042,14 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
DIExpression::get(AI->getContext(), ExprOperands.drop_front());
MIRBuilder.buildFIDbgValue(getOrCreateFrameIndex(*AI), DI.getVariable(),
ExprDerefRemoved);
} else {
for (Register Reg : getOrCreateVRegs(*V)) {
// FIXME: This does not handle register-indirect values at offset 0. The
// direct/indirect thing shouldn't really be handled by something as
// implicit as reg+noreg vs reg+imm in the first place, but it seems
// pretty baked in right now.
MIRBuilder.buildDirectDbgValue(Reg, DI.getVariable(), DI.getExpression());
}
return true;
}
for (Register Reg : getOrCreateVRegs(*V)) {
// FIXME: This does not handle register-indirect values at offset 0. The
// direct/indirect thing shouldn't really be handled by something as
// implicit as reg+noreg vs reg+imm in the first place, but it seems
// pretty baked in right now.
MIRBuilder.buildDirectDbgValue(Reg, DI.getVariable(), DI.getExpression());
}
return true;
}
Expand Down

0 comments on commit b5983a3

Please sign in to comment.