@@ -298,6 +298,7 @@ extern RTDyldMemoryManager* createRTDyldMemoryManagerOSX();
298
298
// important functions
299
299
static Function *jlnew_func;
300
300
static Function *jlthrow_func;
301
+ static Function *jlthrow_line_func;
301
302
static Function *jlerror_func;
302
303
static Function *jltypeerror_func;
303
304
static Function *jlundefvarerror_func;
@@ -467,6 +468,7 @@ typedef struct {
467
468
bool vaStack; // varargs stack-allocated
468
469
bool sret;
469
470
int nReqArgs;
471
+ int lineno;
470
472
std::vector<bool > boundsCheck;
471
473
472
474
jl_gcinfo_t gc;
@@ -1270,7 +1272,7 @@ extern "C" void jl_write_malloc_log(void)
1270
1272
static void show_source_loc (JL_STREAM *out, jl_codectx_t *ctx)
1271
1273
{
1272
1274
if (ctx == NULL ) return ;
1273
- jl_printf (out, " in %s at %s" , ctx->linfo ->name ->name , ctx->linfo ->file ->name );
1275
+ jl_printf (out, " in %s at %s:%d " , ctx->linfo ->name ->name , ctx->linfo ->file ->name , ctx-> lineno );
1274
1276
}
1275
1277
1276
1278
extern " C" void jl_binding_deprecation_warning (jl_binding_t *b);
@@ -4183,6 +4185,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
4183
4185
}
4184
4186
}
4185
4187
}
4188
+ ctx.lineno = lno;
4186
4189
int toplineno = lno;
4187
4190
4188
4191
DIBuilder dbuilder (*m);
@@ -4194,7 +4197,6 @@ static Function *emit_function(jl_lambda_info_t *lam)
4194
4197
DIFile topfile;
4195
4198
DISubprogram SP;
4196
4199
#endif
4197
- DebugLoc inlineLoc;
4198
4200
4199
4201
BasicBlock *b0 = BasicBlock::Create (jl_LLVMContext, " top" , f);
4200
4202
builder.SetInsertPoint (b0);
@@ -4275,8 +4277,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
4275
4277
f); // Function
4276
4278
#endif
4277
4279
// set initial line number
4278
- inlineLoc = DebugLoc::get (lno, 0 , (MDNode*)SP, NULL );
4279
- builder.SetCurrentDebugLocation (inlineLoc);
4280
+ builder.SetCurrentDebugLocation (DebugLoc::get (lno, 0 , (MDNode*)SP, NULL ));
4280
4281
#ifdef LLVM38
4281
4282
f->setSubprogram (SP);
4282
4283
#endif
@@ -4296,7 +4297,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
4296
4297
argname->name , // Variable name
4297
4298
ctx.sret + i + 1 , // Argument number (1-based)
4298
4299
topfile, // File
4299
- toplineno == -1 ? 0 : toplineno , // Line
4300
+ ctx. lineno == -1 ? 0 : ctx. lineno , // Line
4300
4301
// Variable type
4301
4302
julia_type_to_di (varinfo.declType ,ctx.dbuilder ,specsig));
4302
4303
#else
@@ -4305,7 +4306,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
4305
4306
SP, // Scope (current function will be fill in later)
4306
4307
argname->name , // Variable name
4307
4308
topfile, // File
4308
- toplineno == -1 ? 0 : toplineno , // Line (for now, use lineno of the function)
4309
+ ctx. lineno == -1 ? 0 : ctx. lineno , // Line (for now, use lineno of the function)
4309
4310
julia_type_to_di (varinfo.declType ,ctx.dbuilder ,specsig), // Variable type
4310
4311
false , // May be optimized out
4311
4312
0 , // Flags (TODO: Do we need any)
@@ -4319,15 +4320,15 @@ static Function *emit_function(jl_lambda_info_t *lam)
4319
4320
ctx.vaName ->name , // Variable name
4320
4321
ctx.sret + nreq + 1 , // Argument number (1-based)
4321
4322
topfile, // File
4322
- toplineno == -1 ? 0 : toplineno , // Line (for now, use lineno of the function)
4323
+ ctx. lineno == -1 ? 0 : ctx. lineno , // Line (for now, use lineno of the function)
4323
4324
julia_type_to_di (ctx.vars [ctx.vaName ].declType ,ctx.dbuilder ,false ));
4324
4325
#else
4325
4326
ctx.vars [ctx.vaName ].dinfo = ctx.dbuilder ->createLocalVariable (
4326
4327
llvm::dwarf::DW_TAG_arg_variable, // Tag
4327
4328
SP, // Scope (current function will be fill in later)
4328
4329
ctx.vaName ->name , // Variable name
4329
4330
topfile, // File
4330
- toplineno == -1 ? 0 : toplineno , // Line (for now, use lineno of the function)
4331
+ ctx. lineno == -1 ? 0 : ctx. lineno , // Line (for now, use lineno of the function)
4331
4332
julia_type_to_di (ctx.vars [ctx.vaName ].declType ,ctx.dbuilder ,false ), // Variable type
4332
4333
false , // May be optimized out
4333
4334
0 , // Flags (TODO: Do we need any)
@@ -4348,7 +4349,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
4348
4349
SP, // Scope (current function will be fill in later)
4349
4350
s->name , // Variable name
4350
4351
topfile, // File
4351
- toplineno == -1 ? 0 : toplineno , // Line (for now, use lineno of the function)
4352
+ ctx. lineno == -1 ? 0 : ctx. lineno , // Line (for now, use lineno of the function)
4352
4353
julia_type_to_di (varinfo.declType ,ctx.dbuilder ,specsig), // Variable type
4353
4354
false , // May be optimized out
4354
4355
0 // Flags (TODO: Do we need any)
@@ -4372,7 +4373,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
4372
4373
SP, // Scope (current function will be filled in later)
4373
4374
vname->name , // Variable name
4374
4375
topfile, // File
4375
- toplineno == -1 ? 0 : toplineno , // Line (for now, use lineno of the function)
4376
+ ctx. lineno == -1 ? 0 : ctx. lineno , // Line (for now, use lineno of the function)
4376
4377
julia_type_to_di (varinfo.declType ,ctx.dbuilder ,specsig), // Variable type
4377
4378
false , // May be optimized out
4378
4379
0 // Flags (TODO: Do we need any)
@@ -4738,31 +4739,35 @@ static Function *emit_function(jl_lambda_info_t *lam)
4738
4739
}
4739
4740
DebugLoc loc;
4740
4741
if (ctx.debug_enabled ) {
4742
+ MDNode *funcscope = (MDNode*)dbuilder.createLexicalBlockFile (SP, topfile);
4741
4743
MDNode *scope;
4742
4744
if ((dfil == topfile || dfil == NULL ) &&
4743
4745
lno >= toplineno)
4744
4746
{
4745
4747
// for sequentially-defined code,
4746
4748
// set location to line in top file.
4747
4749
// TODO: improve handling of nested inlines
4748
- loc = inlineLoc = DebugLoc::get (lno, 1 , SP, NULL );
4750
+ loc = DebugLoc::get (lno, 1 , SP, NULL );
4749
4751
} else {
4750
4752
// otherwise, we are compiling inlined code,
4751
4753
// so set the DebugLoc "inlinedAt" parameter
4752
4754
// to the current line, then use source loc.
4753
4755
#ifdef LLVM37
4754
4756
scope = (MDNode*)dbuilder.createLexicalBlockFile (SP,dfil);
4755
- MDNode *inlineLocMd = inlineLoc.getAsMDNode ();
4757
+ MDNode *inlineLocMd = DebugLoc::get (toplineno, 1 , funcscope, NULL ).
4758
+ getAsMDNode ();
4756
4759
#else
4757
4760
scope = (MDNode*)dbuilder.createLexicalBlockFile (SP,DIFile (dfil));
4758
- MDNode *inlineLocMd = inlineLoc.getAsMDNode (jl_LLVMContext);
4761
+ MDNode *inlineLocMd = DebugLoc::get (toplineno, 1 , funcscope, NULL ).
4762
+ getAsMDNode (jl_LLVMContext);
4759
4763
#endif
4760
4764
loc = DebugLoc::get (lno, 1 , scope, inlineLocMd);
4761
4765
}
4762
4766
builder.SetCurrentDebugLocation (loc);
4763
4767
}
4764
4768
if (do_coverage)
4765
4769
coverageVisitLine (filename, lno);
4770
+ ctx.lineno = lno; // NOO TOUCHIE; NO TOUCH! See #922
4766
4771
}
4767
4772
if (jl_is_labelnode (stmt)) {
4768
4773
if (prevlabel) continue ;
@@ -5201,6 +5206,15 @@ static void init_julia_llvm_env(Module *m)
5201
5206
jluboundserror_func->setDoesNotReturn ();
5202
5207
add_named_global (jluboundserror_func, (void *)&jl_bounds_error_unboxed_int);
5203
5208
5209
+ std::vector<Type*> args2_throw (0 );
5210
+ args2_throw.push_back (jl_pvalue_llvmt);
5211
+ args2_throw.push_back (T_int32);
5212
+ jlthrow_line_func =
5213
+ (Function*)m->getOrInsertFunction (" jl_throw_with_superfluous_argument" ,
5214
+ FunctionType::get (T_void, args2_throw, false ));
5215
+ jlthrow_line_func->setDoesNotReturn ();
5216
+ add_named_global (jlthrow_line_func, (void *)&jl_throw_with_superfluous_argument);
5217
+
5204
5218
jlnew_func =
5205
5219
Function::Create (jl_func_sig, Function::ExternalLinkage,
5206
5220
" jl_new_structv" , m);
@@ -5231,12 +5245,13 @@ static void init_julia_llvm_env(Module *m)
5231
5245
te_args.push_back (T_pint8);
5232
5246
te_args.push_back (jl_pvalue_llvmt);
5233
5247
te_args.push_back (jl_pvalue_llvmt);
5248
+ te_args.push_back (T_int32);
5234
5249
jltypeerror_func =
5235
5250
Function::Create (FunctionType::get (T_void, te_args, false ),
5236
5251
Function::ExternalLinkage,
5237
- " jl_type_error_rt " , m);
5252
+ " jl_type_error_rt_line " , m);
5238
5253
jltypeerror_func->setDoesNotReturn ();
5239
- add_named_global (jltypeerror_func, (void *)&jl_type_error_rt );
5254
+ add_named_global (jltypeerror_func, (void *)&jl_type_error_rt_line );
5240
5255
5241
5256
std::vector<Type *> args_2ptrs (0 );
5242
5257
args_2ptrs.push_back (jl_pvalue_llvmt);
@@ -5678,16 +5693,13 @@ static inline SmallVector<std::string,10> getTargetFeatures() {
5678
5693
5679
5694
extern " C" void jl_init_codegen (void )
5680
5695
{
5681
- const char *const argv_tailmerge[] = {" " , " -enable-tail-merge=0" }; // NOO TOUCHIE; NO TOUCH! See #922
5682
- cl::ParseCommandLineOptions (sizeof (argv_tailmerge)/sizeof (argv_tailmerge[0 ]), argv_tailmerge, " disable-tail-merge\n " );
5683
5696
#if defined(_OS_WINDOWS_) && defined(_CPU_X86_64_)
5684
- const char *const argv_copyprop [] = {" " , " -disable-copyprop" }; // llvm bug 21743
5685
- cl::ParseCommandLineOptions (sizeof (argv_copyprop )/sizeof (argv_copyprop [0 ]), argv_copyprop , " disable-copyprop\n " );
5697
+ const char *const argv [] = {" " , " -disable-copyprop" }; // llvm bug 21743
5698
+ cl::ParseCommandLineOptions (sizeof (argv )/sizeof (argv [0 ]), argv , " disable-copyprop\n " );
5686
5699
#endif
5687
5700
#ifdef JL_DEBUG_BUILD
5688
5701
cl::ParseEnvironmentOptions (" Julia" , " JULIA_LLVM_ARGS" );
5689
5702
#endif
5690
-
5691
5703
#if defined(_CPU_PPC_) || defined(_CPU_PPC64_)
5692
5704
imaging_mode = true ; // LLVM seems to JIT bad TOC tables for the optimizations we attempt in non-imaging_mode
5693
5705
#else
0 commit comments