[cfe-dev] Indirect call generation for other than native targets

ihusar at fit.vutbr.cz ihusar at fit.vutbr.cz
Tue Jan 29 02:04:14 PST 2013


Hi David, thank you for your reply.

Here are some more details.
I need to process the code produced by clang later in my opt-like passes  
and
there, when I process the CallInst and ask for the called function
 from this code:

  call void bitcast (void (...)* @fun to void ()*)()

like this:

CallInst* ci = dyn_cast<CallInst>(i);
Function* f = ci->getCalledFunction();

the pointer f is set to NULL and according to the comments for
CallInst::getCalledFunction, the call is indirect:

   /// getCalledFunction - Return the function called, or null if this is an
   /// indirect function invocation.

Also e.g. methods for attribute manipulation alway return zero or do  
nothing if the call is indirect.

What is strange to me, is that for the target x86_64 clang generates  
direct call, and
for target i386, there is an indirect call (on 64-bit Fedora 17).

Adam

On Tue, 29 Jan 2013 10:25:53 +0100, David Chisnall  
<David.Chisnall at cl.cam.ac.uk> wrote:

> On 29 Jan 2013, at 09:05, ihusar at fit.vutbr.cz wrote:
>
>> How can i make the nonnaticve targets generate direct calls?
>
> I don't understand the question.  In both cases, you have a direct  
> call.  The only difference is that in the first it is being called as a  
> variadic function with no arguments and in the latter as a non-variadic  
> function of no arguments.  In both cases, it's a direct call.  Did you  
> look at the assembly generated?
>
> David




More information about the cfe-dev mailing list