[PATCH] compile time improvement for MachineSink
Lawrence Hu
lawrence at codeaurora.org
Wed May 13 17:34:10 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9719
Files:
lib/CodeGen/MachineSink.cpp
Index: lib/CodeGen/MachineSink.cpp
===================================================================
--- lib/CodeGen/MachineSink.cpp
+++ lib/CodeGen/MachineSink.cpp
@@ -19,6 +19,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SparseBitVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
@@ -70,6 +71,8 @@
// will be split.
SetVector<std::pair<MachineBasicBlock*,MachineBasicBlock*> > ToSplit;
+ SparseBitVector<> RegsToClearKillFlags;
+
public:
static char ID; // Pass identification
MachineSinking() : MachineFunctionPass(ID) {
@@ -167,9 +170,9 @@
MRI->replaceRegWith(DstReg, SrcReg);
MI->eraseFromParent();
- // Conservatively, clear any kill flags, since it's possible that they are no
- // longer correct.
- MRI->clearKillFlags(SrcReg);
+ // Conservatively, record registers to clear any kill flags later,
+ // since it's possible that they are no longer correct.
+ RegsToClearKillFlags.set(SrcReg);
++NumCoalesces;
return true;
@@ -287,6 +290,15 @@
if (!MadeChange) break;
EverMadeChange = true;
}
+
+ // Now clear any kill flags for recorded registers.
+ if (EverMadeChange) {
+ for (auto I = RegsToClearKillFlags.begin(), E = RegsToClearKillFlags.end();
+ I != E; ++I)
+ MRI->clearKillFlags(*I);
+ }
+ RegsToClearKillFlags.clear();
+
return EverMadeChange;
}
@@ -754,14 +766,11 @@
++MachineBasicBlock::iterator(DbgMI));
}
- // Conservatively, clear any kill flags, since it's possible that they are no
- // longer correct.
- // Note that we have to clear the kill flags for any register this instruction
- // uses as we may sink over another instruction which currently kills the
- // used registers.
+ // Conservatively, record regsters to clear any kill flags later,
+ // since it's possible that they are no longer correct.
for (MachineOperand &MO : MI->operands()) {
if (MO.isReg() && MO.isUse())
- MRI->clearKillFlags(MO.getReg());
+ RegsToClearKillFlags.set(MO.getReg());
}
return true;
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9719.25748.patch
Type: text/x-patch
Size: 2217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150514/58f1fee6/attachment.bin>
More information about the llvm-commits
mailing list