1; REQUIRES: x86 2; RUN: split-file %s %t.dir 3;; LTO 4; RUN: llvm-as %t.dir/main.ll -o %t.main.bc 5; RUN: llvm-as %t.dir/wrap.ll -o %t.wrap.bc 6; RUN: llvm-as %t.dir/other.ll -o %t.other.bc 7; RUN: rm -f %t.bc.lib 8; RUN: llvm-ar rcs %t.bc.lib %t.wrap.bc %t.other.bc 9;; ThinLTO 10; RUN: opt -module-summary %t.dir/main.ll -o %t.main.thin 11; RUN: opt -module-summary %t.dir/wrap.ll -o %t.wrap.thin 12; RUN: opt -module-summary %t.dir/other.ll -o %t.other.thin 13; RUN: rm -f %t.thin.lib 14; RUN: llvm-ar rcs %t.thin.lib %t.wrap.thin %t.other.thin 15;; Object 16; RUN: llc %t.dir/main.ll -o %t.main.obj --filetype=obj 17; RUN: llc %t.dir/wrap.ll -o %t.wrap.obj --filetype=obj 18; RUN: llc %t.dir/other.ll -o %t.other.obj --filetype=obj 19; RUN: rm -f %t.obj.lib 20; RUN: llvm-ar rcs %t.obj.lib %t.wrap.obj %t.other.obj 21 22;; This test verifies that -wrap works correctly for inter-module references to 23;; the wrapped symbol, when LTO or ThinLTO is involved. It checks for various 24;; combinations of bitcode and regular objects. 25 26;; LTO + LTO 27; RUN: lld-link -out:%t.bc-bc.exe %t.main.bc -libpath:%T %t.bc.lib -entry:entry -subsystem:console -wrap:bar -debug:symtab -lldsavetemps 28; RUN: llvm-objdump -d %t.bc-bc.exe | FileCheck %s --check-prefixes=CHECK,JMP 29 30;; LTO + Object 31; RUN: lld-link -out:%t.bc-obj.exe %t.main.bc -libpath:%T %t.obj.lib -entry:entry -subsystem:console -wrap:bar -debug:symtab -lldsavetemps 32; RUN: llvm-objdump -d %t.bc-obj.exe | FileCheck %s --check-prefixes=CHECK,JMP 33 34;; Object + LTO 35; RUN: lld-link -out:%t.obj-bc.exe %t.main.obj -libpath:%T %t.bc.lib -entry:entry -subsystem:console -wrap:bar -debug:symtab -lldsavetemps 36; RUN: llvm-objdump -d %t.obj-bc.exe | FileCheck %s --check-prefixes=CHECK,CALL 37 38;; ThinLTO + ThinLTO 39; RUN: lld-link -out:%t.thin-thin.exe %t.main.thin -libpath:%T %t.thin.lib -entry:entry -subsystem:console -wrap:bar -debug:symtab -lldsavetemps 40; RUN: llvm-objdump -d %t.thin-thin.exe | FileCheck %s --check-prefixes=CHECK,JMP 41 42;; ThinLTO + Object 43; RUN: lld-link -out:%t.thin-obj.exe %t.main.thin -libpath:%T %t.obj.lib -entry:entry -subsystem:console -wrap:bar -debug:symtab -lldsavetemps 44; RUN: llvm-objdump -d %t.thin-obj.exe | FileCheck %s --check-prefixes=CHECK,JMP 45 46;; Object + ThinLTO 47; RUN: lld-link -out:%t.obj-thin.exe %t.main.obj -libpath:%T %t.thin.lib -entry:entry -subsystem:console -wrap:bar -debug:symtab -lldsavetemps 48; RUN: llvm-objdump -d %t.obj-thin.exe | FileCheck %s --check-prefixes=CHECK,CALL 49 50;; Make sure that calls in entry() are not eliminated and that bar is 51;; routed to __wrap_bar. 52 53; CHECK: <entry>: 54; JMP: jmp {{.*}}<__wrap_bar> 55; CALL: callq {{.*}}<__wrap_bar> 56 57;--- main.ll 58target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 59target triple = "x86_64-w64-windows-gnu" 60 61declare void @bar() 62 63define void @entry() { 64 call void @bar() 65 ret void 66} 67 68;--- wrap.ll 69target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 70target triple = "x86_64-w64-windows-gnu" 71 72declare void @other() 73 74define void @__wrap_bar() { 75 call void @other() 76 ret void 77} 78 79;--- other.ll 80target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 81target triple = "x86_64-w64-windows-gnu" 82 83define void @other() { 84 ret void 85} 86