llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-driver Author: Joseph Huber (jhuber6) <details> <summary>Changes</summary> Summary: The change to the new driver used LTO. Clang defaults to O0 while LTO defaults to lto<O2>. The reason for this is because most people do not pass optimizations to the linker step and when linking libraries we will have some that need optimizations and some that don't. In RDC-mode, we only have a single <logical> TU, so we suppress optimizations. Fixes: https://github.com/ROCm/ROCgdb/pull/231 --- Full diff: https://github.com/llvm/llvm-project/pull/211790.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+6) - (modified) clang/test/Driver/hip-toolchain-opt.hip (+2-2) ``````````diff diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 1178f625d1172..c40d2f2949943 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -9892,6 +9892,12 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA, } } + // If no optimization level was requested we default to `-O0` for no-RDC + // mode compilations. Others default to `lto<O2>` as standard in ld.lld. + if (JA.getType() == types::TY_HIP_FATBIN && + !ToolChainArgs.getLastArg(OPT_O_Group)) + CompilerArgs.emplace_back("-O0"); + // If the user explicitly requested it via `--offload-arch` we should // extract it from any static libraries if present. for (StringRef Arg : ToolChainArgs.getAllArgValues(OPT_offload_arch_EQ)) diff --git a/clang/test/Driver/hip-toolchain-opt.hip b/clang/test/Driver/hip-toolchain-opt.hip index 22edf4107004e..57e9d79afd324 100644 --- a/clang/test/Driver/hip-toolchain-opt.hip +++ b/clang/test/Driver/hip-toolchain-opt.hip @@ -75,7 +75,7 @@ // O0-CGO2-NOT: "--lto-CGO2" // ALL: "{{.*}}clang-linker-wrapper{{.*}}" "--should-extract=gfx900" -// DEFAULT-NOT: "--device-compiler=amdgcn-amd-amdhsa=-O{{.*}}" +// DEFAULT: "--device-compiler=amdgcn-amd-amdhsa=-O0" // O0-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O0" // O1-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O1" // O2-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O2" @@ -86,7 +86,7 @@ // O0-CGO2-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O0" // ALL: "-cc1" "-triple" "x86_64-unknown-linux-gnu" -// DEFAULT-NOT: "-O{{.}}" +// DEFAULT: "-O0" // O0-SAME: "-O0" // O1-SAME: "-O1" // O2-SAME: "-O2" `````````` </details> https://github.com/llvm/llvm-project/pull/211790 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
