Unifying AUIPCC and AUICGP relocations meant that the LO relocation now needed to point to the AUI{PCC,CGP} instruction. This was not done and so CGP-relative LO relocations still pointed to their target. This meant that the case of rewriting AUICGP to AUIPCC was broken (as was the bit masking used to do this) because it would point to the wrong location. This broke the motivating case: a global that's defined as const but not declared as const (or not marked as constant when used as an extern in C++).
Fixing this then triggered another issue: we relax AUICGP and, in the typical case, delete the AUICGP instruction entirely (we have a full 4 KiB range for CGP-relative loads and stores because CGP is biased and points to the middle of the region). If we delete the AUICGP instruction, then finding the relocation attached to it (unsurprisingly) fails. This is subsequently fixed by adding a pass that rewrites all of the LO relocations that point to a HI relocation that points to a CGP-relative symbol to point directly to that symbol before doing any relaxations.
The new code also accepts CGP-relative LO relocations pointing directly to the correct symbol. This works in all of the cases where it worked before (if the HI relocation is against an auicgp instruction and the target is CGP-relative), which should let us avoid a second flag day.
Unifying AUIPCC and AUICGP relocations meant that the LO relocation now needed to point to the AUI{PCC,CGP} instruction. This was not done and so CGP-relative LO relocations still pointed to their target. This meant that the case of rewriting AUICGP to AUIPCC was broken (as was the bit masking used to do this) because it would point to the wrong location. This broke the motivating case: a global that's defined as const but not declared as const (or not marked as constant when used as an extern in C++).
Fixing this then triggered another issue: we relax AUICGP and, in the typical case, delete the AUICGP instruction entirely (we have a full 4 KiB range for CGP-relative loads and stores because CGP is biased and points to the middle of the region). If we delete the AUICGP instruction, then finding the relocation attached to it (unsurprisingly) fails. This is subsequently fixed by adding a pass that rewrites all of the LO relocations that point to a HI relocation that points to a CGP-relative symbol to point directly to that symbol before doing any relaxations.
The new code also accepts CGP-relative LO relocations pointing directly to the correct symbol. This works in all of the cases where it worked before (if the HI relocation is against an auicgp instruction and the target is CGP-relative), which should let us avoid a second flag day.