[llvm-bugs] [Bug 27096] New: clang does not devirtualize method pointer calls against final classes when method identity is known at compile time
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 28 08:03:07 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27096
Bug ID: 27096
Summary: clang does not devirtualize method pointer calls
against final classes when method identity is known at
compile time
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Keywords: code-quality
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: hlandau at devever.net
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
// Example:
struct Foo final {
virtual int bar();
};
int a(Foo &f, int (Foo::*fp)()) {
return (f.*fp)();
}
int b(Foo &f) {
return a(f, &Foo::bar);
}
// Generated assembly:
b(Foo&): # @b(Foo&)
mov rax, qword ptr [rdi]
jmp qword ptr [rax] # TAILCALL
// Expected assembly:
b(Foo&): # @b(Foo&)
jmp Foo::bar() # TAILCALL
// Generates expected assembly:
int c(Foo &f) {
return f.bar();
}
// This is the assembly for a, which generates a more conservative
// method pointer call, demonstrating that the knowledge about the identity of
// fp when inlining in b is definitely used to generate the code above.
// Yet the devirtualization which could be taken as a further step above does
not occur.
a(Foo&, int (Foo::*)()): # @a(Foo&, int (Foo::*)())
add rdi, rdx
test sil, 1
je .LBB0_2
mov rax, qword ptr [rdi]
mov rsi, qword ptr [rsi + rax - 1]
.LBB0_2:
jmp rsi # TAILCALL
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160328/1a661777/attachment.html>
More information about the llvm-bugs
mailing list