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

Update to LLVM 15 #633

Merged
merged 7 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions omniscidb/CudaMgr/CudaMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,8 @@ class CudaMgr : public GpuMgr {

void printDeviceProperties() const;

const std::vector<CUcontext>& getDeviceContexts() const {
return device_contexts_;
}
const int getGpuDriverVersion() const {
return gpu_driver_version_;
}
const std::vector<CUcontext>& getDeviceContexts() const { return device_contexts_; }
const int getGpuDriverVersion() const { return gpu_driver_version_; }

void loadGpuModuleData(CUmodule* module,
const void* image,
Expand Down
4 changes: 1 addition & 3 deletions omniscidb/DataMgr/ChunkMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ class ChunkMetadata {
return res;
}

std::string toString() const {
return dump();
}
std::string toString() const { return dump(); }
#endif

template <typename T>
Expand Down
20 changes: 5 additions & 15 deletions omniscidb/DataMgr/DataMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,11 @@ class ProcBuddyinfoParser {
fragmentationPercent_ = (scaled * 100) / total;
}

auto operator[](size_t order) {
return orders_[order];
}
auto begin() {
return orders_.begin();
}
auto end() {
return orders_.end();
}
auto getFragmentationPercent() {
return fragmentationPercent_;
}
auto getInputText() {
return inputText_;
}
auto operator[](size_t order) { return orders_[order]; }
auto begin() { return orders_.begin(); }
auto end() { return orders_.end(); }
auto getFragmentationPercent() { return fragmentationPercent_; }
auto getInputText() { return inputText_; }
};

class DataMgr {
Expand Down
9 changes: 7 additions & 2 deletions omniscidb/QueryEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ set(hdk_default_runtime_functions_module_dependencies
GroupByRuntime.cpp
TopKRuntime.cpp)

list(APPEND DISABLE_OPAQUE_POINTERS_CMD "")
if(${LLVM_PACKAGE_VERSION} VERSION_GREATER_EQUAL "15")
list(APPEND DISABLE_OPAQUE_POINTERS_CMD "-Xclang" "-no-opaque-pointers")
endif()

# Adds a custom command for producing llvm bitcode modules out of a .cpp source.
# Any additional arguments are treated as clang args and bypassed as-is.
function(precompile_llvm_module SOURCE_FILE SUFFIX)
Expand All @@ -195,7 +200,7 @@ function(precompile_llvm_module SOURCE_FILE SUFFIX)
DEPENDS ${hdk_default_runtime_functions_module_dependencies} ${SOURCE_FILE}
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${result_module_name}
COMMAND ${llvm_clangpp_cmd}
ARGS -std=c++17 ${RT_OPT_FLAGS} ${ARGN} -c -emit-llvm
ARGS -std=c++17 ${RT_OPT_FLAGS} ${ARGN} -c -emit-llvm ${DISABLE_OPAQUE_POINTERS_CMD}
${CLANG_SDK_INC} ${CLANG_CRT_INC} ${MAPD_DEFINITIONS} -DEXECUTE_INCLUDE
-o ${CMAKE_CURRENT_BINARY_DIR}/${result_module_name}
-I ${CMAKE_CURRENT_SOURCE_DIR}/../
Expand Down Expand Up @@ -272,7 +277,7 @@ add_custom_command(
DEPENDS ExtensionFunctions.hpp ExtensionFunctionsArray.hpp ExtensionFunctionsTesting.hpp
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ExtensionFunctions.ast.raw
COMMAND ${llvm_clangpp_cmd}
ARGS -DNO_BOOST -std=c++17 -fsyntax-only -Xclang -ast-dump -fno-diagnostics-color -Wno-return-type-c-linkage
ARGS -DNO_BOOST -std=c++17 -fsyntax-only -Xclang -ast-dump -fno-diagnostics-color -Wno-return-type-c-linkage ${DISABLE_OPAQUE_POINTERS_CMD}
-I ${CMAKE_CURRENT_SOURCE_DIR}/../ ${CMAKE_CURRENT_SOURCE_DIR}/ExtensionFunctions.hpp > ${CMAKE_CURRENT_BINARY_DIR}/ExtensionFunctions.ast.raw)

add_custom_command(
Expand Down
6 changes: 2 additions & 4 deletions omniscidb/QueryEngine/CgenState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ std::vector<std::string> CgenState::gpuFunctionsToReplace(llvm::Function* fn) {
CHECK(!fn->isDeclaration());

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

for (auto& basic_block : *fn) {
auto& inst_list = basic_block.getInstList();
for (auto inst_itr = inst_list.begin(); inst_itr != inst_list.end(); ++inst_itr) {
for (auto inst_itr = basic_block.begin(); inst_itr != basic_block.end(); ++inst_itr) {
if (auto call_inst = llvm::dyn_cast<llvm::CallInst>(inst_itr)) {
auto called_fcn = call_inst->getCalledFunction();
CHECK(called_fcn);
Expand Down
8 changes: 2 additions & 6 deletions omniscidb/QueryEngine/CgenState.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,7 @@ struct CgenState {
const std::vector<llvm::Value*>& args);
llvm::Value* emitCall(const std::string& fname, const std::vector<llvm::Value*>& args);

size_t getLiteralBufferUsage(const int device_id) {
return literal_bytes_[device_id];
}
size_t getLiteralBufferUsage(const int device_id) { return literal_bytes_[device_id]; }

llvm::Value* castToTypeIn(llvm::Value* val, const size_t bit_width);

Expand All @@ -317,9 +315,7 @@ struct CgenState {
llvm::ConstantFP::get(llvm::Type::getDoubleTy(context_), v));
}

llvm::ConstantInt* llBool(const bool v) const {
return ::ll_bool(v, context_);
}
llvm::ConstantInt* llBool(const bool v) const { return ::ll_bool(v, context_); }

void emitErrorCheck(llvm::Value* condition, llvm::Value* errorCode, std::string label);

Expand Down
1 change: 1 addition & 0 deletions omniscidb/QueryEngine/Compiler/Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include <llvm/IR/Value.h>
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should live in the cpp I think.

#include <memory>

#include "QueryEngine/ExtensionModules.h"
Expand Down
13 changes: 13 additions & 0 deletions omniscidb/QueryEngine/Compiler/HelperFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ namespace compiler {
std::string mangle_spirv_builtin(const llvm::Function& func) {
CHECK(func.getName().startswith("__spirv_")) << func.getName().str();
std::string new_name;
#if LLVM_VERSION_MAJOR > 14
mangleOpenClBuiltin(
func.getName().str(), func.getArg(0)->getType(), /*pointer_types=*/{}, new_name);
#else
mangleOpenClBuiltin(func.getName().str(), func.getArg(0)->getType(), new_name);
#endif
return new_name;
}
#endif
Expand Down Expand Up @@ -211,7 +216,11 @@ void optimize_ir(llvm::Function* query_func,
CGPM.addPass(AnnotateInternalFunctionsPass());
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));

#if LLVM_VERSION_MAJOR > 15
FPM.addPass(llvm::SROAPass(llvm::SROAOptions::PreserveCFG));
#else
FPM.addPass(llvm::SROAPass());
#endif
// mem ssa drops unused load and store instructions, e.g. passing variables directly
// where possible
FPM.addPass(llvm::EarlyCSEPass(/*enable_mem_ssa=*/true)); // Catch trivial redundancies
Expand All @@ -229,7 +238,11 @@ void optimize_ir(llvm::Function* query_func,
FPM.addPass(llvm::GVNPass());

FPM.addPass(llvm::DSEPass()); // DeadStoreEliminationPass
#if LLVM_VERSION_MAJOR > 14
LPM.addPass(llvm::LICMPass(llvm::LICMOptions()));
#else
LPM.addPass(llvm::LICMPass());
#endif
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), /*UseMemorySSA=*/true));

FPM.addPass(llvm::InstCombinePass());
Expand Down
5 changes: 5 additions & 0 deletions omniscidb/QueryEngine/Execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ Executor::Executor(const ExecutorId executor_id,
, temporary_tables_(nullptr)
, input_table_info_cache_(this)
, thread_id_(logger::thread_id()) {
#if LLVM_VERSION_MAJOR > 14
// temporarily disable opaque pointers
context_->setOpaquePointers(false);
#endif

if (executor_id_ > INVALID_EXECUTOR_ID - 1) {
throw std::runtime_error("Too many executors!");
}
Expand Down
8 changes: 2 additions & 6 deletions omniscidb/QueryEngine/ExecutionEngineWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ class ORCJITExecutionEngineWrapper {
data_layout_->getGlobalPrefix())));
}

~ORCJITExecutionEngineWrapper() {
llvm::cantFail(execution_session_->endSession());
}
~ORCJITExecutionEngineWrapper() { llvm::cantFail(execution_session_->endSession()); }

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

bool exists() const {
return !(execution_session_ == nullptr);
}
bool exists() const { return !(execution_session_ == nullptr); }

void removeModule(llvm::Module* module) {
// Do nothing here. Module is deleted by ORC after materialization.
Expand Down
4 changes: 4 additions & 0 deletions omniscidb/QueryEngine/IRCodegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,12 @@ void Executor::redeclareFilterFunction() {
// copy the filter_func function body over
// see
// https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning/18751365
#if LLVM_VERSION_MAJOR > 15
filter_func2->splice(filter_func2->begin(), cgen_state_->filter_func_);
#else
filter_func2->getBasicBlockList().splice(
filter_func2->begin(), cgen_state_->filter_func_->getBasicBlockList());
#endif

if (cgen_state_->current_func_ == cgen_state_->filter_func_) {
cgen_state_->current_func_ = filter_func2;
Expand Down
12 changes: 3 additions & 9 deletions omniscidb/QueryEngine/JoinHashTable/BaselineHashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,9 @@ class BaselineHashTable : public HashTable {
return reinterpret_cast<int8_t*>(cpu_hash_table_buff_.get());
}

HashType getLayout() const override {
return layout_;
}
size_t getEntryCount() const override {
return entry_count_;
}
size_t getEmittedKeysCount() const override {
return emitted_keys_count_;
}
HashType getLayout() const override { return layout_; }
size_t getEntryCount() const override { return entry_count_; }
size_t getEmittedKeysCount() const override { return emitted_keys_count_; }

private:
std::unique_ptr<int8_t[]> cpu_hash_table_buff_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,17 +531,11 @@ class BaselineJoinHashTableBuilder {
return err;
}

std::unique_ptr<BaselineHashTable> getHashTable() {
return std::move(hash_table_);
}
std::unique_ptr<BaselineHashTable> getHashTable() { return std::move(hash_table_); }

void setHashLayout(HashType layout) {
layout_ = layout;
}
void setHashLayout(HashType layout) { layout_ = layout; }

HashType getHashLayout() const {
return layout_;
}
HashType getHashLayout() const { return layout_; }

private:
std::unique_ptr<BaselineHashTable> hash_table_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,7 @@ class PerfectJoinHashTableBuilder {
}
}

std::unique_ptr<PerfectHashTable> getHashTable() {
return std::move(hash_table_);
}
std::unique_ptr<PerfectHashTable> getHashTable() { return std::move(hash_table_); }

const bool for_semi_anti_join(const JoinType join_type) {
return join_type == JoinType::SEMI || join_type == JoinType::ANTI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,11 @@ struct GenericKeyHandler {
return 0;
}

DEVICE size_t get_number_of_columns() const {
return key_component_count_;
}
DEVICE size_t get_number_of_columns() const { return key_component_count_; }

DEVICE size_t get_key_component_count() const {
return key_component_count_;
}
DEVICE size_t get_key_component_count() const { return key_component_count_; }

DEVICE const JoinColumn* get_join_columns() const {
return join_column_per_key_;
}
DEVICE const JoinColumn* get_join_columns() const { return join_column_per_key_; }

DEVICE const JoinColumnTypeInfo* get_join_column_type_infos() const {
return type_info_per_key_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ struct JoinColumnTupleIterator {
return *this;
}

DEVICE FORCE_INLINE JoinColumnTupleIterator& operator*() {
return *this;
}
DEVICE FORCE_INLINE JoinColumnTupleIterator& operator*() { return *this; }
}; // struct JoinColumnTupleIterator

//! Helper class for viewing multiple JoinColumns and their matching JoinColumnTypeInfos
Expand Down
25 changes: 20 additions & 5 deletions omniscidb/QueryEngine/NativeCodegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,12 @@ std::map<std::string, std::string> get_device_parameters(bool cpu_only) {

result.insert(std::make_pair("cpu_name", llvm::sys::getHostCPUName()));
result.insert(std::make_pair("cpu_triple", llvm::sys::getProcessTriple()));
#if LLVM_VERSION_MAJOR > 15
result.insert(std::make_pair("cpu_cores", std::to_string(llvm::get_physical_cores())));
#else
result.insert(
std::make_pair("cpu_cores", std::to_string(llvm::sys::getHostNumPhysicalCores())));
#endif
result.insert(std::make_pair("cpu_threads", std::to_string(cpu_threads())));

// https://en.cppreference.com/w/cpp/language/types
Expand Down Expand Up @@ -450,7 +454,9 @@ std::unique_ptr<llvm::Module> read_llvm_module_from_bc_file(
llvm::MemoryBuffer* buffer = buffer_or_error.get().get();

auto owner = llvm::parseBitcodeFile(buffer->getMemBufferRef(), context);
CHECK(!owner.takeError());
if (auto err = owner.takeError()) {
CHECK(false) << llvm::toString(std::move(err));
}
CHECK(owner->get());
return std::move(owner.get());
}
Expand Down Expand Up @@ -1222,12 +1228,17 @@ std::vector<llvm::Value*> Executor::inlineHoistedLiterals() {
query_func_literal_loads_function_arguments2[element.first] = argument_values2;
}

// copy the row_func function body over
// see
// https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning/18751365
// copy the row_func function body over
// see
// https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning/18751365
#if LLVM_VERSION_MAJOR > 15
row_func_with_hoisted_literals->splice(row_func_with_hoisted_literals->begin(),
cgen_state_->row_func_);
#else
row_func_with_hoisted_literals->getBasicBlockList().splice(
row_func_with_hoisted_literals->begin(),
cgen_state_->row_func_->getBasicBlockList());
#endif

// also replace row_func arguments with the arguments from row_func_hoisted_literals
for (llvm::Function::arg_iterator I = cgen_state_->row_func_->arg_begin(),
Expand Down Expand Up @@ -1271,10 +1282,14 @@ std::vector<llvm::Value*> Executor::inlineHoistedLiterals() {
// copy the filter_func function body over
// see
// https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning/18751365
#if LLVM_VERSION_MAJOR > 15
filter_func_with_hoisted_literals->splice(filter_func_with_hoisted_literals->begin(),
cgen_state_->filter_func_);
#else
filter_func_with_hoisted_literals->getBasicBlockList().splice(
filter_func_with_hoisted_literals->begin(),
cgen_state_->filter_func_->getBasicBlockList());

#endif
// also replace filter_func arguments with the arguments from
// filter_func_hoisted_literals
for (llvm::Function::arg_iterator I = cgen_state_->filter_func_->arg_begin(),
Expand Down
Loading