Original patch by Weiming Zhao. When addressing a global variable with large offsets, the offset may not fit in the load instruction and thus either needs rematerializaion or extra constant pool entry. This casues code size bloat, especially on Thumb1. This patch tries to encode the offset in the CP entry to save code size. For example: &g_big_struct.x_offset_300 Before: After: movs r0, #75 ldr r1, .LCPI0_0 lsls r0, r0, #2 .LCPI0_0: .long g_big_struct + 300 ldr r1, .LCPI0_0 adds r0, r1 .LCPI0_0: .long g_big_struct In best case, it saves 3 insts (and potentially reduces register pressure) as the example shows. In worst case, if the GV has multiple uses, the original CP entry for the GV base is still needed, and the member can be calculated from previous addressing, it will cost 4 extra bytes (for the CP entry).
Details
Details
- Reviewers
efriedma • zinob weimingz t.p.northover
Diff Detail
Diff Detail
- Repository
- rL LLVM