[llvm-dev] [AArch64] Redzone vs. NeedsRealignment in AArch64FrameLowering.cpp:emitPrologue

Aditya K via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 16 12:58:12 PDT 2016


Hi,
I have a question about the frame lowering when canUseRedzone is true.

In the following code, there appears to be no relation between `NeedsRealignment' and `canUseRedZone'.
Is is possible that stack would be realigned when it uses redzone?


AArch64FrameLowering.cpp
286 void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
287                                         MachineBasicBlock &MBB) const {

.....
 359   if (NumBytes) {
 360     const bool NeedsRealignment = RegInfo->needsStackRealignment(MF);
 361     unsigned scratchSPReg = AArch64::SP;
 362 
 363     if (NeedsRealignment) {
 364       scratchSPReg = findScratchNonCalleeSaveRegister(&MBB);
 365       assert(scratchSPReg != AArch64::NoRegister);
 366     }
 367 
 368     // If we're a leaf function, try using the red zone.
 369     if (!canUseRedZone(MF))
 370       // FIXME: in the case of dynamic re-alignment, NumBytes doesn't have
 371       // the correct value here, as NumBytes also includes padding bytes,
 372       // which shouldn't be counted here.
 373       emitFrameOffset(MBB, MBBI, DL, scratchSPReg, AArch64::SP, -NumBytes, TII,
 374                       MachineInstr::FrameSetup);
 375 
 376     if (NeedsRealignment) {
 377       const unsigned Alignment = MFI->getMaxAlignment();
 378       const unsigned NrBitsToZero = countTrailingZeros(Alignment);

.....
 


Thanks,
-Aditya


 		 	   		  


More information about the llvm-dev mailing list