<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - return value propagation in asm/naked function"
href="https://llvm.org/bugs/show_bug.cgi?id=31811">31811</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>return value propagation in asm/naked function
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Interprocedural Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ck@remobjects.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The null propagation code should not propagate function results for naked
functions as else it's impossible to have asm code that returns it's own value:
When having a naked function like:
; Function Attrs: naked noinline optnone
define i32 @callcatch(i32, i32) #3 !dbg !10103 {
BasicBlock8472:
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
ret i32 0, !dbg !10104
}
; Function Attrs: naked noinline optnone
define void @jumptocont(i32, i32, i32) #3 !dbg !10107 {
BasicBlock8473:
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
ret void, !dbg !10108
}
and calling code is like;
%530 = call i32 @callcatch(i32 %528, i32 %529) #3, !dbg !7648
store i32 %530, i32* %20, !dbg !7648
%531 = load i32, i32* %20, !dbg !7630
...
call void @jumptocont(i32 %531, i32 %532, i32 %533) #3, !dbg
However the return constant propagation code from
<a href="http://llvm.org/docs/doxygen/html/IPConstantPropagation_8cpp_source.html">http://llvm.org/docs/doxygen/html/IPConstantPropagation_8cpp_source.html</a>
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:
%189 = tail call i32 @callcatchn(i32 %188, i32 %12) #10, !dbg !7019
tail call void @jumptocont(i32 0, i32 %14, i32 %12) #10, !dbg !7022
ie using the ret i32 0 as input for jumptocont, which it shouldn't.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>