Summary: We use a section to embed offloading code into the host for later linking. This is normally unique to the translation unit as it is thrown away during linking. However, if the user performs a relocatable link the sections will be merged and we won't be able to access the files stored inside. This patch changes the section variables to have external linkage and a name defined by the section name, so if two sections are combined during linking we get an error.
16 lines
850 B
LLVM
16 lines
850 B
LLVM
; RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
|
|
; RUN: -fembed-offload-object=%S/Inputs/empty.h,section1 \
|
|
; RUN: -fembed-offload-object=%S/Inputs/empty.h,section2 -x ir %s -o - \
|
|
; RUN: | FileCheck %s -check-prefix=CHECK
|
|
|
|
; CHECK: @[[OBJECT1:.+]] = hidden constant [0 x i8] zeroinitializer, section ".llvm.offloading.section1"
|
|
; CHECK: @[[OBJECT2:.+]] = hidden constant [0 x i8] zeroinitializer, section ".llvm.offloading.section2"
|
|
; CHECK: @llvm.compiler.used = appending global [3 x i8*] [i8* @x, i8* getelementptr inbounds ([0 x i8], [0 x i8]* @[[OBJECT1]], i32 0, i32 0), i8* getelementptr inbounds ([0 x i8], [0 x i8]* @[[OBJECT2]], i32 0, i32 0)], section "llvm.metadata"
|
|
|
|
@x = private constant i8 1
|
|
@llvm.compiler.used = appending global [1 x i8*] [i8* @x], section "llvm.metadata"
|
|
|
|
define i32 @foo() {
|
|
ret i32 0
|
|
}
|