This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] when calling conventions are compatible, don't convert the call to undef idiom
ClosedPublic

Authored by ychen on Apr 1 2021, 3:19 PM.

Details

Summary

D24453 enabled libcalls simplication for ARM PCS. This may cause
caller/callee calling conventions mismatch in some situations such as
LTO. This patch makes instcombine aware that the compatible calling
conventions differences are benign (not emitting undef idom).

Diff Detail

Event Timeline

ychen created this revision.Apr 1 2021, 3:19 PM
ychen requested review of this revision.Apr 1 2021, 3:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2021, 3:19 PM
ychen updated this revision to Diff 335895.Apr 7 2021, 11:59 AM
  • fix styling issue
ychen updated this revision to Diff 336590.Apr 9 2021, 6:32 PM
  • fix typo
lebedev.ri accepted this revision.Apr 10 2021, 12:31 AM
lebedev.ri added a subscriber: lebedev.ri.

LGTM, since we were already doing that in SimplifyLibCalls.

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
2160–2161
This revision is now accepted and ready to land.Apr 10 2021, 12:31 AM
ychen updated this revision to Diff 336740.Apr 11 2021, 9:31 PM
  • address comments
This revision was landed with ongoing or failed builds.Apr 12 2021, 9:33 AM
This revision was automatically updated to reflect the committed changes.
nikic added a comment.Apr 12 2021, 2:07 PM

I've temporarily reverted this change because it causes a significant compile-time regression, see https://llvm-compile-time-tracker.com/compare.php?from=4b7bad9eaea2233521a94f6b096aaa88dc584e23&to=f4d682d6ce6c5b3a41a0acf297507c82f5c21eef&stat=instructions. I assume that wasn't intentional.

Looking at the code, what stands out to me is that you're now parsing the target triple eagerly, even though it is only needed if AAPCS is actually involved. Passing it into the function as StringRef instead of Triple is probably sufficient. (More generally, it might make sense to store a parsed target triple in the module...)

ychen added a comment.Apr 12 2021, 2:50 PM

I've temporarily reverted this change because it causes a significant compile-time regression, see https://llvm-compile-time-tracker.com/compare.php?from=4b7bad9eaea2233521a94f6b096aaa88dc584e23&to=f4d682d6ce6c5b3a41a0acf297507c82f5c21eef&stat=instructions. I assume that wasn't intentional.

Looking at the code, what stands out to me is that you're now parsing the target triple eagerly, even though it is only needed if AAPCS is actually involved. Passing it into the function as StringRef instead of Triple is probably sufficient. (More generally, it might make sense to store a parsed target triple in the module...)

Thanks for the report. Passing Stringref does put it back to normal.
https://llvm-compile-time-tracker.com/compare.php?from=23b8264b5255efdc7c87c189feab04520a1979d5&to=69359ebeee6e3bd0e786a51ca542762d3aa4e606&stat=instructions