From 3a3465b71db858723988f61d72b7135e6dff329b Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 15 Jun 2011 20:36:13 +0000 Subject: Add a new function attribute, nonlazybind, which inhibits lazy-loading optimizations when emitting calls to the function; instead those calls may use faster relocations which require the function to be immediately resolved upon loading the dynamic object featuring the call. This is useful when it is known that the function will be called frequently and pervasively and therefore there is no merit in delaying binding of the function. Currently only implemented for x86-64, where it turns into a call through the global offset table. Patch by Dan Gohman, who assures me that he's going to add LangRef documentation for this once it's committed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133080 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/X86/non-lazy-bind.ll | 27 +++++++++++++++++++++++++++ test/Feature/paramattrs.ll | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 test/CodeGen/X86/non-lazy-bind.ll (limited to 'test') diff --git a/test/CodeGen/X86/non-lazy-bind.ll b/test/CodeGen/X86/non-lazy-bind.ll new file mode 100644 index 0000000000..f72965877d --- /dev/null +++ b/test/CodeGen/X86/non-lazy-bind.ll @@ -0,0 +1,27 @@ +; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s + +declare void @lazy() nonlazybind +declare void @not() + +; CHECK: foo: +; CHECK: callq _not +; CHECK: callq *_lazy@GOTPCREL(%rip) +define void @foo() nounwind { + call void @not() + call void @lazy() + ret void +} + +; CHECK: tail_call_regular: +; CHECK: jmp _not +define void @tail_call_regular() nounwind { + tail call void @not() + ret void +} + +; CHECK: tail_call_eager: +; CHECK: jmpq *_lazy@GOTPCREL(%rip) +define void @tail_call_eager() nounwind { + tail call void @lazy() + ret void +} diff --git a/test/Feature/paramattrs.ll b/test/Feature/paramattrs.ll index 3bee6177e0..d686257e79 100644 --- a/test/Feature/paramattrs.ll +++ b/test/Feature/paramattrs.ll @@ -20,3 +20,5 @@ define i32 @main(i32 inreg %argc, i8 ** inreg %argv) nounwind { %retVal = sext i16 %two to i32 ret i32 %retVal } + +declare void @function_to_resolve_eagerly() nonlazybind -- cgit v1.2.3-18-g5258