[llvm-branch-commits] [llvm-branch] r86178 - /llvm/branches/Apple/Leela/lib/CodeGen/ScheduleDAGInstrs.cpp
Bill Wendling
isanbard at gmail.com
Thu Nov 5 13:21:52 PST 2009
Author: void
Date: Thu Nov 5 15:21:51 2009
New Revision: 86178
URL: http://llvm.org/viewvc/llvm-project?rev=86178&view=rev
Log:
$ svn merge -c 85934 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r85934 into '.':
U lib/CodeGen/ScheduleDAGInstrs.cpp
$ svn merge -c 86080 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r86080 into '.':
G lib/CodeGen/ScheduleDAGInstrs.cpp
Modified:
llvm/branches/Apple/Leela/lib/CodeGen/ScheduleDAGInstrs.cpp
Modified: llvm/branches/Apple/Leela/lib/CodeGen/ScheduleDAGInstrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=86178&r1=86177&r2=86178&view=diff
==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/ScheduleDAGInstrs.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/ScheduleDAGInstrs.cpp Thu Nov 5 15:21:51 2009
@@ -98,7 +98,9 @@
/// information and it can be tracked to a normal reference to a known
/// object, return the Value for that object. Otherwise return null.
static const Value *getUnderlyingObjectForInstr(const MachineInstr *MI,
- const MachineFrameInfo *MFI) {
+ const MachineFrameInfo *MFI,
+ bool &MayAlias) {
+ MayAlias = true;
if (!MI->hasOneMemOperand() ||
!(*MI->memoperands_begin())->getValue() ||
(*MI->memoperands_begin())->isVolatile())
@@ -110,6 +112,7 @@
V = getUnderlyingObject(V);
if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V)) {
+ MayAlias = PSV->mayAlias(MFI);
// For now, ignore PseudoSourceValues which may alias LLVM IR values
// because the code that uses this function has no way to cope with
// such aliases.
@@ -124,6 +127,23 @@
return 0;
}
+static bool mayUnderlyingObjectForInstrAlias(const MachineInstr *MI,
+ const MachineFrameInfo *MFI) {
+ if (!MI->hasOneMemOperand() ||
+ !(*MI->memoperands_begin())->getValue() ||
+ (*MI->memoperands_begin())->isVolatile())
+ return true;
+
+ const Value *V = (*MI->memoperands_begin())->getValue();
+ if (!V)
+ return true;
+
+ V = getUnderlyingObject(V);
+ if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V))
+ return PSV->mayAlias(MFI);
+ return true;
+}
+
void ScheduleDAGInstrs::StartBlock(MachineBasicBlock *BB) {
if (MachineLoop *ML = MLI.getLoopFor(BB))
if (BB == ML->getLoopLatch()) {
@@ -347,6 +367,7 @@
for (unsigned i = 0, e = I->second.size(); i != e; ++i)
I->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency));
I->second.clear();
+ I->second.push_back(SU);
}
// See if it is known to just have a single memory reference.
MachineInstr *ChainMI = Chain->getInstr();
@@ -362,8 +383,9 @@
// Unknown memory accesses. Assume the worst.
ChainMMO = 0;
} else if (TID.mayStore()) {
+ bool MayAlias = true;
TrueMemOrderLatency = STORE_LOAD_LATENCY;
- if (const Value *V = getUnderlyingObjectForInstr(MI, MFI)) {
+ if (const Value *V = getUnderlyingObjectForInstr(MI, MFI, MayAlias)) {
// A store to a specific PseudoSourceValue. Add precise dependencies.
// Handle the def in MemDefs, if there is one.
std::map<const Value *, SUnit *>::iterator I = MemDefs.find(V);
@@ -383,22 +405,26 @@
/*Reg=*/0, /*isNormalMemory=*/true));
J->second.clear();
}
- // Add dependencies from all the PendingLoads, since without
- // memoperands we must assume they alias anything.
- for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k)
- PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency));
- // Add a general dependence too, if needed.
- if (Chain)
- Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
+ if (MayAlias) {
+ // Add dependencies from all the PendingLoads, since without
+ // memoperands we must assume they alias anything.
+ for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k)
+ PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency));
+ // Add a general dependence too, if needed.
+ if (Chain)
+ Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
+ }
} else {
// Treat all other stores conservatively.
goto new_chain;
}
} else if (TID.mayLoad()) {
+ bool MayAlias = true;
TrueMemOrderLatency = 0;
if (MI->isInvariantLoad(AA)) {
// Invariant load, no chain dependencies needed!
- } else if (const Value *V = getUnderlyingObjectForInstr(MI, MFI)) {
+ } else if (const Value *V =
+ getUnderlyingObjectForInstr(MI, MFI, MayAlias)) {
// A load from a specific PseudoSourceValue. Add precise dependencies.
std::map<const Value *, SUnit *>::iterator I = MemDefs.find(V);
if (I != MemDefs.end())
@@ -415,15 +441,18 @@
// cases where memoperand information is unavailable.
goto new_chain;
} else {
- // A normal load. Depend on the general chain, as well as on
+ // A "MayAlias" load. Depend on the general chain, as well as on
// all stores. In the absense of MachineMemOperand information,
// we can't even assume that the load doesn't alias well-behaved
// memory locations.
if (Chain)
Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
for (std::map<const Value *, SUnit *>::iterator I = MemDefs.begin(),
- E = MemDefs.end(); I != E; ++I)
- I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
+ E = MemDefs.end(); I != E; ++I) {
+ SUnit *DefSU = I->second;
+ if (mayUnderlyingObjectForInstrAlias(DefSU->getInstr(), MFI))
+ DefSU->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
+ }
PendingLoads.push_back(SU);
}
}
More information about the llvm-branch-commits
mailing list