aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/RegUsageInfoPropagate.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2017-08-24 07:55:15 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2017-08-24 07:55:15 +0000
commitd664315ae896174b49b1feadea75a26dcfd209f2 (patch)
tree2cdd45b460f9699ab2580ffd13d95df9f588a787 /llvm/lib/CodeGen/RegUsageInfoPropagate.cpp
parent00459e4a0618b1832626d0eb320c66bde94ea701 (diff)
downloadllvm-d664315ae896174b49b1feadea75a26dcfd209f2.zip
llvm-d664315ae896174b49b1feadea75a26dcfd209f2.tar.gz
llvm-d664315ae896174b49b1feadea75a26dcfd209f2.tar.bz2
IPRA: Don't assume called function is first call operand
Fixes not finding the called global for AMDGPU call pseudoinstructions, which prevented IPRA from doing much. llvm-svn: 311637
Diffstat (limited to 'llvm/lib/CodeGen/RegUsageInfoPropagate.cpp')
-rw-r--r--llvm/lib/CodeGen/RegUsageInfoPropagate.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/RegUsageInfoPropagate.cpp b/llvm/lib/CodeGen/RegUsageInfoPropagate.cpp
index a39c945..f6d4506 100644
--- a/llvm/lib/CodeGen/RegUsageInfoPropagate.cpp
+++ b/llvm/lib/CodeGen/RegUsageInfoPropagate.cpp
@@ -88,6 +88,19 @@ void RegUsageInfoPropagationPass::getAnalysisUsage(AnalysisUsage &AU) const {
MachineFunctionPass::getAnalysisUsage(AU);
}
+// Assumes call instructions have a single reference to a function.
+static const Function *findCalledFunction(const Module &M, MachineInstr &MI) {
+ for (MachineOperand &MO : MI.operands()) {
+ if (MO.isGlobal())
+ return dyn_cast<Function>(MO.getGlobal());
+
+ if (MO.isSymbol())
+ return M.getFunction(MO.getSymbolName());
+ }
+
+ return nullptr;
+}
+
bool RegUsageInfoPropagationPass::runOnMachineFunction(MachineFunction &MF) {
const Module *M = MF.getFunction()->getParent();
PhysicalRegisterUsageInfo *PRUI = &getAnalysis<PhysicalRegisterUsageInfo>();
@@ -118,15 +131,14 @@ bool RegUsageInfoPropagationPass::runOnMachineFunction(MachineFunction &MF) {
Changed = true;
};
- MachineOperand &Operand = MI.getOperand(0);
- if (Operand.isGlobal())
- UpdateRegMask(cast<Function>(Operand.getGlobal()));
- else if (Operand.isSymbol())
- UpdateRegMask(M->getFunction(Operand.getSymbolName()));
+ if (const Function *F = findCalledFunction(*M, MI)) {
+ UpdateRegMask(F);
+ } else {
+ DEBUG(dbgs() << "Failed to find call target function\n");
+ }
- DEBUG(dbgs()
- << "Call Instruction After Register Usage Info Propagation : \n");
- DEBUG(dbgs() << MI << "\n");
+ DEBUG(dbgs() << "Call Instruction After Register Usage Info Propagation : "
+ << MI << '\n');
}
}