summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-03-19 23:55:38 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-03-19 23:55:38 +0000
commitbbdc26ba1b05215347cae02242fb512586a9554e (patch)
tree817a57b0e795e752dcd62d02750e04a2b9fdba5d
parentc16f5dca27c693f934b12c948b7d53e98ce9111d (diff)
downloadbcm5719-llvm-bbdc26ba1b05215347cae02242fb512586a9554e.tar.gz
bcm5719-llvm-bbdc26ba1b05215347cae02242fb512586a9554e.zip
test: Make a start on a test suite for libLTO.
This works in a similar way to the gold plugin tests. We search for a compatible linker on $PATH and use it to run tests against our just-built libLTO. To start with, test the just added opt level functionality. Differential Revision: http://reviews.llvm.org/D8472 llvm-svn: 232785
-rwxr-xr-xllvm/cmake/config-ix.cmake4
-rw-r--r--llvm/test/CMakeLists.txt4
-rw-r--r--llvm/test/Makefile1
-rw-r--r--llvm/test/lit.cfg17
-rw-r--r--llvm/test/lit.site.cfg.in1
-rw-r--r--llvm/test/tools/lto/lit.local.cfg2
-rw-r--r--llvm/test/tools/lto/opt-level.ll20
7 files changed, 49 insertions, 0 deletions
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index d4800d6860b..c57f9006a84 100755
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -532,6 +532,10 @@ if(GOLD_EXECUTABLE)
"PATH to binutils/include containing plugin-api.h for gold plugin.")
endif()
+if(APPLE)
+ find_program(LD64_EXECUTABLE NAMES ld DOC "The ld64 linker")
+endif()
+
include(FindOCaml)
include(AddOCaml)
if(WIN32)
diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index 5a97ee720bd..cc151f720b4 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -70,6 +70,10 @@ if(TARGET llvm-go)
set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-go)
endif()
+if(APPLE)
+ set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
+endif()
+
if(TARGET ocaml_llvm)
set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS}
ocaml_llvm
diff --git a/llvm/test/Makefile b/llvm/test/Makefile
index f4ed151cfe9..558762e39dc 100644
--- a/llvm/test/Makefile
+++ b/llvm/test/Makefile
@@ -129,6 +129,7 @@ lit.site.cfg: FORCE
@$(ECHOPATH) s=@EXEEXT@=$(EXEEXT)=g >> lit.tmp
@$(ECHOPATH) s=@PYTHON_EXECUTABLE@=$(PYTHON)=g >> lit.tmp
@$(ECHOPATH) s=@GOLD_EXECUTABLE@=ld=g >> lit.tmp
+ @$(ECHOPATH) s=@LD64_EXECUTABLE@=ld=g >> lit.tmp
@$(ECHOPATH) s=@OCAMLFIND@=$(OCAMLFIND)=g >> lit.tmp
@$(ECHOPATH) s!@OCAMLFLAGS@!$(addprefix -cclib ,$(LDFLAGS))!g >> lit.tmp
@$(ECHOPATH) s=@HAVE_OCAMLOPT@=$(HAVE_OCAMLOPT)=g >> lit.tmp
diff --git a/llvm/test/lit.cfg b/llvm/test/lit.cfg
index d34ca69a689..173d51bdf80 100644
--- a/llvm/test/lit.cfg
+++ b/llvm/test/lit.cfg
@@ -188,6 +188,7 @@ config.substitutions.append( ('%llc_dwarf', llc_dwarf) )
# Add site-specific substitutions.
config.substitutions.append( ('%gold', config.gold_executable) )
+config.substitutions.append( ('%ld64', config.ld64_executable) )
config.substitutions.append( ('%go', config.go_executable) )
config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )
@@ -369,6 +370,22 @@ def have_ld_plugin_support():
if have_ld_plugin_support():
config.available_features.add('ld_plugin')
+def have_ld64_plugin_support():
+ if config.ld64_executable == '':
+ return False
+
+ ld_cmd = subprocess.Popen([config.ld64_executable, '-v'], stderr = subprocess.PIPE)
+ ld_out = ld_cmd.stderr.read().decode()
+ ld_cmd.wait()
+
+ if 'ld64' not in ld_out or 'LTO' not in ld_out:
+ return False
+
+ return True
+
+if have_ld64_plugin_support():
+ config.available_features.add('ld64_plugin')
+
# Ask llvm-config about assertion mode.
try:
llvm_config_cmd = subprocess.Popen(
diff --git a/llvm/test/lit.site.cfg.in b/llvm/test/lit.site.cfg.in
index 1c19fd1841f..0f5d223a3ab 100644
--- a/llvm/test/lit.site.cfg.in
+++ b/llvm/test/lit.site.cfg.in
@@ -14,6 +14,7 @@ config.llvm_exe_ext = "@EXEEXT@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.gold_executable = "@GOLD_EXECUTABLE@"
+config.ld64_executable = "@LD64_EXECUTABLE@"
config.ocamlfind_executable = "@OCAMLFIND@"
config.have_ocamlopt = "@HAVE_OCAMLOPT@"
config.have_ocaml_ounit = "@HAVE_OCAML_OUNIT@"
diff --git a/llvm/test/tools/lto/lit.local.cfg b/llvm/test/tools/lto/lit.local.cfg
new file mode 100644
index 00000000000..b91f8f4de9a
--- /dev/null
+++ b/llvm/test/tools/lto/lit.local.cfg
@@ -0,0 +1,2 @@
+if not 'ld64_plugin' in config.available_features:
+ config.unsupported = True
diff --git a/llvm/test/tools/lto/opt-level.ll b/llvm/test/tools/lto/opt-level.ll
new file mode 100644
index 00000000000..013a1f40882
--- /dev/null
+++ b/llvm/test/tools/lto/opt-level.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: env DYLD_LIBRARY_PATH=%llvmshlibdir %ld64 -arch x86_64 -dylib -mllvm -O0 -o %t.dylib %t.o
+; RUN: llvm-nm -no-llvm-bc %t.dylib | FileCheck --check-prefix=CHECK-O0 %s
+; RUN: env DYLD_LIBRARY_PATH=%llvmshlibdir %ld64 -arch x86_64 -dylib -mllvm -O2 -o %t.dylib %t.o
+; RUN: llvm-nm -no-llvm-bc %t.dylib | FileCheck --check-prefix=CHECK-O2 %s
+
+target triple = "x86_64-apple-macosx10.8.0"
+
+; CHECK-O0: t _f1
+; CHECK-O2-NOT: _f1
+define internal void @f1() {
+ ret void
+}
+
+; CHECK-O0: T _f2
+; CHECK-O2: T _f2
+define void @f2() {
+ call void @f1()
+ ret void
+}
OpenPOWER on IntegriCloud