summaryrefslogtreecommitdiff
blob: 7a76d99aca81345148d670895c7a7ec92ab26a93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13e66268..27ff8364 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -218,7 +218,7 @@ if (WASM_ENABLED)
     list(APPEND ISPC_TARGETS wasm-i32x4)
 endif()
 
-set(CLANG_LIBRARY_LIST clangFrontend clangDriver clangSerialization clangParse clangSema clangAnalysis clangAST clangBasic clangEdit clangLex)
+set(CLANG_LIBRARY_LIST clang clang-cpp)
 set(LLVM_COMPONENTS engine ipo bitreader bitwriter instrumentation linker option)
 
 if (${LLVM_VERSION_NUMBER} VERSION_GREATER_EQUAL "10.0.0")
@@ -402,11 +402,8 @@ if (ISPC_USE_ASAN)
 endif()
 
 # Link against Clang libraries
-foreach(clangLib ${CLANG_LIBRARY_LIST})
-    find_library(${clangLib}Path NAMES ${clangLib} HINTS ${LLVM_LIBRARY_DIRS})
-    list(APPEND CLANG_LIBRARY_FULL_PATH_LIST ${${clangLib}Path})
-endforeach()
-target_link_libraries(${PROJECT_NAME} ${CLANG_LIBRARY_FULL_PATH_LIST})
+find_package(Clang REQUIRED)
+target_link_libraries(${PROJECT_NAME} ${CLANG_LIBRARY_LIST})
 
 # Link against LLVM libraries
 target_link_libraries(${PROJECT_NAME} ${LLVM_LIBRARY_LIST})
diff --git a/src/llvmutil.cpp b/src/llvmutil.cpp
index 06fab989..57a7130f 100644
--- a/src/llvmutil.cpp
+++ b/src/llvmutil.cpp
@@ -42,6 +42,7 @@
 #include <llvm/IR/BasicBlock.h>
 #include <llvm/IR/Instructions.h>
 #include <llvm/IR/Module.h>
+#include <llvm/Support/raw_ostream.h>

 #ifdef ISPC_GENX_ENABLED
 #include <llvm/GenXIntrinsics/GenXIntrinsics.h>
@@ -1394,7 +1395,7 @@ static void lDumpValue(llvm::Value *v, std::set<llvm::Value *> &done) {
         return;
 
     fprintf(stderr, "  ");
-    v->dump();
+    v->print(llvm::outs(), false);
     done.insert(v);
 
     if (inst == NULL)
diff --git a/src/opt.cpp b/src/opt.cpp
index d78ac374..a607594a 100644
--- a/src/opt.cpp
+++ b/src/opt.cpp
@@ -142,7 +142,7 @@ static llvm::Pass *CreateFixBooleanSelectPass();
                                                                        getenv("FUNC"), strlen(getenv("FUNC")))))) {    \
         fprintf(stderr, "Start of " NAME "\n");                                                                        \
         fprintf(stderr, "---------------\n");                                                                          \
-        bb.dump();                                                                                                     \
+        bb.print(llvm::outs(), false);                                                                               \
         fprintf(stderr, "---------------\n\n");                                                                        \
     } else /* eat semicolon */
 
@@ -152,7 +152,7 @@ static llvm::Pass *CreateFixBooleanSelectPass();
                                                                        getenv("FUNC"), strlen(getenv("FUNC")))))) {    \
         fprintf(stderr, "End of " NAME " %s\n", modifiedAny ? "** CHANGES **" : "");                                   \
         fprintf(stderr, "---------------\n");                                                                          \
-        bb.dump();                                                                                                     \
+        bb.print(llvm::outs(), false);                                                                               \
         fprintf(stderr, "---------------\n\n");                                                                        \
     } else /* eat semicolon */
 #else
@@ -453,7 +453,7 @@ void Optimize(llvm::Module *module, int optLevel) {
 #ifndef ISPC_NO_DUMPS
     if (g->debugPrint) {
         printf("*** Code going into optimization ***\n");
-        module->dump();
+        module->print(llvm::outs(), nullptr);
     }
 #endif
     DebugPassManager optPM;
@@ -666,7 +666,7 @@ void Optimize(llvm::Module *module, int optLevel) {
 #ifndef ISPC_NO_DUMPS
     if (g->debugPrint) {
         printf("\n*****\nFINAL OUTPUT\n*****\n");
-        module->dump();
+        module->print(llvm::outs(), nullptr);
     }
 #endif
 }
@@ -4256,7 +4256,7 @@ char DebugPass::ID = 0;
 bool DebugPass::runOnModule(llvm::Module &module) {
     fprintf(stderr, "%s", str_output);
     fflush(stderr);
-    module.dump();
+    module.print(llvm::outs(), nullptr);
     return true;
 }
 
@@ -4303,7 +4303,7 @@ void DebugPassFile::run(llvm::Module &module, bool init) {
     snprintf(fname, sizeof(fname), "%s_%d_%s.ll", init ? "init" : "ir", pnum, sanitize(std::string(pname)).c_str());
     llvm::raw_fd_ostream OS(fname, EC, llvm::sys::fs::F_None);
     Assert(!EC && "IR dump file creation failed!");
-    module.print(OS, 0);
+    module.print(OS, nullptr);
 }
 
 bool DebugPassFile::runOnModule(llvm::Module &module) {