I've been looking at code gen.
For release build without debug = true
:
# *** IR Dump After Live DEBUG_VALUE analysis ***
bb.0 (%ir-block.1):
successors: %bb.1(0x12492492), %bb.4(0x24924925), %bb.3(0x24924924), %bb.2(0x12492492), %bb.5(0x12492492); %bb.1(14.29%), %bb.4(28.57%), %bb.3(28.57%), %bb.2(14.29%), %bb.5(14.29%)
liveins: $r0
renamable $r2 = tUXTB killed renamable $r0, 14, $noreg
renamable $r0 = t2LEApcrelJT %jump-table.0, 14, $noreg
renamable $r1, dead $cpsr = tMOVi8 0, 14, $noreg
renamable $r3 = t2ADDrs killed renamable $r0, renamable $r2, 18, 14, $noreg, $noreg
renamable $r0 = IMPLICIT_DEF
t2BR_JT killed renamable $r3, killed renamable $r2, %jump-table.0
# *** IR Dump After ARM constant island placement and branch shortening pass ***:
bb.0 (%ir-block.1):
successors: %bb.4(0x12492492), %bb.2(0x24924925), %bb.3(0x24924924), %bb.5(0x12492492), %bb.6(0x12492492); %bb.4(14.29%), %bb.2(28.57%), %bb.3(28.57%), %bb.5(14.29%), %bb.6(14.29%)
liveins: $r0
renamable $r2 = tUXTB killed renamable $r0, 14, $noreg
renamable $r1, dead $cpsr = tMOVi8 0, 14, $noreg
renamable $r0 = IMPLICIT_DEF
t2TBB_JT $pc, killed $r2, %jump-table.0, 0
With debug = true
# *** IR Dump After Live DEBUG_VALUE analysis ***:
bb.0 (%ir-block.1):
successors: %bb.1(0x12492492), %bb.4(0x24924925), %bb.3(0x24924924), %bb.2(0x12492492), %bb.5(0x12492492); %bb.1(14.29%), %bb.4(28.57%), %bb.3(28.57%), %bb.2(14.29%), %bb.5(14.29%)
liveins: $r0
DBG_VALUE $r0, $noreg, !"res", !DIExpression(), debug-location !25235; /home/shin/proj/sp/camellia/kernel/src/returncode.rs:0 line no:63
DBG_VALUE $r0, $noreg, !"res", !DIExpression(), debug-location !25235; /home/shin/proj/sp/camellia/kernel/src/returncode.rs:0 line no:63
renamable $r2 = tUXTB killed renamable $r0, 14, $noreg, debug-location !25236; /home/shin/proj/sp/camellia/kernel/src/returncode.rs:65:13
renamable $r0 = t2LEApcrelJT %jump-table.0, 14, $noreg
DBG_VALUE $r0, $noreg, !"res", !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !25235; /home/shin/proj/sp/camellia/kernel/src/returncode.rs:0 line no:63
renamable $r1, dead $cpsr = tMOVi8 0, 14, $noreg
renamable $r3 = t2ADDrs killed renamable $r0, renamable $r2, 18, 14, $noreg, $noreg
renamable $r0 = IMPLICIT_DEF
t2BR_JT killed renamable $r3, killed renamable $r2, %jump-table.0
# *** IR Dump After ARM constant island placement and branch shortening pass ***:
bb.0 (%ir-block.1):
successors: %bb.4(0x12492492), %bb.2(0x24924925), %bb.3(0x24924924), %bb.5(0x12492492), %bb.6(0x12492492); %bb.4(14.29%), %bb.2(28.57%), %bb.3(28.57%), %bb.5(14.29%), %bb.6(14.29%)
liveins: $r0
DBG_VALUE $r0, $noreg, !"res", !DIExpression(), debug-location !25235; /home/shin/proj/sp/camellia/kernel/src/returncode.rs:0 line no:63
DBG_VALUE $r0, $noreg, !"res", !DIExpression(), debug-location !25235; /home/shin/proj/sp/camellia/kernel/src/returncode.rs:0 line no:63
renamable $r2 = tUXTB killed renamable $r0, 14, $noreg, debug-location !25236; /home/shin/proj/sp/camellia/kernel/src/returncode.rs:65:13
renamable $r0 = t2LEApcrelJT %jump-table.0, 14, $noreg
DBG_VALUE $r0, $noreg, !"res", !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !25235; /home/shin/proj/sp/camellia/kernel/src/returncode.rs:0 line no:63
renamable $r1, dead $cpsr = tMOVi8 0, 14, $noreg
renamable $r3 = t2ADDrs killed renamable $r0, renamable $r2, 18, 14, $noreg, $noreg
renamable $r0 = IMPLICIT_DEF
t2TBB_JT $pc, killed $r2, %jump-table.0, 0
It seems that after jump table is changed to use PC, r3 is no longer used and should have been removed, but it stays in the build with debug = true
.
In LLVM code ARMConstantIslandPass.cpp
there is a function called RemoveDeadAddBetweenLEAAndJT
which seems responsible for removing the instruction. I had no time to further investigate the problem.
I'll go ahead and ask the LLVM guys since it looks like it is LLVM's problem.