brintos

brintos / llvm-project-archived public Read only

0
0
Text · 41.1 KiB · 6466e18 Raw
572 lines · c
1// REQUIRES: x86-registered-target2// UNSUPPORTED: target={{.*}}-macosx{{.*}}, target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}, target={{.*}}-zos{{.*}}3 4//5// Generate all the types of files we can bundle.6//7// RUN: %clang -O0 -target %itanium_abi_triple %s -E -o %t.i8// RUN: %clangxx -O0 -target %itanium_abi_triple -x c++ %s -E -o %t.ii9// RUN: %clang -O0 -target %itanium_abi_triple %s -S -emit-llvm -o %t.ll10// RUN: %clang -O0 -target %itanium_abi_triple %s -c -emit-llvm -o %t.bc11// RUN: %clang -O0 -target %itanium_abi_triple %s -S -o %t.s12// RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o13// RUN: obj2yaml %t.o > %t.o.yaml14// RUN: %clang -O0 -target %itanium_abi_triple %s -emit-ast -o %t.ast15 16// RUN: echo 'void a() {}' >%t.a.cpp17// RUN: echo 'void b() {}' >%t.b.cpp18// RUN: %clang -target %itanium_abi_triple %t.a.cpp -c -o %t.a.o19// RUN: %clang -target %itanium_abi_triple %t.b.cpp -c -o %t.b.o20//21// Remove .llvm_addrsig section since its offset changes after llvm-objcopy22// removes clang-offload-bundler sections, therefore not good for comparison.23//24// RUN: llvm-objcopy --remove-section=.llvm_addrsig %t.a.o25// RUN: llvm-objcopy --remove-section=.llvm_addrsig %t.b.o26// RUN: obj2yaml %t.a.o > %t.a.yaml27// RUN: obj2yaml %t.b.o > %t.b.yaml28 29//30// Generate an empty file to help with the checks of empty files.31//32// RUN: touch %t.empty33 34//35// Generate a couple of files to bundle with.36//37// RUN: echo 'Content of device file 1' > %t.tgt138// RUN: echo 'Content of device file 2' > %t.tgt239 40//41// Check help message.42//43// RUN: clang-offload-bundler --help | FileCheck %s --check-prefix CK-HELP44// CK-HELP: {{.*}}OVERVIEW: A tool to bundle several input files of the specified type <type>45// CK-HELP: {{.*}}referring to the same source file but different targets into a single46// CK-HELP: {{.*}}one. The resulting file can also be unbundled into different files by47// CK-HELP: {{.*}}this tool if -unbundle is provided.48// CK-HELP: {{.*}}USAGE: clang-offload-bundler [options]49// CK-HELP: {{.*}}-### {{.*}}- Print any external commands that are to be executed instead of actually executing them - for testing purposes.50// CK-HELP: {{.*}}-allow-missing-bundles {{.*}}- Create empty files if bundles are missing when unbundling.51// CK-HELP: {{.*}}-bundle-align=<uint> {{.*}}- Alignment of bundle for binary files52// CK-HELP: {{.*}}-hip-openmp-compatible {{.*}}- Treat hip and hipv4 offload kinds as compatible with openmp kind, and vice versa.53// CK-HELP: {{.*}}-input=<string>  - Input file.  Can be specified multiple times for multiple input files.54// CK-HELP: {{.*}}-inputs=<string>  - [<input file>,...] (deprecated)55// CK-HELP: {{.*}}-list {{.*}}- List bundle IDs in the bundled file.56// CK-HELP: {{.*}}-output=<string>  - Output file.  Can be specified multiple times for multiple output files.57// CK-HELP: {{.*}}-outputs=<string> - [<output file>,...] (deprecated)58// CK-HELP: {{.*}}-targets=<string> - [<offload kind>-<target triple>,...]59// CK-HELP: {{.*}}-type=<string>    - Type of the files to be bundled/unbundled.60// CK-HELP: {{.*}}Current supported types are:61// CK-HELP: {{.*}}i {{.*}}- cpp-output62// CK-HELP: {{.*}}ii {{.*}}- c++-cpp-output63// CK-HELP: {{.*}}ll {{.*}}- llvm64// CK-HELP: {{.*}}bc {{.*}}- llvm-bc65// CK-HELP: {{.*}}s {{.*}}- assembler66// CK-HELP: {{.*}}o {{.*}}- object67// CK-HELP: {{.*}}a {{.*}}- archive of objects68// CK-HELP: {{.*}}gch {{.*}}- precompiled-header69// CK-HELP: {{.*}}ast {{.*}}- clang AST file70// CK-HELP: {{.*}}-unbundle {{.*}}- Unbundle bundled file into several output files.71 72//73// Check errors.74//75// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR176// CK-ERR1: error: only one input file supported in unbundling mode77 78// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -output=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR1A79// CK-ERR1A: error: number of output files and targets should match in unbundling mode80 81// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR282// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR283// CK-ERR2: error: number of input files and targets should match in bundling mode84 85// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.i -output=%t.tgt1 -output=%t.tgt2 -input=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR386// CK-ERR3: error: only one output file supported in bundling mode87 88// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -output=%t.i -output=%t.tgt1 -output=%t.tgt2 -input=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR489// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.i -output=%t.tgt1 -input=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR490// CK-ERR4: error: number of output files and targets should match in unbundling mode91 92// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2.notexist -output=%t.bundle.i 2>&1 | \93// RUN:   FileCheck %s -DFILE=%t.tgt2.notexist -DMSG=%errc_ENOENT --check-prefix CK-ERR594// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.i -output=%t.tgt1 -output=%t.tgt2 -input=%t.bundle.i.notexist -unbundle 2>&1 | \95// RUN:   FileCheck %s -DFILE=%t.bundle.i.notexist -DMSG=%errc_ENOENT --check-prefix CK-ERR596// CK-ERR5: error: '[[FILE]]': [[MSG]]97 98// RUN: not clang-offload-bundler -type=invalid -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s -DTYPE=invalid --check-prefix CK-ERR699// CK-ERR6: error: '[[TYPE]]': invalid file type specified100 101// RUN: not clang-offload-bundler 2>&1 | FileCheck %s --check-prefix CK-ERR7102// CK-ERR7: clang-offload-bundler: for the --type option: must be specified at least once!103 104// RUN: not clang-offload-bundler -type=i -input=%t.i -input=%t.tgt1 -input=%t.tgt2 2>&1 | FileCheck %s -check-prefix=CK-ERR7A105// CK-ERR7A: error: no output file specified!106 107// RUN: not clang-offload-bundler -type=i -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s -check-prefix=CK-ERR7B108// CK-ERR7B: error: for the --targets option: must be specified at least once!109 110// RUN: not clang-offload-bundler -type=i -targets=hxst-powerpcxxle-ibm-linux-gnu,openxp-pxxerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR8111// CK-ERR8: error: invalid target 'hxst-powerpcxxle-ibm-linux-gnu', unknown offloading kind 'hxst', unknown target triple 'powerpcxxle-ibm-linux-gnu'112 113// RUN: not clang-offload-bundler -type=i -targets=host-powerpc64le-ibm-linux-gnu,openxp-pxxerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR8A114// CK-ERR8A: error: invalid target 'openxp-pxxerpc64le-ibm-linux-gnu', unknown offloading kind 'openxp', unknown target triple 'pxxerpc64le-ibm-linux-gnu'115 116// RUN: not clang-offload-bundler -type=i -targets=host-powerpc64le-ibm-linux-gnu,openmp-powerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR8B117// CK-ERR8B: error: invalid target 'xpenmp-x86_xx-pc-linux-gnu', unknown offloading kind 'xpenmp', unknown target triple 'x86_xx-pc-linux-gnu'118 119// RUN: not clang-offload-bundler -type=i -targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR9A120// CK-ERR9A: error: expecting exactly one host target but got 0121 122// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR9B123// CK-ERR9B: error: Duplicate targets are not allowed124 125// RUN: not clang-offload-bundler -type=a -targets=hxst-powerpcxxle-ibm-linux-gnu,openxp-pxxerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR10A126// CK-ERR10A: error: Archive files are only supported for unbundling127 128// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -inputs=%t.tgt1,%t.tgt2 -output=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR11A129// CK-ERR11A: error: -inputs and -input cannot be used together, use only -input instead130 131// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -output=%t.i -outputs=%t.tgt1,%t.tgt2 -input=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR11B132// CK-ERR11B: error: -outputs and -output cannot be used together, use only -output instead133 134//135// Check text bundle. This is a readable format, so we check for the format we expect to find.136//137// RUN: clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.i138// RUN: clang-offload-bundler -type=ii -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.ii -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.ii139// RUN: clang-offload-bundler -type=ll -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.ll -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.ll140// RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.s -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.s141// RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -input=%t.tgt1 -input=%t.s -input=%t.tgt2 -output=%t.bundle3.unordered.s142// RUN: FileCheck %s --input-file %t.bundle3.i --check-prefix CK-TEXTI143// RUN: FileCheck %s --input-file %t.bundle3.ii --check-prefix CK-TEXTI144// RUN: FileCheck %s --input-file %t.bundle3.ll --check-prefix CK-TEXTLL145// RUN: FileCheck %s --input-file %t.bundle3.s --check-prefix CK-TEXTS146// RUN: FileCheck %s --input-file %t.bundle3.unordered.s --check-prefix CK-TEXTS-UNORDERED147 148// CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]149// CK-TEXTI: int A = 0;150// CK-TEXTI: test_func(void)151// CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]152// CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu153// CK-TEXTI: Content of device file 1154// CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu155// CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu156// CK-TEXTI: Content of device file 2157// CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu158 159// CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]160// CK-TEXTLL: @A = {{.*}}global i32 0161// CK-TEXTLL: define {{.*}}@test_func()162// CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]163// CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu164// CK-TEXTLL: Content of device file 1165// CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu166// CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu167// CK-TEXTLL: Content of device file 2168// CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu169 170// CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]171// CK-TEXTS: .globl {{.*}}test_func172// CK-TEXTS: .globl {{.*}}A173// CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]174// CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu175// CK-TEXTS: Content of device file 1176// CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu177// CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu178// CK-TEXTS: Content of device file 2179// CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu180 181// CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu182// CK-TEXTS-UNORDERED: Content of device file 1183// CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu184// CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]185// CK-TEXTS-UNORDERED: .globl {{.*}}test_func186// CK-TEXTS-UNORDERED: .globl {{.*}}A187// CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]188// CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu189// CK-TEXTS-UNORDERED: Content of device file 2190// CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu191 192//193// Check text unbundle. Check if we get the exact same content that we bundled before for each file.194//195// RUN: clang-offload-bundler -type=i -input=%t.bundle3.i -list | FileCheck -check-prefix=CKLST %s196// RUN: clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.i -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.i -unbundle197// RUN: diff %t.i %t.res.i198// RUN: diff %t.tgt1 %t.res.tgt1199// RUN: diff %t.tgt2 %t.res.tgt2200// RUN: clang-offload-bundler -type=i -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.i -unbundle201// RUN: diff %t.tgt1 %t.res.tgt1202// RUN: clang-offload-bundler -type=ii -input=%t.bundle3.ii -list | FileCheck -check-prefix=CKLST %s203// RUN: clang-offload-bundler -type=ii -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.ii -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.ii -unbundle204// RUN: diff %t.ii %t.res.ii205// RUN: diff %t.tgt1 %t.res.tgt1206// RUN: diff %t.tgt2 %t.res.tgt2207// RUN: clang-offload-bundler -type=ii -targets=openmp-x86_64-pc-linux-gnu -output=%t.res.tgt2 -input=%t.bundle3.ii -unbundle208// RUN: diff %t.tgt2 %t.res.tgt2209// RUN: clang-offload-bundler -type=ll -input=%t.bundle3.ll -list | FileCheck -check-prefix=CKLST %s210// RUN: clang-offload-bundler -type=ll -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.ll -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.ll -unbundle211// RUN: diff %t.ll %t.res.ll212// RUN: diff %t.tgt1 %t.res.tgt1213// RUN: diff %t.tgt2 %t.res.tgt2214// RUN: clang-offload-bundler -type=ll -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.ll -unbundle215// RUN: diff %t.tgt1 %t.res.tgt1216// RUN: clang-offload-bundler -type=s -input=%t.bundle3.s -list | FileCheck -check-prefix=CKLST %s217// RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.s -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.s -unbundle218// RUN: diff %t.s %t.res.s219// RUN: diff %t.tgt1 %t.res.tgt1220// RUN: diff %t.tgt2 %t.res.tgt2221// RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.s -output=%t.res.tgt2 -input=%t.bundle3.s -unbundle222// RUN: diff %t.s %t.res.s223// RUN: diff %t.tgt1 %t.res.tgt1224// RUN: diff %t.tgt2 %t.res.tgt2225// RUN: clang-offload-bundler -type=s -targets=openmp-x86_64-pc-linux-gnu -output=%t.res.tgt2 -input=%t.bundle3.s -unbundle226// RUN: diff %t.tgt2 %t.res.tgt2227 228// Check if we can unbundle a file with no magic strings.229// RUN: clang-offload-bundler -type=s -input=%t.s -list | FileCheck -check-prefix=CKLST2 --allow-empty %s230// RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.s -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.s -unbundle -allow-missing-bundles231// RUN: diff %t.s %t.res.s232// RUN: diff %t.empty %t.res.tgt1233// RUN: diff %t.empty %t.res.tgt2234// RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.s -output=%t.res.tgt2 -input=%t.s -unbundle -allow-missing-bundles235// RUN: diff %t.s %t.res.s236// RUN: diff %t.empty %t.res.tgt1237// RUN: diff %t.empty %t.res.tgt2238 239// Check that bindler prints an error if given host bundle does not exist in the fat binary.240// RUN: not clang-offload-bundler -type=s -targets=host-amdgcn-xxx-linux-gnu,openmp-powerpc64le-ibm-linux-gnu -output=%t.res.s -output=%t.res.tgt1 -input=%t.bundle3.s -unbundle 2>&1 | FileCheck %s --check-prefix CK-NO-HOST-BUNDLE241// CK-NO-HOST-BUNDLE: error: Can't find bundles for host-amdgcn-xxx-linux-242 243// Check missing host entry is allowed with -allow-missing-bundles244// RUN: clang-offload-bundler -type=s -targets=host-amdgcn-xxx-linux-gnu,openmp-powerpc64le-ibm-linux-gnu -output=%t.res.s -output=%t.res.tgt1 -input=%t.bundle3.s -unbundle -allow-missing-bundles245 246//247// Check binary bundle/unbundle. The content that we have before bundling must be the same we have after unbundling.248//249// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.bc -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.bc250// RUN: clang-offload-bundler -type=gch -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.ast -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.gch251// RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.ast -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.ast252// RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -input=%t.tgt1 -input=%t.ast -input=%t.tgt2 -output=%t.bundle3.unordered.ast253// RUN: clang-offload-bundler -type=bc -input=%t.bundle3.bc -list | FileCheck -check-prefix=CKLST %s254// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.bc -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.bc -unbundle255// RUN: diff %t.bc %t.res.bc256// RUN: diff %t.tgt1 %t.res.tgt1257// RUN: diff %t.tgt2 %t.res.tgt2258// RUN: clang-offload-bundler -type=bc -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.bc -unbundle259// RUN: diff %t.tgt1 %t.res.tgt1260// RUN: clang-offload-bundler -type=gch -input=%t.bundle3.gch -list | FileCheck -check-prefix=CKLST %s261// RUN: clang-offload-bundler -type=gch -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.gch -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.gch -unbundle262// RUN: diff %t.ast %t.res.gch263// RUN: diff %t.tgt1 %t.res.tgt1264// RUN: diff %t.tgt2 %t.res.tgt2265// RUN: clang-offload-bundler -type=gch -targets=openmp-x86_64-pc-linux-gnu -output=%t.res.tgt2 -input=%t.bundle3.gch -unbundle266// RUN: diff %t.tgt2 %t.res.tgt2267// RUN: clang-offload-bundler -type=ast -input=%t.bundle3.ast -list | FileCheck -check-prefix=CKLST %s268// RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.ast -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.ast -unbundle269// RUN: diff %t.ast %t.res.ast270// RUN: diff %t.tgt1 %t.res.tgt1271// RUN: diff %t.tgt2 %t.res.tgt2272// RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.ast -output=%t.res.tgt2 -input=%t.bundle3.ast -unbundle273// RUN: diff %t.ast %t.res.ast274// RUN: diff %t.tgt1 %t.res.tgt1275// RUN: diff %t.tgt2 %t.res.tgt2276// RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.ast -output=%t.res.tgt2 -input=%t.bundle3.unordered.ast -unbundle277// RUN: diff %t.ast %t.res.ast278// RUN: diff %t.tgt1 %t.res.tgt1279// RUN: diff %t.tgt2 %t.res.tgt2280// RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.ast -unbundle281// RUN: diff %t.tgt1 %t.res.tgt1282 283// Check if we can unbundle a file with no magic strings.284// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.bc -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bc -unbundle -allow-missing-bundles285// RUN: diff %t.bc %t.res.bc286// RUN: diff %t.empty %t.res.tgt1287// RUN: diff %t.empty %t.res.tgt2288// RUN: clang-offload-bundler -type=bc -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.bc -output=%t.res.tgt2 -input=%t.bc -unbundle -allow-missing-bundles289// RUN: diff %t.bc %t.res.bc290// RUN: diff %t.empty %t.res.tgt1291// RUN: diff %t.empty %t.res.tgt2292 293// Check that we do not have to unbundle all available bundles from the fat binary.294// RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.ast -output=%t.res.tgt2 -input=%t.bundle3.unordered.ast -unbundle295// RUN: diff %t.ast %t.res.ast296// RUN: diff %t.tgt2 %t.res.tgt2297 298// Check that we do not have to unbundle all available bundles from the fat binary.299// RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.ast -output=%t.res.tgt2 -input=%t.bundle3.unordered.ast -unbundle300// RUN: diff %t.ast %t.res.ast301// RUN: diff %t.tgt2 %t.res.tgt2302 303//304// Check object bundle/unbundle. The content should be bundled into an ELF305// section (we are using a PowerPC little-endian host which uses ELF). We306// have an already bundled file to check the unbundle and do a dry run on the307// bundling as it cannot be tested in all host platforms that will run these308// tests.309//310 311// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \312// RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD313// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"314 315// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \316// RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS317// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"318 319// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o320// RUN: clang-offload-bundler -type=o -input=%t.bundle3.o -list | FileCheck -check-prefix=CKLST %s321// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.o -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.o -unbundle322// RUN: obj2yaml %t.res.o > %t.res.o.yaml323// RUN: diff %t.o.yaml %t.res.o.yaml324// RUN: diff %t.tgt1 %t.res.tgt1325// RUN: diff %t.tgt2 %t.res.tgt2326// RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.o -output=%t.res.tgt2 -input=%t.bundle3.o -unbundle327// RUN: obj2yaml %t.res.o > %t.res.o.yaml328// RUN: diff %t.o.yaml %t.res.o.yaml329// RUN: diff %t.tgt1 %t.res.tgt1330// RUN: diff %t.tgt2 %t.res.tgt2331// RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.o -unbundle332// RUN: diff %t.tgt1 %t.res.tgt1333 334// Check if we can unbundle a file with no magic strings.335// RUN: clang-offload-bundler -type=o -input=%t.o -list | FileCheck -check-prefix=CKLST2 --allow-empty %s336// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.o -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.o -unbundle -allow-missing-bundles337// RUN: obj2yaml %t.res.o > %t.res.o.yaml338// RUN: diff %t.o.yaml %t.res.o.yaml339// RUN: diff %t.empty %t.res.tgt1340// RUN: diff %t.empty %t.res.tgt2341// RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.o -output=%t.res.tgt2 -input=%t.o -unbundle -allow-missing-bundles342// RUN: obj2yaml %t.res.o > %t.res.o.yaml343// RUN: diff %t.o.yaml %t.res.o.yaml344// RUN: diff %t.empty %t.res.tgt1345// RUN: diff %t.empty %t.res.tgt2346 347//348// Check -bundle-align option349//350 351// RUN: clang-offload-bundler -bundle-align=4096 -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.bc -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.bc352// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.bc -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.bc -unbundle353// RUN: diff %t.bc %t.res.bc354// RUN: diff %t.tgt1 %t.res.tgt1355// RUN: diff %t.tgt2 %t.res.tgt2356 357//358// Check error due to missing bundles359//360// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx900 -input=%t.bc -input=%t.tgt1 -output=%t.hip.bundle.bc361// RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -unbundle \362// RUN:   -targets=hip-amdgcn-amd-amdhsa--gfx906 \363// RUN:   2>&1 | FileCheck -check-prefix=MISS1 %s364// RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -output=%t.tmp2.bc -unbundle \365// RUN:   -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx900 \366// RUN:   2>&1 | FileCheck -check-prefix=MISS1 %s367// MISS1: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx906368// RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -output=%t.tmp2.bc -unbundle \369// RUN:   -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx803 \370// RUN:   2>&1 | FileCheck -check-prefix=MISS2 %s371// MISS2: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx803 and hip-amdgcn-amd-amdhsa--gfx906372// RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -output=%t.tmp2.bc -output=%t.tmp3.bc -unbundle \373// RUN:   -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx1010 \374// RUN:   2>&1 | FileCheck -check-prefix=MISS3 %s375// MISS3: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx1010, hip-amdgcn-amd-amdhsa--gfx803, and hip-amdgcn-amd-amdhsa--gfx906376 377//378// Check error due to duplicate targets379//380// RUN: not clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx900 \381// RUN:   -input=%t.bc -input=%t.tgt1 -input=%t.tgt1 -output=%t.hip.bundle.bc 2>&1 | FileCheck -check-prefix=DUP %s382// RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -output=%t.tmp2.bc -unbundle \383// RUN:   -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx906 \384// RUN:   2>&1 | FileCheck -check-prefix=DUP %s385// DUP: error: Duplicate targets are not allowed386//387// Check -list option388//389 390// RUN: clang-offload-bundler -bundle-align=4096 -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.bc -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.bc391// RUN: not clang-offload-bundler -type=bc -input=%t.bundle3.bc -unbundle -list 2>&1 | FileCheck -check-prefix=CKLST-ERR %s392// CKLST-ERR: error: -unbundle and -list cannot be used together393// RUN: not clang-offload-bundler -type=bc -input=%t.bundle3.bc -targets=host-%itanium_abi_triple -list 2>&1 | FileCheck -check-prefix=CKLST-ERR2 %s394// CKLST-ERR2: error: -targets option is invalid for -list395// RUN: not clang-offload-bundler -type=bc -input=%t.bundle3.bc -output=out.txt -list 2>&1 | FileCheck -check-prefix=CKLST-ERR3 %s396// CKLST-ERR3: error: -outputs option is invalid for -list397// RUN: not clang-offload-bundler -type=bc -input=%t.bundle3.bc -input=%t.bc -list 2>&1 | FileCheck -check-prefix=CKLST-ERR4 %s398// CKLST-ERR4: error: only one input file supported for -list399 400// CKLST-DAG: host-401// CKLST-DAG: openmp-powerpc64le-ibm-linux-gnu402// CKLST-DAG: openmp-x86_64-pc-linux-gnu403 404// CKLST2-NOT: host-405// CKLST2-NOT: openmp-powerpc64le-ibm-linux-gnu406// CKLST2-NOT: openmp-x86_64-pc-linux-gnu407 408//409// Check unbundling archive for HIP.410//411// When the input to clang-offload-bundler is an archive of bundled bitcodes,412// for each target, clang-offload-bundler extracts the bitcode from each413// bundle and archives them. Therefore for each target, the output is an414// archive of unbundled bitcodes.415//416// RUN: mkdir -p %t.dir417// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \418// RUN:   -input=%t.tgt1 -input=%t.tgt2 -output=%t.dir/hip_bundle1.bc419// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \420// RUN:   -input=%t.tgt1 -input=%t.tgt2 -output=%t.dir/hip_bundle2.bc421// RUN: llvm-ar cr %t.dir/hip_archive.a %t.dir/hip_bundle1.bc %t.dir/hip_bundle2.bc422// RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \423// RUN:   -output=%t.dir/hip_900.a -output=%t.dir/hip_906.a -input=%t.dir/hip_archive.a424// RUN: llvm-ar t %t.dir/hip_900.a | FileCheck -check-prefix=HIP-AR-900 %s425// RUN: llvm-ar t %t.dir/hip_906.a | FileCheck -check-prefix=HIP-AR-906 %s426// HIP-AR-900-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx900427// HIP-AR-900-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx900428// HIP-AR-906-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906429// HIP-AR-906-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx906430 431//432// Check unbundling archive for host target433//434// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx900 \435// RUN:   -input=%t.a.o -input=%t.tgt1 -output=%t.a.bundled.o436// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx900 \437// RUN:   -input=%t.b.o -input=%t.tgt1 -output=%t.b.bundled.o438// RUN: rm -f %t.bundled.a439// RUN: llvm-ar cr %t.bundled.a %t.a.bundled.o %t.b.bundled.o440// RUN: cp %t.bundled.a %t.bundled.a.bak441// RUN: clang-offload-bundler -unbundle --targets=host-%itanium_abi_triple -type=a -input=%t.bundled.a -output=%t.host.a442// RUN: rm -f *%itanium_abi_triple*.a.bundled.o *%itanium_abi_triple*.b.bundled.o443// RUN: llvm-ar -x %t.host.a444// RUN: diff %t.bundled.a %t.bundled.a.bak445// RUN: obj2yaml *%itanium_abi_triple*.a.bundled.o > %t.a.unbundled.yaml446// RUN: diff %t.a.unbundled.yaml %t.a.yaml447// RUN: obj2yaml *%itanium_abi_triple*.b.bundled.o > %t.b.unbundled.yaml448// RUN: diff %t.b.unbundled.yaml %t.b.yaml449//450// Check clang-offload-bundler reporting an error when trying to unbundle an archive but451// the input file is not an archive.452//453// RUN: echo 'This is not an archive file.' > %t.non-archive454// RUN: not clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900 \455// RUN:   -output=%t.res.a -input=%t.non-archive --allow-missing-bundles 2>&1 \456// RUN:   | FileCheck %s -check-prefix=INVARCHIVE457// RUN: not clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900 \458// RUN:   -output=%t.res.a -input=%t.non-archive 2>&1 | FileCheck %s -check-prefix=INVARCHIVE459// INVARCHIVE: error: file too small to be an archive460 461//462// Check bundling without host target is allowed for HIP.463//464// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \465// RUN:   -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc466// RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST %s467// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \468// RUN:   -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle469// RUN: diff %t.tgt1 %t.res.tgt1470// RUN: diff %t.tgt2 %t.res.tgt2471//472// NOHOST-NOT: host-473// NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx900474// NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx906475 476//477// Check bundling ID compatibility for HIP.478//479// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack- \480// RUN:   -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack+ \481// RUN:   -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc482// RUN: not clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906 \483// RUN:   -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack+ \484// RUN:   -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc 2>&1 \485// RUN:   | FileCheck %s -check-prefix=CONFLICT-TID486// CONFLICT-TID: error: Cannot bundle inputs with conflicting targets: 'hip-amdgcn-amd-amdhsa--gfx906' and 'hip-amdgcn-amd-amdhsa--gfx906:xnack+'487 488//489// Check extracting bundle entry with compatible target ID for HIP.490//491// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906 \492// RUN:   -input=%t.tgt1 -output=%t.hip.bundle.bc493// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack- \494// RUN:   -output=%t.res.tgt1 -input=%t.hip.bundle.bc -unbundle495// RUN: diff %t.tgt1 %t.res.tgt1496// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack+ \497// RUN:   -output=%t.res.tgt1 -input=%t.hip.bundle.bc -unbundle498// RUN: diff %t.tgt1 %t.res.tgt1499 500// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack+ \501// RUN:   -input=%t.tgt1 -output=%t.hip.bundle.bc502// RUN: not clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack- \503// RUN:   -output=%t.res.tgt1 -input=%t.hip.bundle.bc -unbundle 2>&1 | FileCheck %s -check-prefix=NOXNACK504// NOXNACK: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx906:xnack-505// RUN: not clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906 \506// RUN:   -output=%t.res.tgt1 -input=%t.hip.bundle.bc -unbundle 2>&1 | FileCheck %s -check-prefix=NOGFX906507// NOGFX906: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx906508 509//510// Check hip and hipv4 are compatible as offload kind.511//512// RUN: clang-offload-bundler -type=o -targets=hip-amdgcn-amd-amdhsa--gfx90a -input=%t.tgt1 -output=%t.bundle3.o513// RUN: clang-offload-bundler -type=o -targets=hipv4-amdgcn-amd-amdhsa--gfx90a:sramecc-:xnack+ -output=%t.res.tgt1 -input=%t.bundle3.o -unbundle514// RUN: diff %t.tgt1 %t.res.tgt1515 516// RUN: clang-offload-bundler -type=o -targets=hipv4-amdgcn-amd-amdhsa--gfx90a -input=%t.tgt1 -output=%t.bundle3.o517// RUN: clang-offload-bundler -type=o -targets=hip-amdgcn-amd-amdhsa--gfx90a:sramecc-:xnack+ -output=%t.res.tgt1 -input=%t.bundle3.o -unbundle518// RUN: diff %t.tgt1 %t.res.tgt1519 520//521// Check archive unbundling522//523// Create few code object bundles and archive them to create an input archive524// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-amdgcn-amd-amdhsa--gfx906,openmp-amdgcn-amd-amdhsa--gfx908 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.simple.bundle525// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-amdgcn-amd-amdhsa--gfx903 -input=%t.o -input=%t.tgt1 -output=%t.simple1.bundle526// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx906 -input=%t.o -input=%t.tgt1 -output=%t.simple2.bundle527// RUN: llvm-ar cr %t.input-archive.a %t.simple.bundle %t.simple1.bundle %t.simple2.bundle528 529// RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa--gfx906,openmp-amdgcn-amd-amdhsa--gfx908 -input=%t.input-archive.a -output=%t-archive-gfx906-simple.a -output=%t-archive-gfx908-simple.a530// RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s -check-prefix=GFX906531// RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa--gfx906:xnack+ -input=%t.input-archive.a -output=%t-archive-gfx906-simple.a532// RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s -check-prefix=GFX906533// GFX906: simple-openmp-amdgcn-amd-amdhsa--gfx906534// RUN: llvm-ar t %t-archive-gfx908-simple.a | FileCheck %s -check-prefix=GFX908535// GFX908-NOT: {{gfx906}}536// RUN: not clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-amdgcn-amd-amdhsa--gfx906,openmp-amdgcn-amd-amdhsa--gfx906:sramecc+ -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bad.bundle 2>&1 | FileCheck %s -check-prefix=BADTARGETS537// BADTARGETS: error: Cannot bundle inputs with conflicting targets: 'openmp-amdgcn-amd-amdhsa--gfx906' and 'openmp-amdgcn-amd-amdhsa--gfx906:sramecc+'538 539// Check for error if no compatible code object is found in the heterogeneous archive library540// RUN: not clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa--gfx803 -input=%t.input-archive.a -output=%t-archive-gfx803-incompatible.a 2>&1 | FileCheck %s -check-prefix=INCOMPATIBLEARCHIVE541// INCOMPATIBLEARCHIVE: error: no compatible code object found for the target 'openmp-amdgcn-amd-amdhsa--gfx803' in heterogeneous archive library542 543// Check creation of empty archive if allow-missing-bundles is present and no compatible code object is found in the heterogeneous archive library544// RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa--gfx803 -input=%t.input-archive.a -output=%t-archive-gfx803-empty.a -allow-missing-bundles545// RUN: cat %t-archive-gfx803-empty.a | FileCheck %s -check-prefix=EMPTYARCHIVE546// EMPTYARCHIVE: !<arch>547 548// Check compatibility of OpenMP code objects found in the heterogeneous archive library with HIP code objects of the target549// RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx906,hipv4-amdgcn-amd-amdhsa--gfx908 -input=%t.input-archive.a -output=%t-hip-archive-gfx906-simple.a -output=%t-hipv4-archive-gfx908-simple.a -hip-openmp-compatible550// RUN: llvm-ar t %t-hip-archive-gfx906-simple.a | FileCheck %s -check-prefix=HIPOPENMPCOMPAT551// HIPOPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa--gfx906552// RUN: llvm-ar t %t-hipv4-archive-gfx908-simple.a | FileCheck %s -check-prefix=HIPv4OPENMPCOMPAT553// HIPv4OPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa--gfx908554 555// Check compatibility of HIP code objects found in the heterogeneous archive library with OpenMP code objects of the target556// RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa--gfx906 \557// RUN:   -output=%t.dir/hip-openmp_906.a -input=%t.dir/hip_archive.a -hip-openmp-compatible558// RUN: llvm-ar t %t.dir/hip-openmp_906.a | FileCheck -check-prefix=OPENMPHIPCOMPAT %s559// OPENMPHIPCOMPAT: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906560 561// Check if a malformat bundle id can be detected and an error can be emitted.562// RUN: not clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa -output=%t.dir/hip-openmp_906.a -input=%t.dir/hip_archive.a -hip-openmp-compatible 2>&1 | FileCheck %s -check-prefix=ERROR-WRONG-FORMAT563// ERROR-WRONG-FORMAT: error: Targets need to follow the format '<offload kind>-<target triple>', where '<target triple>' follows the format '<kind>-<arch>-<vendor>-<os>-<env>[-<target id>[:target features]]'.564// RUN: not clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx906 -output=%t.dir/hip-openmp_906.a -input=%t.dir/hip_archive.a -hip-openmp-compatible 2>&1 | FileCheck %s -check-prefix=ERROR-NO-ENV565// ERROR-NO-ENV: error: no compatible code object found for the target 'openmp-amdgcn-amd-amdhsa--'566 567// Some code so that we can create a binary out of this file.568int A = 0;569void test_func(void) {570  ++A;571}572