@@ -1719,6 +1719,14 @@ static void jl_init_function(Function *F)
1719
1719
F->addFnAttr (" no-frame-pointer-elim" , " true" );
1720
1720
#endif
1721
1721
#endif
1722
+ #if JL_LLVM_VERSION >= 110000 && !defined(JL_ASAN_ENABLED) && !defined(_OS_WINDOWS_)
1723
+ // ASAN won't like us accessing undefined memory causing spurious issues,
1724
+ // and Windows has platform-specific handling which causes it to mishandle
1725
+ // this annotation. Other platforms should just ignore this if they don't
1726
+ // implement it.
1727
+ F->addFnAttr (" probe-stack" , " inline-asm" );
1728
+ // F->addFnAttr("stack-probe-size", 4096); // can use this to change the default
1729
+ #endif
1722
1730
}
1723
1731
1724
1732
static std::pair<bool , bool > uses_specsig (jl_method_instance_t *lam, jl_value_t *rettype, bool prefer_specsig)
@@ -6297,28 +6305,15 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6297
6305
}
6298
6306
}
6299
6307
6300
- /*
6301
- // step 6. (optional) check for stack overflow (the slower way)
6302
- Value *cur_sp =
6303
- ctx.builder.CreateCall(Intrinsic::getDeclaration(M,
6304
- Intrinsic::frameaddress),
6305
- ConstantInt::get(T_int32, 0));
6306
- Value *sp_ok =
6307
- ctx.builder.CreateICmpUGT(cur_sp,
6308
- ConstantInt::get(T_size,
6309
- (uptrint_t)jl_stack_lo));
6310
- error_unless(ctx, sp_ok, "stack overflow");
6311
- */
6312
-
6313
- // step 7. set up GC frame
6308
+ // step 6. set up GC frame
6314
6309
allocate_gc_frame (ctx, b0);
6315
6310
Value *last_age = NULL ;
6316
6311
emit_last_age_field (ctx);
6317
6312
if (toplevel || ctx.is_opaque_closure ) {
6318
6313
last_age = tbaa_decorate (tbaa_gcframe, ctx.builder .CreateAlignedLoad (ctx.world_age_field , Align (sizeof (size_t ))));
6319
6314
}
6320
6315
6321
- // step 8 . allocate local variables slots
6316
+ // step 7 . allocate local variables slots
6322
6317
// must be in the first basic block for the llvm mem2reg pass to work
6323
6318
auto allocate_local = [&](jl_varinfo_t &varinfo, jl_sym_t *s) {
6324
6319
jl_value_t *jt = varinfo.value .typ ;
@@ -6436,7 +6431,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6436
6431
}
6437
6432
}
6438
6433
6439
- // step 9 . move args into local variables
6434
+ // step 8 . move args into local variables
6440
6435
Function::arg_iterator AI = f->arg_begin ();
6441
6436
6442
6437
auto get_specsig_arg = [&](jl_value_t *argType, Type *llvmArgType, bool isboxed) {
@@ -6566,7 +6561,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6566
6561
}
6567
6562
}
6568
6563
6569
- // step 10 . allocate rest argument
6564
+ // step 9 . allocate rest argument
6570
6565
CallInst *restTuple = NULL ;
6571
6566
if (va && ctx.vaSlot != -1 ) {
6572
6567
jl_varinfo_t &vi = ctx.slots [ctx.vaSlot ];
@@ -6608,7 +6603,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6608
6603
}
6609
6604
}
6610
6605
6611
- // step 11 . Compute properties for each statements
6606
+ // step 10 . Compute properties for each statements
6612
6607
// This needs to be computed by iterating in the IR order
6613
6608
// instead of control flow order.
6614
6609
auto in_user_mod = [] (jl_module_t *mod) {
@@ -6730,7 +6725,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
6730
6725
Instruction &prologue_end = ctx.builder .GetInsertBlock ()->back ();
6731
6726
6732
6727
6733
- // step 12 . Do codegen in control flow order
6728
+ // step 11 . Do codegen in control flow order
6734
6729
std::vector<int > workstack;
6735
6730
std::map<int , BasicBlock*> BB;
6736
6731
std::map<size_t , BasicBlock*> come_from_bb;
@@ -7288,7 +7283,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
7288
7283
PN->eraseFromParent ();
7289
7284
}
7290
7285
7291
- // step 13 . Perform any delayed instantiations
7286
+ // step 12 . Perform any delayed instantiations
7292
7287
if (ctx.debug_enabled ) {
7293
7288
bool in_prologue = true ;
7294
7289
for (auto &BB : *ctx.f ) {
0 commit comments