Skip to content

Commit

Permalink
Revert "Improve performance of toplevel code (#47578)"
Browse files Browse the repository at this point in the history
This reverts commit 526cbf7.
  • Loading branch information
vchuravy committed Nov 19, 2022
1 parent 1d8f7e0 commit d7e2d11
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7786,6 +7786,13 @@ static jl_llvm_functions_t
ctx.builder.SetInsertPoint(tryblk);
}
else {
if (!jl_is_method(ctx.linfo->def.method) && !ctx.is_opaque_closure) {
// TODO: inference is invalid if this has any effect (which it often does)
LoadInst *world = ctx.builder.CreateAlignedLoad(getSizeTy(ctx.builder.getContext()),
prepare_global_in(jl_Module, jlgetworld_global), Align(sizeof(size_t)));
world->setOrdering(AtomicOrdering::Acquire);
ctx.builder.CreateAlignedStore(world, world_age_field, Align(sizeof(size_t)));
}
emit_stmtpos(ctx, stmt, cursor);
mallocVisitStmt(debuginfoloc, nullptr);
}
Expand Down Expand Up @@ -8011,12 +8018,12 @@ static jl_llvm_functions_t
}

// step 12. Perform any delayed instantiations
bool in_prologue = true;
for (auto &BB : *ctx.f) {
for (auto &I : BB) {
CallBase *call = dyn_cast<CallBase>(&I);
if (call) {
if (ctx.debug_enabled && !I.getDebugLoc()) {
if (ctx.debug_enabled) {
bool in_prologue = true;
for (auto &BB : *ctx.f) {
for (auto &I : BB) {
CallBase *call = dyn_cast<CallBase>(&I);
if (call && !I.getDebugLoc()) {
// LLVM Verifier: inlinable function call in a function with debug info must have a !dbg location
// make sure that anything we attempt to call has some inlining info, just in case optimization messed up
// (except if we know that it is an intrinsic used in our prologue, which should never have its own debug subprogram)
Expand All @@ -8025,24 +8032,12 @@ static jl_llvm_functions_t
I.setDebugLoc(topdebugloc);
}
}
if (toplevel && !ctx.is_opaque_closure && !in_prologue) {
// we're at toplevel; insert an atomic barrier between every instruction
// TODO: inference is invalid if this has any effect (which it often does)
LoadInst *load_world = new LoadInst(getSizeTy(ctx.builder.getContext()),
prepare_global_in(jl_Module, jlgetworld_global), Twine(),
/*isVolatile*/false, Align(sizeof(size_t)), /*insertBefore*/&I);
load_world->setOrdering(AtomicOrdering::Monotonic);
StoreInst *store_world = new StoreInst(load_world, world_age_field,
/*isVolatile*/false, Align(sizeof(size_t)), /*insertBefore*/&I);
(void)store_world;
}
if (&I == &prologue_end)
in_prologue = false;
}
if (&I == &prologue_end)
in_prologue = false;
}
}
if (ctx.debug_enabled)
dbuilder.finalize();
}

if (ctx.vaSlot > 0) {
// remove VA allocation if we never referenced it
Expand Down

0 comments on commit d7e2d11

Please sign in to comment.