summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-08-22 23:37:20 +0000
committerChris Lattner <sabre@nondot.org>2002-08-22 23:37:20 +0000
commitcc63f1c67456f41b25e8ccb8c1dce72067ddbadf (patch)
tree52db175350fef9c25f1efd36dfbb1f0ee627ce9a /lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parentd145c2172fc54160c5edf199a1a96fca492e19bc (diff)
downloadllvm-cc63f1c67456f41b25e8ccb8c1dce72067ddbadf.tar.gz
llvm-cc63f1c67456f41b25e8ccb8c1dce72067ddbadf.tar.bz2
llvm-cc63f1c67456f41b25e8ccb8c1dce72067ddbadf.tar.xz
Eliminated the MemAccessInst class, folding contents into GEP class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3487 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp20
1 files changed, 3 insertions, 17 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index d3aca318b0..5fcab97035 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -76,25 +76,11 @@ namespace {
static inline bool isSafeAlloca(const AllocaInst *AI) {
if (AI->isArrayAllocation()) return false;
+ // Only allow direct loads and stores...
for (Value::use_const_iterator UI = AI->use_begin(), UE = AI->use_end();
- UI != UE; ++UI) { // Loop over all of the uses of the alloca
-
- // Only allow nonindexed memory access instructions...
- if (MemAccessInst *MAI = dyn_cast<MemAccessInst>(*UI)) {
- if (MAI->getPointerOperand() != (Value*)AI)
- return false; // Reject stores of alloca pointer into some other loc.
-
- if (MAI->hasIndices()) { // indexed?
- // Allow the access if there is only one index and the index is
- // zero.
- if (*MAI->idx_begin() != Constant::getNullValue(Type::UIntTy) ||
- MAI->idx_begin()+1 != MAI->idx_end())
- return false;
- }
- } else {
+ UI != UE; ++UI) // Loop over all of the uses of the alloca
+ if (!isa<LoadInst>(*UI) && !isa<StoreInst>(*UI))
return false; // Not a load or store?
- }
- }
return true;
}