Chrisma Pakha via llvm-dev
2020-Aug-18 02:25 UTC
[llvm-dev] Inserting a label after a function call
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 mylabel: movl %eax, %r14d My first attempt was similar to the following file http://www.llvm.org/doxygen/SelectionDAGBuilder_8cpp_source.html, 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 mylabel: Which is not what I desired. My next attempt was to modify the function that lowers the function call inst. I inserted a eh_label node in between the callseq_end node and CopyFromReg node 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, Chrisma -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200817/f169150a/attachment.html>