Skip to content

Commit 9680aca

Browse files
committed
Partial revert to test on windows
1 parent 551cd52 commit 9680aca

File tree

2 files changed

+5
-56
lines changed

2 files changed

+5
-56
lines changed

src/ccall.cpp

+5-35
Original file line numberDiff line numberDiff line change
@@ -409,25 +409,10 @@ Value *llvm_type_rewrite(Value *v, Type *from_type, Type *target_type,
409409
// one or both of from_type and target_type is a VectorType or AggregateType
410410
// LLVM doesn't allow us to cast these values directly, so
411411
// we need to use this alloca copy trick instead
412-
// On ARM and AArch64, the ABI requires casting through memory to different
413-
// sizes.
414-
Value *from;
415-
Value *to;
416-
#if JL_LLVM_VERSION >= 30600
417-
const DataLayout &DL = jl_ExecutionEngine->getDataLayout();
418-
#else
419-
const DataLayout &DL = *jl_ExecutionEngine->getDataLayout();
420-
#endif
421-
if (DL.getTypeAllocSize(target_type) >= DL.getTypeAllocSize(from_type)) {
422-
to = emit_static_alloca(target_type, ctx);
423-
from = builder.CreatePointerCast(to, from_type->getPointerTo());
424-
}
425-
else {
426-
from = emit_static_alloca(from_type, ctx);
427-
to = builder.CreatePointerCast(from, target_type->getPointerTo());
428-
}
429-
builder.CreateStore(v, from);
430-
return builder.CreateLoad(to);
412+
// NOTE: it is assumed that the ABI has ensured that sizeof(from_type) == sizeof(target_type)
413+
Value *mem = emit_static_alloca(target_type, ctx);
414+
builder.CreateStore(v, builder.CreatePointerCast(mem, from_type->getPointerTo()));
415+
return builder.CreateLoad(mem);
431416
}
432417

433418
// --- argument passing and scratch space utilities ---
@@ -1854,23 +1839,8 @@ static jl_cgval_t emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
18541839
jl_cgval_t newst = emit_new_struct(rt, 1, NULL, ctx); // emit a new, empty struct
18551840
assert(newst.typ != NULL && "Type was not concrete");
18561841
assert(newst.isboxed);
1857-
size_t rtsz = jl_datatype_size(rt);
1858-
assert(rtsz > 0);
1859-
int boxalign = jl_gc_alignment(rtsz);
1860-
#ifndef NDEBUG
1861-
#if JL_LLVM_VERSION >= 30600
1862-
const DataLayout &DL = jl_ExecutionEngine->getDataLayout();
1863-
#else
1864-
const DataLayout &DL = *jl_ExecutionEngine->getDataLayout();
1865-
#endif
1866-
// ARM and AArch64 can use a LLVM type larger than the julia
1867-
// type. However, the LLVM type size should be no larger than
1868-
// the GC allocation size. (multiple of `sizeof(void*)`)
1869-
assert(DL.getTypeStoreSize(lrt) <= LLT_ALIGN(jl_datatype_size(rt),
1870-
boxalign));
1871-
#endif
18721842
// copy the data from the return value to the new struct
1873-
tbaa_decorate(newst.tbaa, builder.CreateAlignedStore(result, emit_bitcast(newst.V, prt->getPointerTo()), boxalign));
1843+
tbaa_decorate(newst.tbaa, builder.CreateAlignedStore(result, emit_bitcast(newst.V, prt->getPointerTo()), 16)); // julia gc is aligned 16
18741844
return newst;
18751845
}
18761846
else if (jlrt != prt) {

src/julia_internal.h

-21
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,6 @@ static const int jl_gc_sizeclasses[JL_GC_N_POOLS] = {
9292
// 64, 32, 160, 64, 16, 64, 112, 128, bytes lost
9393
};
9494

95-
STATIC_INLINE int jl_gc_alignment(size_t sz)
96-
{
97-
if (sz == 0)
98-
return sizeof(void*);
99-
#ifdef _P64
100-
(void)sz;
101-
return 16;
102-
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_)
103-
return sz <= 4 ? 8 : 16;
104-
#else
105-
// szclass 8
106-
if (sz <= 4)
107-
return 8;
108-
// szclass 12
109-
if (sz <= 8)
110-
return 4;
111-
// szclass 16+
112-
return 16;
113-
#endif
114-
}
115-
11695
STATIC_INLINE int JL_CONST_FUNC jl_gc_szclass(size_t sz)
11796
{
11897
#ifdef _P64

0 commit comments

Comments
 (0)