This is an archive of the discontinued LLVM Phabricator instance.

[llvm-reduce] Add reduction for aliases and special globals.
ClosedPublic

Authored by fhahn on Oct 27 2020, 12:44 PM.

Details

Summary

This patch adds a new reduction pass that tries to remove aliases and
special globals. It runs early, as most of those likely can be removed
up-front in practice.

This substantially improves llvm-reduce for IR generated by the swift
compiler, which can generate a lot of aliases and special globals, which
lead to lots of invalid reductions.

Removing aliases and special globals together is mostly done for
convenience, because both show up in IR generated by the swift compiler.

I am not sure if it is feasible to add a test case where globals cause problems,
because I think they only cause problems on large inputs where we spend a lot
of time removing globals in llvm.used & co.

Diff Detail

Event Timeline

fhahn created this revision.Oct 27 2020, 12:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2020, 12:44 PM
Herald added a subscriber: mgorny. · View Herald Transcript
fhahn requested review of this revision.Oct 27 2020, 12:44 PM
arsenm added inline comments.Oct 27 2020, 12:59 PM
llvm/tools/llvm-reduce/deltas/ReduceAliasAndSpecialGlobals.cpp
21 ↗(On Diff #301085)

I almost think reducing these should be a separate step

32 ↗(On Diff #301085)

Would it make more sense to replace this with the aliasee as a first step, and rely on ordinary global reduction as a separate phase?

I agree with @arsenm here.

llvm/tools/llvm-reduce/deltas/ReduceAliasAndSpecialGlobals.cpp
21 ↗(On Diff #301085)

+1, the rest of the patch is obvious.

fhahn updated this revision to Diff 301248.Oct 28 2020, 5:17 AM

Update patch to only include alias reduction.

lebedev.ri accepted this revision.Oct 28 2020, 5:20 AM

LGTM, thanks. I was hitting this problem occasionaly, but didn't get to write this reduction.

llvm/tools/llvm-reduce/deltas/ReduceAliases.cpp
35–37

Comment needs updating

llvm/tools/llvm-reduce/deltas/ReduceAliases.h
2

Unsufficient ---- padding

12

missing //

This revision is now accepted and ready to land.Oct 28 2020, 5:20 AM
fhahn added inline comments.Oct 28 2020, 5:25 AM
llvm/tools/llvm-reduce/deltas/ReduceAliasAndSpecialGlobals.cpp
21 ↗(On Diff #301085)

Done, moved to D90302

32 ↗(On Diff #301085)

The updated code now replaces the alias with the aliasee directly.

This revision was landed with ongoing or failed builds.Oct 28 2020, 6:13 AM
This revision was automatically updated to reflect the committed changes.