From 217f7efd9759e285b74a1368dfbd054368d7d9f3 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Thu, 15 Feb 2018 01:01:53 +0000 Subject: [PATCH] AMDGPU: Enable PIC by default for amdgcn Differential Revision: https://reviews.llvm.org/D43094 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325196 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains/CommonArgs.cpp | 4 ++++ test/Driver/amdgcn-toolchain-pic.cl | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 test/Driver/amdgcn-toolchain-pic.cl diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp index 6461a756cc..373e146528 100644 --- a/lib/Driver/ToolChains/CommonArgs.cpp +++ b/lib/Driver/ToolChains/CommonArgs.cpp @@ -864,6 +864,10 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) { } } + // 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/test/Driver/amdgcn-toolchain-pic.cl b/test/Driver/amdgcn-toolchain-pic.cl new file mode 100644 index 0000000000..870f1f3132 --- /dev/null +++ b/test/Driver/amdgcn-toolchain-pic.cl @@ -0,0 +1,7 @@ +// 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: clang{{.*}} "-mrelocation-model" "pic" "-pic-level" "1" -- 2.40.0