<div dir="ltr">We need to disable most forms of IPO on naked functions. We already do this in DeadArgElimination.cpp. We need to do it in more places.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 27, 2017 at 5:15 AM, Carlo Kok via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, I'm trying to have a pure asm function (non inlined) that returns it's own value to the caller.<br>
<br>
; Function Attrs: naked noinline optnone<br>
define i32 @callcatch(i32, i32) #3 !dbg !10103 {<br>
BasicBlock8472:<br>
call void asm "\0D\0Apushl %ebp\0D\0Amovl 8(%esp),%eax\0D\0Amovl 12(%esp), %ebp\0D\0Acalll *%eax\0D\0Apopl %ebp\0D\0Aretl\0D\0A", ""(), !dbg !10104, !srcloc !10106 // this returns in eax<br>
ret i32 0, !dbg !10104<br>
}<br>
<br>
; Function Attrs: naked noinline optnone<br>
define void @jumptocont(i32, i32, i32) #3 !dbg !10107 {<br>
BasicBlock8473:<br>
call void asm "\0D\0A movl 12(%esp), %ebp\0D\0A movl 4(%esp), %eax\0D\0A movl 8(%esp), %esp\0D\0A jmpl *%eax\0D\0A", ""(), !dbg !10108, !srcloc !10110<br>
ret void, !dbg !10108<br>
}<br>
<br>
The calling code is like;<br>
%530 = call i32 @callcatch(i32 %528, i32 %529) #3, !dbg !7648<br>
store i32 %530, i32* %20, !dbg !7648<br>
%531 = load i32, i32* %20, !dbg !7630<br>
...<br>
call void @jumptocont(i32 %531, i32 %532, i32 %533) #3, !dbg<br>
<br>
However the return constant propagation code from<br>
<br>
<a href="http://llvm.org/docs/doxygen/html/IPConstantPropagation_8cpp_source.html" rel="noreferrer" target="_blank">http://llvm.org/docs/doxygen/h<wbr>tml/IPConstantPropagation_8cpp<wbr>_source.html</a><br>
<br>
finds the ret i32 0 and ends up calling jumptocont with i32 0 as a first parameter, which wasn't what I wanted. Ending up like:<br>
<br>
%189 = tail call i32 @callcatchn(i32 %188, i32 %12) #10, !dbg !7019<br>
tail call void @jumptocont(i32 0, i32 %14, i32 %12) #10, !dbg !7022<br>
<br>
I tried unreachable in the callcatch which would make the caller code turn into unreachable too. Is there a workaround for this, or a better way to do this?<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Carlo Kok<br>
RemObjects Software<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</font></span></blockquote></div><br></div>