Changeset View
Changeset View
Standalone View
Standalone View
clang/test/Driver/clang-offload-wrapper.c
Show All 13 Lines | |||||
// | // | ||||
// Generate a file to wrap. | // Generate a file to wrap. | ||||
// | // | ||||
// RUN: echo 'Content of device file' > %t.tgt | // RUN: echo 'Content of device file' > %t.tgt | ||||
// | // | ||||
// Check bitcode produced by the wrapper tool. | // Check bitcode produced by the wrapper tool. | ||||
// | // | ||||
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.bc %t.tgt | // RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.bc %t.tgt 2>&1 | FileCheck %s --check-prefix ELF-WARNING | ||||
// RUN: llvm-dis %t.wrapper.bc -o - | FileCheck %s --check-prefix CHECK-IR | // RUN: llvm-dis %t.wrapper.bc -o - | FileCheck %s --check-prefix CHECK-IR | ||||
// ELF-WARNING: is not an ELF image, so notes cannot be added to it. | |||||
// CHECK-IR: target triple = "x86_64-pc-linux-gnu" | // CHECK-IR: target triple = "x86_64-pc-linux-gnu" | ||||
// CHECK-IR-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i{{32|64}}, i32, i32 } | // CHECK-IR-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i{{32|64}}, i32, i32 } | ||||
// CHECK-IR-DAG: [[IMAGETY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* } | // CHECK-IR-DAG: [[IMAGETY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* } | ||||
// CHECK-IR-DAG: [[DESCTY:%.+]] = type { i32, [[IMAGETY]]*, [[ENTTY]]*, [[ENTTY]]* } | // CHECK-IR-DAG: [[DESCTY:%.+]] = type { i32, [[IMAGETY]]*, [[ENTTY]]*, [[ENTTY]]* } | ||||
// CHECK-IR: [[ENTBEGIN:@.+]] = external hidden constant [[ENTTY]] | // CHECK-IR: [[ENTBEGIN:@.+]] = external hidden constant [[ENTTY]] | ||||
// CHECK-IR: [[ENTEND:@.+]] = external hidden constant [[ENTTY]] | // CHECK-IR: [[ENTEND:@.+]] = external hidden constant [[ENTTY]] | ||||
Show All 15 Lines | |||||
// CHECK-IR: declare void @__tgt_register_lib([[DESCTY]]*) | // CHECK-IR: declare void @__tgt_register_lib([[DESCTY]]*) | ||||
// CHECK-IR: define internal void [[UNREGFN]]() | // CHECK-IR: define internal void [[UNREGFN]]() | ||||
// CHECK-IR: call void @__tgt_unregister_lib([[DESCTY]]* [[DESC]]) | // CHECK-IR: call void @__tgt_unregister_lib([[DESCTY]]* [[DESC]]) | ||||
// CHECK-IR: ret void | // CHECK-IR: ret void | ||||
// CHECK-IR: declare void @__tgt_unregister_lib([[DESCTY]]*) | // CHECK-IR: declare void @__tgt_unregister_lib([[DESCTY]]*) | ||||
// Check that clang-offload-wrapper adds LLVMOMPOFFLOAD notes | |||||
// into the ELF offload images: | |||||
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.64le -DBITS=64 -DENCODING=LSB | |||||
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf64le.bc %t.64le | |||||
// RUN: llvm-dis %t.wrapper.elf64le.bc -o - | FileCheck %s --check-prefix OMPNOTES | |||||
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.64be -DBITS=64 -DENCODING=MSB | |||||
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf64be.bc %t.64be | |||||
// RUN: llvm-dis %t.wrapper.elf64be.bc -o - | FileCheck %s --check-prefix OMPNOTES | |||||
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.32le -DBITS=32 -DENCODING=LSB | |||||
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf32le.bc %t.32le | |||||
// RUN: llvm-dis %t.wrapper.elf32le.bc -o - | FileCheck %s --check-prefix OMPNOTES | |||||
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.32be -DBITS=32 -DENCODING=MSB | |||||
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf32be.bc %t.32be | |||||
// RUN: llvm-dis %t.wrapper.elf32be.bc -o - | FileCheck %s --check-prefix OMPNOTES | |||||
// There is no clean way for extracting the offload image | |||||
// from the object file currently, so try to find | |||||
// the inserted ELF notes in the device image variable's | |||||
// initializer: | |||||
// OMPNOTES: @{{.+}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"{{.*}}LLVMOMPOFFLOAD{{.*}}LLVMOMPOFFLOAD{{.*}}LLVMOMPOFFLOAD{{.*}}" |