forked from OSchip/llvm-project
[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:
parent
412a0101a9
commit
c90681b681
|
@ -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)) {
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue