Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit cbf4b89

Browse files
mbutrovichapavlo
authored andcommitted
LLVM 5.0 and 6.0 compatibility (#1389)
* Preliminary pass at LLVM 6 API changes. References: http://lists.llvm.org/pipermail/llvm-dev/2015-August/089706.html https://reviews.llvm.org/rL298010 https://stackoverflow.com/questions/46367910/llvm-5-0-linking-error-with-llvmmoduledump * Preliminary pass at packages.sh changes for Ubuntu 18.04 LTS. Fixed include issue in udf_parser under Ubuntu 18.04. * Revert "Preliminary pass at packages.sh changes for Ubuntu 18.04 LTS." This reverts commit a40ca21 We want to do packages.sh changes separately. * Add LLVM version check around AllocaInst().
1 parent 3d66d13 commit cbf4b89

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/codegen/codegen.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,19 @@ llvm::Value *CodeGen::AllocateVariable(llvm::Type *type,
9191
// matter where we insert it.
9292

9393
auto *entry_block = code_context_.GetCurrentFunction()->GetEntryBlock();
94+
#if LLVM_VERSION_GE(5, 0)
95+
if (entry_block->empty()) {
96+
return new llvm::AllocaInst(type, 0, name, entry_block);
97+
} else {
98+
return new llvm::AllocaInst(type, 0, name, &entry_block->front());
99+
}
100+
#else
94101
if (entry_block->empty()) {
95102
return new llvm::AllocaInst(type, name, entry_block);
96103
} else {
97104
return new llvm::AllocaInst(type, name, &entry_block->front());
98105
}
106+
#endif
99107
}
100108

101109
llvm::Value *CodeGen::AllocateBuffer(llvm::Type *element_type,

src/codegen/function_builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ FunctionBuilder::~FunctionBuilder() {
143143
// Here, we just need to iterate over the arguments in the function to find a
144144
// match. The names of the arguments were provided and set at construction time.
145145
llvm::Value *FunctionBuilder::GetArgumentByName(std::string name) {
146-
for (auto &arg : func_->getArgumentList()) {
146+
for (auto &arg : func_->args()) {
147147
if (arg.getName().equals(name)) {
148148
return &arg;
149149
}

src/udf/udf_parser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "udf/udf_parser.h"
1414

1515
#include "llvm/ADT/STLExtras.h"
16+
#include "llvm/Support/raw_ostream.h"
1617

1718
#include "codegen/codegen.h"
1819

@@ -45,7 +46,7 @@ void UDFParser::ParseUDF(codegen::CodeGen &cg, codegen::FunctionBuilder &fb,
4546
code_context.SetUDF(func_ptr);
4647

4748
// To check correctness of the codegened UDF
48-
func_ptr->dump();
49+
func_ptr->print(llvm::errs(), nullptr);
4950
}
5051
}
5152
}

0 commit comments

Comments
 (0)