[llvm-dev] Inserting a label after a function call

Chrisma Pakha via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 17 19:25:54 PDT 2020

Hi All,

I am currently attempting to insert a label immediately after a call to a
certain function that returns a value.
For example:

    callq   function
    movl    %eax, %r14d

My first attempt was similar to the following file


function: lowerInvokable.

Where I use a similar mechanism to Exception handling.
However, this seems to work when the return value is stored into a stack.
Otherwise, I would get the following code

    callq   function
    movl    %eax, %r14d

Which is not what I desired.

My next attempt was to modify the function that lowers the function call
I inserted a eh_label node in between the callseq_end node and CopyFromReg
However, I am getting an error message of the following just before the
Greedy Register Allocator pass.

*Bad machine code: Using an undefined physical registerinstruction:
%75:gr32 = COPY*

*operand 1:   killed %eax*

I was wondering if this is because the information passed from callseq_end
to eh_label to CopyFromReg did not propagate properly.
If so, I was wondering whether I need a custom SDNode for this or if I
should add the label once the code representation becomes machine IR.

Previously I try to add the label once the code representation becomes
machine IR.
However, I seem to have an issue in getting the Function object from
the machine inst that represents the function call.
The reason why I need the Function object is so that I can query whether
the function that is being called has a certain attribute or not.

Thank you.
Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200817/f169150a/attachment.html>

More information about the llvm-dev mailing list