zcmt table generation results in incorrect branch resolution
Created by: simonpcook
(This bug was originally found by a downstream user of the zcmt changes, but has been replicated with the CORE-V tools)
Generation of the Zcmt table appears to be resulting in branches being incorrectly resolved (amongst other corruptions).
Using embench-1.0 and my CORE-V toolchain build using these tools, if I build embench with:
./build_all.py --clean --arch riscv32 --board ri5cyverilator --cc riscv32-corev-elf-gcc --chip generic --cflags '-save-temps -c -march=rv32im_zcmt -mabi=ilp32 -mcmodel=medany -static -O2' --ldflags '-march=rv32im_zcmt -mabi=ilp32 -mcmodel=medany -static -nostdlib -nostartfiles' --user-libs '-lm_nano -lc_nano -lgcc' --verbose
and disassemble nsichneu
, looking for the first use of cm.jt
, I find the following:
11b9e: 01cf0463 beq t5,t3,11ba6 <benchmark_body+0x1af0>
11ba2: a062 cm.jt 24
11ba4: 02872e03 lw t3,40(a4)
11ba8: 03472f03 lw t5,52(a4)
Noting the branch target of that first branch, 11ba6
is in the middle of the first lw
instruction quoted, so cannot be where we are expecting to branch to.