diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -64,11 +64,11 @@ bool IsMathErrnoDefault() const override { return false; } bool isCrossCompiling() const override { return true; } - bool isPICDefault() const override { return false; } + bool isPICDefault() const override { return true; } bool isPIEDefault(const llvm::opt::ArgList &Args) const override { return false; } - bool isPICDefaultForced() const override { return false; } + bool isPICDefaultForced() const override { return true; } bool SupportsProfiling() const override { return false; } llvm::opt::DerivedArgList * @@ -97,9 +97,6 @@ /// Needed for translating LTO options. const char *getDefaultLinker() const override { return "ld.lld"; } - /// Should skip argument. - bool shouldSkipArgument(const llvm::opt::Arg *Arg) const; - /// Uses amdgpu-arch tool to get arch of the system GPU. Will return error /// if unable to find one. virtual Expected> diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -611,10 +611,8 @@ if (!DAL) DAL = new DerivedArgList(Args.getBaseArgs()); - for (Arg *A : Args) { - if (!shouldSkipArgument(A)) - DAL->append(A); - } + for (Arg *A : Args) + DAL->append(A); checkTargetID(*DAL); @@ -870,13 +868,6 @@ return BCLibs; } -bool AMDGPUToolChain::shouldSkipArgument(const llvm::opt::Arg *A) const { - Option O = A->getOption(); - if (O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie)) - return true; - return false; -} - llvm::SmallVector ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs, const std::string &GPUArch, diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1418,10 +1418,6 @@ } } - // AMDGPU-specific defaults for PIC. - if (Triple.getArch() == llvm::Triple::amdgcn) - PIC = true; - // The last argument relating to either PIC or PIE wins, and no // other argument is used. If the last argument is any flavor of the // '-fno-...' arguments, both PIC and PIE are disabled. Any PIE diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp --- a/clang/lib/Driver/ToolChains/HIPAMD.cpp +++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp @@ -270,8 +270,7 @@ const OptTable &Opts = getDriver().getOpts(); for (Arg *A : Args) { - if (!shouldSkipArgument(A) && - !shouldSkipSanitizeOption(*this, Args, BoundArch, A)) + if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A)) DAL->append(A); } diff --git a/clang/test/Driver/amdgcn-toolchain-pic.cl b/clang/test/Driver/amdgcn-toolchain-pic.cl --- a/clang/test/Driver/amdgcn-toolchain-pic.cl +++ b/clang/test/Driver/amdgcn-toolchain-pic.cl @@ -1,7 +1,5 @@ -// RUN: %clang -### --target=amdgcn-- -mcpu=gfx803 %s 2>&1 | FileCheck %s -// RUN: %clang -### --target=amdgcn-amd- -mcpu=gfx803 %s 2>&1 | FileCheck %s // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx803 %s 2>&1 | FileCheck %s // RUN: %clang -### --target=amdgcn-amd-amdpal -mcpu=gfx803 %s 2>&1 | FileCheck %s // RUN: %clang -### --target=amdgcn-amd-mesa3d -mcpu=gfx803 %s 2>&1 | FileCheck %s -// CHECK: "-cc1"{{.*}} "-mrelocation-model" "pic" "-pic-level" "1" +// CHECK: "-cc1"{{.*}} "-mrelocation-model" "pic" "-pic-level" "2"