Skip to content
Closed
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
3 changes: 2 additions & 1 deletion ci/scripts/msys2_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ case "${target}" in
packages+=(${MINGW_PACKAGE_PREFIX}-llvm)
packages+=(${MINGW_PACKAGE_PREFIX}-lz4)
packages+=(${MINGW_PACKAGE_PREFIX}-make)
packages+=(${MINGW_PACKAGE_PREFIX}-mlir)
packages+=(${MINGW_PACKAGE_PREFIX}-ninja)
packages+=(${MINGW_PACKAGE_PREFIX}-polly)
packages+=(${MINGW_PACKAGE_PREFIX}-protobuf)
Expand All @@ -60,7 +61,7 @@ case "${target}" in
;;
esac

case "${target}" in
case "${target}" in
cgo)
packages+=(${MINGW_PACKAGE_PREFIX}-arrow)
packages+=(${MINGW_PACKAGE_PREFIX}-gcc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ brew "flatbuffers"
brew "git"
brew "glog"
brew "grpc"
brew "llvm@12"
brew "llvm"
brew "llvm@8"
brew "lz4"
brew "minio"
Expand Down
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ set(ARROW_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(ARROW_DOC_DIR "share/doc/${PROJECT_NAME}")

set(ARROW_LLVM_VERSIONS
"13.0"
"12.0"
"11.1"
"11.0"
Expand Down
12 changes: 6 additions & 6 deletions cpp/src/gandiva/decimal_ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void DecimalIR::InitializeIntrinsics() {
// CPP: return kScaleMultipliers[scale]
llvm::Value* DecimalIR::GetScaleMultiplier(llvm::Value* scale) {
auto const_array = module()->getGlobalVariable(kScaleMultipliersName);
auto ptr = ir_builder()->CreateGEP(const_array, {types()->i32_constant(0), scale});
return ir_builder()->CreateLoad(ptr);
auto ptr = CreateGEP(ir_builder(), const_array, {types()->i32_constant(0), scale});
return CreateLoad(ir_builder(), ptr);
}

// CPP: x <= y ? y : x
Expand Down Expand Up @@ -248,8 +248,8 @@ llvm::Value* DecimalIR::AddLarge(const ValueFull& x, const ValueFull& y,
ir_builder()->CreateCall(module()->getFunction("add_large_decimal128_decimal128"),
args);

auto out_high = ir_builder()->CreateLoad(out_high_ptr);
auto out_low = ir_builder()->CreateLoad(out_low_ptr);
auto out_high = CreateLoad(ir_builder(), out_high_ptr);
auto out_low = CreateLoad(ir_builder(), out_low_ptr);
auto sum = ValueSplit(out_high, out_low).AsInt128(this);
ADD_TRACE_128("AddLarge : sum", sum);
return sum;
Expand Down Expand Up @@ -445,8 +445,8 @@ llvm::Value* DecimalIR::CallDecimalFunction(const std::string& function_name,
// Make call to pre-compiled IR function.
ir_builder()->CreateCall(module()->getFunction(function_name), dis_assembled_args);

auto out_high = ir_builder()->CreateLoad(out_high_ptr);
auto out_low = ir_builder()->CreateLoad(out_low_ptr);
auto out_high = CreateLoad(ir_builder(), out_high_ptr);
auto out_low = CreateLoad(ir_builder(), out_low_ptr);
result = ValueSplit(out_high, out_low).AsInt128(this);
} else {
DCHECK_NE(return_type, types()->void_type());
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/gandiva/engine_llvm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class TestEngine : public ::testing::Test {
loop_var->addIncoming(loop_update, loop_body);

// get the current value
llvm::Value* offset = builder->CreateGEP(arg_elements, loop_var, "offset");
llvm::Value* current_value = builder->CreateLoad(offset, "value");
llvm::Value* offset = CreateGEP(builder, arg_elements, loop_var, "offset");
llvm::Value* current_value = CreateLoad(builder, offset, "value");

// setup sum PHI
llvm::Value* sum_update = builder->CreateAdd(sum, current_value, "sum+ith");
Expand Down
36 changes: 18 additions & 18 deletions cpp/src/gandiva/llvm_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ Status LLVMGenerator::Execute(const arrow::RecordBatch& record_batch,
llvm::Value* LLVMGenerator::LoadVectorAtIndex(llvm::Value* arg_addrs, int idx,
const std::string& name) {
auto* idx_val = types()->i32_constant(idx);
auto* offset = ir_builder()->CreateGEP(arg_addrs, idx_val, name + "_mem_addr");
return ir_builder()->CreateLoad(offset, name + "_mem");
auto* offset = CreateGEP(ir_builder(), arg_addrs, idx_val, name + "_mem_addr");
return CreateLoad(ir_builder(), offset, name + "_mem");
}

/// Get reference to validity array at specified index in the args list.
Expand Down Expand Up @@ -314,8 +314,8 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, int buffer_count,

std::vector<llvm::Value*> slice_offsets;
for (int idx = 0; idx < buffer_count; idx++) {
auto offsetAddr = builder->CreateGEP(arg_addr_offsets, types()->i32_constant(idx));
auto offset = builder->CreateLoad(offsetAddr);
auto offsetAddr = CreateGEP(builder, arg_addr_offsets, types()->i32_constant(idx));
auto offset = CreateLoad(builder, offsetAddr);
slice_offsets.push_back(offset);
}

Expand All @@ -328,8 +328,8 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, int buffer_count,
llvm::Value* position_var = loop_var;
if (selection_vector_mode != SelectionVector::MODE_NONE) {
position_var = builder->CreateIntCast(
builder->CreateLoad(builder->CreateGEP(arg_selection_vector, loop_var),
"uncasted_position_var"),
CreateLoad(builder, CreateGEP(builder, arg_selection_vector, loop_var),
"uncasted_position_var"),
types()->i64_type(), true, "position_var");
}

Expand All @@ -354,7 +354,7 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, int buffer_count,
SetPackedBitValue(output_ref, loop_var, output_value->data());
} else if (arrow::is_primitive(output_type_id) ||
output_type_id == arrow::Type::DECIMAL) {
llvm::Value* slot_offset = builder->CreateGEP(output_ref, loop_var);
llvm::Value* slot_offset = CreateGEP(builder, output_ref, loop_var);
builder->CreateStore(output_value->data(), slot_offset);
} else if (arrow::is_binary_like(output_type_id)) {
// Var-len output. Make a function call to populate the data.
Expand Down Expand Up @@ -550,15 +550,15 @@ void LLVMGenerator::Visitor::Visit(const VectorReadFixedLenValueDex& dex) {
break;

case arrow::Type::DECIMAL: {
auto slot_offset = builder->CreateGEP(slot_ref, slot_index);
slot_value = builder->CreateLoad(slot_offset, dex.FieldName());
auto slot_offset = CreateGEP(builder, slot_ref, slot_index);
slot_value = CreateLoad(builder, slot_offset, dex.FieldName());
lvalue = generator_->BuildDecimalLValue(slot_value, dex.FieldType());
break;
}

default: {
auto slot_offset = builder->CreateGEP(slot_ref, slot_index);
slot_value = builder->CreateLoad(slot_offset, dex.FieldName());
auto slot_offset = CreateGEP(builder, slot_ref, slot_index);
slot_value = CreateLoad(builder, slot_offset, dex.FieldName());
lvalue = std::make_shared<LValue>(slot_value);
break;
}
Expand All @@ -579,14 +579,14 @@ void LLVMGenerator::Visitor::Visit(const VectorReadVarLenValueDex& dex) {
builder->CreateAdd(loop_var_, GetSliceOffset(dex.OffsetsIdx()));

// => offset_start = offsets[loop_var]
slot = builder->CreateGEP(offsets_slot_ref, offsets_slot_index);
llvm::Value* offset_start = builder->CreateLoad(slot, "offset_start");
slot = CreateGEP(builder, offsets_slot_ref, offsets_slot_index);
llvm::Value* offset_start = CreateLoad(builder, slot, "offset_start");

// => offset_end = offsets[loop_var + 1]
llvm::Value* offsets_slot_index_next = builder->CreateAdd(
offsets_slot_index, generator_->types()->i64_constant(1), "loop_var+1");
slot = builder->CreateGEP(offsets_slot_ref, offsets_slot_index_next);
llvm::Value* offset_end = builder->CreateLoad(slot, "offset_end");
slot = CreateGEP(builder, offsets_slot_ref, offsets_slot_index_next);
llvm::Value* offset_end = CreateLoad(builder, slot, "offset_end");

// => len_value = offset_end - offset_start
llvm::Value* len_value =
Expand All @@ -595,7 +595,7 @@ void LLVMGenerator::Visitor::Visit(const VectorReadVarLenValueDex& dex) {
// get the data from the data array, at offset 'offset_start'.
llvm::Value* data_slot_ref =
GetBufferReference(dex.DataIdx(), kBufferTypeData, dex.Field());
llvm::Value* data_value = builder->CreateGEP(data_slot_ref, offset_start);
llvm::Value* data_value = CreateGEP(builder, data_slot_ref, offset_start);
ADD_VISITOR_TRACE("visit var-len data vector " + dex.FieldName() + " len %T",
len_value);
result_.reset(new LValue(data_value, len_value));
Expand Down Expand Up @@ -806,7 +806,7 @@ void LLVMGenerator::Visitor::Visit(const NullableInternalFuncDex& dex) {
result_ = BuildFunctionCall(native_function, arrow_return_type, &params);

// load the result validity and truncate to i1.
llvm::Value* result_valid_i8 = builder->CreateLoad(result_valid_ptr);
llvm::Value* result_valid_i8 = CreateLoad(builder, result_valid_ptr);
llvm::Value* result_valid = builder->CreateTrunc(result_valid_i8, types->i1_type());

// set validity bit in the local bitmap.
Expand Down Expand Up @@ -1221,7 +1221,7 @@ LValuePtr LLVMGenerator::Visitor::BuildFunctionCall(const NativeFunction* func,
? decimalIR.CallDecimalFunction(func->pc_name(), llvm_return_type, *params)
: generator_->AddFunctionCall(func->pc_name(), llvm_return_type, *params);
auto value_len =
(result_len_ptr == nullptr) ? nullptr : builder->CreateLoad(result_len_ptr);
(result_len_ptr == nullptr) ? nullptr : CreateLoad(builder, result_len_ptr);
return std::make_shared<LValue>(value, value_len);
}
}
Expand Down
13 changes: 13 additions & 0 deletions cpp/src/gandiva/llvm_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

// Workaround for deprecated builder methods as of LLVM 13: ARROW-14363
inline llvm::Value* CreateGEP(llvm::IRBuilder<>* builder, llvm::Value* Ptr,
llvm::ArrayRef<llvm::Value*> IdxList,
const llvm::Twine& Name = "") {
return builder->CreateGEP(Ptr->getType()->getScalarType()->getPointerElementType(), Ptr,
IdxList, Name);
}

inline llvm::LoadInst* CreateLoad(llvm::IRBuilder<>* builder, llvm::Value* Ptr,
const llvm::Twine& Name = "") {
return builder->CreateLoad(Ptr->getType()->getPointerElementType(), Ptr, Name);
}