-
Notifications
You must be signed in to change notification settings - Fork 17k
[CIR] Handle explicit instantiation declaration in getVTableLinkage #193809
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Replace errorNYI for TSK_ExplicitInstantiationDeclaration with the correct linkage logic: use discardable ODR linkage for MSVC, and for Itanium choose between AvailableExternallyLinkage (when the vtable can be speculatively emitted) or ExternalLinkage. Fixes point 3 of #192330.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir | ||
| // RUN: FileCheck --input-file=%t.cir %s | ||
| // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add RUN lines to compile without -fclangir? This is useful for verifying that we do the same thing as classic codegen. |
||
| // RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s | ||
|
|
||
| // Test that explicit instantiation declarations don't trigger | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment isn't useful. I'd delete it. |
||
| // "getVTableLinkage: explicit instantiation declaration" errorNYI. | ||
|
|
||
| template <typename T> | ||
| struct Base { | ||
| virtual ~Base() {} | ||
| virtual void foo() {} | ||
| T val; | ||
| }; | ||
|
|
||
| extern template class Base<int>; | ||
|
|
||
| void use(Base<int> *p) { | ||
| p->foo(); | ||
| } | ||
|
|
||
| // Verify the virtual call goes through the vtable. | ||
| // CHECK: cir.func {{.*}} @_Z3useP4BaseIiE | ||
| // CHECK: cir.vtable.get_vptr | ||
| // CHECK: cir.vtable.get_virtual_fn_addr | ||
|
|
||
| // LLVM: define {{.*}} @_Z3useP4BaseIiE | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The llvm_unreachable on line 375 relates to this same kind. It shouldn't be unreachable. That isn't implemented in the incubator, but it is in classic codegen (doing basically what you have here). Can you add that in this PR also. It will require an additional test case to reach that code.