This is an archive of the discontinued LLVM Phabricator instance.

InferAddressSpaces: Fix assert on inferred source for inttoptr/ptrtoint
ClosedPublic

Authored by arsenm on Feb 8 2022, 6:00 PM.

Details

Summary

If we had some source value we could infer an address space from that
went through a ptrtoint/inttoptr pair, this would fail since bitcast
can't change the address space.

Fixes issue 53665.

Diff Detail

Event Timeline

arsenm created this revision.Feb 8 2022, 6:00 PM
arsenm requested review of this revision.Feb 8 2022, 6:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2022, 6:00 PM
Herald added a subscriber: wdng. · View Herald Transcript
cchen added a subscriber: cchen.Feb 8 2022, 6:10 PM
jdoerfert added inline comments.Feb 9 2022, 12:52 PM
llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
667

Doesn't this break if we require both, an AS and a bitcast?
Wouldn't BitCastInst::CreatePointerBitCastOrAddrSpaceCast be a more generic (and shorter) choice here?

llvm/test/Transforms/InferAddressSpaces/AMDGPU/issue53665.ll
48

I don't see the difference between this one and the first function. AS 1 vs 3?

arsenm added inline comments.Feb 9 2022, 1:00 PM
llvm/test/Transforms/InferAddressSpaces/AMDGPU/issue53665.ll
48

Yes

arsenm updated this revision to Diff 407555.Feb 10 2022, 8:47 AM

Use CreatePointerBitCastOrAddrSpaceCast

This revision is now accepted and ready to land.Feb 10 2022, 11:55 AM
cchen added a comment.Feb 10 2022, 1:04 PM

Can we push this patch back to 14.x release branch?