summaryrefslogtreecommitdiff
path: root/examples/Kaleidoscope
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2015-08-27 20:31:44 +0000
committerLang Hames <lhames@gmail.com>2015-08-27 20:31:44 +0000
commit8c46d7964e996f60e4cf0f8ee08be5da22ddf1a3 (patch)
treee44ea3959efa313373fb9f7775aa46e634a4e989 /examples/Kaleidoscope
parent742f5d8f37c26df6c5f1bf27e258a038c757bb07 (diff)
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
Diffstat (limited to 'examples/Kaleidoscope')
-rw-r--r--examples/Kaleidoscope/Chapter4/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter4/toy.cpp8
-rw-r--r--examples/Kaleidoscope/Chapter5/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter5/toy.cpp8
-rw-r--r--examples/Kaleidoscope/Chapter6/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter6/toy.cpp8
-rw-r--r--examples/Kaleidoscope/Chapter7/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter7/toy.cpp8
-rw-r--r--examples/Kaleidoscope/Chapter8/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter8/toy.cpp8
10 files changed, 30 insertions, 20 deletions
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;
}