Alpha: Fix unaligned access addressing
Alpha unaligned loads/stores now correctly handle large frame offsets, fixing compiler errors.
This commit corrects how Alpha unaligned load and store operations compute memory addresses. Previously, these operations directly used constants that were not resolved early enough, causing internal compiler errors when stack frame offsets exceeded 64K. The fix uses copy_addr_to_reg to ensure addresses are properly materialized, preventing the issue and making -fstack-protector more reliable by avoiding a common trigger for this bug.
In Details
The Alpha unaligned load/store expanders in alpha.cc previously calculated byte addresses as CONST_INT and passed them directly to SET. The add_operand used by these expanders only accepts constants within certain ranges (K for lda, L for ldah). When stack frames grow large, and especially when a stack protector canary pushes an array beyond the 64K boundary, the constant address would exceed these limits. This caused extract_insn to fail because no adddi3 pattern matched. The fix replaces the direct constant usage with copy_addr_to_reg, which handles arbitrary constants by…
- unaligned access
- Memory access (load or store) where the address does not fall on a boundary required by the data type's size. Some architectures handle this efficiently, others trap or require special instructions.
- stack frame
- A region of memory allocated on the call stack for a function call, containing local variables, parameters, and return address.
- stack protector
- A security feature (e.g., -fstack-protector) that adds a 'canary' value to the stack to detect buffer overflows. If the canary is overwritten, it indicates an overflow, and the program typically terminates to prevent exploitation.
- internal compiler error
- An error that occurs within the compiler itself, indicating a bug in the compiler's logic rather than an error in the user's source code.
- insn recognition
- The compiler pass responsible for matching generated intermediate code patterns to specific machine instructions for the target architecture.