The previous patch introduced the offloading binary format so we can
store some metada along with the binary image. This patch introduces
using this inside the linker wrapper and Clang instead of the previous
method that embedded the metadata in the section name.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/test/Frontend/embed-object.ll | ||
---|---|---|
6 | Can we salvage the test intention and embed two objects? | |
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | ||
311 | This should be a proper conditional and error check. | |
316 | Why is the cast at the call site not in the callee? Are these casts even necessary at all? | |
469 | Isn't this 99% the same as above, from offset = 0 to the end? |
I'm sorry for noticing it this late but this change seems to have broken the test on 32-bit x86:
FAIL: Clang :: Frontend/embed-object.ll (8280 of 15613) ******************** TEST 'Clang :: Frontend/embed-object.ll' FAILED ******************** Script: -- : 'RUN: at line 1'; /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/clang -cc1 -internal-isystem /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/15.0.0/include -nostdsysteminc -triple x86_64-unknown-linux-gnu -emit-llvm -fembed-offload-object=/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/Inputs/empty.h -fembed-offload-object=/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/Inputs/empty.h -x ir /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll -o - | /usr/lib/llvm/15/bin/FileCheck /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll -check-prefix=CHECK -- Exit Code: 1 Command Output (stderr): -- + : 'RUN: at line 1' + /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/clang -cc1 -internal-isystem /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/15.0.0/include -nostdsysteminc -triple x86_64-unknown-linux-gnu -emit-llvm -fembed-offload-object=/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/Inputs/empty.h -fembed-offload-object=/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/Inputs/empty.h -x ir /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll -o - + /usr/lib/llvm/15/bin/FileCheck /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll -check-prefix=CHECK warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module] 1 warning generated. /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll:6:10: error: CHECK: expected string not found in input ; CHECK: @[[OBJECT_1:.+]] = private constant [0 x i8] zeroinitializer, section ".llvm.offloading", align 8, !exclude ^ <stdin>:1:1: note: scanning from here ; ModuleID = '/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll' ^ <stdin>:8:20: note: possible intended match here @llvm.embedded.object.1 = private constant [0 x i8] zeroinitializer, section ".llvm.offloading", align 4, !exclude !0 ^ Input file: <stdin> Check file: /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll -dump-input=help explains the following input dump. Input was: <<<<<< 1: ; ModuleID = '/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll' check:6'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found 2: source_filename = "/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.ll" check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4: target triple = "x86_64-unknown-linux-gnu" check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5: check:6'0 ~ 6: @x = private constant i8 1 check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7: @llvm.embedded.object = private constant [0 x i8] zeroinitializer, section ".llvm.offloading", align 4, !exclude !0 check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8: @llvm.embedded.object.1 = private constant [0 x i8] zeroinitializer, section ".llvm.offloading", align 4, !exclude !0 check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ check:6'1 ? possible intended match 9: @llvm.compiler.used = appending global [3 x ptr] [ptr @x, ptr @llvm.embedded.object, ptr @llvm.embedded.object.1], section "llvm.metadata" check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10: check:6'0 ~ 11: define i32 @foo() { check:6'0 ~~~~~~~~~~~~~~~~~~~~ 12: ret i32 0 check:6'0 ~~~~~~~~~~~ 13: } check:6'0 ~~ . . . >>>>>> -- ******************** FAIL: Clang :: Frontend/embed-object.c (8281 of 15613) ******************** TEST 'Clang :: Frontend/embed-object.c' FAILED ******************** Script: -- : 'RUN: at line 1'; /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/clang -cc1 -internal-isystem /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/15.0.0/include -nostdsysteminc -x c -triple x86_64-unknown-linux-gnu -emit-llvm -fembed-offload-object=/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/Inputs/empty.h -o - /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c | /usr/lib/llvm/15/bin/FileCheck /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c -- Exit Code: 1 Command Output (stderr): -- + : 'RUN: at line 1' + /usr/lib/llvm/15/bin/FileCheck /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c + /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/clang -cc1 -internal-isystem /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/15.0.0/include -nostdsysteminc -x c -triple x86_64-unknown-linux-gnu -emit-llvm -fembed-offload-object=/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/Inputs/empty.h -o - /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c:3:11: error: CHECK: expected string not found in input // CHECK: @[[OBJECT:.+]] = private constant [0 x i8] zeroinitializer, section ".llvm.offloading", align 8, !exclude ^ <stdin>:1:1: note: scanning from here ; ModuleID = '/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c' ^ <stdin>:6:13: note: possible intended match here @llvm.embedded.object = private constant [0 x i8] zeroinitializer, section ".llvm.offloading", align 4, !exclude !0 ^ Input file: <stdin> Check file: /var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c -dump-input=help explains the following input dump. Input was: <<<<<< 1: ; ModuleID = '/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c' check:3'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found 2: source_filename = "/var/tmp/portage/sys-devel/clang-15.0.0.9999/work/clang/test/Frontend/embed-object.c" check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4: target triple = "x86_64-unknown-linux-gnu" check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5: check:3'0 ~ 6: @llvm.embedded.object = private constant [0 x i8] zeroinitializer, section ".llvm.offloading", align 4, !exclude !0 check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ check:3'1 ? possible intended match 7: @llvm.compiler.used = appending global [1 x ptr] [ptr @llvm.embedded.object], section "llvm.metadata" check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8: check:3'0 ~ 9: ; Function Attrs: noinline nounwind optnone check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10: define dso_local void @foo() #0 { check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 11: entry: check:3'0 ~~~~~~~ . . . >>>>>> -- ********************
Seems to be a difference in the alignment, I'm not sure why this changes though because the test should specify x86_64.
Actually I think the alignment comes from alignof on a struct which doesn't care about the target, just the machine compiling it. Even still that struct has int64_t members so I figured it would be 8-byte aligned. I should probably just hard-code it to 8.
Can we salvage the test intention and embed two objects?