diff options
author | Devang Patel <dpatel@apple.com> | 2011-10-17 17:35:01 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-10-17 17:35:01 +0000 |
commit | 6c15fec3c5b4770570a4d681762a7bd510e65077 (patch) | |
tree | 428859b9d1a1293e34d953d200cfacb50794b073 /lib | |
parent | 4007529d4b014f43a1c7089f9b285a67c1c9b853 (diff) | |
download | llvm-6c15fec3c5b4770570a4d681762a7bd510e65077.tar.gz llvm-6c15fec3c5b4770570a4d681762a7bd510e65077.tar.bz2 llvm-6c15fec3c5b4770570a4d681762a7bd510e65077.tar.xz |
It is safe to speculate load from GOT. This fixes performance regression caused by r141689.
Radar 10281206.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142202 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/MachineLICM.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/CodeGen/MachineLICM.cpp b/lib/CodeGen/MachineLICM.cpp index a1f80d5282..8f7a8ebb26 100644 --- a/lib/CodeGen/MachineLICM.cpp +++ b/lib/CodeGen/MachineLICM.cpp @@ -762,6 +762,21 @@ void MachineLICM::UpdateRegPressure(const MachineInstr *MI) { } } +/// isLoadFromGOT - Return true if this machine instruction loads from +/// global offset table. +static bool isLoadFromGOT(MachineInstr &MI) { + assert (MI.getDesc().mayLoad() && "Expected MI that loads!"); + for (MachineInstr::mmo_iterator I = MI.memoperands_begin(), + E = MI.memoperands_end(); I != E; ++I) { + if (const Value *V = (*I)->getValue()) { + if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V)) + if (PSV == PSV->getGOT()) + return true; + } + } + return false; +} + /// IsLICMCandidate - Returns true if the instruction may be a suitable /// candidate for LICM. e.g. If the instruction is a call, then it's obviously /// not safe to hoist it. @@ -775,7 +790,8 @@ bool MachineLICM::IsLICMCandidate(MachineInstr &I) { // it dominates all exiting blocks. If it doesn't, then there is a path out of // the loop which does not execute this load, so we can't hoist it. // Stores and side effects are already checked by isSafeToMove. - if (I.getDesc().mayLoad() && !IsGuaranteedToExecute(I.getParent())) + if (I.getDesc().mayLoad() && !isLoadFromGOT(I) && + !IsGuaranteedToExecute(I.getParent())) return false; return true; |