[PATCH] D51336: [HIP] Fix output file extension

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 27 21:16:53 PDT 2018

yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.

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

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.



Index: test/Driver/hip-output-file-name.hip
--- /dev/null
+++ test/Driver/hip-output-file-name.hip
@@ -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"
Index: lib/Driver/Action.cpp
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -382,7 +382,7 @@
 void OffloadBundlingJobAction::anchor() {}
 OffloadBundlingJobAction::OffloadBundlingJobAction(ActionList &Inputs)
-    : JobAction(OffloadBundlingJobClass, Inputs, Inputs.front()->getType()) {}
+    : JobAction(OffloadBundlingJobClass, Inputs, Inputs.back()->getType()) {}
 void OffloadUnbundlingJobAction::anchor() {}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51336.162794.patch
Type: text/x-patch
Size: 1012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180828/ce8eacec/attachment.bin>

More information about the cfe-commits mailing list