summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2016-08-12 17:13:28 +0000
committerPete Cooper <peter_cooper@apple.com>2016-08-12 17:13:28 +0000
commit980a935e27f14ae7b3a85bb4b4821e8730f6c673 (patch)
treee9236ba232bb5d47aaa89ebb5ac2b85f5de9160d /llvm/lib/Transforms
parent1dc065b659cc2b45b750b3773cbf7331289bf9e9 (diff)
downloadbcm5719-llvm-980a935e27f14ae7b3a85bb4b4821e8730f6c673.tar.gz
bcm5719-llvm-980a935e27f14ae7b3a85bb4b4821e8730f6c673.zip
constify InstCombine::foldAllocaCmp. NFC.
This is part of an effort to constify ValueTracking.cpp. This change is to methods which need const Value* instead of Value* to go with the upcoming changes to ValueTracking. llvm-svn: 278528
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp19
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineInternal.h3
2 files changed, 12 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 52cadb1d9a3..847b4a19995 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1051,8 +1051,9 @@ Instruction *InstCombiner::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
return transformToIndexedCompare(GEPLHS, RHS, Cond, DL);
}
-Instruction *InstCombiner::foldAllocaCmp(ICmpInst &ICI, AllocaInst *Alloca,
- Value *Other) {
+Instruction *InstCombiner::foldAllocaCmp(ICmpInst &ICI,
+ const AllocaInst *Alloca,
+ const Value *Other) {
assert(ICI.isEquality() && "Cannot fold non-equality comparison.");
// It would be tempting to fold away comparisons between allocas and any
@@ -1071,8 +1072,8 @@ Instruction *InstCombiner::foldAllocaCmp(ICmpInst &ICI, AllocaInst *Alloca,
unsigned MaxIter = 32; // Break cycles and bound to constant-time.
- SmallVector<Use *, 32> Worklist;
- for (Use &U : Alloca->uses()) {
+ SmallVector<const Use *, 32> Worklist;
+ for (const Use &U : Alloca->uses()) {
if (Worklist.size() >= MaxIter)
return nullptr;
Worklist.push_back(&U);
@@ -1081,8 +1082,8 @@ Instruction *InstCombiner::foldAllocaCmp(ICmpInst &ICI, AllocaInst *Alloca,
unsigned NumCmps = 0;
while (!Worklist.empty()) {
assert(Worklist.size() <= MaxIter);
- Use *U = Worklist.pop_back_val();
- Value *V = U->getUser();
+ const Use *U = Worklist.pop_back_val();
+ const Value *V = U->getUser();
--MaxIter;
if (isa<BitCastInst>(V) || isa<GetElementPtrInst>(V) || isa<PHINode>(V) ||
@@ -1091,7 +1092,7 @@ Instruction *InstCombiner::foldAllocaCmp(ICmpInst &ICI, AllocaInst *Alloca,
} else if (isa<LoadInst>(V)) {
// Loading from the pointer doesn't escape it.
continue;
- } else if (auto *SI = dyn_cast<StoreInst>(V)) {
+ } else if (const auto *SI = dyn_cast<StoreInst>(V)) {
// Storing *to* the pointer is fine, but storing the pointer escapes it.
if (SI->getValueOperand() == U->get())
return nullptr;
@@ -1100,7 +1101,7 @@ Instruction *InstCombiner::foldAllocaCmp(ICmpInst &ICI, AllocaInst *Alloca,
if (NumCmps++)
return nullptr; // Found more than one cmp.
continue;
- } else if (auto *Intrin = dyn_cast<IntrinsicInst>(V)) {
+ } else if (const auto *Intrin = dyn_cast<IntrinsicInst>(V)) {
switch (Intrin->getIntrinsicID()) {
// These intrinsics don't escape or compare the pointer. Memset is safe
// because we don't allow ptrtoint. Memcpy and memmove are safe because
@@ -1115,7 +1116,7 @@ Instruction *InstCombiner::foldAllocaCmp(ICmpInst &ICI, AllocaInst *Alloca,
} else {
return nullptr;
}
- for (Use &U : V->uses()) {
+ for (const Use &U : V->uses()) {
if (Worklist.size() >= MaxIter)
return nullptr;
Worklist.push_back(&U);
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index ea6827cbc29..c555ff8d129 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -541,7 +541,8 @@ private:
Instruction *foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
ICmpInst::Predicate Cond, Instruction &I);
- Instruction *foldAllocaCmp(ICmpInst &ICI, AllocaInst *Alloca, Value *Other);
+ Instruction *foldAllocaCmp(ICmpInst &ICI, const AllocaInst *Alloca,
+ const Value *Other);
Instruction *foldCmpLoadFromIndexedGlobal(GetElementPtrInst *GEP,
GlobalVariable *GV, CmpInst &ICI,
ConstantInt *AndCst = nullptr);
OpenPOWER on IntegriCloud