This is an archive of the discontinued LLVM Phabricator instance.

MemoryBuiltins: also check function definition for allocalign
ClosedPublic

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

Details

Summary

This got changed to use hasAttrSomewhere() during review, and I didn't
notice until today when I was writing some tests for another part of
this system that using hasAttrSomewhere only checked the callsite for
allocalign, rather than both the callsite and the definition. This fixes
that by introducing a helper method.

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 14 2022, 3:20 PM

This should have a test, e.g. in InstCombine.

This should have a test, e.g. in InstCombine.

That happens as part of D121642 - is that okay?

nikic added a comment.Mar 24 2022, 6:23 AM

This should have a test, e.g. in InstCombine.

That happens as part of D121642 - is that okay?

I'd suggest pre-committing the tests, so that the test diff then shows up in the individual patches.

durin42 updated this revision to Diff 420233.Apr 4 2022, 10:45 AM
durin42 edited the summary of this revision. (Show Details)
nikic added inline comments.Apr 6 2022, 2:13 AM
llvm/lib/Analysis/MemoryBuiltins.cpp
343

Maybe we should have a helper function on CallBase for this whole logic? See CallBase::getReturnedArgOperand() which implements exactly the same but with Attribute::Returned instead of Attribute::AllocAlign.

durin42 updated this revision to Diff 420847.Apr 6 2022, 7:41 AM
durin42 edited the summary of this revision. (Show Details)
durin42 marked an inline comment as done.Apr 6 2022, 7:41 AM
nikic added inline comments.Apr 7 2022, 2:40 AM
llvm/lib/IR/Instructions.cpp
340

That wasn't quite what I had in mind: I don't think we'll want to fetch allocalign beyond that one callsite. Rather, we could have CallBase::getArgOperandWithAttribute(AttrKind) and then use that both in getReturnedArgOperand() and in getAllocAlignment().

durin42 updated this revision to Diff 421201.Apr 7 2022, 7:36 AM
durin42 marked an inline comment as done.Apr 7 2022, 7:37 AM
nikic accepted this revision.Apr 7 2022, 7:57 AM

LGTM

This revision is now accepted and ready to land.Apr 7 2022, 7:57 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.