mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 23:52:31 +00:00
disable byval
This commit is contained in:
parent
e311cd562b
commit
472b7ef7e6
@ -326,13 +326,6 @@ static void addLLVMArgAttr(LLVMValueRef arg_val, unsigned param_index, const cha
|
||||
return addLLVMAttr(arg_val, param_index + 1, attr_name);
|
||||
}
|
||||
|
||||
static void addLLVMCallsiteAttr(LLVMValueRef call_instr, unsigned param_index, const char *attr_name) {
|
||||
unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name, strlen(attr_name));
|
||||
assert(kind_id != 0);
|
||||
LLVMAttributeRef llvm_attr = LLVMCreateEnumAttribute(LLVMGetGlobalContext(), kind_id, 0);
|
||||
LLVMAddCallSiteAttribute(call_instr, param_index + 1, llvm_attr);
|
||||
}
|
||||
|
||||
static bool is_symbol_available(CodeGen *g, Buf *name) {
|
||||
return g->exported_symbol_names.maybe_get(name) == nullptr && g->external_prototypes.maybe_get(name) == nullptr;
|
||||
}
|
||||
@ -581,11 +574,6 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
|
||||
if (param_type->id == TypeTableEntryIdPointer) {
|
||||
addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "nonnull");
|
||||
}
|
||||
// Note: byval is disabled on windows due to an LLVM bug:
|
||||
// https://github.com/ziglang/zig/issues/536
|
||||
if (is_byval && g->zig_target.os != OsWindows) {
|
||||
addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "byval");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t err_ret_trace_arg_index = get_err_ret_trace_arg_index(g, fn_table_entry);
|
||||
@ -3114,15 +3102,6 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
|
||||
}
|
||||
|
||||
|
||||
for (size_t param_i = 0; param_i < fn_type_id->param_count; param_i += 1) {
|
||||
FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i];
|
||||
// Note: byval is disabled on windows due to an LLVM bug:
|
||||
// https://github.com/ziglang/zig/issues/536
|
||||
if (gen_info->is_byval && g->zig_target.os != OsWindows) {
|
||||
addLLVMCallsiteAttr(result, (unsigned)gen_info->gen_index, "byval");
|
||||
}
|
||||
}
|
||||
|
||||
if (instruction->is_async) {
|
||||
LLVMValueRef payload_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr, err_union_payload_index, "");
|
||||
LLVMBuildStore(g->builder, result, payload_ptr);
|
||||
|
@ -13,6 +13,7 @@ comptime {
|
||||
_ = @import("cases/bugs/656.zig");
|
||||
_ = @import("cases/bugs/828.zig");
|
||||
_ = @import("cases/bugs/920.zig");
|
||||
_ = @import("cases/byval_arg_var.zig");
|
||||
_ = @import("cases/cast.zig");
|
||||
_ = @import("cases/const_slice_child.zig");
|
||||
_ = @import("cases/coroutines.zig");
|
||||
|
27
test/cases/byval_arg_var.zig
Normal file
27
test/cases/byval_arg_var.zig
Normal file
@ -0,0 +1,27 @@
|
||||
const std = @import("std");
|
||||
|
||||
var result: []const u8 = "wrong";
|
||||
|
||||
test "aoeu" {
|
||||
start();
|
||||
blowUpStack(10);
|
||||
|
||||
std.debug.assert(std.mem.eql(u8, result, "string literal"));
|
||||
}
|
||||
|
||||
fn start() void {
|
||||
foo("string literal");
|
||||
}
|
||||
|
||||
fn foo(x: var) void {
|
||||
bar(x);
|
||||
}
|
||||
|
||||
fn bar(x: var) void {
|
||||
result = x;
|
||||
}
|
||||
|
||||
fn blowUpStack(x: u32) void {
|
||||
if (x == 0) return;
|
||||
blowUpStack(x - 1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user