[PATCH] D60513: [HIP] Use -mlink-builtin-bitcode to link device library
This revision was automatically updated to reflect the committed changes. Closed by commit rL358290: [HIP] Use -mlink-builtin-bitcode to link device library (authored by yaxunl, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D60513?vs=194517=194904#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60513/new/ https://reviews.llvm.org/D60513 Files: cfe/trunk/lib/Driver/ToolChains/HIP.cpp cfe/trunk/test/Driver/hip-device-libs.hip cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip cfe/trunk/test/Driver/hip-toolchain-rdc.hip Index: cfe/trunk/test/Driver/hip-toolchain-rdc.hip === --- cfe/trunk/test/Driver/hip-toolchain-rdc.hip +++ cfe/trunk/test/Driver/hip-toolchain-rdc.hip @@ -18,6 +18,7 @@ // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803" // CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]] @@ -27,11 +28,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803" // CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]] // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC]] [[B_BC]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV1:".*-gfx803-linked-.*bc"]] // CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa" @@ -49,18 +50,21 @@ // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" // CHECK-SAME: "-emit-llvm-bc" // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900" -// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip" +// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" +// CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[A_SRC]] // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" // CHECK-SAME: "-emit-llvm-bc" // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900" -// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip" +// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" +// CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[B_SRC]] // CHECK: [[LLVM_LINK]] [[A_BC]] [[B_BC]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV2:".*-gfx900-linked-.*bc"]] // CHECK: [[OPT]] [[LINKED_BC_DEV2]] "-mtriple=amdgcn-amd-amdhsa" Index: cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip === --- cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip +++ cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip @@ -22,11 +22,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803" // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[A_BC_803:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]] // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC_803]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV_A_803:".*-gfx803-linked-.*bc"]] // CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa" @@ -50,11 +50,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900" // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[A_BC_900:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[A_SRC]] // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC_900]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV_A_900:".*-gfx900-linked-.*bc"]] // CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa" @@ -94,11 +94,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803" // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[B_BC_803:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]] // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[B_BC_803]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV_B_803:".*-gfx803-linked-.*bc"]]
[PATCH] D60513: [HIP] Use -mlink-builtin-bitcode to link device library
ashi1 accepted this revision. ashi1 added a comment. This revision is now accepted and ready to land. LGTM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60513/new/ https://reviews.llvm.org/D60513 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D60513: [HIP] Use -mlink-builtin-bitcode to link device library
yaxunl created this revision. yaxunl added reviewers: tra, ashi1. Herald added a subscriber: jdoerfert. Use -mlink-builtin-bitcode instead of llvm-link to link device library so that device library bitcode and user device code can be compiled in a consistent way. This is the same approach used by CUDA and OpenMP. https://reviews.llvm.org/D60513 Files: lib/Driver/ToolChains/HIP.cpp test/Driver/hip-device-libs.hip test/Driver/hip-toolchain-no-rdc.hip test/Driver/hip-toolchain-rdc.hip Index: test/Driver/hip-toolchain-rdc.hip === --- test/Driver/hip-toolchain-rdc.hip +++ test/Driver/hip-toolchain-rdc.hip @@ -18,6 +18,7 @@ // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803" // CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]] @@ -27,11 +28,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803" // CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]] // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC]] [[B_BC]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV1:".*-gfx803-linked-.*bc"]] // CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa" @@ -49,18 +50,21 @@ // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" // CHECK-SAME: "-emit-llvm-bc" // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900" -// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip" +// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" +// CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[A_SRC]] // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" // CHECK-SAME: "-emit-llvm-bc" // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900" -// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip" +// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" +// CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[B_SRC]] // CHECK: [[LLVM_LINK]] [[A_BC]] [[B_BC]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV2:".*-gfx900-linked-.*bc"]] // CHECK: [[OPT]] [[LINKED_BC_DEV2]] "-mtriple=amdgcn-amd-amdhsa" Index: test/Driver/hip-toolchain-no-rdc.hip === --- test/Driver/hip-toolchain-no-rdc.hip +++ test/Driver/hip-toolchain-no-rdc.hip @@ -22,11 +22,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803" // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[A_BC_803:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]] // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC_803]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV_A_803:".*-gfx803-linked-.*bc"]] // CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa" @@ -50,11 +50,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900" // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[A_BC_900:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[A_SRC]] // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC_900]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV_A_900:".*-gfx900-linked-.*bc"]] // CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa" @@ -94,11 +94,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803" // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" +// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[B_BC_803:".*bc"]] "-x" "hip" // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]] // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[B_BC_803]] -// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: "-o" [[LINKED_BC_DEV_B_803:".*-gfx803-linked-.*bc"]] // CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_B_803]] "-mtriple=amdgcn-amd-amdhsa" @@ -122,11 +122,11 @@ // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900" // CHECK-SAME: "-fcuda-is-device"