<html>
<head>
<base href="http://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 --- - Clang doesn't devirtualize all vcalls in ctors/dtors"
href="http://llvm.org/bugs/show_bug.cgi?id=17863">17863</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang doesn't devirtualize all vcalls in ctors/dtors
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>timurrrr@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>e.g. for this code:
--------------------------
struct A { virtual void a(); };
struct B { virtual void b(); };
struct C : virtual A, virtual B {
C();
virtual void key_function();
virtual void a();
virtual void b();
};
C::C() { a(); b(); }
void C::key_function() {}
--------------------------
the assembly for C::C() at -O3 is
--------------------------
_ZN1CC1Ev: # complete ctor
pushq %rbx
movq %rdi, %rbx
movq $_ZTV1C+40, (%rbx)
movq $_ZTV1C+88, 8(%rbx)
callq _ZN1C1aEv # call to C::a is devirtualized
movq (%rbx), %rax
movq %rbx, %rdi
popq %rbx
jmpq *16(%rax) # call to C::b is not!
...
_ZN1CC2Ev: # base ctor
pushq %rbx
movq %rdi, %rbx
movq (%rsi), %rax
movq %rax, (%rbx)
movq 8(%rsi), %rcx
movq -32(%rax), %rax
movq %rcx, (%rbx,%rax)
movq 16(%rsi), %rax
movq (%rbx), %rcx
movq -40(%rcx), %rcx
movq %rax, (%rbx,%rcx)
movq (%rbx), %rax
callq *(%rax) # looks like even C::a is not devirtualized
movq (%rbx), %rax
movq %rbx, %rdi
popq %rbx
jmpq *16(%rax) # call C::b is not devirtualized
--------------------------
The same pattern holds if I define C::C() as "b(); a();" - only the
first vcall in the complete ctor is devirtualized.</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>