This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] avoid crashing on attribute propagation
ClosedPublic

Authored by spatel on Jan 20 2021, 1:46 PM.

Details

Summary

In https://llvm.org/PR48810 , we are crashing while trying to propagate attributes from mempcpy (returns void*) to memcpy (returns nothing - void).
We can avoid the crash by removing known incompatible attributes for the void return type.
I'm not sure if this goes far enough (should we just drop all attributes since this isn't the same function?). We also need to audit other transforms in LibCallSimplifier to make sure there are no other cases that have the same problem.

Diff Detail

Event Timeline

spatel created this revision.Jan 20 2021, 1:46 PM
spatel requested review of this revision.Jan 20 2021, 1:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2021, 1:46 PM
jdoerfert accepted this revision.Jan 20 2021, 2:00 PM

LGTM, one comment below though.

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
1158

We could attach (some, if not all) return value attributes to the first operand in order to preserve them. I guess a FIXME would do for now if you don't feel like including this.

This revision is now accepted and ready to land.Jan 20 2021, 2:00 PM
xbolva00 accepted this revision.Jan 20 2021, 3:34 PM
xbolva00 added a subscriber: xbolva00.

LG

spatel marked an inline comment as done.Jan 21 2021, 4:54 AM
spatel added inline comments.
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
1158

I haven't looked at what is currently possible with attribute transforms other than this, so I'll add a comment. Not sure if/when I can extend the patch.

This revision was automatically updated to reflect the committed changes.
spatel marked an inline comment as done.
jdoerfert added inline comments.Jan 21 2021, 7:00 AM
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
1158

Comment is fine. This bug needs fixing ;)