diff options
author | Artur Pilipenko <apilipenko@azulsystems.com> | 2016-04-27 11:00:48 +0000 |
---|---|---|
committer | Artur Pilipenko <apilipenko@azulsystems.com> | 2016-04-27 11:00:48 +0000 |
commit | 9bb6beabf4f4b7815b0e172530fb190a2a04c5ad (patch) | |
tree | 49dfa05b0079639b4d643f20c8e63606cb3ef8d6 /llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | |
parent | a4d7d783d04f15b65c749daa33baa3d94b1e5904 (diff) | |
download | bcm5719-llvm-9bb6beabf4f4b7815b0e172530fb190a2a04c5ad.tar.gz bcm5719-llvm-9bb6beabf4f4b7815b0e172530fb190a2a04c5ad.zip |
isSafeToLoadUnconditionally support queries without a context
This is required to use this function from isSafeToSpeculativelyExecute
Reviewed By: hfinkel
Differential Revision: http://reviews.llvm.org/D16231
llvm-svn: 267692
Diffstat (limited to 'llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 5e782692a78..9ff149ae91d 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1136,6 +1136,8 @@ public: /// We can do this to a select if its only uses are loads and if the operand to /// the select can be loaded unconditionally. static bool isSafeSelectToSpeculate(SelectInst *SI) { + const DataLayout &DL = SI->getModule()->getDataLayout(); + for (User *U : SI->users()) { LoadInst *LI = dyn_cast<LoadInst>(U); if (!LI || !LI->isSimple()) return false; @@ -1143,10 +1145,10 @@ static bool isSafeSelectToSpeculate(SelectInst *SI) { // Both operands to the select need to be dereferencable, either absolutely // (e.g. allocas) or at this point because we can see other accesses to it. if (!isSafeToLoadUnconditionally(SI->getTrueValue(), LI->getAlignment(), - LI)) + DL, LI)) return false; if (!isSafeToLoadUnconditionally(SI->getFalseValue(), LI->getAlignment(), - LI)) + DL, LI)) return false; } @@ -1193,6 +1195,8 @@ static bool isSafePHIToSpeculate(PHINode *PN) { MaxAlign = std::max(MaxAlign, LI->getAlignment()); } + const DataLayout &DL = PN->getModule()->getDataLayout(); + // Okay, we know that we have one or more loads in the same block as the PHI. // We can transform this if it is safe to push the loads into the predecessor // blocks. The only thing to watch out for is that we can't put a possibly @@ -1217,7 +1221,7 @@ static bool isSafePHIToSpeculate(PHINode *PN) { // If this pointer is always safe to load, or if we can prove that there is // already a load in the block, then we can move the load to the pred block. - if (isSafeToLoadUnconditionally(InVal, MaxAlign, Pred->getTerminator())) + if (isSafeToLoadUnconditionally(InVal, MaxAlign, DL, Pred->getTerminator())) continue; return false; |