This is an archive of the discontinued LLVM Phabricator instance.

[ConstantFold] Get rid of special cases for sizeof etc.
ClosedPublic

Authored by efriedma on Jul 29 2021, 4:37 PM.

Details

Summary

Constant folding will fold these down to simple constants (or at least, expressions that don't involve a GEP). We don't need heroics to try to optimize the form of the expression before that happens.

Fixes https://bugs.llvm.org/show_bug.cgi?id=51232 .

Diff Detail

Event Timeline

efriedma created this revision.Jul 29 2021, 4:37 PM
efriedma requested review of this revision.Jul 29 2021, 4:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2021, 4:37 PM
Herald added a subscriber: aheejin. · View Herald Transcript

I can’t say much about the code change itself, but it does indeed fix the build failure I was seeing, thanks!

nikic accepted this revision.Jul 31 2021, 12:59 AM
nikic added a subscriber: nikic.

LGTM -- the target-dependent folder is going to reduce these to constants, I don't see any value in trying very hard to optimize them in the target-indepenedent folder.

Note that you need to adjust clang codegen tests as well.

llvm/test/Other/constant-fold-gep.ll
50

Outdated comment.

This revision is now accepted and ready to land.Jul 31 2021, 12:59 AM
This revision was landed with ongoing or failed builds.Jul 31 2021, 1:21 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2021, 1:21 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thanks! Do you think this would be suitable for the 13.x release branch too?

Just committed 6eb2ffba to fix a couple regression tests.

Seems low-risk to cherry-pick to 13.x.