This is an archive of the discontinued LLVM Phabricator instance.

InstCombineCalls: when adding an align attribute, never reduce it
ClosedPublic

Authored by durin42 on Mar 14 2022, 2:25 PM.

Details

Summary

Sometimes we can infer an align from an allocalign but the function
already promised it'd be more-aligned than the allocalign and there's an
existing align that we shouldn't reduce. Make sure we handle that
correctly.

Diff Detail

Event Timeline

durin42 created this revision.Mar 14 2022, 2:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 2:25 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
durin42 requested review of this revision.Mar 14 2022, 2:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 2:25 PM
nikic added a subscriber: nikic.Mar 24 2022, 6:22 AM
nikic added inline comments.
llvm/test/Transforms/InstCombine/InferAlignAttribute.ll
2

We shouldn't be testing -O2 in InstCombine tests.

jyknight added inline comments.Apr 1 2022, 11:30 AM
llvm/test/Transforms/InstCombine/InferAlignAttribute.ll
37–39

Please explicitly note that this is mildly undesirable (yet conservatively correct) behavior. We would prefer the result to have an align 128, if that were to happen.

Also would be helpful to note that it is a simplified example of what happens in practice with _mm_malloc which calls posix_memalign.

durin42 updated this revision to Diff 420234.Apr 4 2022, 10:45 AM
durin42 edited the summary of this revision. (Show Details)
durin42 marked 2 inline comments as done.Apr 4 2022, 10:51 AM
nikic accepted this revision.Apr 6 2022, 2:15 AM
nikic added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
2843

While you're here: This explicit removeRetAttr shouldn't be necessary. addRetAttr overwrites an existing attribute.

This revision is now accepted and ready to land.Apr 6 2022, 2:15 AM
durin42 updated this revision to Diff 420848.Apr 6 2022, 7:41 AM
durin42 updated this revision to Diff 420909.Apr 6 2022, 9:10 AM
durin42 marked an inline comment as done.

removed the removeRetAttr - I agree it shouldn't be needed

durin42 updated this revision to Diff 421202.Apr 7 2022, 7:36 AM
This revision was landed with ongoing or failed builds.Apr 7 2022, 9:39 AM
This revision was automatically updated to reflect the committed changes.