Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit a3bb7a0

Browse files
committed
Build changes for LLVM 16
1 parent d64d4f6 commit a3bb7a0

File tree

7 files changed

+47
-14
lines changed

7 files changed

+47
-14
lines changed

omniscidb/QueryEngine/CgenState.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ std::vector<std::string> CgenState::gpuFunctionsToReplace(llvm::Function* fn) {
299299
CHECK(!fn->isDeclaration());
300300

301301
for (auto& basic_block : *fn) {
302-
auto& inst_list = basic_block.getInstList();
303-
for (auto inst_itr = inst_list.begin(); inst_itr != inst_list.end(); ++inst_itr) {
302+
for (auto inst_itr = basic_block.begin(); inst_itr != basic_block.end(); ++inst_itr) {
304303
if (auto call_inst = llvm::dyn_cast<llvm::CallInst>(inst_itr)) {
305304
auto called_fcn = call_inst->getCalledFunction();
306305
CHECK(called_fcn);
@@ -332,8 +331,7 @@ void CgenState::replaceFunctionForGpu(const std::string& fcn_to_replace,
332331
<< " for parent function " << fn->getName().str();
333332

334333
for (auto& basic_block : *fn) {
335-
auto& inst_list = basic_block.getInstList();
336-
for (auto inst_itr = inst_list.begin(); inst_itr != inst_list.end(); ++inst_itr) {
334+
for (auto inst_itr = basic_block.begin(); inst_itr != basic_block.end(); ++inst_itr) {
337335
if (auto call_inst = llvm::dyn_cast<llvm::CallInst>(inst_itr)) {
338336
auto called_fcn = call_inst->getCalledFunction();
339337
CHECK(called_fcn);

omniscidb/QueryEngine/Compiler/Backend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#pragma once
1616

1717
#include <llvm/IR/Value.h>
18+
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
1819
#include <memory>
1920

2021
#include "QueryEngine/ExtensionModules.h"

omniscidb/QueryEngine/Compiler/HelperFunctions.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ namespace compiler {
5353
std::string mangle_spirv_builtin(const llvm::Function& func) {
5454
CHECK(func.getName().startswith("__spirv_")) << func.getName().str();
5555
std::string new_name;
56+
#if LLVM_VERSION_MAJOR > 14
57+
mangleOpenClBuiltin(
58+
func.getName().str(), func.getArg(0)->getType(), /*pointer_types=*/{}, new_name);
59+
#else
5660
mangleOpenClBuiltin(func.getName().str(), func.getArg(0)->getType(), new_name);
61+
#endif
5762
return new_name;
5863
}
5964
#endif
@@ -213,7 +218,11 @@ void optimize_ir(llvm::Function* query_func,
213218
CGPM.addPass(AnnotateInternalFunctionsPass());
214219
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
215220

221+
#if LLVM_VERSION_MAJOR > 15
222+
FPM.addPass(llvm::SROAPass(llvm::SROAOptions::PreserveCFG));
223+
#else
216224
FPM.addPass(llvm::SROAPass());
225+
#endif
217226
// mem ssa drops unused load and store instructions, e.g. passing variables directly
218227
// where possible
219228
FPM.addPass(llvm::EarlyCSEPass(/*enable_mem_ssa=*/true)); // Catch trivial redundancies
@@ -231,7 +240,11 @@ void optimize_ir(llvm::Function* query_func,
231240
FPM.addPass(llvm::GVNPass());
232241

233242
FPM.addPass(llvm::DSEPass()); // DeadStoreEliminationPass
243+
#if LLVM_VERSION_MAJOR > 14
244+
LPM.addPass(llvm::LICMPass(llvm::LICMOptions()));
245+
#else
234246
LPM.addPass(llvm::LICMPass());
247+
#endif
235248
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), /*UseMemorySSA=*/true));
236249

237250
FPM.addPass(llvm::InstCombinePass());

omniscidb/QueryEngine/ExecutionEngineWrapper.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ class ORCJITExecutionEngineWrapper {
7474
data_layout_->getGlobalPrefix())));
7575
}
7676

77-
~ORCJITExecutionEngineWrapper() {
78-
llvm::cantFail(execution_session_->endSession());
79-
}
77+
~ORCJITExecutionEngineWrapper() { llvm::cantFail(execution_session_->endSession()); }
8078

8179
ORCJITExecutionEngineWrapper(const ORCJITExecutionEngineWrapper& other) = delete;
8280
ORCJITExecutionEngineWrapper(ORCJITExecutionEngineWrapper&& other) = delete;
@@ -102,9 +100,7 @@ class ORCJITExecutionEngineWrapper {
102100
return reinterpret_cast<void*>(symbol->getAddress());
103101
}
104102

105-
bool exists() const {
106-
return !(execution_session_ == nullptr);
107-
}
103+
bool exists() const { return !(execution_session_ == nullptr); }
108104

109105
void removeModule(llvm::Module* module) {
110106
// Do nothing here. Module is deleted by ORC after materialization.

omniscidb/QueryEngine/IRCodegen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,12 @@ void Executor::redeclareFilterFunction() {
934934
// copy the filter_func function body over
935935
// see
936936
// https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning/18751365
937+
#if LLVM_VERSION_MAJOR > 15
938+
filter_func2->splice(filter_func2->begin(), cgen_state_->filter_func_);
939+
#else
937940
filter_func2->getBasicBlockList().splice(
938941
filter_func2->begin(), cgen_state_->filter_func_->getBasicBlockList());
942+
#endif
939943

940944
if (cgen_state_->current_func_ == cgen_state_->filter_func_) {
941945
cgen_state_->current_func_ = filter_func2;

omniscidb/QueryEngine/NativeCodegen.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,12 @@ std::map<std::string, std::string> get_device_parameters(bool cpu_only) {
272272

273273
result.insert(std::make_pair("cpu_name", llvm::sys::getHostCPUName()));
274274
result.insert(std::make_pair("cpu_triple", llvm::sys::getProcessTriple()));
275+
#if LLVM_VERSION_MAJOR > 15
276+
result.insert(std::make_pair("cpu_cores", std::to_string(llvm::get_physical_cores())));
277+
#else
275278
result.insert(
276279
std::make_pair("cpu_cores", std::to_string(llvm::sys::getHostNumPhysicalCores())));
280+
#endif
277281
result.insert(std::make_pair("cpu_threads", std::to_string(cpu_threads())));
278282

279283
// https://en.cppreference.com/w/cpp/language/types
@@ -1222,12 +1226,17 @@ std::vector<llvm::Value*> Executor::inlineHoistedLiterals() {
12221226
query_func_literal_loads_function_arguments2[element.first] = argument_values2;
12231227
}
12241228

1225-
// copy the row_func function body over
1226-
// see
1227-
// https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning/18751365
1229+
// copy the row_func function body over
1230+
// see
1231+
// https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning/18751365
1232+
#if LLVM_VERSION_MAJOR > 15
1233+
row_func_with_hoisted_literals->splice(row_func_with_hoisted_literals->begin(),
1234+
cgen_state_->row_func_);
1235+
#else
12281236
row_func_with_hoisted_literals->getBasicBlockList().splice(
12291237
row_func_with_hoisted_literals->begin(),
12301238
cgen_state_->row_func_->getBasicBlockList());
1239+
#endif
12311240

12321241
// also replace row_func arguments with the arguments from row_func_hoisted_literals
12331242
for (llvm::Function::arg_iterator I = cgen_state_->row_func_->arg_begin(),
@@ -1271,10 +1280,14 @@ std::vector<llvm::Value*> Executor::inlineHoistedLiterals() {
12711280
// copy the filter_func function body over
12721281
// see
12731282
// https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning/18751365
1283+
#if LLVM_VERSION_MAJOR > 15
1284+
filter_func_with_hoisted_literals->splice(filter_func_with_hoisted_literals->begin(),
1285+
cgen_state_->filter_func_);
1286+
#else
12741287
filter_func_with_hoisted_literals->getBasicBlockList().splice(
12751288
filter_func_with_hoisted_literals->begin(),
12761289
cgen_state_->filter_func_->getBasicBlockList());
1277-
1290+
#endif
12781291
// also replace filter_func arguments with the arguments from
12791292
// filter_func_hoisted_literals
12801293
for (llvm::Function::arg_iterator I = cgen_state_->filter_func_->arg_begin(),

omniscidb/QueryEngine/RowFuncBuilder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,11 @@ void RowFuncBuilder::codegenApproxQuantile(const size_t target_idx,
13241324
calc = llvm::BasicBlock::Create(cs->context_, "calc_approx_quantile");
13251325
skip = llvm::BasicBlock::Create(cs->context_, "skip_approx_quantile");
13261326
irb.CreateCondBr(skip_cond, skip, calc);
1327+
#if LLVM_VERSION_MAJOR > 15
1328+
cs->current_func_->insert(cs->current_func_->end(), calc);
1329+
#else
13271330
cs->current_func_->getBasicBlockList().push_back(calc);
1331+
#endif
13281332
irb.SetInsertPoint(calc);
13291333
}
13301334
if (!arg_type->isFloatingPoint()) {
@@ -1336,7 +1340,11 @@ void RowFuncBuilder::codegenApproxQuantile(const size_t target_idx,
13361340
"agg_approx_quantile", llvm::Type::getVoidTy(cs->context_), agg_args);
13371341
if (nullable) {
13381342
irb.CreateBr(skip);
1343+
#if LLVM_VERSION_MAJOR > 15
1344+
cs->current_func_->insert(cs->current_func_->end(), skip);
1345+
#else
13391346
cs->current_func_->getBasicBlockList().push_back(skip);
1347+
#endif
13401348
irb.SetInsertPoint(skip);
13411349
}
13421350
}

0 commit comments

Comments
 (0)