<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 --- - [WinEH] bad codegen AllocAInst inside cleanup pad"
href="https://llvm.org/bugs/show_bug.cgi?id=26251">26251</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[WinEH] bad codegen AllocAInst inside cleanup pad
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>r.sagitario@gmx.de
</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>Not sure if this is meant to be supported, but adding an AllocAInst inside a
cleanuppad generates code that does not restore the stack correctly. This
cleanup IR:
////////////////
cleanuppad: ; preds = %0
%1 = cleanuppad within none [] ; [#uses = 4]
%cleanup.frame = alloca [40 x i8] ; [#uses = 1, size/byte = 40]
%2 = bitcast [40 x i8]* %cleanup.frame to i8* ; [#uses = 2]
%3 = call i1 @_d_enter_cleanup(i8* %2) [ "funclet"(token %1) ] ; [#uses = 1]
br i1 %3, label %finally1, label %cleanupret
finally1: ; preds = %cleanuppad
call x86_stdcallcc void @"\01__D7cleanup5sexitFZv"() #0 [ "funclet"(token %1)
]
br label %cleanupret
cleanupret: ; preds = %cleanuppad,
%finally1
call void @_d_leave_cleanup(i8* %2) [ "funclet"(token %1) ]
cleanupret from %1 unwind to caller
////////////////
is translated to this x86-asm:
////////////////
"?dtor$2@?0?__D7cleanup7cleanupFZv@4HA":
LBB0_2:
pushl %ebp
pushl %eax
addl $12, %ebp
movl $40, %eax
calll __chkstk
movl %esp, %eax
movl $-1, -16(%ebp)
subl $4, %esp
movl %eax, (%esp)
movl %eax, -32(%ebp)
calll __d_enter_cleanup
addl $4, %esp
testb $1, %al
jne LBB0_3
jmp LBB0_4
LBB0_3:
movl $-1, -16(%ebp)
calll __D7cleanup5sexitFZv
LBB0_4:
movl $-1, -16(%ebp)
movl -32(%ebp), %eax
pushl %eax
calll __d_leave_cleanup
addl $8, %esp
popl %ebp
retl
////////////////
Please note that %esp is changed by the "calll __chkstk; movl %esp, %eax"
sequence, but never restored.
I'll attach the full IR and asm files.</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>