inconsistant/non uniform traitement of global and param
u32 x = 2;
param int x = 1;
export fn f_param() -> reg u32 {
reg u32 r;
r = x;
return r;
}
param int y = 1;
u32 y = 2;
export fn f_global() -> reg u32 {
reg u32 r;
r = y;
return r;
}
both functions return 1; I think f_global should return 2.
/* -------------------------------------------------------------------- / / After param expansion */
global u32 x.177 = 0X2;
global u32 y.176 = 0X2; export fn f_param () -> (reg u32) { reg u32 r.179;
r.179 = ((32u) 1); /* u32 */ return (r.179); }
export fn f_global () -> (reg u32) { reg u32 r.178;
r.178 = ((32u) 1); /* u32 */ return (r.178); }
Compiling with version 2023.06.3 produces the following warnings:
"bug_604.jazz", line 2 (10-11) warning: the variable x is already declared at "bug_604.jazz", line 1 (4-5) "bug_604.jazz", line 11 (4-5) warning: the variable y is already declared at "bug_604.jazz", line 10 (10-11)
Moreover, the generated assembly is as follows:
f_global:
movl glob_data + 0(%rip), %eax
ret
f_param:
movl $1, %eax
ret
.data
.p2align 5
glob_data:
.byte 2
.byte 0
.byte 0
.byte 0
So function f_global reads from the global y and returns 2, whereas f_param returns 1 (i.e., the value of the parameter ’x`).