@@ -1777,6 +1777,14 @@ static void jl_init_function(Function *F)
1777
1777
#ifdef JL_DISABLE_FPO
1778
1778
F->addFnAttr (" frame-pointer" , " all" );
1779
1779
#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
1780
1788
}
1781
1789
1782
1790
static std::pair<bool , bool > uses_specsig (jl_method_instance_t *lam, jl_value_t *rettype, bool prefer_specsig)
@@ -6488,28 +6496,15 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6488
6496
}
6489
6497
}
6490
6498
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
6499
+ // step 6. set up GC frame
6505
6500
allocate_gc_frame (ctx, b0);
6506
6501
Value *last_age = NULL ;
6507
6502
emit_last_age_field (ctx);
6508
6503
if (toplevel || ctx.is_opaque_closure ) {
6509
6504
last_age = tbaa_decorate (tbaa_gcframe, ctx.builder .CreateAlignedLoad (ctx.world_age_field , Align (sizeof (size_t ))));
6510
6505
}
6511
6506
6512
- // step 8 . allocate local variables slots
6507
+ // step 7 . allocate local variables slots
6513
6508
// must be in the first basic block for the llvm mem2reg pass to work
6514
6509
auto allocate_local = [&](jl_varinfo_t &varinfo, jl_sym_t *s) {
6515
6510
jl_value_t *jt = varinfo.value .typ ;
@@ -6627,7 +6622,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6627
6622
}
6628
6623
}
6629
6624
6630
- // step 9 . move args into local variables
6625
+ // step 8 . move args into local variables
6631
6626
Function::arg_iterator AI = f->arg_begin ();
6632
6627
6633
6628
auto get_specsig_arg = [&](jl_value_t *argType, Type *llvmArgType, bool isboxed) {
@@ -6757,7 +6752,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6757
6752
}
6758
6753
}
6759
6754
6760
- // step 10 . allocate rest argument
6755
+ // step 9 . allocate rest argument
6761
6756
CallInst *restTuple = NULL ;
6762
6757
if (va && ctx.vaSlot != -1 ) {
6763
6758
jl_varinfo_t &vi = ctx.slots [ctx.vaSlot ];
@@ -6799,7 +6794,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6799
6794
}
6800
6795
}
6801
6796
6802
- // step 11 . Compute properties for each statements
6797
+ // step 10 . Compute properties for each statements
6803
6798
// This needs to be computed by iterating in the IR order
6804
6799
// instead of control flow order.
6805
6800
auto in_user_mod = [] (jl_module_t *mod) {
@@ -6921,7 +6916,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6921
6916
Instruction &prologue_end = ctx.builder .GetInsertBlock ()->back ();
6922
6917
6923
6918
6924
- // step 12 . Do codegen in control flow order
6919
+ // step 11 . Do codegen in control flow order
6925
6920
std::vector<int > workstack;
6926
6921
std::map<int , BasicBlock*> BB;
6927
6922
std::map<size_t , BasicBlock*> come_from_bb;
@@ -7468,7 +7463,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
7468
7463
PN->eraseFromParent ();
7469
7464
}
7470
7465
7471
- // step 13 . Perform any delayed instantiations
7466
+ // step 12 . Perform any delayed instantiations
7472
7467
if (ctx.debug_enabled ) {
7473
7468
bool in_prologue = true ;
7474
7469
for (auto &BB : *ctx.f ) {
0 commit comments