xref: /llvm-project/lld/test/COFF/lto-imp-prefix.ll (revision 143133fe685bd0b8819a96bdc1af6a4ff2877b13)
1; REQUIRES: x86
2
3; RUN: rm -rf %t.dir
4; RUN: split-file %s %t.dir
5; RUN: llvm-as %t.dir/main.ll -o %t.main.obj
6; RUN: llvm-as %t.dir/other1.ll -o %t.other1.obj
7; RUN: llvm-as %t.dir/other2.ll -o %t.other2.obj
8
9; RUN: lld-link /entry:entry %t.main.obj %t.other1.obj /out:%t1.exe /subsystem:console /debug:symtab
10
11;; Check that we don't retain __imp_ prefixed symbols we don't need.
12; RUN: llvm-nm %t1.exe | FileCheck %s
13; CHECK-NOT: __imp_unusedFunc
14
15; RUN: lld-link /entry:entry %t.main.obj %t.other2.obj /out:%t2.exe /subsystem:console
16
17;--- main.ll
18target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
19target triple = "x86_64-w64-windows-gnu"
20
21define void @entry() {
22entry:
23  tail call void @importedFunc()
24  tail call void @other()
25  ret void
26}
27
28declare dllimport void @importedFunc()
29
30declare void @other()
31
32;--- other1.ll
33target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
34target triple = "x86_64-w64-windows-gnu"
35
36@__imp_importedFunc = global ptr @importedFuncReplacement
37
38define internal void @importedFuncReplacement() {
39entry:
40  ret void
41}
42
43@__imp_unusedFunc = global ptr @unusedFuncReplacement
44
45define internal void @unusedFuncReplacement() {
46entry:
47  ret void
48}
49
50define void @other() {
51entry:
52  ret void
53}
54
55;--- other2.ll
56target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
57target triple = "x86_64-w64-windows-gnu"
58
59@__imp_importedFunc = global ptr @importedFunc
60
61; Test with two external symbols with the same name, with/without the __imp_
62; prefix.
63define void @importedFunc() {
64entry:
65  ret void
66}
67
68define void @other() {
69entry:
70  ret void
71}
72