From: Lang Hames Date: Thu, 27 Aug 2015 20:31:44 +0000 (+0000) Subject: Recommit r246175 - Add Kaleidoscope regression tests, with a fix to make sure X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=8c46d7964e996f60e4cf0f8ee08be5da22ddf1a3 Recommit r246175 - Add Kaleidoscope regression tests, with a fix to make sure the kaleidoscope 'library' functions aren't dead-stripped in release builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246201 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/tutorial/LangImpl4.rst b/docs/tutorial/LangImpl4.rst index 702886f6aec..92dcc3d33a0 100644 --- a/docs/tutorial/LangImpl4.rst +++ b/docs/tutorial/LangImpl4.rst @@ -566,7 +566,7 @@ if we add: /// putchard - putchar that takes a double and returns 0. extern "C" double putchard(double X) { - putchar((char)X); + fputc((char)X, stderr); return 0; } diff --git a/examples/Kaleidoscope/Chapter4/CMakeLists.txt b/examples/Kaleidoscope/Chapter4/CMakeLists.txt index 44e1aeecaae..89feed143ad 100644 --- a/examples/Kaleidoscope/Chapter4/CMakeLists.txt +++ b/examples/Kaleidoscope/Chapter4/CMakeLists.txt @@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS add_kaleidoscope_chapter(Kaleidoscope-Ch4 toy.cpp ) + +export_executable_symbols(Kaleidoscope-Ch4) diff --git a/examples/Kaleidoscope/Chapter4/toy.cpp b/examples/Kaleidoscope/Chapter4/toy.cpp index 12777ae2c75..fe8ec17b4e8 100644 --- a/examples/Kaleidoscope/Chapter4/toy.cpp +++ b/examples/Kaleidoscope/Chapter4/toy.cpp @@ -631,14 +631,14 @@ static void MainLoop() { //===----------------------------------------------------------------------===// /// putchard - putchar that takes a double and returns 0. -extern "C" double putchard(double X) { - putchar((char)X); +__attribute__((used)) extern "C" double putchard(double X) { + fputc((char)X, stderr); return 0; } /// printd - printf that takes a double prints it as "%f\n", returning 0. -extern "C" double printd(double X) { - printf("%f\n", X); +__attribute__((used)) extern "C" double printd(double X) { + fprintf(stderr, "%f\n", X); return 0; } diff --git a/examples/Kaleidoscope/Chapter5/CMakeLists.txt b/examples/Kaleidoscope/Chapter5/CMakeLists.txt index b62ed410103..c0ae70654c3 100644 --- a/examples/Kaleidoscope/Chapter5/CMakeLists.txt +++ b/examples/Kaleidoscope/Chapter5/CMakeLists.txt @@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS add_kaleidoscope_chapter(Kaleidoscope-Ch5 toy.cpp ) + +export_executable_symbols(Kaleidoscope-Ch5) diff --git a/examples/Kaleidoscope/Chapter5/toy.cpp b/examples/Kaleidoscope/Chapter5/toy.cpp index 83af1776b20..4658edcd4ce 100644 --- a/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/examples/Kaleidoscope/Chapter5/toy.cpp @@ -905,14 +905,14 @@ static void MainLoop() { //===----------------------------------------------------------------------===// /// putchard - putchar that takes a double and returns 0. -extern "C" double putchard(double X) { - putchar((char)X); +__attribute__((used)) extern "C" double putchard(double X) { + fputc((char)X, stderr); return 0; } /// printd - printf that takes a double prints it as "%f\n", returning 0. -extern "C" double printd(double X) { - printf("%f\n", X); +__attribute__((used)) extern "C" double printd(double X) { + fprintf(stderr, "%f\n", X); return 0; } diff --git a/examples/Kaleidoscope/Chapter6/CMakeLists.txt b/examples/Kaleidoscope/Chapter6/CMakeLists.txt index 6bb2b193752..49627f07ddf 100644 --- a/examples/Kaleidoscope/Chapter6/CMakeLists.txt +++ b/examples/Kaleidoscope/Chapter6/CMakeLists.txt @@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS add_kaleidoscope_chapter(Kaleidoscope-Ch6 toy.cpp ) + +export_executable_symbols(Kaleidoscope-Ch6) diff --git a/examples/Kaleidoscope/Chapter6/toy.cpp b/examples/Kaleidoscope/Chapter6/toy.cpp index e1bed45189e..9d9914a4b89 100644 --- a/examples/Kaleidoscope/Chapter6/toy.cpp +++ b/examples/Kaleidoscope/Chapter6/toy.cpp @@ -1023,14 +1023,14 @@ static void MainLoop() { //===----------------------------------------------------------------------===// /// putchard - putchar that takes a double and returns 0. -extern "C" double putchard(double X) { - putchar((char)X); +__attribute__((used)) extern "C" double putchard(double X) { + fputc((char)X, stderr); return 0; } /// printd - printf that takes a double prints it as "%f\n", returning 0. -extern "C" double printd(double X) { - printf("%f\n", X); +__attribute__((used)) extern "C" double printd(double X) { + fprintf(stderr, "%f\n", X); return 0; } diff --git a/examples/Kaleidoscope/Chapter7/CMakeLists.txt b/examples/Kaleidoscope/Chapter7/CMakeLists.txt index 27c18cdd065..e67d7928efe 100644 --- a/examples/Kaleidoscope/Chapter7/CMakeLists.txt +++ b/examples/Kaleidoscope/Chapter7/CMakeLists.txt @@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS add_kaleidoscope_chapter(Kaleidoscope-Ch7 toy.cpp ) + +export_executable_symbols(Kaleidoscope-Ch7) diff --git a/examples/Kaleidoscope/Chapter7/toy.cpp b/examples/Kaleidoscope/Chapter7/toy.cpp index 4558522952c..d61d880e540 100644 --- a/examples/Kaleidoscope/Chapter7/toy.cpp +++ b/examples/Kaleidoscope/Chapter7/toy.cpp @@ -1189,14 +1189,14 @@ static void MainLoop() { //===----------------------------------------------------------------------===// /// putchard - putchar that takes a double and returns 0. -extern "C" double putchard(double X) { - putchar((char)X); +__attribute__((used)) extern "C" double putchard(double X) { + fputc((char)X, stderr); return 0; } /// printd - printf that takes a double prints it as "%f\n", returning 0. -extern "C" double printd(double X) { - printf("%f\n", X); +__attribute__((used)) extern "C" double printd(double X) { + fprintf(stderr, "%f\n", X); return 0; } diff --git a/examples/Kaleidoscope/Chapter8/CMakeLists.txt b/examples/Kaleidoscope/Chapter8/CMakeLists.txt index e335cb48ac7..d9b5cc421be 100644 --- a/examples/Kaleidoscope/Chapter8/CMakeLists.txt +++ b/examples/Kaleidoscope/Chapter8/CMakeLists.txt @@ -9,3 +9,5 @@ set(LLVM_LINK_COMPONENTS add_kaleidoscope_chapter(Kaleidoscope-Ch8 toy.cpp ) + +export_executable_symbols(Kaleidoscope-Ch8) diff --git a/examples/Kaleidoscope/Chapter8/toy.cpp b/examples/Kaleidoscope/Chapter8/toy.cpp index 7338c6ebc50..5f97a157336 100644 --- a/examples/Kaleidoscope/Chapter8/toy.cpp +++ b/examples/Kaleidoscope/Chapter8/toy.cpp @@ -1383,14 +1383,14 @@ static void MainLoop() { //===----------------------------------------------------------------------===// /// putchard - putchar that takes a double and returns 0. -extern "C" double putchard(double X) { - putchar((char)X); +__attribute__((used)) extern "C" double putchard(double X) { + fputc((char)X, stderr); return 0; } /// printd - printf that takes a double prints it as "%f\n", returning 0. -extern "C" double printd(double X) { - printf("%f\n", X); +__attribute__((used)) extern "C" double printd(double X) { + fprintf(stderr, "%f\n", X); return 0; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1f417c2a0fc..464a6f0161a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,7 @@ +if(LLVM_BUILD_EXAMPLES) + set(ENABLE_EXAMPLES 1) +endif() + configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg @@ -96,6 +100,16 @@ if(TARGET ocaml_llvm) ) endif() +if(LLVM_BUILD_EXAMPLES) + list(APPEND LLVM_TEST_DEPENDS + Kaleidoscope-Ch3 + Kaleidoscope-Ch4 + Kaleidoscope-Ch5 + Kaleidoscope-Ch6 + Kaleidoscope-Ch7 + ) +endif() + add_lit_testsuite(check-llvm "Running the LLVM regression tests" ${CMAKE_CURRENT_BINARY_DIR} PARAMS llvm_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg diff --git a/test/Makefile b/test/Makefile index 558762e39dc..9b37cedaaff 100644 --- a/test/Makefile +++ b/test/Makefile @@ -146,6 +146,7 @@ lit.site.cfg: FORCE @$(ECHOPATH) s=@HOST_ARCH@=$(HOST_ARCH)=g >> lit.tmp @$(ECHOPATH) s=@HAVE_LIBZ@=$(HAVE_LIBZ)=g >> lit.tmp @$(ECHOPATH) s=@HAVE_DIA_SDK@=0=g >> lit.tmp + @$(ECHOPATH) s=@ENABLE_EXAMPLES@=$(BUILD_EXAMPLES)=g >> lit.tmp @sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@ @-rm -f lit.tmp diff --git a/test/lit.cfg b/test/lit.cfg index 167a81afad1..38a2ec20ec8 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -258,6 +258,12 @@ for pattern in [r"\bbugpoint\b(?!-)", r"\byaml2obj\b", r"\byaml-bench\b", r"\bverify-uselistorder\b", + r"\bKaleidoscope-Ch3\b", + r"\bKaleidoscope-Ch4\b", + r"\bKaleidoscope-Ch5\b", + r"\bKaleidoscope-Ch6\b", + r"\bKaleidoscope-Ch7\b", + r"\bKaleidoscope-Ch8\b", # Handle these specially as they are strings searched # for during testing. r"\| \bcount\b", diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 0b8ca65a18e..a1810379658 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -35,6 +35,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" config.have_zlib = "@HAVE_LIBZ@" config.have_dia_sdk = @HAVE_DIA_SDK@ config.enable_ffi = "@LLVM_ENABLE_FFI@" +config.test_examples = "@ENABLE_EXAMPLES@" # Support substitution of the tools_dir with user parameters. This is # used when we can't determine the tool dir at configuration time.