brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 9e0b149 Raw
42 lines · plain
1; REQUIRES: x862 3;; Test linking of weak symbols with LTO. The weak symbol may be defined4;; by another object file, or may be left undefined. When compiling the5;; IR with an undefined weak symbol, the emitted object file will contain6;; a weak alias pointing at an absolute symbol for the address null.7;; Make sure both cases can be linked correctly.8 9; RUN: split-file %s %t.dir10; RUN: llvm-as %t.dir/main.ll -o %t.main.obj11; RUN: llvm-as %t.dir/optional.ll -o %t.optional.obj12 13; RUN: lld-link /entry:main %t.main.obj /out:%t-undef.exe14; RUN: lld-link /entry:main %t.main.obj %t.optional.obj /out:%t-def.exe15 16;--- main.ll17target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"18target triple = "x86_64-pc-windows-msvc"19 20define dso_local i32 @main() {21entry:22  %cmp = icmp ne ptr @optionalFunc, null23  br i1 %cmp, label %if.then, label %if.end24 25if.then:26  tail call void @optionalFunc()27  br label %if.end28 29if.end:30  ret i32 031}32 33declare extern_weak void @optionalFunc()34 35;--- optional.ll36target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"37target triple = "x86_64-pc-windows-msvc"38 39define void @optionalFunc() {40  ret void41}42