This is an archive of the discontinued LLVM Phabricator instance.

[LangRef] Allow non-power-of-two assume operand bundle
ClosedPublic

Authored by nikic on Feb 10 2022, 12:53 AM.

Details

Summary

There has been a lot of confusion on this in the past (see for example https://reviews.llvm.org/D110634 and earlier revisions), so let's try to get some clarity here. This patch specifies that a) specifying a non-constant assumed alignment is explicitly allowed and b) an invalid (non-power-of-two) alignment is not UB, but rather converts it into an assumption that the pointer is null.

This change is done for two reasons: a) Assume operand bundles are specifically used in cases where the alignment is not known during frontend codegen (otherwise we'd just use an align attribute), so rejecting this case doesn't make sense. b) At least for aligned_alloc the C standard specifies that passing an invalid alignment results in a null pointer, not undefined behavior.

Diff Detail

Event Timeline

nikic requested review of this revision.Feb 10 2022, 12:53 AM
nikic created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2022, 12:53 AM

Would work for me, others?

nikic added a comment.Feb 17 2022, 3:26 AM

Any other thoughts on this?

I believe the proposed semantics would match what the proposed allocalign attribute specifies in https://reviews.llvm.org/D117921.

I haven't followed the details in the source-level construct, but if this makes it easier to nail down the behavior in LLVM, that's good for me.

Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2022, 1:56 AM
jyknight accepted this revision.Mar 18 2022, 8:37 AM

Being consistent with allocalign's proposed semantics sounds good to me.

This revision is now accepted and ready to land.Mar 18 2022, 8:37 AM
This revision was landed with ongoing or failed builds.Mar 23 2022, 7:53 AM
This revision was automatically updated to reflect the committed changes.