[llvm] r246201 - Recommit r246175 - Add Kaleidoscope regression tests, with a fix to make sure

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 13:31:44 PDT 2015


Author: lhames
Date: Thu Aug 27 15:31:44 2015
New Revision: 246201

URL: http://llvm.org/viewvc/llvm-project?rev=246201&view=rev
Log:
Recommit r246175 - Add Kaleidoscope regression tests, with a fix to make sure
the kaleidoscope 'library' functions aren't dead-stripped in release builds.


Modified:
    llvm/trunk/docs/tutorial/LangImpl4.rst
    llvm/trunk/examples/Kaleidoscope/Chapter4/CMakeLists.txt
    llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp
    llvm/trunk/examples/Kaleidoscope/Chapter5/CMakeLists.txt
    llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp
    llvm/trunk/examples/Kaleidoscope/Chapter6/CMakeLists.txt
    llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp
    llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt
    llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp
    llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt
    llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp
    llvm/trunk/test/CMakeLists.txt
    llvm/trunk/test/Makefile
    llvm/trunk/test/lit.cfg
    llvm/trunk/test/lit.site.cfg.in

Modified: llvm/trunk/docs/tutorial/LangImpl4.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl4.rst?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/docs/tutorial/LangImpl4.rst (original)
+++ llvm/trunk/docs/tutorial/LangImpl4.rst Thu Aug 27 15:31:44 2015
@@ -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;
     }
 

Modified: llvm/trunk/examples/Kaleidoscope/Chapter4/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter4/CMakeLists.txt?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter4/CMakeLists.txt (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter4/CMakeLists.txt Thu Aug 27 15:31:44 2015
@@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch4
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch4)

Modified: llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp Thu Aug 27 15:31:44 2015
@@ -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;
 }
 

Modified: llvm/trunk/examples/Kaleidoscope/Chapter5/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter5/CMakeLists.txt?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter5/CMakeLists.txt (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter5/CMakeLists.txt Thu Aug 27 15:31:44 2015
@@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch5
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch5)

Modified: llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp Thu Aug 27 15:31:44 2015
@@ -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;
 }
 

Modified: llvm/trunk/examples/Kaleidoscope/Chapter6/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter6/CMakeLists.txt?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter6/CMakeLists.txt (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter6/CMakeLists.txt Thu Aug 27 15:31:44 2015
@@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch6
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch6)

Modified: llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp Thu Aug 27 15:31:44 2015
@@ -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;
 }
 

Modified: llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt Thu Aug 27 15:31:44 2015
@@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch7
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch7)

Modified: llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp Thu Aug 27 15:31:44 2015
@@ -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;
 }
 

Modified: llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt Thu Aug 27 15:31:44 2015
@@ -9,3 +9,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch8
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch8)

Modified: llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp (original)
+++ llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp Thu Aug 27 15:31:44 2015
@@ -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;
 }
 

Modified: llvm/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CMakeLists.txt?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/test/CMakeLists.txt (original)
+++ llvm/trunk/test/CMakeLists.txt Thu Aug 27 15:31:44 2015
@@ -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

Modified: llvm/trunk/test/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Makefile?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/test/Makefile (original)
+++ llvm/trunk/test/Makefile Thu Aug 27 15:31:44 2015
@@ -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
 

Modified: llvm/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/test/lit.cfg (original)
+++ llvm/trunk/test/lit.cfg Thu Aug 27 15:31:44 2015
@@ -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",

Modified: llvm/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.site.cfg.in?rev=246201&r1=246200&r2=246201&view=diff
==============================================================================
--- llvm/trunk/test/lit.site.cfg.in (original)
+++ llvm/trunk/test/lit.site.cfg.in Thu Aug 27 15:31:44 2015
@@ -35,6 +35,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_S
 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.




More information about the llvm-commits mailing list