This is an archive of the discontinued LLVM Phabricator instance.

[CallGraph] Teach the CallGraph about non-leaf intrinsics.
ClosedPublic

Authored by sanjoy on Jun 17 2015, 5:50 PM.

Details

Summary

Currently intrinsics don't affect the creation of the call graph.
This is not accurate with respect to statepoint and patchpoint
intrinsics -- these do call (or invoke) LLVM level functions.

This change fixes this inconsistency by adding a call to the external
node for call sites that call these non-leaf intrinsics. This coupled
with the fact that these intrinsics also escape the function pointer
they call gives us a conservatively correct call graph.

Diff Detail

Repository
rL LLVM

Event Timeline

sanjoy updated this revision to Diff 27905.Jun 17 2015, 5:50 PM
sanjoy retitled this revision from to [CallGraph] Teach the CallGraph about non-leaf intrinsics..
sanjoy updated this object.
sanjoy edited the test plan for this revision. (Show Details)
sanjoy added reviewers: reames, chandlerc, atrick, pgavlin.
sanjoy added a subscriber: Unknown Object (MLST).
chandlerc accepted this revision.Jun 17 2015, 8:54 PM
chandlerc edited edge metadata.

As I mentioned on the email thread, I expect LazyCallGraph to just DTRT, but I'd love it if you could add the analogous test case to it and make sure of that.

This patch looks fine without the output parameter (see my comment below). If I've missed something and it is needed, just explain and I'll think more about the API.

include/llvm/IR/Intrinsics.h
55–61 ↗(On Diff #27905)

The TargetArg parameter isn't used yet, correct? I'd leave it off until it is used. I'm not a huge fan of the unsigned output parameter, but hard to suggest alternatives when there are no users..

This revision is now accepted and ready to land.Jun 17 2015, 8:54 PM
pgavlin accepted this revision.Jun 18 2015, 10:13 AM
pgavlin edited edge metadata.

This looks good to me as well. I'm also a bit leery of returning the call target as an argument index. Perhaps it will eventually make more sense to add an overload that operates on the call itself and returns the argument itself, but as Chandler mentioned, it's hard to tell without an example use.

sanjoy updated this revision to Diff 27947.Jun 18 2015, 12:11 PM
sanjoy edited edge metadata.
  • address review
This revision was automatically updated to reflect the committed changes.