[PATCH] D114590: [CodeGen] Emit alignment "Max Skip" operand for align directives
Nicholas Guy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 1 07:48:39 PST 2021
NickGuy updated this revision to Diff 391026.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114590/new/
https://reviews.llvm.org/D114590
Files:
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/CodeGen/MachineBasicBlock.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2447,7 +2447,7 @@
// two boundary. If a global value is specified, and if that global has
// an explicit alignment requested, it will override the alignment request
// if required for correctness.
-void AsmPrinter::emitAlignment(Align Alignment, const GlobalObject *GV) const {
+void AsmPrinter::emitAlignment(Align Alignment, const GlobalObject *GV, unsigned MaxBytesToEmit) const {
if (GV)
Alignment = getGVAlignment(GV, GV->getParent()->getDataLayout(), Alignment);
@@ -2460,7 +2460,7 @@
STI = &getSubtargetInfo();
else
STI = TM.getMCSubtargetInfo();
- OutStreamer->emitCodeAlignment(Alignment.value(), STI);
+ OutStreamer->emitCodeAlignment(Alignment.value(), STI, MaxBytesToEmit);
} else
OutStreamer->emitValueToAlignment(Alignment.value());
}
@@ -3253,7 +3253,7 @@
// Emit an alignment directive for this block, if needed.
const Align Alignment = MBB.getAlignment();
if (Alignment != Align(1))
- emitAlignment(Alignment);
+ emitAlignment(Alignment, nullptr, MBB.getMaxBytesForAlignment());
// Switch to a new section if this basic block must begin a section. The
// entry block is always placed in the function section and is handled
Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -136,6 +136,11 @@
/// Alignment of the basic block. One if the basic block does not need to be
/// aligned.
Align Alignment;
+ /// Maximum amount of bytes that can be added to align the basic block.
+ /// Zero to represent no maximum.
+ /// Values greater than Alignment^2 are understood to be functionally useless,
+ /// and are equivalent to a value of Zero.
+ uint8_t MaxBytesForAlignment = 0;
/// Indicate that this basic block is entered via an exception handler.
bool IsEHPad = false;
@@ -521,6 +526,11 @@
/// Set alignment of the basic block.
void setAlignment(Align A) { Alignment = A; }
+ /// Return the maximum amount of padding allowed for aligning the basic block
+ uint8_t getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
+ /// Set the maximum amount of padding allowed for aligning the basic block
+ void setMaxBytesForAlignment(uint8_t MaxBytes) { MaxBytesForAlignment = MaxBytes; }
+
/// Returns true if the block is a landing pad. That is this basic block is
/// entered via an exception handler.
bool isEHPad() const { return IsEHPad; }
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===================================================================
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -432,7 +432,7 @@
/// global value is specified, and if that global has an explicit alignment
/// requested, it will override the alignment request if required for
/// correctness.
- void emitAlignment(Align Alignment, const GlobalObject *GV = nullptr) const;
+ void emitAlignment(Align Alignment, const GlobalObject *GV = nullptr, unsigned MaxBytesToEmit = 0) const;
/// Lower the specified LLVM Constant to an MCExpr.
virtual const MCExpr *lowerConstant(const Constant *CV);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114590.391026.patch
Type: text/x-patch
Size: 3517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211201/80a14fca/attachment.bin>
More information about the llvm-commits
mailing list