[llvm] r348976 - [globalisel] Rename GISelChangeObserver's erasedInstr() to erasingInstr() and related nits. NFC
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 12 13:32:02 PST 2018
Author: dsanders
Date: Wed Dec 12 13:32:01 2018
New Revision: 348976
URL: http://llvm.org/viewvc/llvm-project?rev=348976&view=rev
Log:
[globalisel] Rename GISelChangeObserver's erasedInstr() to erasingInstr() and related nits. NFC
Summary:
There's little of interest that can be done to an already-erased instruction.
You can't inspect it, write it to a debug log, etc. It ought to be notification
that we're about to erase it. Rename the function to clarify the timing of the
event and reflect current usage.
Also fixed one case where we were trying to print an erased instruction.
Reviewers: aditya_nandakumar
Reviewed By: aditya_nandakumar
Subscribers: rovka, kristof.beyls, llvm-commits
Differential Revision: https://reviews.llvm.org/D55611
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
llvm/trunk/include/llvm/CodeGen/GlobalISel/GISelChangeObserver.h
llvm/trunk/lib/CodeGen/GlobalISel/Combiner.cpp
llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp
llvm/trunk/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/CombinerHelper.h?rev=348976&r1=348975&r2=348976&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/CombinerHelper.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/CombinerHelper.h Wed Dec 12 13:32:01 2018
@@ -30,7 +30,6 @@ class CombinerHelper {
MachineRegisterInfo &MRI;
GISelChangeObserver &Observer;
- void eraseInstr(MachineInstr &MI);
void scheduleForVisit(MachineInstr &MI);
public:
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/GISelChangeObserver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/GISelChangeObserver.h?rev=348976&r1=348975&r2=348976&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/GISelChangeObserver.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/GISelChangeObserver.h Wed Dec 12 13:32:01 2018
@@ -18,7 +18,7 @@
namespace llvm {
/// Abstract class that contains various methods for clients to notify about
/// changes. This should be the preferred way for APIs to notify changes.
-/// Typically calling erasedInstr/createdInstr multiple times should not affect
+/// Typically calling erasingInstr/createdInstr multiple times should not affect
/// the result. The observer would likely need to check if it was already
/// notified earlier (consider using GISelWorkList).
class MachineInstr;
@@ -26,8 +26,8 @@ class GISelChangeObserver {
public:
virtual ~GISelChangeObserver() {}
- /// An instruction was erased.
- virtual void erasedInstr(MachineInstr &MI) = 0;
+ /// An instruction is about to be erased.
+ virtual void erasingInstr(MachineInstr &MI) = 0;
/// An instruction was created and inserted into the function.
virtual void createdInstr(MachineInstr &MI) = 0;
/// This instruction was mutated in some way.
Modified: llvm/trunk/lib/CodeGen/GlobalISel/Combiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/Combiner.cpp?rev=348976&r1=348975&r2=348976&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/Combiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/Combiner.cpp Wed Dec 12 13:32:01 2018
@@ -43,7 +43,7 @@ public:
WorkListMaintainer(WorkListTy &WorkList) : WorkList(WorkList) {}
virtual ~WorkListMaintainer() {}
- void erasedInstr(MachineInstr &MI) override {
+ void erasingInstr(MachineInstr &MI) override {
LLVM_DEBUG(dbgs() << "Erased: "; MI.print(dbgs()); dbgs() << "\n");
WorkList.remove(&MI);
}
Modified: llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp?rev=348976&r1=348975&r2=348976&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp Wed Dec 12 13:32:01 2018
@@ -23,9 +23,6 @@ CombinerHelper::CombinerHelper(GISelChan
MachineIRBuilder &B)
: Builder(B), MRI(Builder.getMF().getRegInfo()), Observer(Observer) {}
-void CombinerHelper::eraseInstr(MachineInstr &MI) {
- Observer.erasedInstr(MI);
-}
void CombinerHelper::scheduleForVisit(MachineInstr &MI) {
Observer.createdInstr(MI);
}
@@ -299,8 +296,8 @@ bool CombinerHelper::tryCombineExtending
Observer.createdInstr(*NewMI);
}
for (auto &EraseMI : ScheduleForErase) {
+ Observer.erasingInstr(*EraseMI);
EraseMI->eraseFromParent();
- Observer.erasedInstr(*EraseMI);
}
MI.getOperand(0).setReg(ChosenDstReg);
Modified: llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp?rev=348976&r1=348975&r2=348976&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp Wed Dec 12 13:32:01 2018
@@ -94,7 +94,8 @@ public:
LLVM_DEBUG(dbgs() << ".. .. New MI: " << MI;);
}
- void erasedInstr(MachineInstr &MI) override {
+ void erasingInstr(MachineInstr &MI) override {
+ LLVM_DEBUG(dbgs() << ".. .. Erasing: " << MI;);
InstList.remove(&MI);
ArtifactList.remove(&MI);
}
@@ -146,7 +147,7 @@ bool Legalizer::runOnMachineFunction(Mac
const LegalizerInfo &LInfo(Helper.getLegalizerInfo());
LegalizationArtifactCombiner ArtCombiner(Helper.MIRBuilder, MF.getRegInfo(), LInfo);
auto RemoveDeadInstFromLists = [&WorkListObserver](MachineInstr *DeadMI) {
- WorkListObserver.erasedInstr(*DeadMI);
+ WorkListObserver.erasingInstr(*DeadMI);
};
bool Changed = false;
do {
@@ -175,7 +176,7 @@ bool Legalizer::runOnMachineFunction(Mac
MachineInstr &MI = *ArtifactList.pop_back_val();
assert(isPreISelGenericOpcode(MI.getOpcode()) && "Expecting generic opcode");
if (isTriviallyDead(MI, MRI)) {
- LLVM_DEBUG(dbgs() << MI << "Is dead; erasing.\n");
+ LLVM_DEBUG(dbgs() << MI << "Is dead\n");
RemoveDeadInstFromLists(&MI);
MI.eraseFromParentAndMarkDBGValuesForRemoval();
continue;
@@ -183,7 +184,7 @@ bool Legalizer::runOnMachineFunction(Mac
SmallVector<MachineInstr *, 4> DeadInstructions;
if (ArtCombiner.tryCombineInstruction(MI, DeadInstructions)) {
for (auto *DeadMI : DeadInstructions) {
- LLVM_DEBUG(dbgs() << ".. Erasing Dead Instruction " << *DeadMI);
+ LLVM_DEBUG(dbgs() << *DeadMI << "Is dead\n");
RemoveDeadInstFromLists(DeadMI);
DeadMI->eraseFromParentAndMarkDBGValuesForRemoval();
}
Modified: llvm/trunk/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp?rev=348976&r1=348975&r2=348976&view=diff
==============================================================================
--- llvm/trunk/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp (original)
+++ llvm/trunk/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp Wed Dec 12 13:32:01 2018
@@ -15,7 +15,7 @@ class DummyGISelObserver : public GISelC
public:
void changedInstr(MachineInstr &MI) override {}
void createdInstr(MachineInstr &MI) override {}
- void erasedInstr(MachineInstr &MI) override {}
+ void erasingInstr(MachineInstr &MI) override {}
};
// Test CTTZ expansion when CTTZ_ZERO_UNDEF is legal or custom,
More information about the llvm-commits
mailing list