This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 9b0885ade1 GH-45999: [C++][Gandiva] Fix crashes on LLVM 20.1.1 (#46000)
9b0885ade1 is described below
commit 9b0885ade1c8bbefa173e79391c2f1a61b93456d
Author: Antoine Pitrou <[email protected]>
AuthorDate: Wed Apr 2 03:43:17 2025 +0200
GH-45999: [C++][Gandiva] Fix crashes on LLVM 20.1.1 (#46000)
### Rationale for this change
Avoid creating an invalid `llvm::Value*` that is then ignored when the
output is not variable-width.
### Are these changes tested?
Locally and on CI.
### Are there any user-facing changes?
No, just a bugfix.
* GitHub Issue: #45999
Authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
cpp/src/gandiva/llvm_generator.cc | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/cpp/src/gandiva/llvm_generator.cc
b/cpp/src/gandiva/llvm_generator.cc
index 43f9ed324e..605c1cd9fd 100644
--- a/cpp/src/gandiva/llvm_generator.cc
+++ b/cpp/src/gandiva/llvm_generator.cc
@@ -277,6 +277,8 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr,
int buffer_count,
std::string& fn_name,
SelectionVector::Mode
selection_vector_mode) {
llvm::IRBuilder<>* builder = ir_builder();
+ const auto output_type_id = output->Type()->id();
+
// Create fn prototype :
// int expr_1 (long **addrs, long *offsets, long **bitmaps,
// long *context_ptr, long nrec)
@@ -341,12 +343,18 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr,
int buffer_count,
// Add reference to output vector (in entry block)
builder->SetInsertPoint(loop_entry);
+
llvm::Value* output_ref =
GetDataReference(arg_addrs, output->data_idx(), output->field());
- llvm::Value* output_buffer_ptr_ref = GetDataBufferPtrReference(
- arg_addrs, output->data_buffer_ptr_idx(), output->field());
+ llvm::Value* output_buffer_ptr_ref =
+ arrow::is_binary_like(output_type_id)
+ ? GetDataBufferPtrReference(arg_addrs, output->data_buffer_ptr_idx(),
+ output->field())
+ : nullptr;
llvm::Value* output_offset_ref =
- GetOffsetsReference(arg_addrs, output->offsets_idx(), output->field());
+ arrow::is_binary_like(output_type_id)
+ ? GetOffsetsReference(arg_addrs, output->offsets_idx(),
output->field())
+ : nullptr;
std::vector<llvm::Value*> slice_offsets;
for (int idx = 0; idx < buffer_count; idx++) {
@@ -388,7 +396,6 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr,
int buffer_count,
// save the value in the output vector.
builder->SetInsertPoint(loop_body_tail);
- auto output_type_id = output->Type()->id();
if (output_type_id == arrow::Type::BOOL) {
SetPackedBitValue(output_ref, loop_var, output_value->data());
} else if (arrow::is_primitive(output_type_id) ||