Recommit r246175 - Add Kaleidoscope regression tests, with a fix to make sure
authorLang Hames <lhames@gmail.com>
Thu, 27 Aug 2015 20:31:44 +0000 (20:31 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 27 Aug 2015 20:31:44 +0000 (20:31 +0000)
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

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

index 702886f6aec6b432f4b51795339307634e99cb4a..92dcc3d33a0ed89fdfa82d0d783f6f8f5184dcda 100644 (file)
@@ -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;
     }
 
index 44e1aeecaaeb9d6b0b934556829ca2c060bc38f6..89feed143adcd53ab0ed2d5e4e1d4c4e66dccdda 100644 (file)
@@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch4
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch4)
index 12777ae2c758fa93587b969b6c546aaedd9c9423..fe8ec17b4e897ca308223366f225f82ae201c009 100644 (file)
@@ -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;
 }
 
index b62ed410103fa07ae349359c35e10ff93a4db896..c0ae70654c363cfecfbf8b3e08d622a64d99f87c 100644 (file)
@@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch5
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch5)
index 83af1776b20ebcf80307eee32e3d50ef8b30de4a..4658edcd4cec16a5b8d6e5cb12c569bd53d5a593 100644 (file)
@@ -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;
 }
 
index 6bb2b19375276d45099c41f2072252e12a4a7d65..49627f07ddf05ece09bdcac0bf8d9f46cb163c2b 100644 (file)
@@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch6
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch6)
index e1bed45189e0593d36c113036b200757080b7f9f..9d9914a4b89aa9d342811582fdb547151e4881e4 100644 (file)
@@ -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;
 }
 
index 27c18cdd0654ff0a48df6f1d1aea1cd9f2331b46..e67d7928efe79539522bb8e955de6c522469aa31 100644 (file)
@@ -13,3 +13,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch7
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch7)
index 4558522952ce26d405745f2c8c1f3e426d349ccd..d61d880e5403b529cc62ff5c4d4a5106caf18ed5 100644 (file)
@@ -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;
 }
 
index e335cb48ac7a244d19bb9f36ddd60c7cb827e9c1..d9b5cc421be397e6a7df382b4901505caec67f6d 100644 (file)
@@ -9,3 +9,5 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch8
   toy.cpp
   )
+
+export_executable_symbols(Kaleidoscope-Ch8)
index 7338c6ebc50bd15b86b686827031e96a64bb23b5..5f97a157336b363622edfbd8ea875859610edee5 100644 (file)
@@ -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;
 }
 
index 1f417c2a0fc6715489dc4e452b31c909f0bed1ae..464a6f0161a97a4f9622b045a8a6728a230c2896 100644 (file)
@@ -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
index 558762e39dc2c1fe39c78dca028e30f5fa41a3be..9b37cedaaffd8ca0e6acdc23a25b0186cd797ecd 100644 (file)
@@ -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
 
index 167a81afad1ce5a026a3785111eee24310ebcc31..38a2ec20ec8d6b4f4b61edd70a32f44bc5aff0e2 100644 (file)
@@ -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",
index 0b8ca65a18e702f8cc34e79da269a2c202a13502..a181037965882291134a1cfa3683165cbd43bd9e 100644 (file)
@@ -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.