-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[clang][AMDGPU] Enable module splitting by default #128509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -630,8 +630,11 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, | |
getToolChain().AddFilePathLibArgs(Args, CmdArgs); | ||
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); | ||
if (C.getDriver().isUsingLTO()) { | ||
addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0], | ||
C.getDriver().getLTOMode() == LTOK_Thin); | ||
const bool ThinLTO = (C.getDriver().getLTOMode() == LTOK_Thin); | ||
addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0], ThinLTO); | ||
|
||
if (!ThinLTO) | ||
addFullLTOPartitionOption(C.getDriver(), Args, CmdArgs); | ||
} else if (Args.hasArg(options::OPT_mcpu_EQ)) { | ||
CmdArgs.push_back(Args.MakeArgString( | ||
"-plugin-opt=mcpu=" + | ||
|
@@ -708,6 +711,33 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D, | |
options::OPT_m_amdgpu_Features_Group); | ||
} | ||
|
||
static unsigned getFullLTOPartitions(const Driver &D, const ArgList &Args) { | ||
const Arg *A = Args.getLastArg(options::OPT_flto_partitions_EQ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
// In the absence of an option, use 8 as the default. | ||
if (!A) | ||
return 8; | ||
int Value = 0; | ||
if (StringRef(A->getValue()).getAsInteger(10, Value) || (Value < 1)) { | ||
D.Diag(diag::err_drv_invalid_int_value) | ||
<< A->getAsString(Args) << A->getValue(); | ||
return 1; | ||
} | ||
|
||
return Value; | ||
} | ||
|
||
void amdgpu::addFullLTOPartitionOption(const Driver &D, | ||
const llvm::opt::ArgList &Args, | ||
llvm::opt::ArgStringList &CmdArgs) { | ||
// TODO: Should this be restricted to fgpu-rdc only ? Currently we'll | ||
// also do it for non gpu-rdc LTO | ||
|
||
if (unsigned NumParts = getFullLTOPartitions(D, Args); NumParts > 1) { | ||
CmdArgs.push_back( | ||
Args.MakeArgString("--lto-partitions=" + Twine(NumParts))); | ||
} | ||
} | ||
|
||
/// AMDGPU Toolchain | ||
AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, | ||
const ArgList &Args) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// RUN: %clang -### --target=x86_64-linux-gnu \ | ||
// RUN: -x hip --cuda-gpu-arch=gfx803 --flto-partitions=42 \ | ||
// RUN: --no-offload-new-driver --emit-static-lib -nogpulib \ | ||
// RUN: -fuse-ld=lld -B%S/Inputs/lld -fgpu-rdc -nogpuinc \ | ||
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \ | ||
// RUN: %S/Inputs/hip_multiple_inputs/b.hip \ | ||
// RUN: 2>&1 | FileCheck %s --check-prefix=FIXED-PARTS | ||
|
||
// FIXED-PARTS-NOT: "*.llvm-link" | ||
// FIXED-PARTS-NOT: ".*opt" | ||
// FIXED-PARTS-NOT: ".*llc" | ||
// FIXED-PARTS: [[LLD: ".*lld.*"]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols" | ||
// FIXED-PARTS-SAME: "-plugin-opt=mcpu=gfx803" | ||
// FIXED-PARTS-SAME: "--lto-partitions=42" | ||
// FIXED-PARTS-SAME: "-o" "{{.*out}}" "{{.*bc}}" | ||
|
||
// RUN: not %clang -### --target=x86_64-linux-gnu \ | ||
// RUN: -x hip --cuda-gpu-arch=gfx803 --flto-partitions=a \ | ||
// RUN: --no-offload-new-driver --emit-static-lib -nogpulib \ | ||
// RUN: -fuse-ld=lld -B%S/Inputs/lld -fgpu-rdc -nogpuinc \ | ||
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \ | ||
// RUN: %S/Inputs/hip_multiple_inputs/b.hip \ | ||
// RUN: 2>&1 | FileCheck %s --check-prefix=LTO_PARTS_INV0 | ||
|
||
// LTO_PARTS_INV0: clang: error: invalid integral value 'a' in '--flto-partitions=a' | ||
|
||
// RUN: not %clang -### --target=x86_64-linux-gnu \ | ||
// RUN: -x hip --cuda-gpu-arch=gfx803 --flto-partitions=0 \ | ||
// RUN: --no-offload-new-driver --emit-static-lib -nogpulib \ | ||
// RUN: -fuse-ld=lld -B%S/Inputs/lld -fgpu-rdc -nogpuinc \ | ||
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \ | ||
// RUN: %S/Inputs/hip_multiple_inputs/b.hip \ | ||
// RUN: 2>&1 | FileCheck %s --check-prefix=LTO_PARTS_INV1 | ||
|
||
// LTO_PARTS_INV1: clang: error: invalid integral value '0' in '--flto-partitions=0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we added a top level option for this it probably should've been made to work for non-AMDGPU uses.