Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions llvm/lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,8 +1237,11 @@ AliasResult BasicAAResult::aliasGEP(
if (V1Size.isScalable() || V2Size.isScalable())
return AliasResult::MayAlias;

// We need to know both acess sizes for all the following heuristics.
if (!V1Size.hasValue() || !V2Size.hasValue())
// We need to know both access sizes for all the following heuristics. Don't
// try to reason about sizes larger than the index space.
unsigned BW = DecompGEP1.Offset.getBitWidth();
if (!V1Size.hasValue() || !V2Size.hasValue() ||
!isUIntN(BW, V1Size.getValue()) || !isUIntN(BW, V2Size.getValue()))
return AliasResult::MayAlias;

APInt GCD;
Expand Down Expand Up @@ -1293,7 +1296,6 @@ AliasResult BasicAAResult::aliasGEP(

// Compute ranges of potentially accessed bytes for both accesses. If the
// interseciton is empty, there can be no overlap.
unsigned BW = OffsetRange.getBitWidth();
ConstantRange Range1 = OffsetRange.add(
ConstantRange(APInt(BW, 0), APInt(BW, V1Size.getValue())));
ConstantRange Range2 =
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/Analysis/BasicAA/size-overflow.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; RUN: opt -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s

target datalayout = "p:32:32"

; Make sure that using a LocationSize larget than the index space does not
; assert.

; Just Mod: Ptr: i32* %gep <-> call void @llvm.memset.p0.i64(ptr %p, i8 0, i64 68719476736, i1 false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing CHECK below?

Suggested change
; Just Mod: Ptr: i32* %gep <-> call void @llvm.memset.p0.i64(ptr %p, i8 0, i64 68719476736, i1 false)
; CHECK: Just Mod: Ptr: i32* %gep <-> call void @llvm.memset.p0.i64(ptr %p, i8 0, i64 68719476736, i1 false)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, looks like I never actually ran the new test...

define void @test(ptr %p, i32 %idx) {
%gep = getelementptr i8, ptr %p, i32 %idx
load i32, ptr %gep
call void @llvm.memset.i64(ptr %p, i8 0, i64 u0x100000000, i1 false)
ret void
}
Loading