Skip to content

Commit 7da505b

Browse files
committed
Revert "add stack-probes to make stack-overflow detection more reliable (#40068)"
This reverts commit c0f8aef.
1 parent 92c84bf commit 7da505b

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/codegen.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,14 +1777,6 @@ static void jl_init_function(Function *F)
17771777
#ifdef JL_DISABLE_FPO
17781778
F->addFnAttr("frame-pointer", "all");
17791779
#endif
1780-
#if !defined(_COMPILER_ASAN_ENABLED_) && !defined(_OS_WINDOWS_)
1781-
// ASAN won't like us accessing undefined memory causing spurious issues,
1782-
// and Windows has platform-specific handling which causes it to mishandle
1783-
// this annotation. Other platforms should just ignore this if they don't
1784-
// implement it.
1785-
F->addFnAttr("probe-stack", "inline-asm");
1786-
//F->addFnAttr("stack-probe-size", 4096); // can use this to change the default
1787-
#endif
17881780
}
17891781

17901782
static std::pair<bool, bool> uses_specsig(jl_method_instance_t *lam, jl_value_t *rettype, bool prefer_specsig)
@@ -6496,15 +6488,28 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
64966488
}
64976489
}
64986490

6499-
// step 6. set up GC frame
6491+
/*
6492+
// step 6. (optional) check for stack overflow (the slower way)
6493+
Value *cur_sp =
6494+
ctx.builder.CreateCall(Intrinsic::getDeclaration(M,
6495+
Intrinsic::frameaddress),
6496+
ConstantInt::get(T_int32, 0));
6497+
Value *sp_ok =
6498+
ctx.builder.CreateICmpUGT(cur_sp,
6499+
ConstantInt::get(T_size,
6500+
(uptrint_t)jl_stack_lo));
6501+
error_unless(ctx, sp_ok, "stack overflow");
6502+
*/
6503+
6504+
// step 7. set up GC frame
65006505
allocate_gc_frame(ctx, b0);
65016506
Value *last_age = NULL;
65026507
emit_last_age_field(ctx);
65036508
if (toplevel || ctx.is_opaque_closure) {
65046509
last_age = tbaa_decorate(tbaa_gcframe, ctx.builder.CreateAlignedLoad(ctx.world_age_field, Align(sizeof(size_t))));
65056510
}
65066511

6507-
// step 7. allocate local variables slots
6512+
// step 8. allocate local variables slots
65086513
// must be in the first basic block for the llvm mem2reg pass to work
65096514
auto allocate_local = [&](jl_varinfo_t &varinfo, jl_sym_t *s) {
65106515
jl_value_t *jt = varinfo.value.typ;
@@ -6622,7 +6627,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
66226627
}
66236628
}
66246629

6625-
// step 8. move args into local variables
6630+
// step 9. move args into local variables
66266631
Function::arg_iterator AI = f->arg_begin();
66276632

66286633
auto get_specsig_arg = [&](jl_value_t *argType, Type *llvmArgType, bool isboxed) {
@@ -6752,7 +6757,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
67526757
}
67536758
}
67546759

6755-
// step 9. allocate rest argument
6760+
// step 10. allocate rest argument
67566761
CallInst *restTuple = NULL;
67576762
if (va && ctx.vaSlot != -1) {
67586763
jl_varinfo_t &vi = ctx.slots[ctx.vaSlot];
@@ -6794,7 +6799,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
67946799
}
67956800
}
67966801

6797-
// step 10. Compute properties for each statements
6802+
// step 11. Compute properties for each statements
67986803
// This needs to be computed by iterating in the IR order
67996804
// instead of control flow order.
68006805
auto in_user_mod = [] (jl_module_t *mod) {
@@ -6916,7 +6921,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
69166921
Instruction &prologue_end = ctx.builder.GetInsertBlock()->back();
69176922

69186923

6919-
// step 11. Do codegen in control flow order
6924+
// step 12. Do codegen in control flow order
69206925
std::vector<int> workstack;
69216926
std::map<int, BasicBlock*> BB;
69226927
std::map<size_t, BasicBlock*> come_from_bb;
@@ -7463,7 +7468,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
74637468
PN->eraseFromParent();
74647469
}
74657470

7466-
// step 12. Perform any delayed instantiations
7471+
// step 13. Perform any delayed instantiations
74677472
if (ctx.debug_enabled) {
74687473
bool in_prologue = true;
74697474
for (auto &BB : *ctx.f) {

test/llvmpasses/noinline.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ include(joinpath("..", "testhelpers", "llvmpasses.jl"))
1717
return A + B
1818
end
1919

20-
# CHECK: attributes #{{[0-9]+}} = {{{[^}]*}} noinline {{[^}]*}}}
20+
# CHECK: attributes #{{[0-9]+}} = {{{([a-z]+ )*}} noinline {{([a-z]+ )*}}}
2121
emit(simple_noinline, Float64, Float64)

0 commit comments

Comments
 (0)