xref: /llvm-project/lld/test/MachO/symbol-resolution-warning.ll (revision a033184abb80b84c1fa6c2bc6a915c24f56b40f1)
1; REQUIRES: x86
2; RUN: rm -rf %t; split-file %s %t
3
4; RUN: opt %t/f.ll -o %t/f.o
5; RUN: llvm-ar rcs %t/libf.a %t/f.o
6; RUN: llc -filetype=obj %t/q.ll -o %t/q.o
7; RUN: llvm-ar rcs %t/libq.a %t/q.o
8; RUN: llc -filetype=obj %t/m.ll -o %t/m.o
9
10; RUN: %no-fatal-warnings-lld -dylib -lSystem -L%t %t/libf.a %t/m.o -o %t/test.out 2>&1 | FileCheck %s
11
12; We can't read symbols that are set by module asm in the bitcode's symbol table.
13; LTO internalizes `odr` in `f.ll`, and thus the prevailing `odr` remains unresolved.
14; `q.ll` is loaded after LTO is finished during post-processing LC linker options.
15; The unresolved prevailing `odr` is now resolved with `q.ll`.
16
17; CHECK: warning: The pending prevailing symbol(_odr) in the bitcode file({{.*}}libf.a(f.o)) is overridden by a post-processed native object (from native archive): {{.*}}libq.a(q.o)
18
19;--- f.ll
20target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
21target triple = "x86_64-apple-macosx10.15.0"
22
23!0 = !{!"-lq"}
24!llvm.linker.options = !{!0}
25
26define i64 @f()  {
27  %1 = call i64 @odr()
28  %2 = call i64 @q()
29  %3 = add i64 %1, %2
30  ret i64 %3
31}
32
33define weak hidden i64 @odr() noinline {
34  ret i64 1
35}
36
37declare i64 @q()
38
39;--- q.ll
40target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
41target triple = "x86_64-apple-macosx10.15.0"
42
43define i64 @q() {
44  %1 = call i64 @odr()
45  ret i64 %1
46}
47
48define linkonce_odr hidden i64 @odr() noinline {
49  ret i64 2
50}
51
52;--- m.ll
53target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
54target triple = "x86_64-apple-macosx10.15.0"
55
56declare i64 @f()
57
58define i64 @m() {
59  %1 = call i64 @f()
60  ret i64 %1
61}
62