]> granicus.if.org Git - clang/commitdiff
[HIP] Fix output file extension
authorYaxun Liu <Yaxun.Liu@amd.com>
Tue, 28 Aug 2018 21:09:09 +0000 (21:09 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Tue, 28 Aug 2018 21:09:09 +0000 (21:09 +0000)
OffloadBundlingJobAction constructor accepts a list of JobAction as inputs.
The host JobAction is the last one. The file type of OffloadBundlingJobAction
should be determined by the host JobAction (the last one) instead of the first
one.

Since HIP emits LLVM bitcode for device compilation, device JobAction has
different file type as host Job Action. This bug causes incorrect output file
extension for HIP.

This patch fixes it by using the last input JobAction (host JobAction) to determine
file type of OffloadBundlingJobAction.

Differential Revision: https://reviews.llvm.org/D51336

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340873 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Action.cpp
test/Driver/hip-output-file-name.hip [new file with mode: 0644]

index 99d588d9c009ca8c6dfe01bd66f201b9cb93f170..f90904387511e75a39089009ce7a4dc5743562e2 100644 (file)
@@ -382,7 +382,7 @@ VerifyPCHJobAction::VerifyPCHJobAction(Action *Input, types::ID Type)
 void OffloadBundlingJobAction::anchor() {}
 
 OffloadBundlingJobAction::OffloadBundlingJobAction(ActionList &Inputs)
-    : JobAction(OffloadBundlingJobClass, Inputs, Inputs.front()->getType()) {}
+    : JobAction(OffloadBundlingJobClass, Inputs, Inputs.back()->getType()) {}
 
 void OffloadUnbundlingJobAction::anchor() {}
 
diff --git a/test/Driver/hip-output-file-name.hip b/test/Driver/hip-output-file-name.hip
new file mode 100644 (file)
index 0000000..65887f4
--- /dev/null
@@ -0,0 +1,9 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -c -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang-offload-bundler{{.*}}"-outputs=hip-output-file-name.o"