Open wan-yuqi opened 3 months ago
@llvm/issue-subscribers-backend-risc-v
Author: nomore (wan-yuqi)
Not 100% sure, just some thoughts.
addi a0, a0, 0
is also used as nop for alignment. Even though the variable Var
is aligned doesn't indicate this instruction lui
is properly aligned. So some instructions around may need addi a0, a0, 0
to align themselves.
Not 100% sure, just some thoughts.
addi a0, a0, 0
is also used as nop for alignment. Even though the variableVar
is aligned doesn't indicate this instructionlui
is properly aligned. So some instructions around may needaddi a0, a0, 0
to align themselves.
The nop instruction used for alignment has a relocation.type
of R_RISCV_ALIGN
, while the nop here is actually R_RISCV_LO12_I
. So i think there should be no impact.
When compiling a program which uses a global symbol and targets
riscv*
, it will generate a sequence instructions for calculating address:When the address of
Var
is aligned to 0x1000, such as 0x20000, calculation instructions will be:I think
mv a0, a0
could be eliminated by linker relaxation (which the target and source registers are the same and R_RISCV_LO12_I isADDI
) to reduce unnecessary instructions. But it' s not mentioned in riscv-elf-psabi-doc. Is there any negative impact?