[llvm-commits] [PATCH] More closely match docs for CallSite::getCalledFunction

Duncan Sands baldrick at free.fr
Thu Jul 19 23:32:23 PDT 2012


Hi Nick,

> The documentation for CallSite::getCalledFunction is inconsistent with
> what the function does. Without optimization, a direct call may be
> made through a cast.

the cast may not be trivial, for example it might cast a function type with
lots of parameters to one with no parameters or vice versa.  I mean, it is
trivial in the sense that it is a bitcast, but it can have a non-trivial
semantic impact.  When there is a bitcast, optimization pass authors need to
think about what the right thing to do is.  CallSite::getCalledFunction is
for the no-brainer case where no extra cogitation is required.

  This causes the function to return null even
> though the call was direct. This is problematic for those of us using
> LLVM in a context where we can't necessarily apply optimizations
> before running our analyses.
>
> Attached is a patch that simply calls stripPointerCasts on the called
> value before converting it into a Function. I realize that handling
> the general case may not be a priority, so alternatively, I could
> submit a patch that makes the documentation more explicit about this
> limitation.

I would rather have a doc patch, and fix users of getCalledFunction that
could handle the bitcast case but don't.

Ciao, Duncan.



More information about the llvm-commits mailing list