This is an archive of the discontinued LLVM Phabricator instance.

Fix the samplepgo indirect call promotion bug: we should not promote a direct call.
ClosedPublic

Authored by danielcdh on Feb 5 2017, 3:32 PM.

Details

Summary

Checking CS.getCalledFunction() == nullptr does not necessary indicate indirect call. We also need to check if CS.getCalledValue() is not a constant.

Event Timeline

danielcdh created this revision.Feb 5 2017, 3:32 PM
davidxl added inline comments.Feb 6 2017, 10:51 AM
lib/Transforms/IPO/SampleProfile.cpp
638

Refactor the code in llvm/Analysis/IndirectCallSiteVisitor.h and reuse the indirect call site query routine.

danielcdh updated this revision to Diff 87275.Feb 6 2017, 11:48 AM
danielcdh marked an inline comment as done.

update

davidxl added inline comments.Feb 6 2017, 12:05 PM
include/llvm/IR/CallSite.h
116

check if getCalledValue nullness?

121

getCalledValue constant case?

danielcdh updated this revision to Diff 87283.Feb 6 2017, 12:32 PM
danielcdh marked an inline comment as done.

update

danielcdh added inline comments.Feb 6 2017, 12:32 PM
include/llvm/IR/CallSite.h
121

I used "stripPointerCasts" on getCalledValue() so that this is not needed any more.

davidxl added inline comments.Feb 6 2017, 1:32 PM
include/llvm/IR/CallSite.h
121

how is it so?

danielcdh added inline comments.Feb 6 2017, 1:35 PM
include/llvm/IR/CallSite.h
121

stripPointerCasts comment says "Strip off pointer casts, all-zero GEPs, and aliases.", so for the constants (alias), it will give the actual function that it aliases to.

davidxl accepted this revision.Feb 6 2017, 3:43 PM

lgtm.

This revision is now accepted and ready to land.Feb 6 2017, 3:43 PM
danielcdh closed this revision.Feb 6 2017, 3:44 PM