[PATCH] D50218: [OpenMP] Encode offload target triples into comdat key for offload initialization code
Sergey Dmitriev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 2 20:16:27 PDT 2018
sdmitriev created this revision.
sdmitriev added reviewers: ABataev, hfinkel.
Herald added subscribers: cfe-commits, mgrang, guansong.
Encoding offload target triples onto comdat group key for offload initialization code guarantees that it will be executed once per each unique combination of offload targets.
Repository:
rC Clang
https://reviews.llvm.org/D50218
Files:
lib/CodeGen/CGOpenMPRuntime.cpp
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3818,7 +3818,17 @@
CGF.disableDebugInfo();
const auto &FI = CGM.getTypes().arrangeNullaryFunction();
llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(FI);
- std::string Descriptor = getName({"omp_offloading", "descriptor_reg"});
+
+ // Encode offload target triples into the registration function name. It
+ // will serve as a comdat key for the registration/unregistration code for
+ // this particular combination of offloading targets.
+ SmallVector<StringRef, 4U> RegFnNameParts;
+ RegFnNameParts.push_back("omp_offloading");
+ RegFnNameParts.push_back("descriptor_reg");
+ for (const auto &Device : Devices)
+ RegFnNameParts.push_back(Device.getTriple());
+ std::sort(RegFnNameParts.begin() + 2, RegFnNameParts.end());
+ std::string Descriptor = getName(RegFnNameParts);
RegFn = CGM.CreateGlobalInitOrDestructFunction(FTy, Descriptor, FI);
CGF.StartFunction(GlobalDecl(), C.VoidTy, RegFn, FI, FunctionArgList());
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__tgt_register_lib), Desc);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50218.158900.patch
Type: text/x-patch
Size: 1250 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180803/86b08d11/attachment.bin>
More information about the cfe-commits
mailing list