diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Utils/GlobalStatus.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Utils/GlobalStatus.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Utils/GlobalStatus.cpp b/contrib/llvm-project/llvm/lib/Transforms/Utils/GlobalStatus.cpp index f782396be7b6..9bfc73e4ba6c 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Utils/GlobalStatus.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Utils/GlobalStatus.cpp @@ -105,8 +105,10 @@ static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS, // value, not an aggregate), keep more specific information about // stores. if (GS.StoredType != GlobalStatus::Stored) { - if (const GlobalVariable *GV = - dyn_cast<GlobalVariable>(SI->getOperand(1))) { + const Value *Ptr = SI->getPointerOperand(); + if (isa<ConstantExpr>(Ptr)) + Ptr = Ptr->stripPointerCasts(); + if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) { Value *StoredVal = SI->getOperand(0); if (Constant *C = dyn_cast<Constant>(StoredVal)) { @@ -125,9 +127,9 @@ static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS, GS.StoredType = GlobalStatus::InitializerStored; } else if (GS.StoredType < GlobalStatus::StoredOnce) { GS.StoredType = GlobalStatus::StoredOnce; - GS.StoredOnceValue = StoredVal; + GS.StoredOnceStore = SI; } else if (GS.StoredType == GlobalStatus::StoredOnce && - GS.StoredOnceValue == StoredVal) { + GS.getStoredOnceValue() == StoredVal) { // noop. } else { GS.StoredType = GlobalStatus::Stored; |