[Attributor][FIX] Don't crash on ptr2int/int2ptr instructions

An integer isn't allowed in getAlignmentForValue so we need to stop at a
ptr2int instruction during exploration.
This commit is contained in:
Johannes Doerfert 2020-01-02 16:41:17 -06:00
parent 412a0101a9
commit c90681b681
2 changed files with 12 additions and 1 deletions

View File

@ -3466,7 +3466,8 @@ static unsigned int getKnownAlignForUse(Attributor &A,
// We need to follow common pointer manipulation uses to the accesses they
// feed into.
if (isa<CastInst>(I)) {
TrackUse = true;
// Follow all but ptr2int casts.
TrackUse = !isa<PtrToIntInst>(I);
return 0;
}
if (auto *GEP = dyn_cast<GetElementPtrInst>(I)) {

View File

@ -398,5 +398,15 @@ define void @test12-6(i32* align 4 %p) {
ret void
}
; Don't crash on ptr2int/int2ptr uses.
define i64 @ptr2int(i32* %p) {
%p2i = ptrtoint i32* %p to i64
ret i64 %p2i
}
define i64* @int2ptr(i64 %i) {
%i2p = inttoptr i64 %i to i64*
ret i64* %i2p
}
attributes #0 = { nounwind uwtable noinline }
attributes #1 = { uwtable noinline }