diff options
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 572f37a..92ffae1 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -551,7 +551,7 @@ enum PointerStripKind { PSK_ZeroIndices, PSK_ZeroIndicesAndAliases, PSK_ZeroIndicesSameRepresentation, - PSK_ZeroIndicesAndInvariantGroups, + PSK_ForAliasAnalysis, PSK_InBoundsConstantIndices, PSK_InBounds }; @@ -577,7 +577,7 @@ static const Value *stripPointerCastsAndOffsets( case PSK_ZeroIndices: case PSK_ZeroIndicesAndAliases: case PSK_ZeroIndicesSameRepresentation: - case PSK_ZeroIndicesAndInvariantGroups: + case PSK_ForAliasAnalysis: if (!GEP->hasAllZeroIndices()) return V; break; @@ -602,6 +602,9 @@ static const Value *stripPointerCastsAndOffsets( V = cast<Operator>(V)->getOperand(0); } else if (StripKind == PSK_ZeroIndicesAndAliases && isa<GlobalAlias>(V)) { V = cast<GlobalAlias>(V)->getAliasee(); + } else if (StripKind == PSK_ForAliasAnalysis && isa<PHINode>(V) && + cast<PHINode>(V)->getNumIncomingValues() == 1) { + V = cast<PHINode>(V)->getIncomingValue(0); } else { if (const auto *Call = dyn_cast<CallBase>(V)) { if (const Value *RV = Call->getReturnedArgOperand()) { @@ -611,7 +614,7 @@ static const Value *stripPointerCastsAndOffsets( // 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_ZeroIndicesAndInvariantGroups && + if (StripKind == PSK_ForAliasAnalysis && (Call->getIntrinsicID() == Intrinsic::launder_invariant_group || Call->getIntrinsicID() == Intrinsic::strip_invariant_group)) { V = Call->getArgOperand(0); @@ -643,8 +646,8 @@ const Value *Value::stripInBoundsConstantOffsets() const { return stripPointerCastsAndOffsets<PSK_InBoundsConstantIndices>(this); } -const Value *Value::stripPointerCastsAndInvariantGroups() const { - return stripPointerCastsAndOffsets<PSK_ZeroIndicesAndInvariantGroups>(this); +const Value *Value::stripPointerCastsForAliasAnalysis() const { + return stripPointerCastsAndOffsets<PSK_ForAliasAnalysis>(this); } const Value *Value::stripAndAccumulateConstantOffsets( |