[Openmp-commits] [openmp] 4a66860 - [OpenMP] Add an option to disable function internalization
via Openmp-commits
openmp-commits at lists.llvm.org
Wed Jul 21 18:18:43 PDT 2021
Author: Joseph Huber
Date: 2021-07-21T21:18:18-04:00
New Revision: 4a6686042472a6a3f9d6ca7a0d1bb7f46cbbc415
URL: https://github.com/llvm/llvm-project/commit/4a6686042472a6a3f9d6ca7a0d1bb7f46cbbc415
DIFF: https://github.com/llvm/llvm-project/commit/4a6686042472a6a3f9d6ca7a0d1bb7f46cbbc415.diff
LOG: [OpenMP] Add an option to disable function internalization
Function internalization can sometimes occur in situations where we want to
keep the call sites intact. This patch adds an option to disable function
internalization and prevents the device runtime from being internalized while
creating the bitcode library.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D106438
Added:
Modified:
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 44aa249ad08c1..d6ca4087eebf5 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -56,6 +56,11 @@ static cl::opt<bool> EnableParallelRegionMerging(
cl::desc("Enable the OpenMP region merging optimization."), cl::Hidden,
cl::init(false));
+static cl::opt<bool>
+ DisableInternalization("openmp-opt-disable-internalization", cl::ZeroOrMore,
+ cl::desc("Disable function internalization."),
+ cl::Hidden, cl::init(false));
+
static cl::opt<bool> PrintICVValues("openmp-print-icv-values", cl::init(false),
cl::Hidden);
static cl::opt<bool> PrintOpenMPKernels("openmp-print-gpu-kernels",
@@ -3824,7 +3829,8 @@ PreservedAnalyses OpenMPOptPass::run(Module &M, ModuleAnalysisManager &AM) {
DenseSet<const Function *> InternalizedFuncs;
if (isOpenMPDevice(M))
for (Function &F : M)
- if (!F.isDeclaration() && !Kernels.contains(&F) && IsCalled(F)) {
+ if (!F.isDeclaration() && !Kernels.contains(&F) && IsCalled(F) &&
+ !DisableInternalization) {
if (Attributor::internalizeFunction(F, /* Force */ true)) {
InternalizedFuncs.insert(&F);
} else if (!F.hasLocalLinkage() && !F.hasFnAttribute(Attribute::Cold)) {
diff --git a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
index 6371230993a0e..903c8d9ec8315 100644
--- a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
+++ b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
@@ -107,6 +107,7 @@ macro(add_cuda_bc_library)
set(cu_cmd ${CLANG_TOOL}
-xc++
-c
+ -mllvm -openmp-opt-disable-internalization
-std=c++14
-ffreestanding
-target amdgcn-amd-amdhsa
diff --git a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
index 5120a9c0abc45..2f16dbb3dd781 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -153,6 +153,7 @@ set(cuda_src_files
# Set flags for LLVM Bitcode compilation.
set(bc_flags -S -x c++ -O1 -std=c++14
+ -mllvm -openmp-opt-disable-internalization
-target nvptx64
-Xclang -emit-llvm-bc
-Xclang -aux-triple -Xclang ${aux_triple}
More information about the Openmp-commits
mailing list