[llvm] [AVR] Support stack realignment (PR #187129)
Patryk Wychowaniec via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 13:48:31 PDT 2026
================
@@ -222,6 +213,32 @@ void AVRFrameLowering::emitEpilogue(MachineFunction &MF,
restoreStatusRegister(MF, MBB);
}
+StackOffset AVRFrameLowering::getFrameIndexReference(const MachineFunction &MF,
+ int FI,
+ Register &FrameReg) const {
+ int64_t Offset;
+ const MachineFrameInfo &MFI = MF.getFrameInfo();
+
+ switch (MFI.getStackID(FI)) {
+ case TargetStackID::Default:
+ Offset = MFI.getObjectOffset(FI) + MFI.getOffsetAdjustment() +
+ MFI.getStackSize() - getOffsetOfLocalArea() + 1;
+
+ assert(Offset > 0);
+ break;
+
+ case TargetStackID::AvrAlign:
+ Offset = MFI.getObjectOffset(FI);
----------------
Patryk27 wrote:
I kiinda see what you mean, but in some sense the variables _do_ end up in two different spaces - that's because all variables that belong to the `AvrAlign` stack end up addressed via a different register:
```cpp
void fun() {
// Will be addressed using register Y:
int a;
int b;
// Will be addressed using a dynamically allocated, stack-aligned register:
_Alignas(4) int c;
_Alignas(4) int d;
/* ... */
}
```
I'm not saying we _have to_ implement it the way I did, but if everything you say is "lol no", then it doesn't really help me. If I had twenty implementation ideas, I would've written them down here.
https://github.com/llvm/llvm-project/pull/187129
More information about the llvm-commits
mailing list