ARC: Enforce function alignment at code emission time

Don't do this in the MachineFunctionInfo constructor. Also, ensure the
alignment rather than overwriting it outright. I vaguely remember
there was another place to enforce the target minimum alignment, but I
couldn't find it (it's there for instructions).
This commit is contained in:
Matt Arsenault 2020-06-18 09:37:33 -04:00
parent 95605b784b
commit bbd78519f9
2 changed files with 9 additions and 4 deletions

View File

@ -42,6 +42,8 @@ public:
StringRef getPassName() const override { return "ARC Assembly Printer"; }
void emitInstruction(const MachineInstr *MI) override;
bool runOnMachineFunction(MachineFunction &MF) override;
};
} // end anonymous namespace
@ -61,6 +63,12 @@ void ARCAsmPrinter::emitInstruction(const MachineInstr *MI) {
EmitToStreamer(*OutStreamer, TmpInst);
}
bool ARCAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Functions are 4-byte aligned.
MF.ensureAlignment(Align(4));
AsmPrinter::runOnMachineFunction(MF);
}
// Force static initialization.
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCAsmPrinter() {
RegisterAsmPrinter<ARCAsmPrinter> X(getTheARCTarget());

View File

@ -33,10 +33,7 @@ public:
explicit ARCFunctionInfo(MachineFunction &MF)
: ReturnStackOffsetSet(false), VarArgsFrameIndex(0),
ReturnStackOffset(-1U), MaxCallStackReq(0) {
// Functions are 4-byte aligned.
MF.setAlignment(Align(4));
}
ReturnStackOffset(-1U), MaxCallStackReq(0) {}
~ARCFunctionInfo() {}