[llvm] r273231 - [ImplicitNullCchecks] NFC cleanup
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 19:10:19 PDT 2016
Author: sanjoy
Date: Mon Jun 20 21:10:18 2016
New Revision: 273231
URL: http://llvm.org/viewvc/llvm-project?rev=273231&view=rev
Log:
[ImplicitNullCchecks] NFC cleanup
- Remove unsued constructor
- Tighten up the interface for NullCheck
Modified:
llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp
Modified: llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp?rev=273231&r1=273230&r2=273231&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp (original)
+++ llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp Mon Jun 20 21:10:18 2016
@@ -59,7 +59,7 @@ namespace {
class ImplicitNullChecks : public MachineFunctionPass {
/// Represents one null check that can be made implicit.
- struct NullCheck {
+ class NullCheck {
// The memory operation the null check can be folded into.
MachineInstr *MemOperation;
@@ -75,10 +75,7 @@ class ImplicitNullChecks : public Machin
// The block branched to if the pointer is null.
MachineBasicBlock *NullSucc;
- NullCheck()
- : MemOperation(), CheckOperation(), CheckBlock(), NotNullSucc(),
- NullSucc() {}
-
+ public:
explicit NullCheck(MachineInstr *memOperation, MachineInstr *checkOperation,
MachineBasicBlock *checkBlock,
MachineBasicBlock *notNullSucc,
@@ -86,6 +83,16 @@ class ImplicitNullChecks : public Machin
: MemOperation(memOperation), CheckOperation(checkOperation),
CheckBlock(checkBlock), NotNullSucc(notNullSucc), NullSucc(nullSucc) {
}
+
+ MachineInstr *getMemOperation() const { return MemOperation; }
+
+ MachineInstr *getCheckOperation() const { return CheckOperation; }
+
+ MachineBasicBlock *getCheckBlock() const { return CheckBlock; }
+
+ MachineBasicBlock *getNotNullSucc() const { return NotNullSucc; }
+
+ MachineBasicBlock *getNullSucc() const { return NullSucc; }
};
const TargetInstrInfo *TII = nullptr;
@@ -388,7 +395,7 @@ void ImplicitNullChecks::rewriteNullChec
for (auto &NC : NullCheckList) {
// Remove the conditional branch dependent on the null check.
- unsigned BranchesRemoved = TII->RemoveBranch(*NC.CheckBlock);
+ unsigned BranchesRemoved = TII->RemoveBranch(*NC.getCheckBlock());
(void)BranchesRemoved;
assert(BranchesRemoved > 0 && "expected at least one branch!");
@@ -396,13 +403,13 @@ void ImplicitNullChecks::rewriteNullChec
// check earlier ensures that this bit of code motion is legal. We do not
// touch the successors list for any basic block since we haven't changed
// control flow, we've just made it implicit.
- MachineInstr *FaultingLoad =
- insertFaultingLoad(NC.MemOperation, NC.CheckBlock, NC.NullSucc);
+ MachineInstr *FaultingLoad = insertFaultingLoad(
+ NC.getMemOperation(), NC.getCheckBlock(), NC.getNullSucc());
// Now the values defined by MemOperation, if any, are live-in of
// the block of MemOperation.
// The original load operation may define implicit-defs alongside
// the loaded value.
- MachineBasicBlock *MBB = NC.MemOperation->getParent();
+ MachineBasicBlock *MBB = NC.getMemOperation()->getParent();
for (const MachineOperand &MO : FaultingLoad->operands()) {
if (!MO.isReg() || !MO.isDef())
continue;
@@ -411,12 +418,12 @@ void ImplicitNullChecks::rewriteNullChec
continue;
MBB->addLiveIn(Reg);
}
- NC.MemOperation->eraseFromParent();
- NC.CheckOperation->eraseFromParent();
+ NC.getMemOperation()->eraseFromParent();
+ NC.getCheckOperation()->eraseFromParent();
// Insert an *unconditional* branch to not-null successor.
- TII->InsertBranch(*NC.CheckBlock, NC.NotNullSucc, nullptr, /*Cond=*/None,
- DL);
+ TII->InsertBranch(*NC.getCheckBlock(), NC.getNotNullSucc(), nullptr,
+ /*Cond=*/None, DL);
NumImplicitNullChecks++;
}
More information about the llvm-commits
mailing list