https://bugs.llvm.org/show_bug.cgi?id=49765
Bug ID: 49765
Summary: LLVM cannot devirtualize with MSVC-style RTTI
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: r...@google.com
CC: aeuba...@google.com, llvm-bugs@lists.llvm.org,
pe...@pcc.me.uk
Consider this simple case when devirtualization should be possible after
inlining the constructor:
https://gcc.godbolt.org/z/osGe67s9b
struct Foo {
Foo() {}
virtual ~Foo() {}
virtual void f() {}
int x;
};
int main() {
Foo *p = new Foo();
p->f();
delete p;
}
When RTTI data is disabled (/GR- / -fno-rtti-data), we cannot devirtualize the
call to Foo::f. We can optimize the vptr load, but the vtable alias inhibits
full devirtualization. See this instruction:
call qword ptr [rip + "??_7Foo@@6B@"+8]
LLVM knows exactly which vtable we are loading from, but because of the MSVC
RTTI alias code pattern, it refuses to optimize away the load.
We should either make the optimize more aggressive, or find a better IR pattern
for MSVC-style RTTI.
Arthur had a patch to address this, but maybe it isn't sound:
https://reviews.llvm.org/D99240
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs