Skip to content

Commit 7b95ca7

Browse files
committed
....
1 parent e499e7f commit 7b95ca7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

deps/LLVMExtra/include/LLVMExtra.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
160160
// Constant data
161161
#if LLVM_VERSION_MAJOR < 21
162162
LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const void *Data,
163-
unsigned NumElements);
163+
size_t SizeInBytes);
164164
#endif
165165

166166
// Missing opaque pointer APIs

deps/LLVMExtra/lib/Core.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,10 @@ void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
571571

572572
#if LLVM_VERSION_MAJOR < 21
573573
LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const void *Data,
574-
unsigned NumElements) {
575-
StringRef S((const char *)Data,
576-
NumElements * unwrap(ElementTy)->getPrimitiveSizeInBits() / 8);
577-
return wrap(ConstantDataArray::getRaw(S, NumElements, unwrap(ElementTy)));
574+
size_t SizeInBytes) {
575+
Type *Ty = unwrap(ElementTy);
576+
size_t Len = SizeInBytes / (Ty->getPrimitiveSizeInBits() / 8);
577+
return wrap(ConstantDataArray::getRaw(StringRef((const char*)Data, SizeInBytes), Len, Ty));
578578
}
579579
#endif
580580

src/core/value/constant.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Create a constant array of simple data values of the given type and data.
270270
function ConstantDataArray(typ::LLVMType, data::AbstractVector{T}) where {T <: Union{Integer, AbstractFloat}}
271271
# TODO: can we look up the primitive size of the LLVM type?
272272
# use that to assert it matches the Julia element type.
273-
return ConstantDataArray(API.LLVMConstDataArray(typ, data, length(data)))
273+
return ConstantDataArray(API.LLVMConstDataArray(typ, data, sizeof(data)))
274274
end
275275

276276
"""

0 commit comments

Comments
 (0)