This is an archive of the discontinued LLVM Phabricator instance.

[Assignment Tracking] Check getTypeSizeInBits result for scalable vector types
ClosedPublic

Authored by Orlando on Apr 25 2023, 2:19 AM.

Details

Summary

Without this patch, in getAssignmentInfo the result of getTypeSizeInBits is cast to uint64_t, which a) is an operation that will eventually be unsupported by the API according to the comments, and b) causes an assertion failure if the type is a scalable vector. Don't cast the TypeSize to uint64_t and check isScalable before getting the fixed size.

This can result in incorrect variable locations, see llvm.org/PR62346 (but is better than crashing).

Diff Detail

Event Timeline

Orlando created this revision.Apr 25 2023, 2:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 2:19 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Orlando requested review of this revision.Apr 25 2023, 2:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 2:19 AM
DavidSpickett resigned from this revision.Apr 26 2023, 2:58 AM

I'm not qualified to review this, others are.

paulwalker-arm added inline comments.Apr 27 2023, 2:53 AM
llvm/lib/IR/DebugInfo.cpp
1950

Is the use of "Scalar" here accurate? given it's only scalable vectors that are being rejected.

Only a suggestion but what about changing getAssignmentInfoImpl to take a TypeSize instead of an uint64_t and then reject scalable sizes within that? This way if/when scalable support is required the structure will already be in place.

Orlando updated this revision to Diff 517526.Apr 27 2023, 5:41 AM
Orlando marked an inline comment as done.

+ Address review comment

llvm/lib/IR/DebugInfo.cpp
1950

Thanks, I agree that way is better - fixed.

paulwalker-arm accepted this revision.Apr 27 2023, 4:12 PM
This revision is now accepted and ready to land.Apr 27 2023, 4:12 PM