Skip to content

Commit 7ce7ec4

Browse files
authored
Merge branch 'master' into kf/issingletontype
2 parents 38ac198 + 526cbf7 commit 7ce7ec4

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/codegen.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7786,13 +7786,6 @@ static jl_llvm_functions_t
77867786
ctx.builder.SetInsertPoint(tryblk);
77877787
}
77887788
else {
7789-
if (!jl_is_method(ctx.linfo->def.method) && !ctx.is_opaque_closure) {
7790-
// TODO: inference is invalid if this has any effect (which it often does)
7791-
LoadInst *world = ctx.builder.CreateAlignedLoad(getSizeTy(ctx.builder.getContext()),
7792-
prepare_global_in(jl_Module, jlgetworld_global), Align(sizeof(size_t)));
7793-
world->setOrdering(AtomicOrdering::Acquire);
7794-
ctx.builder.CreateAlignedStore(world, world_age_field, Align(sizeof(size_t)));
7795-
}
77967789
emit_stmtpos(ctx, stmt, cursor);
77977790
mallocVisitStmt(debuginfoloc, nullptr);
77987791
}
@@ -8018,12 +8011,12 @@ static jl_llvm_functions_t
80188011
}
80198012

80208013
// step 12. Perform any delayed instantiations
8021-
if (ctx.debug_enabled) {
8022-
bool in_prologue = true;
8023-
for (auto &BB : *ctx.f) {
8024-
for (auto &I : BB) {
8025-
CallBase *call = dyn_cast<CallBase>(&I);
8026-
if (call && !I.getDebugLoc()) {
8014+
bool in_prologue = true;
8015+
for (auto &BB : *ctx.f) {
8016+
for (auto &I : BB) {
8017+
CallBase *call = dyn_cast<CallBase>(&I);
8018+
if (call) {
8019+
if (ctx.debug_enabled && !I.getDebugLoc()) {
80278020
// LLVM Verifier: inlinable function call in a function with debug info must have a !dbg location
80288021
// make sure that anything we attempt to call has some inlining info, just in case optimization messed up
80298022
// (except if we know that it is an intrinsic used in our prologue, which should never have its own debug subprogram)
@@ -8032,12 +8025,24 @@ static jl_llvm_functions_t
80328025
I.setDebugLoc(topdebugloc);
80338026
}
80348027
}
8035-
if (&I == &prologue_end)
8036-
in_prologue = false;
8028+
if (toplevel && !ctx.is_opaque_closure && !in_prologue) {
8029+
// we're at toplevel; insert an atomic barrier between every instruction
8030+
// TODO: inference is invalid if this has any effect (which it often does)
8031+
LoadInst *load_world = new LoadInst(getSizeTy(ctx.builder.getContext()),
8032+
prepare_global_in(jl_Module, jlgetworld_global), Twine(),
8033+
/*isVolatile*/false, Align(sizeof(size_t)), /*insertBefore*/&I);
8034+
load_world->setOrdering(AtomicOrdering::Monotonic);
8035+
StoreInst *store_world = new StoreInst(load_world, world_age_field,
8036+
/*isVolatile*/false, Align(sizeof(size_t)), /*insertBefore*/&I);
8037+
(void)store_world;
8038+
}
80378039
}
8040+
if (&I == &prologue_end)
8041+
in_prologue = false;
80388042
}
8039-
dbuilder.finalize();
80408043
}
8044+
if (ctx.debug_enabled)
8045+
dbuilder.finalize();
80418046

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

0 commit comments

Comments
 (0)