This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyLibCalls] Don't change alignment when creating memset
ClosedPublic

Authored by sstefan1 on Apr 20 2021, 11:08 AM.

Details

Summary

Fix for PR49984

This was discovered during Attributor testing. Memset was always created with alignment of 1 and in case when strncpy alignment was changed it triggered an assertion in the AttrBuilder. Memset will now be created with appropriate alignment.

Diff Detail

Event Timeline

sstefan1 created this revision.Apr 20 2021, 11:08 AM
sstefan1 requested review of this revision.Apr 20 2021, 11:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2021, 11:08 AM
sstefan1 retitled this revision from [SimplifyLibCalls] Don't change alignment when creating memset Fix for PR49984 to [SimplifyLibCalls] Don't change alignment when creating memset.Apr 20 2021, 11:09 AM
sstefan1 edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Apr 20 2021, 11:32 AM
lebedev.ri requested changes to this revision.Apr 20 2021, 11:33 AM
lebedev.ri added a subscriber: lebedev.ri.

Please explain the problem in patch's description.

This revision now requires changes to proceed.Apr 20 2021, 11:33 AM
sstefan1 edited the summary of this revision. (Show Details)Apr 20 2021, 11:56 AM
lebedev.ri added inline comments.Apr 20 2021, 12:02 PM
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
577–578

The comment is now wrong

sstefan1 added inline comments.Apr 20 2021, 2:33 PM
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
577–578

Yeah, forgot to update. I guess alignment shouldn't be mentioned anymore.

sstefan1 updated this revision to Diff 339000.Apr 20 2021, 2:33 PM

update comment

Looks ok as a fix. I am just wondering if some other places should be checked as well.

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

Could we expect same problem here in the future?

lebedev.ri resigned from this revision.Apr 21 2021, 8:59 AM
This revision is now accepted and ready to land.Apr 21 2021, 8:59 AM

Looks ok as a fix. I am just wondering if some other places should be checked as well.

Good question. I've just checked and this is the only place to call addParamAttributes() which has the assertion. Other places just set attributes.

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

No, as long as addParamAttributes() is not called bellow.

Ok, thank you.