<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - clang++ is inefficient in passing class as function parameter with x86 32-bit ABI"
href="https://bugs.llvm.org/show_bug.cgi?id=36592">36592</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang++ is inefficient in passing class as function parameter with x86 32-bit ABI
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++abi
</td>
</tr>
<tr>
<th>Version</th>
<td>4.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>handeng@cisco.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>clang++ is inefficient in passing class as function parameter with x86 32-bit
ABI.
Below is the example and output
===================================
test.cc
===================================
#include <stdint.h>
typedef struct {
uint32_t v;
} struct_t;
class class_t {
public:
uint32_t v;
};
#ifdef CLASS
#define uint32_t class_t
#elif defined(STRUCT)
#define uint32_t struct_t
#endif
uint32_t t1;
uint32_t t2;
void func1 (uint32_t w1, uint32_t w2);
void func2()
{
func1(t1, t2);
}
===================================
clang -x c++ -m32 -O3 -c test.cc
objdump -d test.o
===================================
test.o: file format elf32-i386
Disassembly of section .text:
00000000 <_Z5func2v>:
0: 83 ec 0c sub $0xc,%esp
3: 83 ec 08 sub $0x8,%esp
6: ff 35 00 00 00 00 pushl 0x0
c: ff 35 00 00 00 00 pushl 0x0
12: e8 fc ff ff ff call 13 <_Z5func2v+0x13>
17: 83 c4 1c add $0x1c,%esp
1a: c3 ret
===================================
clang -x c++ -m32 -O3 -c test.cc -DSTRUCT
objdump -d test.o
===================================
00000000 <_Z5func2v>:
0: 83 ec 0c sub $0xc,%esp
3: 83 ec 08 sub $0x8,%esp
6: ff 35 00 00 00 00 pushl 0x0
c: ff 35 00 00 00 00 pushl 0x0
12: e8 fc ff ff ff call 13 <_Z5func2v+0x13>
17: 83 c4 1c add $0x1c,%esp
1a: c3 ret
===================================
clang -x c++ -m32 -O3 -c test.cc -DCLASS
objdump -d test.o
===================================
00000000 <_Z5func2v>:
0: 83 ec 1c sub $0x1c,%esp
3: a1 00 00 00 00 mov 0x0,%eax
8: 89 44 24 18 mov %eax,0x18(%esp)
c: a1 00 00 00 00 mov 0x0,%eax
11: 89 44 24 10 mov %eax,0x10(%esp)
15: 8b 44 24 10 mov 0x10(%esp),%eax
19: 89 44 24 04 mov %eax,0x4(%esp)
1d: 8b 44 24 18 mov 0x18(%esp),%eax
21: 89 04 24 mov %eax,(%esp)
24: e8 fc ff ff ff call 25 <_Z5func2v+0x25>
29: 83 c4 1c add $0x1c,%esp
2c: c3 ret
===================================
icc -x c++ -m32 -O3 -c test.cc -DCLASS
objdump -d test.o
===================================
00000000 <_Z5func2v>:
0: 83 ec 14 sub $0x14,%esp
3: ff 35 00 00 00 00 pushl 0x0
9: ff 35 00 00 00 00 pushl 0x0
f: e8 fc ff ff ff call 10 <_Z5func2v+0x10>
14: 83 c4 1c add $0x1c,%esp
17: c3 ret
18: 0f 1f 84 00 00 00 00 nopl 0x0(%eax,%eax,1)
1f: 00</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>