]> granicus.if.org Git - clang/commitdiff
AMDGPU: Enable PIC by default for amdgcn
authorKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>
Thu, 15 Feb 2018 01:01:53 +0000 (01:01 +0000)
committerKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>
Thu, 15 Feb 2018 01:01:53 +0000 (01:01 +0000)
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
test/Driver/amdgcn-toolchain-pic.cl [new file with mode: 0644]

index 6461a756cc9b4bc500ea254f844752f8d837e872..373e14652878eb6e0dab357c8dd3998106172e44 100644 (file)
@@ -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 (file)
index 0000000..870f1f3
--- /dev/null
@@ -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"