-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
llvm:optimizationsquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
Reproducer:
// RUN: clang++ -O1 -flto -fvirtual-function-elimination -fvisibility=hidden %s
#include <stdio.h>
class MyClass {
public:
virtual int foo(int e) {
return 42+e;
}
};
int main() {
MyClass c;
using casted_foo_t = int (MyClass::*)(long);
auto casted_foo = (casted_foo_t)&MyClass::foo;
printf("%d\n", (c.*casted_foo)(2));
}
Output:
Segmentation fault (core dumped)
The type metadata node for foo ( !"_ZTSM7MyClassFiiE.virtual" ) and casted_foo_t ( !"_ZTSM7MyClassFilE.virtual" ) is different.
In GlobalDCE, these callsites are analyzed only with type metadata, and address taken here is not captured.
GlobalStatus might not help here, as the virtual-function's use-list only contains vtables.
Metadata
Metadata
Assignees
Labels
llvm:optimizationsquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!