1 // REQUIRES: x86-registered-target 2 3 // 4 // Check help message. 5 // 6 // RUN: clang-offload-wrapper --help | FileCheck %s --check-prefix CHECK-HELP 7 // CHECK-HELP: {{.*}}OVERVIEW: A tool to create a wrapper bitcode for offload target binaries. Takes offload 8 // CHECK-HELP: {{.*}}target binaries as input and produces bitcode file containing target binaries packaged 9 // CHECK-HELP: {{.*}}as data and initialization code which registers target binaries in offload runtime. 10 // CHECK-HELP: {{.*}}USAGE: clang-offload-wrapper [options] <input files> 11 // CHECK-HELP: {{.*}} -o=<filename> - Output filename 12 // CHECK-HELP: {{.*}} --target=<triple> - Target triple for the output module 13 14 // 15 // Generate a file to wrap. 16 // 17 // RUN: echo 'Content of device file' > %t.tgt 18 19 // 20 // Check bitcode produced by the wrapper tool. 21 // 22 // RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.bc %t.tgt 23 // RUN: llvm-dis %t.wrapper.bc -o - | FileCheck %s --check-prefix CHECK-IR 24 25 // CHECK-IR: target triple = "x86_64-pc-linux-gnu" 26 27 // CHECK-IR-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i{{32|64}}, i32, i32 } 28 // CHECK-IR-DAG: [[IMAGETY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* } 29 // CHECK-IR-DAG: [[DESCTY:%.+]] = type { i32, [[IMAGETY]]*, [[ENTTY]]*, [[ENTTY]]* } 30 31 // CHECK-IR: [[ENTBEGIN:@.+]] = external hidden constant [[ENTTY]] 32 // CHECK-IR: [[ENTEND:@.+]] = external hidden constant [[ENTTY]] 33 34 // CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x [[ENTTY]]] zeroinitializer, section "omp_offloading_entries" 35 36 // CHECK-IR: [[BIN:@.+]] = internal unnamed_addr constant [[BINTY:\[[0-9]+ x i8\]]] c"Content of device file{{.+}}" 37 38 // CHECK-IR: [[IMAGES:@.+]] = internal unnamed_addr constant [1 x [[IMAGETY]]] [{{.+}} { i8* getelementptr inbounds ([[BINTY]], [[BINTY]]* [[BIN]], i64 0, i64 0), i8* getelementptr inbounds ([[BINTY]], [[BINTY]]* [[BIN]], i64 1, i64 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }] 39 40 // CHECK-IR: [[DESC:@.+]] = internal constant [[DESCTY]] { i32 1, [[IMAGETY]]* getelementptr inbounds ([1 x [[IMAGETY]]], [1 x [[IMAGETY]]]* [[IMAGES]], i64 0, i64 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] } 41 42 // CHECK-IR: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* [[REGFN:@.+]], i8* null }] 43 // CHECK-IR: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* [[UNREGFN:@.+]], i8* null }] 44 45 // CHECK-IR: define internal void [[REGFN]]() 46 // CHECK-IR: call void @__tgt_register_lib([[DESCTY]]* [[DESC]]) 47 // CHECK-IR: ret void 48 49 // CHECK-IR: declare void @__tgt_register_lib([[DESCTY]]*) 50 51 // CHECK-IR: define internal void [[UNREGFN]]() 52 // CHECK-IR: call void @__tgt_unregister_lib([[DESCTY]]* [[DESC]]) 53 // CHECK-IR: ret void 54 55 // CHECK-IR: declare void @__tgt_unregister_lib([[DESCTY]]*) 56