@@ -981,7 +981,7 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg, LLVMValueRef stack_trace
981
981
msg_arg,
982
982
stack_trace_arg,
983
983
};
984
- ZigLLVMBuildCall(g->builder, fn_val, args, 2, llvm_cc, ZigLLVM_FnInlineAuto , "");
984
+ ZigLLVMBuildCall(g->builder, fn_val, args, 2, llvm_cc, ZigLLVM_CallAttrAuto , "");
985
985
if (!stack_trace_is_llvm_alloca) {
986
986
// The stack trace argument is not in the stack of the caller, so
987
987
// we'd like to set tail call here, but because slices (the type of msg_arg) are
@@ -1201,7 +1201,8 @@ static LLVMValueRef get_return_err_fn(CodeGen *g) {
1201
1201
1202
1202
LLVMPositionBuilderAtEnd(g->builder, dest_non_null_block);
1203
1203
LLVMValueRef args[] = { err_ret_trace_ptr, return_address };
1204
- ZigLLVMBuildCall(g->builder, add_error_return_trace_addr_fn_val, args, 2, get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_FnInlineAlways, "");
1204
+ ZigLLVMBuildCall(g->builder, add_error_return_trace_addr_fn_val, args, 2,
1205
+ get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAlwaysInline, "");
1205
1206
LLVMBuildRetVoid(g->builder);
1206
1207
1207
1208
LLVMPositionBuilderAtEnd(g->builder, prev_block);
@@ -1370,13 +1371,13 @@ static void gen_safety_crash_for_err(CodeGen *g, LLVMValueRef err_val, Scope *sc
1370
1371
err_val,
1371
1372
};
1372
1373
call_instruction = ZigLLVMBuildCall(g->builder, safety_crash_err_fn, args, 2,
1373
- get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_FnInlineAuto , "");
1374
+ get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto , "");
1374
1375
} else {
1375
1376
LLVMValueRef args[] = {
1376
1377
err_val,
1377
1378
};
1378
1379
call_instruction = ZigLLVMBuildCall(g->builder, safety_crash_err_fn, args, 1,
1379
- get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_FnInlineAuto , "");
1380
+ get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto , "");
1380
1381
}
1381
1382
if (!is_llvm_alloca) {
1382
1383
LLVMSetTailCall(call_instruction, true);
@@ -2216,7 +2217,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {
2216
2217
LLVMValueRef addr_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr_val, &ptr_index, 1, "");
2217
2218
LLVMValueRef this_addr_val = LLVMBuildLoad(g->builder, addr_ptr, "");
2218
2219
LLVMValueRef args[] = {dest_stack_trace_ptr, this_addr_val};
2219
- ZigLLVMBuildCall(g->builder, add_error_return_trace_addr_fn_val, args, 2, get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_FnInlineAlways , "");
2220
+ ZigLLVMBuildCall(g->builder, add_error_return_trace_addr_fn_val, args, 2, get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAlwaysInline , "");
2220
2221
LLVMValueRef prev_frames_left = LLVMBuildLoad(g->builder, frames_left_ptr, "");
2221
2222
LLVMValueRef new_frames_left = LLVMBuildNUWSub(g->builder, prev_frames_left, usize_one, "");
2222
2223
LLVMValueRef done_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, new_frames_left, usize_zero, "");
@@ -2253,7 +2254,7 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, IrExecutable *execut
2253
2254
LLVMValueRef my_err_trace_val = get_cur_err_ret_trace_val(g, save_err_ret_addr_instruction->base.scope,
2254
2255
&is_llvm_alloca);
2255
2256
ZigLLVMBuildCall(g->builder, return_err_fn, &my_err_trace_val, 1,
2256
- get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_FnInlineAuto , "");
2257
+ get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto , "");
2257
2258
2258
2259
ZigType *ret_type = g->cur_fn->type_entry->data.fn.fn_type_id.return_type;
2259
2260
if (fn_is_async(g->cur_fn) && codegen_fn_has_err_ret_tracing_arg(g, ret_type)) {
@@ -2297,7 +2298,7 @@ static LLVMValueRef gen_resume(CodeGen *g, LLVMValueRef fn_val, LLVMValueRef tar
2297
2298
LLVMValueRef arg_val = LLVMConstSub(LLVMConstAllOnes(usize_type_ref),
2298
2299
LLVMConstInt(usize_type_ref, resume_id, false));
2299
2300
LLVMValueRef args[] = {target_frame_ptr, arg_val};
2300
- return ZigLLVMBuildCall(g->builder, fn_val, args, 2, LLVMFastCallConv, ZigLLVM_FnInlineAuto , "");
2301
+ return ZigLLVMBuildCall(g->builder, fn_val, args, 2, LLVMFastCallConv, ZigLLVM_CallAttrAuto , "");
2301
2302
}
2302
2303
2303
2304
static LLVMBasicBlockRef gen_suspend_begin(CodeGen *g, const char *name_hint) {
@@ -2424,7 +2425,7 @@ static void gen_async_return(CodeGen *g, IrInstructionReturn *instruction) {
2424
2425
LLVMValueRef my_err_trace_val = get_cur_err_ret_trace_val(g, instruction->base.scope, &is_llvm_alloca);
2425
2426
LLVMValueRef args[] = { dest_trace_ptr, my_err_trace_val };
2426
2427
ZigLLVMBuildCall(g->builder, get_merge_err_ret_traces_fn_val(g), args, 2,
2427
- get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_FnInlineAuto , "");
2428
+ get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto , "");
2428
2429
}
2429
2430
}
2430
2431
@@ -4142,16 +4143,28 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
4142
4143
fn_walk.data.call.gen_param_types = &gen_param_types;
4143
4144
walk_function_params(g, fn_type, &fn_walk);
4144
4145
4145
- ZigLLVM_FnInline fn_inline;
4146
- switch (instruction->fn_inline) {
4147
- case FnInlineAuto:
4148
- fn_inline = ZigLLVM_FnInlineAuto;
4146
+ ZigLLVM_CallAttr call_attr;
4147
+ switch (instruction->modifier) {
4148
+ case CallModifierBuiltin:
4149
+ case CallModifierCompileTime:
4150
+ zig_unreachable();
4151
+ case CallModifierNone:
4152
+ case CallModifierNoAsync:
4153
+ case CallModifierAsync:
4154
+ call_attr = ZigLLVM_CallAttrAuto;
4149
4155
break;
4150
- case FnInlineAlways :
4151
- fn_inline = (instruction->fn_entry == nullptr) ? ZigLLVM_FnInlineAuto : ZigLLVM_FnInlineAlways ;
4156
+ case CallModifierNeverTail :
4157
+ call_attr = ZigLLVM_CallAttrNeverTail ;
4152
4158
break;
4153
- case FnInlineNever:
4154
- fn_inline = ZigLLVM_FnInlineNever;
4159
+ case CallModifierNeverInline:
4160
+ call_attr = ZigLLVM_CallAttrNeverInline;
4161
+ break;
4162
+ case CallModifierAlwaysTail:
4163
+ call_attr = ZigLLVM_CallAttrAlwaysTail;
4164
+ break;
4165
+ case CallModifierAlwaysInline:
4166
+ ir_assert(instruction->fn_entry != nullptr, &instruction->base);
4167
+ call_attr = ZigLLVM_CallAttrAlwaysInline;
4155
4168
break;
4156
4169
}
4157
4170
@@ -4257,7 +4270,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
4257
4270
4258
4271
if (instruction->new_stack == nullptr || instruction->is_async_call_builtin) {
4259
4272
result = ZigLLVMBuildCall(g->builder, fn_val,
4260
- gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, fn_inline , "");
4273
+ gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, call_attr , "");
4261
4274
} else if (instruction->modifier == CallModifierAsync) {
4262
4275
zig_panic("TODO @asyncCall of non-async function");
4263
4276
} else {
@@ -4269,7 +4282,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
4269
4282
}
4270
4283
gen_set_stack_pointer(g, new_stack_addr);
4271
4284
result = ZigLLVMBuildCall(g->builder, fn_val,
4272
- gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, fn_inline , "");
4285
+ gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, call_attr , "");
4273
4286
if (src_return_type->id != ZigTypeIdUnreachable) {
4274
4287
LLVMValueRef stackrestore_fn_val = get_stackrestore_fn_val(g);
4275
4288
LLVMBuildCall(g->builder, stackrestore_fn_val, &old_stack_ref, 1, "");
@@ -4947,7 +4960,7 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable
4947
4960
4948
4961
LLVMValueRef enum_tag_value = ir_llvm_value(g, instruction->target);
4949
4962
return ZigLLVMBuildCall(g->builder, enum_name_function, &enum_tag_value, 1,
4950
- get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_FnInlineAuto , "");
4963
+ get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto , "");
4951
4964
}
4952
4965
4953
4966
static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executable,
@@ -5903,7 +5916,7 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstruction *source_ins
5903
5916
LLVMValueRef dest_trace_ptr = get_cur_err_ret_trace_val(g, source_instr->scope, &is_llvm_alloca);
5904
5917
LLVMValueRef args[] = { dest_trace_ptr, src_trace_ptr };
5905
5918
ZigLLVMBuildCall(g->builder, get_merge_err_ret_traces_fn_val(g), args, 2,
5906
- get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_FnInlineAuto , "");
5919
+ get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto , "");
5907
5920
}
5908
5921
if (non_async && type_has_bits(result_type)) {
5909
5922
LLVMValueRef result_ptr = (result_loc == nullptr) ? their_result_ptr : result_loc;
@@ -6137,6 +6150,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
6137
6150
case IrInstructionIdLoadPtr:
6138
6151
case IrInstructionIdHasDecl:
6139
6152
case IrInstructionIdUndeclaredIdent:
6153
+ case IrInstructionIdCallExtra:
6140
6154
case IrInstructionIdCallSrc:
6141
6155
case IrInstructionIdAllocaSrc:
6142
6156
case IrInstructionIdEndExpr:
@@ -8146,6 +8160,7 @@ static void define_builtin_fns(CodeGen *g) {
8146
8160
create_builtin_fn(g, BuiltinFnIdFrameAddress, "frameAddress", 0);
8147
8161
create_builtin_fn(g, BuiltinFnIdFrameSize, "frameSize", 1);
8148
8162
create_builtin_fn(g, BuiltinFnIdAs, "as", 2);
8163
+ create_builtin_fn(g, BuiltinFnIdCall, "call", 3);
8149
8164
}
8150
8165
8151
8166
static const char *bool_to_str(bool b) {
0 commit comments