Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports for 1.9.0-rc1 #48733

Merged
merged 53 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1360b3a
Restrict `path` to be an `AbstractString` in `lbt_forward()`
staticfloat Feb 7, 2023
d0a7175
Update LLVM build to 14.0.6+2 (#48544)
vchuravy Feb 8, 2023
ceacba1
Update checksums for llvm 14.0.6+2 (#48659)
vchuravy Feb 12, 2023
6213bb8
[REPL] Meta-e: Don't execute the edited code when exiting editor (#46…
fredrikekre Feb 13, 2023
d43d055
Disable frame-pointer-optimiation on Linux (#48660)
vchuravy Feb 13, 2023
b3d42d1
Fix Base.libllvm_path and jl_get_libllvm don't support non-ASCII char…
wesjenkins Feb 14, 2023
25bad18
fix #47658, state stack overflow on unions containing typevars (#48221)
JeffBezanson Jan 24, 2023
f7c4f59
restore kwcall_mt optimizations
Feb 20, 2023
5e39fc6
lattice: fix minor lattice issues (#47570)
aviatesk Nov 16, 2022
84e3545
Put back getfield :boundscheck hack (#48677)
Keno Feb 15, 2023
2324310
make `insert_extension_triggers` idempotent
KristofferC Feb 8, 2023
7734b34
fix printing of parents to extensions in `@time_imports`
KristofferC Feb 10, 2023
6545919
julia_cmd() docstring: include pkgimages (#48392)
fonsp Feb 13, 2023
1121d25
Allow for use 60% of constrained/total system memory (#48614)
gbaraldi Feb 10, 2023
a66d092
update loading test to best-practices (#48429)
vtjnash Jan 31, 2023
5453936
only load extension triggers from the evnironment where the parent pa…
KristofferC Feb 20, 2023
86b9df2
effects: taint `:nothrow` effect on unknown `:static_parameter` (#46791)
aviatesk Feb 8, 2023
af0e4c1
force singlethreading during precompilation (#48592)
IanButterworth Feb 10, 2023
0cb0bb4
Bump LLD to get dsymutil and use it for pkgimgs (#48628)
gbaraldi Feb 11, 2023
624c665
put back DelimitedFiles as a non-sysimage "stdlib" (#48671)
KristofferC Feb 21, 2023
956f54b
[OpenBLAS_jll] Upgrade to new build optimised for PowerPC (#48689)
giordano Feb 20, 2023
b5d9781
staticdata: encode link_id in tagged linkage (#48673)
vtjnash Feb 17, 2023
50b8c13
Add world argument to jl_create_native. (#48746)
maleadt Feb 21, 2023
1c22e77
[compiler] Teach type inference that `GotoIfNot` can throw (#48583)
staticfloat Feb 7, 2023
d2de99d
Stop renumbering statements in inference proper (#48022)
Keno Dec 29, 2022
a6a19e4
inference: fix the correctness of inference bail out interface (#48826)
aviatesk Mar 1, 2023
09757f7
effects: taint `nonoverlayed` when bailing out inference (#48838)
aviatesk Mar 1, 2023
2761b06
effects: handle va-method properly when refining `:inaccessiblememonl…
aviatesk Mar 3, 2023
e25fcc9
Test: add space after test failure for visual clarity (#48526)
IanButterworth Feb 21, 2023
54bdee8
[Make.inc] Define new variable `PATCHELF_SET_RPATH_ARG`
giordano Feb 25, 2023
a671f0c
Accept weakdeps as a source for UUIDS for Preferences
vchuravy Feb 26, 2023
b5243af
add a type assert to logging to prevent Base.require invalidation (#4…
KristofferC Feb 28, 2023
2497f83
Add libjulia-internal to ORCJIT symbol resolution (#48712)
topolarity Feb 28, 2023
8ba214d
Update MbedTLS to 2.28.2 (#48806)
mkitti Feb 28, 2023
b710bd2
Always use `-Wl,--warn-unresolved-symbols` in MSAN builds (#48835)
giordano Mar 1, 2023
3f040ca
Calculate a checksum for the system image (#48869)
timholy Mar 3, 2023
df3f686
fixup! effects: taint `nonoverlayed` when bailing out inference (#48838)
vchuravy Mar 3, 2023
44085f9
Atomically order specsigflags, specptr, and invoke (#47832)
pchintalapudi Feb 22, 2023
570251e
enable re-using external code in pkgimages (#48723)
vtjnash Feb 25, 2023
4710009
Fix final gc lowering on dynamically sized allocation (#48620)
wsmoses Feb 10, 2023
b07fb40
gf: cache cache_with_orig decision (#48833)
vtjnash Mar 1, 2023
d57c4ea
bump Pkg to latest 1.9
Mar 3, 2023
ec5e702
fixup! fixup! effects: taint `nonoverlayed` when bailing out inferenc…
KristofferC Mar 3, 2023
65a025f
staticdata: make hookup of code instances correct (#48751)
vtjnash Mar 3, 2023
c1cb058
staticdata: make completeinfo memory-/gc-safe (#48832)
vtjnash Mar 1, 2023
fcde569
fixup! gf: cache cache_with_orig decision (#48833)
vchuravy Mar 6, 2023
be9df3f
Merge pull request #48881 from JuliaLang/vc/backports-1.9
KristofferC Mar 6, 2023
8024dd6
Add note to NEWS about keywords in tab completion (#48863)
pbouffard Mar 3, 2023
fd1108b
staticdata: set method.nroots_sysimg in `jl_write_values` (#48875)
timholy Mar 3, 2023
96b3fe3
staticdata: check ci->relocatability before caching external speciali…
timholy Mar 3, 2023
9f3b747
Initialize JIT bytes
pchintalapudi Mar 5, 2023
e6249e7
Fix sorting missing values with offset indices (#48864)
LilithHafner Mar 6, 2023
9ced070
Fix heapsize hint and use a line for max memory (#48747)
gbaraldi Mar 3, 2023
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
Prev Previous commit
Next Next commit
Fix final gc lowering on dynamically sized allocation (#48620)
(cherry picked from commit 7e57dc7)
  • Loading branch information
wsmoses authored and KristofferC committed Mar 3, 2023
commit 4710009fd04460aafb4b10f9a9568f907d2d95ea
48 changes: 31 additions & 17 deletions src/llvm-final-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct FinalLowerGC: private JuliaPassContext {
Function *queueBindingFunc;
Function *poolAllocFunc;
Function *bigAllocFunc;
Function *allocTypedFunc;
Instruction *pgcstack;

// Lowers a `julia.new_gc_frame` intrinsic.
Expand Down Expand Up @@ -205,23 +206,35 @@ Value *FinalLowerGC::lowerGCAllocBytes(CallInst *target, Function &F)
{
++GCAllocBytesCount;
assert(target->arg_size() == 2);
auto sz = (size_t)cast<ConstantInt>(target->getArgOperand(1))->getZExtValue();
// This is strongly architecture and OS dependent
int osize;
int offset = jl_gc_classify_pools(sz, &osize);
CallInst *newI;

IRBuilder<> builder(target);
builder.SetCurrentDebugLocation(target->getDebugLoc());
auto ptls = target->getArgOperand(0);
CallInst *newI;
if (offset < 0) {
newI = builder.CreateCall(
bigAllocFunc,
{ ptls, ConstantInt::get(getSizeTy(F.getContext()), sz + sizeof(void*)) });
}
else {
auto pool_offs = ConstantInt::get(Type::getInt32Ty(F.getContext()), offset);
auto pool_osize = ConstantInt::get(Type::getInt32Ty(F.getContext()), osize);
newI = builder.CreateCall(poolAllocFunc, { ptls, pool_offs, pool_osize });
Attribute derefAttr;

if (auto CI = dyn_cast<ConstantInt>(target->getArgOperand(1))) {
size_t sz = (size_t)CI->getZExtValue();
// This is strongly architecture and OS dependent
int osize;
int offset = jl_gc_classify_pools(sz, &osize);
if (offset < 0) {
newI = builder.CreateCall(
bigAllocFunc,
{ ptls, ConstantInt::get(getSizeTy(F.getContext()), sz + sizeof(void*)) });
derefAttr = Attribute::getWithDereferenceableBytes(F.getContext(), sz + sizeof(void*));
}
else {
auto pool_offs = ConstantInt::get(Type::getInt32Ty(F.getContext()), offset);
auto pool_osize = ConstantInt::get(Type::getInt32Ty(F.getContext()), osize);
newI = builder.CreateCall(poolAllocFunc, { ptls, pool_offs, pool_osize });
derefAttr = Attribute::getWithDereferenceableBytes(F.getContext(), osize);
}
} else {
auto size = builder.CreateZExtOrTrunc(target->getArgOperand(1), getSizeTy(F.getContext()));
size = builder.CreateAdd(size, ConstantInt::get(getSizeTy(F.getContext()), sizeof(void*)));
newI = builder.CreateCall(allocTypedFunc, { ptls, size, ConstantPointerNull::get(Type::getInt8PtrTy(F.getContext())) });
derefAttr = Attribute::getWithDereferenceableBytes(F.getContext(), sizeof(void*));
}
newI->setAttributes(newI->getCalledFunction()->getAttributes());
newI->takeName(target);
Expand All @@ -237,8 +250,9 @@ bool FinalLowerGC::doInitialization(Module &M) {
queueBindingFunc = getOrDeclare(jl_well_known::GCQueueBinding);
poolAllocFunc = getOrDeclare(jl_well_known::GCPoolAlloc);
bigAllocFunc = getOrDeclare(jl_well_known::GCBigAlloc);
allocTypedFunc = getOrDeclare(jl_well_known::GCAllocTyped);

GlobalValue *functionList[] = {queueRootFunc, queueBindingFunc, poolAllocFunc, bigAllocFunc};
GlobalValue *functionList[] = {queueRootFunc, queueBindingFunc, poolAllocFunc, bigAllocFunc, allocTypedFunc};
unsigned j = 0;
for (unsigned i = 0; i < sizeof(functionList) / sizeof(void*); i++) {
if (!functionList[i])
Expand All @@ -254,8 +268,8 @@ bool FinalLowerGC::doInitialization(Module &M) {

bool FinalLowerGC::doFinalization(Module &M)
{
GlobalValue *functionList[] = {queueRootFunc, queueBindingFunc, poolAllocFunc, bigAllocFunc};
queueRootFunc = queueBindingFunc = poolAllocFunc = bigAllocFunc = nullptr;
GlobalValue *functionList[] = {queueRootFunc, queueBindingFunc, poolAllocFunc, bigAllocFunc, allocTypedFunc};
queueRootFunc = queueBindingFunc = poolAllocFunc = bigAllocFunc = allocTypedFunc = nullptr;
auto used = M.getGlobalVariable("llvm.compiler.used");
if (!used)
return false;
Expand Down
19 changes: 19 additions & 0 deletions src/llvm-pass-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ namespace jl_well_known {
static const char *GC_POOL_ALLOC_NAME = XSTR(jl_gc_pool_alloc);
static const char *GC_QUEUE_ROOT_NAME = XSTR(jl_gc_queue_root);
static const char *GC_QUEUE_BINDING_NAME = XSTR(jl_gc_queue_binding);
static const char *GC_ALLOC_TYPED_NAME = XSTR(jl_gc_alloc_typed);

using jl_intrinsics::addGCAllocAttributes;

Expand Down Expand Up @@ -292,4 +293,22 @@ namespace jl_well_known {
func->addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
return func;
});

const WellKnownFunctionDescription GCAllocTyped(
GC_ALLOC_TYPED_NAME,
[](const JuliaPassContext &context) {
auto allocTypedFunc = Function::Create(
FunctionType::get(
context.T_prjlvalue,
{ Type::getInt8PtrTy(context.getLLVMContext()),
sizeof(size_t) == sizeof(uint32_t) ?
Type::getInt32Ty(context.getLLVMContext()) :
Type::getInt64Ty(context.getLLVMContext()),
Type::getInt8PtrTy(context.getLLVMContext()) },
false),
Function::ExternalLinkage,
GC_ALLOC_TYPED_NAME);
allocTypedFunc->addFnAttr(Attribute::getWithAllocSizeArgs(context.getLLVMContext(), 1, None));
return addGCAllocAttributes(allocTypedFunc, context.getLLVMContext());
});
}
3 changes: 3 additions & 0 deletions src/llvm-pass-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ namespace jl_well_known {

// `jl_gc_queue_binding`: queues a binding for GC.
extern const WellKnownFunctionDescription GCQueueBinding;

// `jl_gc_alloc_typed`: allocates bytes.
extern const WellKnownFunctionDescription GCAllocTyped;
}

#endif
15 changes: 15 additions & 0 deletions test/llvmpasses/final-lower-gc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ top:
ret {} addrspace(10)* %v
}

define {} addrspace(10)* @gc_alloc_lowering_var(i64 %size) {
top:
; CHECK-LABEL: @gc_alloc_lowering_var
%pgcstack = call {}*** @julia.get_pgcstack()
%ptls = call {}*** @julia.ptls_states()
%ptls_i8 = bitcast {}*** %ptls to i8*
; CHECK: %0 = add i64 %size, 8
; CHECK: %v = call noalias nonnull {} addrspace(10)* @ijl_gc_alloc_typed(i8* %ptls_i8, i64 %0, i8* null)
%v = call {} addrspace(10)* @julia.gc_alloc_bytes(i8* %ptls_i8, i64 %size)
%0 = bitcast {} addrspace(10)* %v to {} addrspace(10)* addrspace(10)*
%1 = getelementptr {} addrspace(10)*, {} addrspace(10)* addrspace(10)* %0, i64 -1
store {} addrspace(10)* @tag, {} addrspace(10)* addrspace(10)* %1, align 8, !tbaa !0
ret {} addrspace(10)* %v
}

!0 = !{!1, !1, i64 0}
!1 = !{!"jtbaa_gcframe", !2, i64 0}
!2 = !{!"jtbaa"}