This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Liveness for internal functions.
ClosedPublic

Authored by sstefan1 on Aug 13 2019, 11:03 AM.

Details

Summary

For an internal function, if all its call sites are dead, the body of the function is considered dead. This patch also updates checkForAllCallSites with llvm::function_ref.

Diff Detail

Repository
rL LLVM

Event Timeline

sstefan1 created this revision.Aug 13 2019, 11:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2019, 11:04 AM

Test missing, otherwise good

llvm/lib/Transforms/IPO/Attributor.cpp
1495 ↗(On Diff #214883)

Move this into a helper function as it is a copy of the init code.

sstefan1 updated this revision to Diff 214934.Aug 13 2019, 2:55 PM
  • adding tests & helper function
jdoerfert added inline comments.Aug 13 2019, 2:59 PM
llvm/test/Transforms/FunctionAttrs/liveness.ll
29 ↗(On Diff #214934)

We should kill dead functions in the manifest method.

sstefan1 updated this revision to Diff 215262.EditedAug 14 2019, 3:03 PM
  • Replace dead functions with undef
jdoerfert added inline comments.Aug 14 2019, 3:08 PM
llvm/test/Transforms/FunctionAttrs/align.ll
130 ↗(On Diff #215262)

Use this as scc test in liveness and make one of them live in this test so that all become live

llvm/test/Transforms/FunctionAttrs/liveness.ll
18 ↗(On Diff #215262)

These should not be derived anymore. We stopped annotating dead stuff.

sstefan1 marked an inline comment as done.Aug 14 2019, 3:12 PM
sstefan1 added inline comments.
llvm/test/Transforms/FunctionAttrs/liveness.ll
18 ↗(On Diff #215262)

Didn't intend to include this. This is actually a leftover. Didn't see you committed that.

sstefan1 updated this revision to Diff 215277.Aug 14 2019, 4:05 PM
  • add scc test
jdoerfert accepted this revision.Aug 14 2019, 4:55 PM

A few minor comments, otherwise LGTM.

llvm/lib/Transforms/IPO/Attributor.cpp
1289 ↗(On Diff #215277)

maybe (!...empty())

llvm/test/Transforms/FunctionAttrs/align.ll
140 ↗(On Diff #215277)

This will not pass lit

llvm/test/Transforms/FunctionAttrs/liveness.ll
18 ↗(On Diff #215262)

Make sure this passes after rebase.

This revision is now accepted and ready to land.Aug 14 2019, 4:55 PM
sstefan1 updated this revision to Diff 215970.Aug 19 2019, 1:16 PM
  • small update
  • Attributor::isAssumedDead() fix
jdoerfert added inline comments.Aug 19 2019, 1:47 PM
llvm/lib/Transforms/IPO/Attributor.cpp
1848 ↗(On Diff #215970)

Only do the whole conditional once. Hence, add && AssumedLiveBlocks.empy() to the conditional in line 1838.

1878 ↗(On Diff #215970)

I'm confused. When do we need this status flag here, I mean why isn't the one above sufficient. And if this one is needed, why only if we find a new NextNoReturnI and not once the path size changes (as before)?

2370 ↗(On Diff #215970)

This is not a valid cast.

You want &AA::ID == &AAIsDead::ID

llvm/test/Transforms/FunctionAttrs/align.ll
95 ↗(On Diff #215970)

Why do we loose the align?

sstefan1 marked 5 inline comments as done.Aug 20 2019, 2:16 AM
sstefan1 added inline comments.
llvm/lib/Transforms/IPO/Attributor.cpp
1878 ↗(On Diff #215970)

This was actually a leftover. I was trying things when I thought I messed something with verification.

sstefan1 updated this revision to Diff 216159.Aug 20 2019, 8:27 AM
sstefan1 marked 2 inline comments as done.
addressing comments
jdoerfert added inline comments.Aug 20 2019, 10:11 AM
llvm/lib/Transforms/IPO/Attributor.cpp
1640 ↗(On Diff #216159)

Add a new STATS_DECL... here to count number of dead internal functions.

This revision was automatically updated to reflect the committed changes.