[clang] 0456654 - [OpenMP] Fix embedding offload code when there is no offloading toolchain
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Tue May 10 10:34:29 PDT 2022
Author: Joseph Huber
Date: 2022-05-10T13:33:20-04:00
New Revision: 045665423e6e893ee168368dab10469c8d3168c5
URL: https://github.com/llvm/llvm-project/commit/045665423e6e893ee168368dab10469c8d3168c5
DIFF: https://github.com/llvm/llvm-project/commit/045665423e6e893ee168368dab10469c8d3168c5.diff
LOG: [OpenMP] Fix embedding offload code when there is no offloading toolchain
Summary:
We use the `--offload-new-driver` option to enable offload code
embedding. The check for when to do this was flawed and was enabling it
too early in the case of OpenMP, causing a segfault when dereferencing
the offloading toolchain.
Added:
Modified:
clang/lib/Driver/ToolChains/Clang.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 4fc126353475..6934b8dd2d6c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4405,8 +4405,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
(JA.isHostOffloading(Action::OFK_OpenMP) &&
Args.hasFlag(options::OPT_fopenmp_new_driver,
options::OPT_no_offload_new_driver, true)) ||
- Args.hasFlag(options::OPT_offload_new_driver,
- options::OPT_no_offload_new_driver, false);
+ (JA.isHostOffloading(C.getActiveOffloadKinds()) &&
+ Args.hasFlag(options::OPT_offload_new_driver,
+ options::OPT_no_offload_new_driver, false));
+
bool IsUsingLTO = D.isUsingLTO(IsDeviceOffloadAction);
auto LTOMode = D.getLTOMode(IsDeviceOffloadAction);
More information about the cfe-commits
mailing list