diff options
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/IR/Module.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/IR/Value.cpp | 30 | ||||
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 2 |
4 files changed, 13 insertions, 27 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index a78de6a0c84..ee0c1e1f5f6 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -521,10 +521,8 @@ bool Constant::needsRelocation() const { return false; // Relative pointers do not need to be dynamically relocated. - if (auto *LHSGV = dyn_cast<GlobalValue>( - LHSOp0->stripPointerCastsNoFollowAliases())) - if (auto *RHSGV = dyn_cast<GlobalValue>( - RHSOp0->stripPointerCastsNoFollowAliases())) + if (auto *LHSGV = dyn_cast<GlobalValue>(LHSOp0->stripPointerCasts())) + if (auto *RHSGV = dyn_cast<GlobalValue>(RHSOp0->stripPointerCasts())) if (LHSGV->isDSOLocal() && RHSGV->isDSOLocal()) return false; } diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index dbf4035ac7c..25efd009194 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -604,7 +604,7 @@ GlobalVariable *llvm::collectUsedGlobalVariables( const ConstantArray *Init = cast<ConstantArray>(GV->getInitializer()); for (Value *Op : Init->operands()) { - GlobalValue *G = cast<GlobalValue>(Op->stripPointerCastsNoFollowAliases()); + GlobalValue *G = cast<GlobalValue>(Op->stripPointerCasts()); Set.insert(G); } return GV; diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index b3dcaee766c..c66cbddafd9 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -455,9 +455,8 @@ namespace { // Various metrics for how much to strip off of pointers. enum PointerStripKind { PSK_ZeroIndices, - PSK_ZeroIndicesAndAliases, - PSK_ZeroIndicesAndAliasesSameRepresentation, - PSK_ZeroIndicesAndAliasesAndInvariantGroups, + PSK_ZeroIndicesSameRepresentation, + PSK_ZeroIndicesAndInvariantGroups, PSK_InBoundsConstantIndices, PSK_InBounds }; @@ -475,10 +474,9 @@ static const Value *stripPointerCastsAndOffsets(const Value *V) { do { if (auto *GEP = dyn_cast<GEPOperator>(V)) { switch (StripKind) { - case PSK_ZeroIndicesAndAliases: - case PSK_ZeroIndicesAndAliasesSameRepresentation: - case PSK_ZeroIndicesAndAliasesAndInvariantGroups: case PSK_ZeroIndices: + case PSK_ZeroIndicesSameRepresentation: + case PSK_ZeroIndicesAndInvariantGroups: if (!GEP->hasAllZeroIndices()) return V; break; @@ -494,15 +492,11 @@ static const Value *stripPointerCastsAndOffsets(const Value *V) { V = GEP->getPointerOperand(); } else if (Operator::getOpcode(V) == Instruction::BitCast) { V = cast<Operator>(V)->getOperand(0); - } else if (StripKind != PSK_ZeroIndicesAndAliasesSameRepresentation && + } else if (StripKind != PSK_ZeroIndicesSameRepresentation && Operator::getOpcode(V) == Instruction::AddrSpaceCast) { // TODO: If we know an address space cast will not change the // representation we could look through it here as well. V = cast<Operator>(V)->getOperand(0); - } else if (auto *GA = dyn_cast<GlobalAlias>(V)) { - if (StripKind == PSK_ZeroIndices || GA->isInterposable()) - return V; - V = GA->getAliasee(); } else { if (const auto *Call = dyn_cast<CallBase>(V)) { if (const Value *RV = Call->getReturnedArgOperand()) { @@ -512,7 +506,7 @@ static const Value *stripPointerCastsAndOffsets(const Value *V) { // The result of launder.invariant.group must alias it's argument, // but it can't be marked with returned attribute, that's why it needs // special case. - if (StripKind == PSK_ZeroIndicesAndAliasesAndInvariantGroups && + if (StripKind == PSK_ZeroIndicesAndInvariantGroups && (Call->getIntrinsicID() == Intrinsic::launder_invariant_group || Call->getIntrinsicID() == Intrinsic::strip_invariant_group)) { V = Call->getArgOperand(0); @@ -529,16 +523,11 @@ static const Value *stripPointerCastsAndOffsets(const Value *V) { } // end anonymous namespace const Value *Value::stripPointerCasts() const { - return stripPointerCastsAndOffsets<PSK_ZeroIndicesAndAliases>(this); + return stripPointerCastsAndOffsets<PSK_ZeroIndices>(this); } const Value *Value::stripPointerCastsSameRepresentation() const { - return stripPointerCastsAndOffsets< - PSK_ZeroIndicesAndAliasesSameRepresentation>(this); -} - -const Value *Value::stripPointerCastsNoFollowAliases() const { - return stripPointerCastsAndOffsets<PSK_ZeroIndices>(this); + return stripPointerCastsAndOffsets<PSK_ZeroIndicesSameRepresentation>(this); } const Value *Value::stripInBoundsConstantOffsets() const { @@ -546,8 +535,7 @@ const Value *Value::stripInBoundsConstantOffsets() const { } const Value *Value::stripPointerCastsAndInvariantGroups() const { - return stripPointerCastsAndOffsets<PSK_ZeroIndicesAndAliasesAndInvariantGroups>( - this); + return stripPointerCastsAndOffsets<PSK_ZeroIndicesAndInvariantGroups>(this); } const Value * diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 6fa58741be1..0350edb2454 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -673,7 +673,7 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) { Assert(InitArray, "wrong initalizer for intrinsic global variable", Init); for (Value *Op : InitArray->operands()) { - Value *V = Op->stripPointerCastsNoFollowAliases(); + Value *V = Op->stripPointerCasts(); Assert(isa<GlobalVariable>(V) || isa<Function>(V) || isa<GlobalAlias>(V), "invalid llvm.used member", V); |