summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
diff options
context:
space:
mode:
authorEli Friedman <efriedma@quicinc.com>2019-05-24 01:03:51 +0000
committerEli Friedman <efriedma@quicinc.com>2019-05-24 01:03:51 +0000
commit052f87ae36163cbd2033617eba655af7f1438733 (patch)
treec3cb706a0ab4cea070e5526146d3c01558912690 /llvm/lib/Transforms/IPO
parent09ad8c8f73dbc64efada18e7ae2f9b64eb1be215 (diff)
downloadbcm5719-llvm-052f87ae36163cbd2033617eba655af7f1438733.tar.gz
bcm5719-llvm-052f87ae36163cbd2033617eba655af7f1438733.zip
Revert r361460
It regresses https://bugs.llvm.org/show_bug.cgi?id=38309 (represented by the testcase test/Transforms/GlobalOpt/globalsra-multigep.ll). llvm-svn: 361581
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp27
1 files changed, 4 insertions, 23 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index c4f268a6511..c4fb3ce77f6 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -184,7 +184,7 @@ static bool IsSafeComputationToRemove(Value *V, const TargetLibraryInfo *TLI) {
/// This GV is a pointer root. Loop over all users of the global and clean up
/// any that obviously don't assign the global a value that isn't dynamically
/// allocated.
-static bool CleanupPointerRootUsers(Value *V,
+static bool CleanupPointerRootUsers(GlobalVariable *GV,
const TargetLibraryInfo *TLI) {
// A brief explanation of leak checkers. The goal is to find bugs where
// pointers are forgotten, causing an accumulating growth in memory
@@ -202,7 +202,7 @@ static bool CleanupPointerRootUsers(Value *V,
SmallVector<std::pair<Instruction *, Instruction *>, 32> Dead;
// Constants can't be pointers to dynamically allocated memory.
- for (Value::user_iterator UI = V->user_begin(), E = V->user_end();
+ for (Value::user_iterator UI = GV->user_begin(), E = GV->user_end();
UI != E;) {
User *U = *UI++;
if (StoreInst *SI = dyn_cast<StoreInst>(U)) {
@@ -232,9 +232,6 @@ static bool CleanupPointerRootUsers(Value *V,
Dead.push_back(std::make_pair(I, MTI));
}
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(U)) {
- if (CE->getOpcode() == Instruction::GetElementPtr) {
- Changed |= CleanupPointerRootUsers(CE, TLI);
- }
if (CE->use_empty()) {
CE->destroyConstant();
Changed = true;
@@ -244,7 +241,7 @@ static bool CleanupPointerRootUsers(Value *V,
C->destroyConstant();
// This could have invalidated UI, start over from scratch.
Dead.clear();
- CleanupPointerRootUsers(V, TLI);
+ CleanupPointerRootUsers(GV, TLI);
return true;
}
}
@@ -394,22 +391,6 @@ static bool isSafeSROAGEP(User *U) {
[](User *UU) { return isSafeSROAElementUse(UU); });
}
-/// Return true if the specified GEP is a safe user of a derived
-/// expression from a global that we want to SROA.
-static bool isSafeSubSROAGEP(User *U) {
-
- // Check to see if this ConstantExpr GEP is SRA'able. In particular, we
- // don't like < 3 operand CE's, and we don't like non-constant integer
- // indices. This enforces that all uses are 'gep GV, 0, C, ...' for some
- // value of C.
- if (U->getNumOperands() < 3 || !isa<Constant>(U->getOperand(1)) ||
- !cast<Constant>(U->getOperand(1))->isNullValue())
- return false;
-
- return llvm::all_of(U->users(),
- [](User *UU) { return isSafeSROAElementUse(UU); });
-}
-
/// Return true if the specified instruction is a safe user of a derived
/// expression from a global that we want to SROA.
static bool isSafeSROAElementUse(Value *V) {
@@ -428,7 +409,7 @@ static bool isSafeSROAElementUse(Value *V) {
return SI->getOperand(0) != V;
// Otherwise, it must be a GEP. Check it and its users are safe to SRA.
- return isa<GetElementPtrInst>(I) && isSafeSubSROAGEP(I);
+ return isa<GetElementPtrInst>(I) && isSafeSROAGEP(I);
}
/// Look at all uses of the global and decide whether it is safe for us to
OpenPOWER on IntegriCloud