-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization in clang frontend breaks dynamic_cast
on Apple platforms.
#120129
Comments
llvm's emits |
@llvm/issue-subscribers-clang-codegen Author: Akira Hatanaka (ahatanak)
This is caused by 9d525bf.
% cat a.h
% cat a.cc
% cat b.cc
% clang++ -std=c++11 -c a.cc -O1 |
Interesting. What does Looking at the code, as far as I can see the only time we should be setting the vtable as having hidden visibility is if the class has hidden visibility, and in that case we turn off the optimization because In any case, assuming the ABI intent on this target is that vtables are not unique, we should ensure that |
Yes, we can make
Does |
I can't answer that with any authority, but I was previously told (though I don't recall who by) that If Perhaps we should have both an LLVM IR annotation meaning "mergeable" and one meaning "duplicatable", and Clang can set only "mergeable" on vtables at least by default. Then if the Apple ABI wants to make them duplicatable, that can be enabled in a way that also turns off this optimization? |
This is caused by 9d525bf.
dynamic_cast
in the following code fails unless the optimization is disabled by passing-fno-assume-unique-vtables
.% cat a.h
% cat a.cc
% cat b.cc
% clang++ -std=c++11 -c a.cc -O1
% clang++ -std=c++11 -c b.cc -O1
% clang++ -shared -o liba.so a.o
% clang++ --std=c++11 -o a.out b.o -Wl,-rpath,$PWD liba.so
% ./a.out
% echo $?
0
The text was updated successfully, but these errors were encountered: