Skip to content

Commit b03400b

Browse files
committed
fix #922
1 parent 024068a commit b03400b

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/cgutils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ static Value *emit_array_nd_index(Value *a, size_t nd, jl_value_t **args,
581581

582582
ctx->f->getBasicBlockList().push_back(failBB);
583583
builder.SetInsertPoint(failBB);
584-
builder.CreateCall(jlraise_func, builder.CreateLoad(jlboundserr_var));
584+
builder.CreateCall2(jlraise_line_func, builder.CreateLoad(jlboundserr_var),
585+
ConstantInt::get(T_int32, ctx->lineno));
585586
builder.CreateUnreachable();
586587

587588
ctx->f->getBasicBlockList().push_back(endBB);

src/codegen.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ static GlobalVariable *jlboundserr_var;
108108
// important functions
109109
static Function *jlnew_func;
110110
static Function *jlraise_func;
111+
static Function *jlraise_line_func;
111112
static Function *jlerror_func;
112113
static Function *jltypeerror_func;
113114
static Function *jlcheckassign_func;
@@ -331,6 +332,7 @@ typedef struct {
331332
jl_sym_t *vaName; // name of vararg argument
332333
bool vaStack; // varargs stack-allocated
333334
int nReqArgs;
335+
int lineno;
334336
} jl_codectx_t;
335337

336338
static Value *emit_expr(jl_value_t *expr, jl_codectx_t *ctx, bool boxed=true,
@@ -1913,6 +1915,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
19131915
filename = ((jl_sym_t*)jl_exprarg(stmt, 1))->name;
19141916
}
19151917
}
1918+
ctx.lineno = lno;
19161919

19171920
// TODO: Fix when moving to new LLVM version
19181921
dbuilder->createCompileUnit(0x01, filename, ".", "julia", true, "", 0);
@@ -2213,10 +2216,12 @@ static Function *emit_function(jl_lambda_info_t *lam)
22132216
if (jl_is_linenode(stmt)) {
22142217
int lno = jl_linenode_line(stmt);
22152218
builder.SetCurrentDebugLocation(DebugLoc::get(lno, 1, (MDNode*)SP, NULL));
2219+
ctx.lineno = lno;
22162220
}
22172221
else if (jl_is_expr(stmt) && ((jl_expr_t*)stmt)->head == line_sym) {
22182222
int lno = jl_unbox_long(jl_exprarg(stmt, 0));
22192223
builder.SetCurrentDebugLocation(DebugLoc::get(lno, 1, (MDNode*)SP, NULL));
2224+
ctx.lineno = lno;
22202225
}
22212226
if (jl_is_labelnode(stmt)) {
22222227
if (prevlabel) continue;
@@ -2430,6 +2435,14 @@ static void init_julia_llvm_env(Module *m)
24302435
jlraise_func->setDoesNotReturn();
24312436
jl_ExecutionEngine->addGlobalMapping(jlraise_func, (void*)&jl_raise);
24322437

2438+
std::vector<Type*> args2_raise(0);
2439+
args2_raise.push_back(jl_pvalue_llvmt);
2440+
args2_raise.push_back(T_int32);
2441+
jlraise_line_func =
2442+
(Function*)jl_Module->getOrInsertFunction("jl_raise_with_superfluous_argument",
2443+
FunctionType::get(T_void, args2_raise, false));
2444+
jlraise_line_func->setDoesNotReturn();
2445+
24332446
jlnew_func =
24342447
Function::Create(FunctionType::get(jl_pvalue_llvmt, args1_, false),
24352448
Function::ExternalLinkage,

src/julia.expmap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@
168168
jl_ptr_to_array_1d;
169169
jl_readdir;
170170
jl_readuntil;
171+
jl_raise;
172+
jl_raise_with_superfluous_argument;
171173
jl_register_toplevel_eh;
172174
jl_reshape_array;
173175
jl_restore_system_image;

src/task.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,11 @@ void jl_raise(jl_value_t *e)
555555
jl_exit(1);
556556
}
557557

558+
DLLEXPORT void jl_raise_with_superfluous_argument(jl_value_t *e, int line)
559+
{
560+
jl_raise(e);
561+
}
562+
558563
jl_task_t *jl_new_task(jl_function_t *start, size_t ssize)
559564
{
560565
size_t pagesz = jl_page_size;

0 commit comments

Comments
 (0)