[llvm] 43125b6 - [OpenMP] Use protected visibility for the kernel environment
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 11:24:37 PDT 2023
Author: Joseph Huber
Date: 2023-08-15T12:47:44-05:00
New Revision: 43125b63925be6d5e205f07443fb00bfdb745c10
URL: https://github.com/llvm/llvm-project/commit/43125b63925be6d5e205f07443fb00bfdb745c10
DIFF: https://github.com/llvm/llvm-project/commit/43125b63925be6d5e205f07443fb00bfdb745c10.diff
LOG: [OpenMP] Use protected visibility for the kernel environment
Summary:
These new globals should use protected visibility. Visibility like this
helps certain checks on AMDGPU architecture and LTO.
Added:
Modified:
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 48857757047564..c1b203be30512f 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4038,15 +4038,18 @@ OpenMPIRBuilder::createTargetInit(const LocationDescription &Loc, bool IsSPMD) {
Twine DynamicEnvironmentName = KernelName + "_dynamic_environment";
Constant *DynamicEnvironmentInitializer =
ConstantStruct::get(DynamicEnvironment, {DebugIndentionLevelVal});
- Constant *DynamicEnvironmentGV = new GlobalVariable(
- M, DynamicEnvironment, /* IsConstant */ false,
- GlobalValue::WeakODRLinkage, DynamicEnvironmentInitializer,
- DynamicEnvironmentName,
- /* InsertBefore */ nullptr, llvm::GlobalValue::NotThreadLocal,
+ GlobalVariable *DynamicEnvironmentGV = new GlobalVariable(
+ M, DynamicEnvironment, /*IsConstant=*/false, GlobalValue::WeakODRLinkage,
+ DynamicEnvironmentInitializer, DynamicEnvironmentName,
+ /*InsertBefore=*/nullptr, GlobalValue::NotThreadLocal,
DL.getDefaultGlobalsAddressSpace());
- if (DynamicEnvironmentGV->getType() != DynamicEnvironmentPtr)
- DynamicEnvironmentGV = ConstantExpr::getAddrSpaceCast(
- DynamicEnvironmentGV, DynamicEnvironmentPtr);
+ DynamicEnvironmentGV->setVisibility(GlobalValue::ProtectedVisibility);
+
+ Constant *DynamicEnvironment =
+ DynamicEnvironmentGV->getType() == DynamicEnvironmentPtr
+ ? DynamicEnvironmentGV
+ : ConstantExpr::getAddrSpaceCast(DynamicEnvironmentGV,
+ DynamicEnvironmentPtr);
Constant *ConfigurationEnvironmentInitializer = ConstantStruct::get(
ConfigurationEnvironment, {
@@ -4058,19 +4061,22 @@ OpenMPIRBuilder::createTargetInit(const LocationDescription &Loc, bool IsSPMD) {
KernelEnvironment, {
ConfigurationEnvironmentInitializer,
Ident,
- DynamicEnvironmentGV,
+ DynamicEnvironment,
});
Twine KernelEnvironmentName = KernelName + "_kernel_environment";
- Constant *KernelEnvironmentGV = new GlobalVariable(
- M, KernelEnvironment, /* IsConstant */ true, GlobalValue::WeakODRLinkage,
+ GlobalVariable *KernelEnvironmentGV = new GlobalVariable(
+ M, KernelEnvironment, /*IsConstant=*/true, GlobalValue::WeakODRLinkage,
KernelEnvironmentInitializer, KernelEnvironmentName,
- /* InsertBefore */ nullptr, llvm::GlobalValue::NotThreadLocal,
+ /*InsertBefore=*/nullptr, GlobalValue::NotThreadLocal,
DL.getDefaultGlobalsAddressSpace());
- if (KernelEnvironmentGV->getType() != KernelEnvironmentPtr)
- KernelEnvironmentGV = ConstantExpr::getAddrSpaceCast(KernelEnvironmentGV,
- KernelEnvironmentPtr);
-
- CallInst *ThreadKind = Builder.CreateCall(Fn, {KernelEnvironmentGV});
+ KernelEnvironmentGV->setVisibility(GlobalValue::ProtectedVisibility);
+
+ Constant *KernelEnvironment =
+ KernelEnvironmentGV->getType() == KernelEnvironmentPtr
+ ? KernelEnvironmentGV
+ : ConstantExpr::getAddrSpaceCast(KernelEnvironmentGV,
+ KernelEnvironmentPtr);
+ CallInst *ThreadKind = Builder.CreateCall(Fn, {KernelEnvironment});
Value *ExecUserCode = Builder.CreateICmpEQ(
ThreadKind, ConstantInt::get(ThreadKind->getType(), -1),
More information about the llvm-commits
mailing list