summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDeclCXX.cpp
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2019-05-09 13:55:44 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2019-05-09 13:55:44 +0000
commite6cf6c78f88ffb7eed69b0eaa60785eab9df2b88 (patch)
treebfe60eb40c0baae3646a31c2524fbe8bc1b27e9a /clang/lib/CodeGen/CGDeclCXX.cpp
parent9db0e72570f73e4e8aaf870201f2c1bc738baee3 (diff)
downloadbcm5719-llvm-e6cf6c78f88ffb7eed69b0eaa60785eab9df2b88.tar.gz
bcm5719-llvm-e6cf6c78f88ffb7eed69b0eaa60785eab9df2b88.zip
[OpenCL] Make global ctor init function a kernel
We need to be able to enqueue internal function that initializes global constructors on the host side. Therefore it has to be converted to a kernel. This change factors out common logic for adding kernel metadata and moves it from CodeGenFunction to CodeGenModule in order to make it accessible for the extra use case. Differential revision: https://reviews.llvm.org/D61488 llvm-svn: 360342
Diffstat (limited to 'clang/lib/CodeGen/CGDeclCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGDeclCXX.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index c7d65f16191..ce0163723c4 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -580,6 +580,19 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
AddGlobalCtor(Fn);
+ // In OpenCL global init functions must be converted to kernels in order to
+ // be able to launch them from the host.
+ // FIXME: Some more work might be needed to handle destructors correctly.
+ // Current initialization function makes use of function pointers callbacks.
+ // We can't support function pointers especially between host and device.
+ // However it seems global destruction has little meaning without any
+ // dynamic resource allocation on the device and program scope variables are
+ // destroyed by the runtime when program is released.
+ if (getLangOpts().OpenCL) {
+ GenOpenCLArgMetadata(Fn);
+ Fn->setCallingConv(llvm::CallingConv::SPIR_KERNEL);
+ }
+
CXXGlobalInits.clear();
}
OpenPOWER on IntegriCloud