[qfcc] Add failing test for array life

It seems that the optimizer keeps array assignments live when passing
the array as a pointer, but not when passing the address of an element.
Found when testing the following code:

    BasisBlade *pga_blades[16] = {
        blades[1],  blades[2],  blades[3],  blades[4],
        blades[7],  blades[6],  blades[5],  blades[0],
        blades[8],  blades[9],  blades[10], blades[15],
        blades[14], blades[13], blades[12], blades[11],
    };
    BasisGroup *pga_groups[4] = {
        [BasisGroup new:4 basis:&pga_blades[ 0]],
        [BasisGroup new:4 basis:&pga_blades[ 4]],
        [BasisGroup new:4 basis:&pga_blades[ 8]],
        [BasisGroup new:4 basis:&pga_blades[12]],
    };

Only the first element of pga_blades is being assigned in the optimized
code, but everything is correct when not optimizing.
This commit is contained in:
Bill Currie 2023-05-13 17:17:50 +09:00
parent e2464ed879
commit ce6b27cfae
2 changed files with 31 additions and 0 deletions

View file

@ -10,6 +10,7 @@ fail_bins=
test_progs_dat=\ test_progs_dat=\
tools/qfcc/test/address-cast.dat \ tools/qfcc/test/address-cast.dat \
tools/qfcc/test/alignment.dat \ tools/qfcc/test/alignment.dat \
tools/qfcc/test/arraylife.dat \
tools/qfcc/test/assignchain.dat \ tools/qfcc/test/assignchain.dat \
tools/qfcc/test/anonstruct.dat \ tools/qfcc/test/anonstruct.dat \
tools/qfcc/test/chewed-alias.dat \ tools/qfcc/test/chewed-alias.dat \
@ -157,6 +158,16 @@ tools/qfcc/test/anonstruct.run: $(qfcc_test_run_deps)
include $(anonstruct_dep) # am--include-marker include $(anonstruct_dep) # am--include-marker
r_depfiles_remade += $(anonstruct_dep) r_depfiles_remade += $(anonstruct_dep)
tools_qfcc_test_arraylife_dat_SOURCES=tools/qfcc/test/arraylife.r
arraylife_obj=$(tools_qfcc_test_arraylife_dat_SOURCES:.r=.o)
arraylife_dep=$(call qcautodep,$(tools_qfcc_test_arraylife_dat_SOURCES))
tools/qfcc/test/arraylife.dat$(EXEEXT): $(arraylife_obj) $(QFCC_DEP)
$(V_QFCCLD)$(QLINK) -o $@ $(arraylife_obj)
tools/qfcc/test/arraylife.run: $(qfcc_test_run_deps)
@$(top_srcdir)/tools/qfcc/test/build-run $@
include $(arraylife_dep) # am--include-marker
r_depfiles_remade += $(arraylife_dep)
tools_qfcc_test_assignchain_dat_SOURCES=tools/qfcc/test/assignchain.r tools_qfcc_test_assignchain_dat_SOURCES=tools/qfcc/test/assignchain.r
assignchain_obj=$(tools_qfcc_test_assignchain_dat_SOURCES:.r=.o) assignchain_obj=$(tools_qfcc_test_assignchain_dat_SOURCES:.r=.o)
assignchain_dep=$(call qcautodep,$(tools_qfcc_test_assignchain_dat_SOURCES)) assignchain_dep=$(call qcautodep,$(tools_qfcc_test_assignchain_dat_SOURCES))

View file

@ -0,0 +1,20 @@
vector
bar (float *v)
{
return [v[0], v[1], v[2]];
}
vector
foo (float x, float y, float z)
{
float v[3] = { x, y, z };
return bar (&v[0]);
}
int
main ()
{
int ret = 0;
ret |= foo(1,2,3) != [1, 2, 3];
return ret;
}