Skip to content

Commit

Permalink
Partial revert "[HIP] Fix -mllvm option for device lld linker" (llvm#…
Browse files Browse the repository at this point in the history
…80202)

This partially reverts commit aa964f1
because it caused perf regressions in rccl due to drop of -mllvm
-amgpu-kernarg-preload-count=16 from the linker step. Potentially it
could cause similar regressions for other HIP apps using -mllvm options
with -fgpu-rdc.

Fixes: SWDEV-443345
  • Loading branch information
yxsamliu authored Jan 31, 2024
1 parent f264da4 commit 7c2e32d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions clang/lib/Driver/ToolChains/HIPAMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
if (IsThinLTO)
LldArgs.push_back(Args.MakeArgString("-plugin-opt=-force-import-all"));

for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
LldArgs.push_back(
Args.MakeArgString(Twine("-plugin-opt=") + A->getValue(0)));
}

if (C.getDriver().isSaveTempsEnabled())
LldArgs.push_back("-save-temps");

Expand Down
12 changes: 6 additions & 6 deletions clang/test/Driver/hip-toolchain-mllvm.hip
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// REQUIRES: x86-registered-target
// REQUIRES: amdgpu-registered-target

// Check only -Xoffload-linker -mllvm=* options are passed
// to device lld linker.
// -mllvm options are passed to clang only.
// Check -Xoffload-linker -mllvm=* options are passed
// to device lld linker only.
// -mllvm options are passed to clang and device lld linker.

// RUN: %clang -### --target=x86_64-linux-gnu \
// RUN: --offload-arch=gfx803 --offload-arch=gfx900 \
Expand Down Expand Up @@ -33,15 +33,15 @@
// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
// CHECK-SAME: {{.*}} "-target-cpu" "gfx803"
// CHECK-SAME: {{.*}} "-mllvm" "-unroll-count=10" {{.*}}
// CHECK: [[LLD:".*lld.*"]] {{.*}}"-m" "elf64_amdgpu"{{.*}} "-plugin-opt=-inline-threshold=100"
// CHECK: [[LLD:".*lld.*"]] {{.*}}"-m" "elf64_amdgpu"{{.*}} "-plugin-opt=-unroll-count=10"{{.*}} "-plugin-opt=-inline-threshold=100"

// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
// CHECK-SAME: {{.*}} "-target-cpu" "gfx900"
// CHECK-SAME: {{.*}} "-mllvm" "-unroll-count=10" {{.*}}
// CHECK: [[LLD:".*lld.*"]] {{.*}} "-plugin-opt=-inline-threshold=100"
// CHECK: [[LLD:".*lld.*"]] {{.*}} "-plugin-opt=-unroll-count=10"{{.*}} "-plugin-opt=-inline-threshold=100"

// NEG-NOT: {{".*opt"}}
// NEG-NOT: {{".*llc"}}
// NEG-NOT: "-plugin-opt=-unroll-count=10"
// NEG-NOT: "-m" "elf_x86_64"{{.*}} "-plugin-opt=-unroll-count=10"
// NEG-NOT: "-m" "elf_x86_64"{{.*}} "-plugin-opt=-inline-threshold=100"

0 comments on commit 7c2e32d

Please sign in to comment.