Skip to content

Commit 78f0871

Browse files
committed
Revert rG58de1e2c5eee548a9b365e3b1554d87317072ad9 "Fix stack layout for frames larger than 2gb (#84114)"
This is failing on some EXPENSIVE_CHECKS buildbots
1 parent 313bf28 commit 78f0871

21 files changed

+86
-116
lines changed

llvm/include/llvm/CodeGen/MachineFrameInfo.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class MachineFrameInfo {
251251
/// targets, this value is only used when generating debug info (via
252252
/// TargetRegisterInfo::getFrameIndexReference); when generating code, the
253253
/// corresponding adjustments are performed directly.
254-
int64_t OffsetAdjustment = 0;
254+
int OffsetAdjustment = 0;
255255

256256
/// The prolog/epilog code inserter may process objects that require greater
257257
/// alignment than the default alignment the target provides.
@@ -280,7 +280,7 @@ class MachineFrameInfo {
280280
/// setup/destroy pseudo instructions (as defined in the TargetFrameInfo
281281
/// class). This information is important for frame pointer elimination.
282282
/// It is only valid during and after prolog/epilog code insertion.
283-
uint64_t MaxCallFrameSize = ~UINT64_C(0);
283+
unsigned MaxCallFrameSize = ~0u;
284284

285285
/// The number of bytes of callee saved registers that the target wants to
286286
/// report for the current function in the CodeView S_FRAMEPROC record.
@@ -591,10 +591,10 @@ class MachineFrameInfo {
591591
uint64_t estimateStackSize(const MachineFunction &MF) const;
592592

593593
/// Return the correction for frame offsets.
594-
int64_t getOffsetAdjustment() const { return OffsetAdjustment; }
594+
int getOffsetAdjustment() const { return OffsetAdjustment; }
595595

596596
/// Set the correction for frame offsets.
597-
void setOffsetAdjustment(int64_t Adj) { OffsetAdjustment = Adj; }
597+
void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
598598

599599
/// Return the alignment in bytes that this function must be aligned to,
600600
/// which is greater than the default stack alignment provided by the target.
@@ -655,17 +655,17 @@ class MachineFrameInfo {
655655
/// CallFrameSetup/Destroy pseudo instructions are used by the target, and
656656
/// then only during or after prolog/epilog code insertion.
657657
///
658-
uint64_t getMaxCallFrameSize() const {
658+
unsigned getMaxCallFrameSize() const {
659659
// TODO: Enable this assert when targets are fixed.
660660
//assert(isMaxCallFrameSizeComputed() && "MaxCallFrameSize not computed yet");
661661
if (!isMaxCallFrameSizeComputed())
662662
return 0;
663663
return MaxCallFrameSize;
664664
}
665665
bool isMaxCallFrameSizeComputed() const {
666-
return MaxCallFrameSize != ~UINT64_C(0);
666+
return MaxCallFrameSize != ~0u;
667667
}
668-
void setMaxCallFrameSize(uint64_t S) { MaxCallFrameSize = S; }
668+
void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
669669

670670
/// Returns how many bytes of callee-saved registers the target pushed in the
671671
/// prologue. Only used for debug info.

llvm/include/llvm/CodeGen/TargetFrameLowering.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TargetFrameLowering {
5151
// Maps a callee saved register to a stack slot with a fixed offset.
5252
struct SpillSlot {
5353
unsigned Reg;
54-
int64_t Offset; // Offset relative to stack pointer on function entry.
54+
int Offset; // Offset relative to stack pointer on function entry.
5555
};
5656

5757
struct DwarfFrameBase {
@@ -66,7 +66,7 @@ class TargetFrameLowering {
6666
// Used with FrameBaseKind::Register.
6767
unsigned Reg;
6868
// Used with FrameBaseKind::CFA.
69-
int64_t Offset;
69+
int Offset;
7070
struct WasmFrameBase WasmLoc;
7171
} Location;
7272
};

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class MCAsmBackend {
232232
virtual void handleAssemblerFlag(MCAssemblerFlag Flag) {}
233233

234234
/// Generate the compact unwind encoding for the CFI instructions.
235-
virtual uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
235+
virtual uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
236236
const MCContext *Ctxt) const {
237237
return 0;
238238
}

llvm/include/llvm/MC/MCDwarf.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,15 @@ class MCCFIInstruction {
508508
MCSymbol *Label;
509509
unsigned Register;
510510
union {
511-
int64_t Offset;
511+
int Offset;
512512
unsigned Register2;
513513
};
514514
unsigned AddressSpace = ~0u;
515515
SMLoc Loc;
516516
std::vector<char> Values;
517517
std::string Comment;
518518

519-
MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int64_t O, SMLoc Loc,
519+
MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, SMLoc Loc,
520520
StringRef V = "", StringRef Comment = "")
521521
: Operation(Op), Label(L), Register(R), Offset(O), Loc(Loc),
522522
Values(V.begin(), V.end()), Comment(Comment) {
@@ -528,7 +528,7 @@ class MCCFIInstruction {
528528
assert(Op == OpRegister);
529529
}
530530

531-
MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int64_t O, unsigned AS,
531+
MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, unsigned AS,
532532
SMLoc Loc)
533533
: Operation(Op), Label(L), Register(R), Offset(O), AddressSpace(AS),
534534
Loc(Loc) {
@@ -538,30 +538,30 @@ class MCCFIInstruction {
538538
public:
539539
/// .cfi_def_cfa defines a rule for computing CFA as: take address from
540540
/// Register and add Offset to it.
541-
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register,
542-
int64_t Offset, SMLoc Loc = {}) {
541+
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset,
542+
SMLoc Loc = {}) {
543543
return MCCFIInstruction(OpDefCfa, L, Register, Offset, Loc);
544544
}
545545

546546
/// .cfi_def_cfa_register modifies a rule for computing CFA. From now
547547
/// on Register will be used instead of the old one. Offset remains the same.
548548
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register,
549549
SMLoc Loc = {}) {
550-
return MCCFIInstruction(OpDefCfaRegister, L, Register, INT64_C(0), Loc);
550+
return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, Loc);
551551
}
552552

553553
/// .cfi_def_cfa_offset modifies a rule for computing CFA. Register
554554
/// remains the same, but offset is new. Note that it is the absolute offset
555555
/// that will be added to a defined register to the compute CFA address.
556-
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset,
556+
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int Offset,
557557
SMLoc Loc = {}) {
558558
return MCCFIInstruction(OpDefCfaOffset, L, 0, Offset, Loc);
559559
}
560560

561561
/// .cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but
562562
/// Offset is a relative value that is added/subtracted from the previous
563563
/// offset.
564-
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int64_t Adjustment,
564+
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment,
565565
SMLoc Loc = {}) {
566566
return MCCFIInstruction(OpAdjustCfaOffset, L, 0, Adjustment, Loc);
567567
}
@@ -581,15 +581,15 @@ class MCCFIInstruction {
581581
/// .cfi_offset Previous value of Register is saved at offset Offset
582582
/// from CFA.
583583
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register,
584-
int64_t Offset, SMLoc Loc = {}) {
584+
int Offset, SMLoc Loc = {}) {
585585
return MCCFIInstruction(OpOffset, L, Register, Offset, Loc);
586586
}
587587

588588
/// .cfi_rel_offset Previous value of Register is saved at offset
589589
/// Offset from the current CFA register. This is transformed to .cfi_offset
590590
/// using the known displacement of the CFA register from the CFA.
591591
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register,
592-
int64_t Offset, SMLoc Loc = {}) {
592+
int Offset, SMLoc Loc = {}) {
593593
return MCCFIInstruction(OpRelOffset, L, Register, Offset, Loc);
594594
}
595595

@@ -602,44 +602,44 @@ class MCCFIInstruction {
602602

603603
/// .cfi_window_save SPARC register window is saved.
604604
static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc = {}) {
605-
return MCCFIInstruction(OpWindowSave, L, 0, INT64_C(0), Loc);
605+
return MCCFIInstruction(OpWindowSave, L, 0, 0, Loc);
606606
}
607607

608608
/// .cfi_negate_ra_state AArch64 negate RA state.
609609
static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc = {}) {
610-
return MCCFIInstruction(OpNegateRAState, L, 0, INT64_C(0), Loc);
610+
return MCCFIInstruction(OpNegateRAState, L, 0, 0, Loc);
611611
}
612612

613613
/// .cfi_restore says that the rule for Register is now the same as it
614614
/// was at the beginning of the function, after all initial instructions added
615615
/// by .cfi_startproc were executed.
616616
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register,
617617
SMLoc Loc = {}) {
618-
return MCCFIInstruction(OpRestore, L, Register, INT64_C(0), Loc);
618+
return MCCFIInstruction(OpRestore, L, Register, 0, Loc);
619619
}
620620

621621
/// .cfi_undefined From now on the previous value of Register can't be
622622
/// restored anymore.
623623
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register,
624624
SMLoc Loc = {}) {
625-
return MCCFIInstruction(OpUndefined, L, Register, INT64_C(0), Loc);
625+
return MCCFIInstruction(OpUndefined, L, Register, 0, Loc);
626626
}
627627

628628
/// .cfi_same_value Current value of Register is the same as in the
629629
/// previous frame. I.e., no restoration is needed.
630630
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register,
631631
SMLoc Loc = {}) {
632-
return MCCFIInstruction(OpSameValue, L, Register, INT64_C(0), Loc);
632+
return MCCFIInstruction(OpSameValue, L, Register, 0, Loc);
633633
}
634634

635635
/// .cfi_remember_state Save all current rules for all registers.
636636
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc = {}) {
637-
return MCCFIInstruction(OpRememberState, L, 0, INT64_C(0), Loc);
637+
return MCCFIInstruction(OpRememberState, L, 0, 0, Loc);
638638
}
639639

640640
/// .cfi_restore_state Restore the previously saved state.
641641
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc = {}) {
642-
return MCCFIInstruction(OpRestoreState, L, 0, INT64_C(0), Loc);
642+
return MCCFIInstruction(OpRestoreState, L, 0, 0, Loc);
643643
}
644644

645645
/// .cfi_escape Allows the user to add arbitrary bytes to the unwind
@@ -650,7 +650,7 @@ class MCCFIInstruction {
650650
}
651651

652652
/// A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE
653-
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int64_t Size,
653+
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size,
654654
SMLoc Loc = {}) {
655655
return MCCFIInstruction(OpGnuArgsSize, L, 0, Size, Loc);
656656
}
@@ -677,7 +677,7 @@ class MCCFIInstruction {
677677
return AddressSpace;
678678
}
679679

680-
int64_t getOffset() const {
680+
int getOffset() const {
681681
assert(Operation == OpDefCfa || Operation == OpOffset ||
682682
Operation == OpRelOffset || Operation == OpDefCfaOffset ||
683683
Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize ||
@@ -705,7 +705,7 @@ struct MCDwarfFrameInfo {
705705
unsigned CurrentCfaRegister = 0;
706706
unsigned PersonalityEncoding = 0;
707707
unsigned LsdaEncoding = 0;
708-
uint64_t CompactUnwindEncoding = 0;
708+
uint32_t CompactUnwindEncoding = 0;
709709
bool IsSignalFrame = false;
710710
bool IsSimple = false;
711711
unsigned RAReg = static_cast<unsigned>(INT_MAX);

llvm/lib/CodeGen/CFIInstrInserter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class CFIInstrInserter : public MachineFunctionPass {
6868
struct MBBCFAInfo {
6969
MachineBasicBlock *MBB;
7070
/// Value of cfa offset valid at basic block entry.
71-
int64_t IncomingCFAOffset = -1;
71+
int IncomingCFAOffset = -1;
7272
/// Value of cfa offset valid at basic block exit.
73-
int64_t OutgoingCFAOffset = -1;
73+
int OutgoingCFAOffset = -1;
7474
/// Value of cfa register valid at basic block entry.
7575
unsigned IncomingCFARegister = 0;
7676
/// Value of cfa register valid at basic block exit.
@@ -120,7 +120,7 @@ class CFIInstrInserter : public MachineFunctionPass {
120120
/// Return the cfa offset value that should be set at the beginning of a MBB
121121
/// if needed. The negated value is needed when creating CFI instructions that
122122
/// set absolute offset.
123-
int64_t getCorrectCFAOffset(MachineBasicBlock *MBB) {
123+
int getCorrectCFAOffset(MachineBasicBlock *MBB) {
124124
return MBBVector[MBB->getNumber()].IncomingCFAOffset;
125125
}
126126

@@ -175,7 +175,7 @@ void CFIInstrInserter::calculateCFAInfo(MachineFunction &MF) {
175175

176176
void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
177177
// Outgoing cfa offset set by the block.
178-
int64_t SetOffset = MBBInfo.IncomingCFAOffset;
178+
int SetOffset = MBBInfo.IncomingCFAOffset;
179179
// Outgoing cfa register set by the block.
180180
unsigned SetRegister = MBBInfo.IncomingCFARegister;
181181
MachineFunction *MF = MBBInfo.MBB->getParent();
@@ -188,7 +188,7 @@ void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
188188
for (MachineInstr &MI : *MBBInfo.MBB) {
189189
if (MI.isCFIInstruction()) {
190190
std::optional<unsigned> CSRReg;
191-
std::optional<int64_t> CSROffset;
191+
std::optional<int> CSROffset;
192192
unsigned CFIIndex = MI.getOperand(0).getCFIIndex();
193193
const MCCFIInstruction &CFI = Instrs[CFIIndex];
194194
switch (CFI.getOperation()) {

llvm/lib/CodeGen/MachineFrameInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void MachineFrameInfo::computeMaxCallFrameSize(
197197
for (MachineInstr &MI : MBB) {
198198
unsigned Opcode = MI.getOpcode();
199199
if (Opcode == FrameSetupOpcode || Opcode == FrameDestroyOpcode) {
200-
uint64_t Size = TII.getFrameSize(MI);
200+
unsigned Size = TII.getFrameSize(MI);
201201
MaxCallFrameSize = std::max(MaxCallFrameSize, Size);
202202
if (FrameSDOps != nullptr)
203203
FrameSDOps->push_back(&MI);

llvm/lib/CodeGen/PrologEpilogInserter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ void PEI::calculateCallFrameInfo(MachineFunction &MF) {
366366
return;
367367

368368
// (Re-)Compute the MaxCallFrameSize.
369-
[[maybe_unused]] uint64_t MaxCFSIn =
370-
MFI.isMaxCallFrameSizeComputed() ? MFI.getMaxCallFrameSize() : UINT64_MAX;
369+
[[maybe_unused]] uint32_t MaxCFSIn =
370+
MFI.isMaxCallFrameSizeComputed() ? MFI.getMaxCallFrameSize() : UINT32_MAX;
371371
std::vector<MachineBasicBlock::iterator> FrameSDOps;
372372
MFI.computeMaxCallFrameSize(MF, &FrameSDOps);
373373
assert(MFI.getMaxCallFrameSize() <= MaxCFSIn &&

llvm/lib/MC/MCDwarf.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,8 @@ static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol,
12981298
namespace {
12991299

13001300
class FrameEmitterImpl {
1301-
int64_t CFAOffset = 0;
1302-
int64_t InitialCFAOffset = 0;
1301+
int CFAOffset = 0;
1302+
int InitialCFAOffset = 0;
13031303
bool IsEH;
13041304
MCObjectStreamer &Streamer;
13051305

@@ -1413,7 +1413,7 @@ void FrameEmitterImpl::emitCFIInstruction(const MCCFIInstruction &Instr) {
14131413
if (!IsEH)
14141414
Reg = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);
14151415

1416-
int64_t Offset = Instr.getOffset();
1416+
int Offset = Instr.getOffset();
14171417
if (IsRelative)
14181418
Offset -= CFAOffset;
14191419
Offset = Offset / dataAlignmentFactor;

llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ class DarwinAArch64AsmBackend : public AArch64AsmBackend {
584584
/// Encode compact unwind stack adjustment for frameless functions.
585585
/// See UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK in compact_unwind_encoding.h.
586586
/// The stack size always needs to be 16 byte aligned.
587-
uint64_t encodeStackAdjustment(uint64_t StackSize) const {
587+
uint32_t encodeStackAdjustment(uint32_t StackSize) const {
588588
return (StackSize / 16) << 12;
589589
}
590590

@@ -602,7 +602,7 @@ class DarwinAArch64AsmBackend : public AArch64AsmBackend {
602602
}
603603

604604
/// Generate the compact unwind encoding from the CFI directives.
605-
uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
605+
uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
606606
const MCContext *Ctxt) const override {
607607
ArrayRef<MCCFIInstruction> Instrs = FI->Instructions;
608608
if (Instrs.empty())
@@ -612,10 +612,10 @@ class DarwinAArch64AsmBackend : public AArch64AsmBackend {
612612
return CU::UNWIND_ARM64_MODE_DWARF;
613613

614614
bool HasFP = false;
615-
uint64_t StackSize = 0;
615+
unsigned StackSize = 0;
616616

617-
uint64_t CompactUnwindEncoding = 0;
618-
int64_t CurOffset = 0;
617+
uint32_t CompactUnwindEncoding = 0;
618+
int CurOffset = 0;
619619
for (size_t i = 0, e = Instrs.size(); i != e; ++i) {
620620
const MCCFIInstruction &Inst = Instrs[i];
621621

llvm/lib/Target/ARM/ARMFrameLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
11651165
if (STI.splitFramePushPop(MF)) {
11661166
unsigned DwarfReg = MRI->getDwarfRegNum(
11671167
Reg == ARM::R12 ? ARM::RA_AUTH_CODE : Reg, true);
1168-
uint64_t Offset = MFI.getObjectOffset(FI);
1168+
unsigned Offset = MFI.getObjectOffset(FI);
11691169
unsigned CFIIndex = MF.addFrameInst(
11701170
MCCFIInstruction::createOffset(nullptr, DwarfReg, Offset));
11711171
BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
@@ -1187,7 +1187,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
11871187
if ((Reg >= ARM::D0 && Reg <= ARM::D31) &&
11881188
(Reg < ARM::D8 || Reg >= ARM::D8 + AFI->getNumAlignedDPRCS2Regs())) {
11891189
unsigned DwarfReg = MRI->getDwarfRegNum(Reg, true);
1190-
uint64_t Offset = MFI.getObjectOffset(FI);
1190+
unsigned Offset = MFI.getObjectOffset(FI);
11911191
unsigned CFIIndex = MF.addFrameInst(
11921192
MCCFIInstruction::createOffset(nullptr, DwarfReg, Offset));
11931193
BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ enum CompactUnwindEncodings {
11481148
/// instructions. If the CFI instructions describe a frame that cannot be
11491149
/// encoded in compact unwind, the method returns UNWIND_ARM_MODE_DWARF which
11501150
/// tells the runtime to fallback and unwind using dwarf.
1151-
uint64_t ARMAsmBackendDarwin::generateCompactUnwindEncoding(
1151+
uint32_t ARMAsmBackendDarwin::generateCompactUnwindEncoding(
11521152
const MCDwarfFrameInfo *FI, const MCContext *Ctxt) const {
11531153
DEBUG_WITH_TYPE("compact-unwind", llvm::dbgs() << "generateCU()\n");
11541154
// Only armv7k uses CFI based unwinding.

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ARMAsmBackendDarwin : public ARMAsmBackend {
3434
/*Is64Bit=*/false, cantFail(MachO::getCPUType(TT)), Subtype);
3535
}
3636

37-
uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
37+
uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
3838
const MCContext *Ctxt) const override;
3939
};
4040
} // end namespace llvm

0 commit comments

Comments
 (0)