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

Commit 4767d37

Browse files
committed
Require LLVM 15 or greater
Earlier versions of LLVM do not support opaque pointers. LLVM 15 does not support opaque pointers in SPIRV. LLVM 16 supports opaque pointers across all backends.
1 parent 341dbed commit 4767d37

12 files changed

+7
-94
lines changed

omniscidb/QueryEngine/CgenState.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,8 @@ void CgenState::maybeCloneFunctionRecursive(llvm::Function* fn, bool is_l0) {
190190
}
191191

192192
llvm::SmallVector<llvm::ReturnInst*, 8> Returns; // Ignore returns cloned.
193-
#if LLVM_VERSION_MAJOR > 12
194193
llvm::CloneFunctionInto(
195194
fn, func_impl, vmap_, llvm::CloneFunctionChangeType::DifferentModule, Returns);
196-
#else
197-
llvm::CloneFunctionInto(fn, func_impl, vmap_, /*ModuleLevelChanges=*/true, Returns);
198-
#endif
199195

200196
for (auto it = llvm::inst_begin(fn), e = llvm::inst_end(fn); it != e; ++it) {
201197
if (llvm::isa<llvm::CallInst>(*it)) {

omniscidb/QueryEngine/CgenState.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,15 @@ struct CgenState {
267267
const auto arg_ti = func_type->getParamType(0);
268268
CHECK(arg_ti->isPointerTy());
269269
auto attr_list = func->getAttributes();
270-
#if LLVM_VERSION_MAJOR > 13
271270
llvm::AttrBuilder arr_arg_builder(context_, attr_list.getParamAttrs(0));
272-
#else
273-
llvm::AttrBuilder arr_arg_builder(attr_list.getParamAttributes(0));
274-
#endif
275271
arr_arg_builder.addStructRetAttr(args_in[0]->getType());
276272
func->addParamAttrs(0, arr_arg_builder);
277273
}
278274
const size_t arg_start = has_struct_return ? 1 : 0;
279275
for (size_t i = arg_start; i < func->arg_size(); i++) {
280276
if (struct_args.count(i) > 0) {
281277
auto attr_list = func->getAttributes();
282-
#if LLVM_VERSION_MAJOR > 13
283278
llvm::AttrBuilder arr_arg_builder(context_, attr_list.getParamAttrs(i));
284-
#else
285-
llvm::AttrBuilder arr_arg_builder(attr_list.getParamAttributes(i));
286-
#endif
287279
arr_arg_builder.addByValAttr(args_in[i]->getType());
288280
func->addParamAttrs(i, arr_arg_builder);
289281
}

omniscidb/QueryEngine/Compiler/Backend.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
#include "QueryEngine/ExtensionFunctionsWhitelist.h"
2222
#include "QueryEngine/NvidiaKernel.h"
2323

24+
#include <llvm/ExecutionEngine/JITSymbol.h>
2425
#include <llvm/IR/DebugInfo.h>
2526
#include <llvm/IR/InstIterator.h>
2627
#include <llvm/IR/IntrinsicInst.h>
2728
#include <llvm/IR/LegacyPassManager.h>
2829
#include <llvm/IR/Verifier.h>
2930
#include <llvm/IRReader/IRReader.h>
31+
#include <llvm/MC/TargetRegistry.h>
3032
#include <llvm/Passes/PassBuilder.h>
3133
#include <llvm/Support/TargetSelect.h>
3234
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
@@ -35,13 +37,6 @@
3537
#include "LLVMSPIRVLib/LLVMSPIRVLib.h"
3638
#endif
3739

38-
#include <llvm/ExecutionEngine/JITSymbol.h>
39-
40-
#if LLVM_VERSION_MAJOR > 13
41-
#include <llvm/MC/TargetRegistry.h>
42-
#else
43-
#include <llvm/Support/TargetRegistry.h>
44-
#endif
4540
namespace compiler {
4641

4742
static llvm::sys::Mutex g_ee_create_mutex;
@@ -119,13 +114,9 @@ std::shared_ptr<CpuCompilationContext> CPUBackend::generateNativeCPUCode(
119114
return msg;
120115
};
121116

122-
#if LLVM_VERSION_MAJOR > 12
123117
auto self_epc = llvm::cantFail(llvm::orc::SelfExecutorProcessControl::Create());
124118
auto execution_session =
125119
std::make_unique<llvm::orc::ExecutionSession>(std::move(self_epc));
126-
#else
127-
auto execution_session = std::make_unique<llvm::orc::ExecutionSession>();
128-
#endif
129120

130121
auto target_machine_builder_or_error = llvm::orc::JITTargetMachineBuilder::detectHost();
131122
if (!target_machine_builder_or_error) {

omniscidb/QueryEngine/Compiler/HelperFunctions.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ std::string mangle_spirv_builtin(const llvm::Function& func) {
5757
std::string new_name;
5858
#if LLVM_VERSION_MAJOR > 15
5959
llvm::mangleOpenClBuiltin(func.getName().str(), func.getArg(0)->getType(), new_name);
60-
61-
#elif LLVM_VERSION_MAJOR > 14
60+
#else
6261
mangleOpenClBuiltin(
6362
func.getName().str(), func.getArg(0)->getType(), /*pointer_types=*/{}, new_name);
64-
#else
65-
mangleOpenClBuiltin(func.getName().str(), func.getArg(0)->getType(), new_name);
6663
#endif
6764
return new_name;
6865
}
@@ -253,11 +250,7 @@ void optimize_ir(llvm::Function* query_func,
253250
FPM.addPass(llvm::GVNPass());
254251

255252
FPM.addPass(llvm::DSEPass()); // DeadStoreEliminationPass
256-
#if LLVM_VERSION_MAJOR > 14
257253
LPM.addPass(llvm::LICMPass(llvm::LICMOptions()));
258-
#else
259-
LPM.addPass(llvm::LICMPass());
260-
#endif
261254
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), /*UseMemorySSA=*/true));
262255

263256
FPM.addPass(llvm::InstCombinePass());
@@ -304,12 +297,8 @@ void replace_function(llvm::Module* from, llvm::Module* to, const std::string& f
304297
vmap[&*j] = &*pos_fn_arg_it++;
305298
}
306299
llvm::SmallVector<llvm::ReturnInst*, 8> returns;
307-
#if LLVM_VERSION_MAJOR > 12
308300
llvm::CloneFunctionInto(
309301
target_fn, from_fn, vmap, llvm::CloneFunctionChangeType::DifferentModule, returns);
310-
#else
311-
llvm::CloneFunctionInto(target_fn, from_fn, vmap, true, returns);
312-
#endif
313302

314303
for (auto& BB : *target_fn) {
315304
for (llvm::BasicBlock::iterator bbi = BB.begin(); bbi != BB.end();) {

omniscidb/QueryEngine/GpuSharedMemoryUtils.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,7 @@ void GpuSharedMemCodeBuilder::codegenReduction(const CompilationOptions& co) {
187187
}
188188
agg_func_found = true;
189189
std::vector<llvm::Value*> args;
190-
#if LLVM_VERSION_MAJOR > 13
191190
const auto num_arg_operands = func_call.arg_size();
192-
#else
193-
const auto num_arg_operands = func_call.getNumArgOperands();
194-
#endif
195191
for (size_t i = 0; i < num_arg_operands; ++i) {
196192
args.push_back(func_call.getArgOperand(i));
197193
}
@@ -368,11 +364,7 @@ void replace_called_function_with(llvm::Function* main_func,
368364
auto& instruction = llvm::cast<llvm::CallInst>(*it);
369365
if (std::string(instruction.getCalledFunction()->getName()) == target_func_name) {
370366
std::vector<llvm::Value*> args;
371-
#if LLVM_VERSION_MAJOR > 13
372367
const auto num_arg_operands = instruction.arg_size();
373-
#else
374-
const auto num_arg_operands = instruction.getNumArgOperands();
375-
#endif
376368
for (size_t i = 0; i < num_arg_operands; ++i) {
377369
args.push_back(instruction.getArgOperand(i));
378370
}

omniscidb/QueryEngine/LLVMFunctionAttributesUtil.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,14 @@
1717
#include "LLVMFunctionAttributesUtil.h"
1818

1919
void mark_function_always_inline(llvm::Function* func, llvm::LLVMContext& context) {
20-
#if LLVM_VERSION_MAJOR > 13
2120
func->addAttributeAtIndex(llvm::AttributeList::AttrIndex::FunctionIndex,
2221
llvm::Attribute::get(context, llvm::Attribute::AlwaysInline));
23-
#else
24-
func->addAttribute(llvm::AttributeList::AttrIndex::FunctionIndex,
25-
llvm::Attribute::AlwaysInline);
26-
#endif
2722
}
2823

2924
void mark_function_never_inline(llvm::Function* func, llvm::LLVMContext& context) {
3025
clear_function_attributes(func);
31-
#if LLVM_VERSION_MAJOR > 13
3226
func->addAttributeAtIndex(llvm::AttributeList::AttrIndex::FunctionIndex,
3327
llvm::Attribute::get(context, llvm::Attribute::NoInline));
34-
#else
35-
func->addAttribute(llvm::AttributeList::AttrIndex::FunctionIndex,
36-
llvm::Attribute::NoInline);
37-
#endif
3828
}
3929

4030
void clear_function_attributes(llvm::Function* func) {

omniscidb/QueryEngine/NativeCodegen.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
#include "QueryEngine/Execute.h"
1818

19-
#if LLVM_VERSION_MAJOR < 12
20-
static_assert(false, "LLVM Version >= 12 is required.");
19+
#if LLVM_VERSION_MAJOR < 15
20+
static_assert(false, "LLVM Version >= 15 is required.");
2121
#endif
2222

2323
#include <llvm/Analysis/ScopedNoAliasAA.h>
@@ -70,16 +70,8 @@ static_assert(false, "LLVM Version >= 12 is required.");
7070

7171
#include <boost/filesystem.hpp>
7272

73-
#if LLVM_VERSION_MAJOR > 13
74-
7573
#define LLVM_NUM_OPERANDS(x) x->arg_size()
7674

77-
#else
78-
79-
#define LLVM_NUM_OPERANDS(x) x->getNumArgOperands()
80-
81-
#endif
82-
8375
namespace {
8476

8577
/* SHOW_DEFINED(<llvm::Module instance>) prints the function names

omniscidb/QueryEngine/QueryTemplateGenerator.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424
#include <llvm/IR/Instructions.h>
2525
#include <llvm/IR/Verifier.h>
2626

27-
#if LLVM_VERSION_MAJOR > 13
2827
#define ATTR_BUILDER(ctx) llvm::AttrBuilder B(ctx);
29-
#else
30-
#define ATTR_BUILDER(ctx) llvm::AttrBuilder B;
31-
#endif
3228

3329
namespace {
3430

@@ -348,21 +344,13 @@ class QueryTemplateGenerator {
348344
PAS = llvm::AttributeList::get(mod->getContext(), 10U, B);
349345
}
350346

351-
// NOTE(adb): This attribute is missing in the query template. Why?
352-
#if LLVM_VERSION_MAJOR > 14
347+
// NOTE(adb): This attribute is missing in the query template. Why?
353348
Attrs.push_back(PAS);
354349
{
355350
ATTR_BUILDER(mod->getContext());
356351
B.addUWTableAttr(llvm::UWTableKind::Default);
357352
PAS = llvm::AttributeList::get(mod->getContext(), ~0U, B);
358353
}
359-
#else
360-
{
361-
ATTR_BUILDER(mod->getContext());
362-
B.addAttribute(llvm::Attribute::UWTable);
363-
PAS = llvm::AttributeList::get(mod->getContext(), ~0U, B);
364-
}
365-
#endif
366354

367355
Attrs.push_back(PAS);
368356

omniscidb/QueryEngine/RowFuncBuilder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ bool RowFuncBuilder::codegen(llvm::Value* filter_result,
170170
LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
171171
total_matched_ptr,
172172
matched_cnt,
173-
#if LLVM_VERSION_MAJOR > 12
174173
LLVM_ALIGN(8),
175-
#endif
176174
llvm::AtomicOrdering::Monotonic);
177175
} else {
178176
old_total_matched_val = LL_BUILDER.CreateLoad(

omniscidb/QueryEngine/TargetExprBuilder.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ void TargetExprCodegen::codegen(
222222
LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
223223
acc_i64,
224224
LL_INT(int64_t(1)),
225-
#if LLVM_VERSION_MAJOR > 12
226225
LLVM_ALIGN(8),
227-
#endif
228226
llvm::AtomicOrdering::Monotonic);
229227
}
230228
} else {
@@ -239,9 +237,7 @@ void TargetExprCodegen::codegen(
239237
LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
240238
acc_i32,
241239
LL_INT(1),
242-
#if LLVM_VERSION_MAJOR > 12
243240
LLVM_ALIGN(4),
244-
#endif
245241
llvm::AtomicOrdering::Monotonic);
246242
}
247243
} else {
@@ -253,17 +249,13 @@ void TargetExprCodegen::codegen(
253249
LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
254250
shared_acc_i32,
255251
LL_INT(1),
256-
#if LLVM_VERSION_MAJOR > 12
257252
LLVM_ALIGN(4),
258-
#endif
259253
llvm::AtomicOrdering::Monotonic);
260254
} else {
261255
LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
262256
acc_i32,
263257
LL_INT(1),
264-
#if LLVM_VERSION_MAJOR > 12
265258
LLVM_ALIGN(4),
266-
#endif
267259
llvm::AtomicOrdering::Monotonic);
268260
}
269261
}

0 commit comments

Comments
 (0)