Skip to content

Commit 3416d4f

Browse files
authored
[AA] Assert that alias() arguments are pointers (#138242)
Assert instead of returning NoAlias for non-pointers. This makes sure that people don't confuse alias (working on locations) with getModRefInfo (working on instructions).
1 parent 56097bc commit 3416d4f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/Analysis/AliasAnalysis.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
110110
AliasResult AAResults::alias(const MemoryLocation &LocA,
111111
const MemoryLocation &LocB, AAQueryInfo &AAQI,
112112
const Instruction *CtxI) {
113+
assert(LocA.Ptr->getType()->isPointerTy() &&
114+
LocB.Ptr->getType()->isPointerTy() &&
115+
"Can only call alias() on pointers");
113116
AliasResult Result = AliasResult::MayAlias;
114117

115118
if (EnableAATrace) {

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,6 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
15741574
if (isValueEqualInPotentialCycles(V1, V2, AAQI))
15751575
return AliasResult::MustAlias;
15761576

1577-
if (!V1->getType()->isPointerTy() || !V2->getType()->isPointerTy())
1578-
return AliasResult::NoAlias; // Scalars cannot alias each other
1579-
15801577
// Figure out what objects these things are pointing to if we can.
15811578
const Value *O1 = getUnderlyingObject(V1, MaxLookupSearchDepth);
15821579
const Value *O2 = getUnderlyingObject(V2, MaxLookupSearchDepth);

0 commit comments

Comments
 (0)