diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
| commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
| tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /test/Transforms/FunctionImport | |
| parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) | |
Notes
Diffstat (limited to 'test/Transforms/FunctionImport')
| -rw-r--r-- | test/Transforms/FunctionImport/Inputs/funcimport_var2.ll | 10 | ||||
| -rw-r--r-- | test/Transforms/FunctionImport/funcimport.ll | 12 | ||||
| -rw-r--r-- | test/Transforms/FunctionImport/funcimport_var.ll | 27 |
3 files changed, 42 insertions, 7 deletions
diff --git a/test/Transforms/FunctionImport/Inputs/funcimport_var2.ll b/test/Transforms/FunctionImport/Inputs/funcimport_var2.ll new file mode 100644 index 000000000000..95abe658e345 --- /dev/null +++ b/test/Transforms/FunctionImport/Inputs/funcimport_var2.ll @@ -0,0 +1,10 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@link = internal global i32 0, align 4 + +; Function Attrs: norecurse nounwind readnone uwtable +define nonnull i32* @get_link() local_unnamed_addr { + ret i32* @link +} + diff --git a/test/Transforms/FunctionImport/funcimport.ll b/test/Transforms/FunctionImport/funcimport.ll index cc732a3bd98d..4ff51a33b5e6 100644 --- a/test/Transforms/FunctionImport/funcimport.ll +++ b/test/Transforms/FunctionImport/funcimport.ll @@ -36,16 +36,14 @@ entry: ; CHECK-DAG: declare void @weakalias declare void @weakalias(...) #1 -; Cannot create an alias to available_externally -; CHECK-DAG: declare void @analias +; External alias imported as available_externally copy of aliasee +; CHECK-DAG: define available_externally void @analias declare void @analias(...) #1 -; Aliases import the aliasee function +; External alias imported as available_externally copy of aliasee +; (linkoncealias is an external alias to a linkonce_odr) declare void @linkoncealias(...) #1 -; INSTLIMDEF-DAG: Import linkoncealias -; INSTLIMDEF-DAG: Import linkoncefunc -; CHECK-DAG: define linkonce_odr void @linkoncefunc() -; CHECK-DAG: @linkoncealias = alias void (...), bitcast (void ()* @linkoncefunc to void (...)* +; CHECK-DAG: define available_externally void @linkoncealias() ; INSTLIMDEF-DAG: Import referencestatics ; INSTLIMDEF-DAG: define available_externally i32 @referencestatics(i32 %i) !thinlto_src_module !0 { diff --git a/test/Transforms/FunctionImport/funcimport_var.ll b/test/Transforms/FunctionImport/funcimport_var.ll new file mode 100644 index 000000000000..a93cabba69a6 --- /dev/null +++ b/test/Transforms/FunctionImport/funcimport_var.ll @@ -0,0 +1,27 @@ +; This test makes sure a static var is not selected as a callee target +; (which will crash compilation). +; RUN: opt -module-summary %s -o %t.bc +; RUN: opt -module-summary %p/Inputs/funcimport_var2.ll -o %t2.bc +; RUN: llvm-lto -thinlto -thinlto-action=thinlink -o %t3 %t.bc %t2.bc +; RUN: llvm-lto -thinlto -thinlto-action=import -thinlto-index=%t3 %t.bc %t2.bc +; RUN: llvm-lto -thinlto -thinlto-action=run %t.bc %t2.bc +; RUN: llvm-nm %t.bc.thinlto.o | FileCheck %s +; RUN: llvm-lto2 run %t.bc %t2.bc -o %t.out \ +; RUN: -r %t.bc,_Z4LinkPKcS0_,plx \ +; RUN: -r %t.bc,link,l \ +; RUN: -r %t2.bc,get_link,plx +; RUN: llvm-nm %t.out.1 | FileCheck %s +; CHECK: U link + +; REQUIRES: x86-registered-target + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define i32 @_Z4LinkPKcS0_(i8*, i8*) local_unnamed_addr { + %3 = tail call i32 @link(i8* %0, i8* %1) #2 + ret i32 %3 +} + +; Function Attrs: nounwind +declare i32 @link(i8*, i8*) local_unnamed_addr |
