This is an archive of the discontinued LLVM Phabricator instance.

[LCG] Add aliased functions as LCG roots
ClosedPublic

Authored by Carrot on Mar 27 2019, 1:24 PM.

Details

Summary

Current LCG doesn't check aliased functions. So if an internal function has a public alias it will not be added to CG SCC, but it is still reachable from outside through the alias.
So this patch adds aliased functions to SCC.

Diff Detail

Repository
rL LLVM

Event Timeline

Carrot created this revision.Mar 27 2019, 1:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2019, 1:24 PM
tejohnson added inline comments.Mar 27 2019, 1:54 PM
lib/Analysis/LazyCallGraph.cpp
192 ↗(On Diff #192507)

Presumably aliases with internal linkage themselves can be ignored.

Carrot updated this revision to Diff 192518.Mar 27 2019, 2:13 PM
Carrot marked an inline comment as done.
chandlerc requested changes to this revision.Mar 27 2019, 4:41 PM

Good catch!

lib/Analysis/LazyCallGraph.cpp
191 ↗(On Diff #192518)

I would rewrite the comment to more closely match the patch description: "Externally visible aliases of internal functions are also viable entry edges to the module."

192–200 ↗(On Diff #192518)

All of this should go above I think, right after we walk the module. We want to have the complete entry edge set before we visit globals and do the reference visit walk.

196–197 ↗(On Diff #192518)

Include the fact that it is being added due to an alias, and the name of that alias?

test/Analysis/LazyCallGraph/alias.ll
3 ↗(On Diff #192518)

Also test that internal aliases *don't* become reachable?

This revision now requires changes to proceed.Mar 27 2019, 4:41 PM
Carrot updated this revision to Diff 192705.Mar 28 2019, 1:00 PM
Carrot marked 4 inline comments as done.
chandlerc accepted this revision.Apr 4 2019, 3:35 PM

LGTM!

test/Analysis/LazyCallGraph/alias.ll
23 ↗(On Diff #192705)

nit: can drop this comment.

30 ↗(On Diff #192705)

nit: same

38 ↗(On Diff #192705)

nit: same

This revision is now accepted and ready to land.Apr 4 2019, 3:35 PM
Carrot updated this revision to Diff 193926.Apr 5 2019, 11:47 AM
Carrot marked 3 inline comments as done.

Will check in this version.

This revision was automatically updated to reflect the committed changes.