[PATCH] D11889: AMDGPU/SI: Update LiveVariables
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 9 15:23:43 PDT 2015
arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: llvm-commits.
Herald added a subscriber: MatzeB.
This is simple but won't work if/when this pass is moved to be post-SSA.
http://reviews.llvm.org/D11889
Files:
lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
Index: lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
===================================================================
--- lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
+++ lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
@@ -48,6 +48,7 @@
#include "SIInstrInfo.h"
#include "SIRegisterInfo.h"
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
+#include "llvm/CodeGen/LiveVariables.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachinePostDominators.h"
@@ -94,6 +95,7 @@
INITIALIZE_PASS_BEGIN(SIFixSGPRLiveRanges, DEBUG_TYPE,
"SI Fix SGPR Live Ranges", false, false)
INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
+INITIALIZE_PASS_DEPENDENCY(LiveVariables)
INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTree)
INITIALIZE_PASS_END(SIFixSGPRLiveRanges, DEBUG_TYPE,
"SI Fix SGPR Live Ranges", false, false)
@@ -111,10 +113,13 @@
const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
const SIRegisterInfo *TRI = static_cast<const SIRegisterInfo *>(
MF.getSubtarget().getRegisterInfo());
- LiveIntervals *LIS = &getAnalysis<LiveIntervals>();
- MachinePostDominatorTree *PDT = &getAnalysis<MachinePostDominatorTree>();
+
+ MachinePostDominatorTree *PDT = &getAnalysis<MachinePostDominatorTree>();
std::vector<std::pair<unsigned, LiveRange *>> SGPRLiveRanges;
+ LiveIntervals *LIS = &getAnalysis<LiveIntervals>();
+ LiveVariables *LV = getAnalysisIfAvailable<LiveVariables>();
+
// First pass, collect all live intervals for SGPRs
for (const MachineBasicBlock &MBB : MF) {
for (const MachineInstr &MI : MBB) {
@@ -196,6 +201,9 @@
<< SuccB->getNumber()
<< " with NCD = BB#" << NCD->getNumber() << '\n');
+ assert(TargetRegisterInfo::isVirtualRegister(Reg) &&
+ "Not expecting to extend live range of physreg");
+
// FIXME: Need to figure out how to update LiveRange here so this pass
// will be able to preserve LiveInterval analysis.
MachineInstr *NCDSGPRUse =
@@ -206,6 +214,11 @@
SlotIndex SI = LIS->InsertMachineInstrInMaps(NCDSGPRUse);
LIS->extendToIndices(*LR, SI);
+ if (LV) {
+ // TODO: This won't work post-SSA
+ LV->HandleVirtRegUse(Reg, NCD, NCDSGPRUse);
+ }
+
DEBUG(NCDSGPRUse->dump());
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11889.31624.patch
Type: text/x-patch
Size: 2362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150809/28d852ae/attachment.bin>
More information about the llvm-commits
mailing list