From bbd78519f9a15669580563b93a3ab5d4cad1febc Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Thu, 18 Jun 2020 09:37:33 -0400 Subject: [PATCH] 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). --- llvm/lib/Target/ARC/ARCAsmPrinter.cpp | 8 ++++++++ llvm/lib/Target/ARC/ARCMachineFunctionInfo.h | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/ARC/ARCAsmPrinter.cpp b/llvm/lib/Target/ARC/ARCAsmPrinter.cpp index cf511cd..03024e0 100644 --- a/llvm/lib/Target/ARC/ARCAsmPrinter.cpp +++ b/llvm/lib/Target/ARC/ARCAsmPrinter.cpp @@ -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 X(getTheARCTarget()); diff --git a/llvm/lib/Target/ARC/ARCMachineFunctionInfo.h b/llvm/lib/Target/ARC/ARCMachineFunctionInfo.h index d4dcf9b..968c6b6 100644 --- a/llvm/lib/Target/ARC/ARCMachineFunctionInfo.h +++ b/llvm/lib/Target/ARC/ARCMachineFunctionInfo.h @@ -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() {} -- 2.7.4