aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2011-11-03 00:56:36 +0000
committerPete Cooper <peter_cooper@apple.com>2011-11-03 00:56:36 +0000
commitd1ffc739c1f88352c79a63ff17b828b3a529777e (patch)
treeb7485775b37dc1aa76761ad280b2eb0f7b4a5434 /lib/CodeGen/MachineInstr.cpp
parentcde546497067bf2ed40b9473582212df4ccd8141 (diff)
downloadexternal_llvm-d1ffc739c1f88352c79a63ff17b828b3a529777e.zip
external_llvm-d1ffc739c1f88352c79a63ff17b828b3a529777e.tar.gz
external_llvm-d1ffc739c1f88352c79a63ff17b828b3a529777e.tar.bz2
Treat objc selector reference globals as invariant so that MachineLICM can hoist them out of loops. Fixes <rdar://problem/6027699>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143600 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
-rw-r--r--lib/CodeGen/MachineInstr.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index a240667..a2fd3c4 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -1232,6 +1232,19 @@ bool MachineInstr::hasVolatileMemoryRef() const {
return false;
}
+/// pointsToRuntimeConstantMemory - Return true if this value points to data
+/// which does never changes once the program starts running
+static bool pointsToRuntimeConstantMemory(const Value *V) {
+ if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
+ StringRef Name = GV->getName();
+ // These special values are known to be constant at runtime
+ // TODO: a new linkage type for these would be far better than this check
+ if (Name.startswith("\01L_OBJC_SELECTOR_REFERENCES_"))
+ return true;
+ }
+ return false;
+}
+
/// isInvariantLoad - Return true if this instruction is loading from a
/// location whose value is invariant across the function. For example,
/// loading a value from the constant pool or from the argument area
@@ -1259,6 +1272,8 @@ bool MachineInstr::isInvariantLoad(AliasAnalysis *AA) const {
if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V))
if (PSV->isConstant(MFI))
continue;
+ if (pointsToRuntimeConstantMemory(V))
+ continue;
// If we have an AliasAnalysis, ask it whether the memory is constant.
if (AA && AA->pointsToConstantMemory(
AliasAnalysis::Location(V, (*I)->getSize(),