authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-04 18:43:31+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-04 18:43:31+02:00
log389d1177a57a442b7814d9fdede2a088c614b69d
treecde4ee4841a020ece280e0c23634d3abf44a6be7
parent97779442d0a551d96f2a0b1799e96944918af32e

stage1: Fix LLVM error in inline asm invocation

Pointer types need an extra indirection layer during the generation of the function prototype for inline asm blocks. Closes #3606

2 files changed, 18 insertions(+), 1 deletions(-)

src/stage1/codegen.cpp+3-1
......@@ -4880,6 +4880,9 @@ static LLVMValueRef ir_render_asm_gen(CodeGen *g, IrExecutableGen *executable, I
48804880 type_ref = get_llvm_type(g, wider_type);
48814881 value_ref = gen_widen_or_shorten(g, false, type, wider_type, value_ref);
48824882 }
4883 } else if (handle_is_ptr(g, type)) {
4884 ZigType *gen_type = get_pointer_to_type(g, type, true);
4885 type_ref = get_llvm_type(g, gen_type);
48834886 }
48844887
48854888 param_types[param_index] = type_ref;
......@@ -9296,7 +9299,6 @@ static void init(CodeGen *g) {
92969299 char *layout_str = LLVMCopyStringRepOfTargetData(g->target_data_ref);
92979300 LLVMSetDataLayout(g->module, layout_str);
92989301
9299
93009302 assert(g->pointer_size_bytes == LLVMPointerSize(g->target_data_ref));
93019303 g->is_big_endian = (LLVMByteOrder(g->target_data_ref) == LLVMBigEndian);
93029304
test/stage1/behavior/asm.zig+15
......@@ -87,6 +87,21 @@ test "sized integer/float in asm input" {
8787 );
8888}
8989
90test "struct/array/union types as input values" {
91 asm volatile (""
92 :
93 : [_] "m" (@as([1]u32, undefined))
94 ); // fails
95 asm volatile (""
96 :
97 : [_] "m" (@as(struct { x: u32, y: u8 }, undefined))
98 ); // fails
99 asm volatile (""
100 :
101 : [_] "m" (@as(union { x: u32, y: u8 }, undefined))
102 ); // fails
103}
104
90105extern fn this_is_my_alias() i32;
91106
92107export fn derp() i32 {