[OPENMP]Do not emit special virtual function for NVPTX target.
There are no special virtual function handlers (like __cxa_pure_virtual)
defined for NVPTX target, so just emit such functions as null pointers
to prevent issues with linking and unresolved references.
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index a8dce3c..59631e8 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -676,7 +676,12 @@
// Method is acceptable, continue processing as usual.
}
- auto getSpecialVirtualFn = [&](StringRef name) {
+ auto getSpecialVirtualFn = [&](StringRef name) -> llvm::Constant * {
+ // For NVPTX devices in OpenMP emit special functon as null pointers,
+ // otherwise linking ends up with unresolved references.
+ if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPIsDevice &&
+ CGM.getTriple().isNVPTX())
+ return llvm::ConstantPointerNull::get(CGM.Int8PtrTy);
llvm::FunctionType *fnTy =
llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
llvm::Constant *fn = cast<llvm::Constant>(