Skip to content

Commit 28e1473

Browse files
authored
MC: Remove bundle alignment mode
The being-removed PNaCl has a Software Fault Isolation mechanism, which requires that certain instructions and groups of instructions do not cross a bundle boundary. When `.bundle_align_mode` is in effect, each instruction is placed in its own fragment, allowing flexible NOP padding. This feature has significantly complicated our refactoring of MCStreamer and MCFragment, leading to considerable effort spent untangling it (including flushPendingLabels (7500646), MCAssembler iteration improvement, and recent MCFragment refactoring). * Make MCObjectStreamer::emitInstToData non-virtual and delete MCELFStreamer::emitInstTodata * Delete MCELFStreamer::emitValueImpl and emitValueToAlignment Minor instructions:u decrease for both -O0 -g and -O3 builds https://llvm-compile-time-tracker.com/compare.php?from=c06d3a7b728293cbc53ff91239d6cd87c0982ffb&to=9b078c7f228bc5b6cdbfe839f751c9407f8aec3e&stat=instructions:u Pull Request: #148781
1 parent 0f6a2db commit 28e1473

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+26
-6868
lines changed

llvm/include/llvm/MC/MCAssembler.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ class MCAssembler {
8585
// refactoring too.
8686
mutable SmallPtrSet<const MCSymbol *, 32> ThumbFuncs;
8787

88-
/// The bundle alignment size currently set in the assembler.
89-
///
90-
/// By default it's 0, which means bundling is disabled.
91-
unsigned BundleAlignSize = 0;
92-
9388
/// Evaluate a fixup to a relocatable expression and the value which should be
9489
/// placed into the fixup.
9590
///
@@ -143,8 +138,6 @@ class MCAssembler {
143138
/// Compute the effective fragment size.
144139
LLVM_ABI uint64_t computeFragmentSize(const MCFragment &F) const;
145140

146-
LLVM_ABI void layoutBundle(MCFragment *Prev, MCFragment *F) const;
147-
148141
// Get the offset of the given fragment inside its containing section.
149142
uint64_t getFragmentOffset(const MCFragment &F) const { return F.Offset; }
150143

@@ -203,16 +196,6 @@ class MCAssembler {
203196
bool getRelaxAll() const { return RelaxAll; }
204197
void setRelaxAll(bool Value) { RelaxAll = Value; }
205198

206-
bool isBundlingEnabled() const { return BundleAlignSize != 0; }
207-
208-
unsigned getBundleAlignSize() const { return BundleAlignSize; }
209-
210-
void setBundleAlignSize(unsigned Size) {
211-
assert((Size == 0 || !(Size & (Size - 1))) &&
212-
"Expect a power-of-two bundle align size");
213-
BundleAlignSize = Size;
214-
}
215-
216199
const_iterator begin() const { return Sections.begin(); }
217200
const_iterator end() const { return Sections.end(); }
218201

@@ -226,12 +209,6 @@ class MCAssembler {
226209
LLVM_ABI bool registerSection(MCSection &Section);
227210
LLVM_ABI bool registerSymbol(const MCSymbol &Symbol);
228211

229-
/// Write the necessary bundle padding to \p OS.
230-
/// Expects a fragment \p F containing instructions and its size \p FSize.
231-
LLVM_ABI void writeFragmentPadding(raw_ostream &OS,
232-
const MCEncodedFragment &F,
233-
uint64_t FSize) const;
234-
235212
LLVM_ABI void reportError(SMLoc L, const Twine &Msg) const;
236213
// Record pending errors during layout iteration, as they may go away once the
237214
// layout is finalized.

llvm/include/llvm/MC/MCELFStreamer.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,15 @@ class MCELFStreamer : public MCObjectStreamer {
6565
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
6666
Align ByteAlignment) override;
6767

68-
void emitValueImpl(const MCExpr *Value, unsigned Size,
69-
SMLoc Loc = SMLoc()) override;
70-
7168
void emitIdent(StringRef IdentString) override;
7269

73-
void emitValueToAlignment(Align, int64_t, uint8_t, unsigned) override;
74-
7570
void emitCGProfileEntry(const MCSymbolRefExpr *From,
7671
const MCSymbolRefExpr *To, uint64_t Count) override;
7772

7873
// This is final. Override MCTargetStreamer::finish instead for
7974
// target-specific code.
8075
void finishImpl() final;
8176

82-
void emitBundleAlignMode(Align Alignment) override;
83-
void emitBundleLock(bool AlignToEnd) override;
84-
void emitBundleUnlock() override;
85-
8677
/// ELF object attributes section emission support
8778
struct AttributeItem {
8879
// This structure holds all attributes, accounting for their string /
@@ -151,9 +142,6 @@ class MCELFStreamer : public MCObjectStreamer {
151142
}
152143

153144
private:
154-
bool isBundleLocked() const;
155-
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
156-
157145
void finalizeCGProfileEntry(const MCSymbolRefExpr *&S, uint64_t Offset);
158146
void finalizeCGProfile();
159147

llvm/include/llvm/MC/MCObjectStreamer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class MCObjectStreamer : public MCStreamer {
5959
DenseMap<const MCSymbol *, SmallVector<PendingAssignment, 1>>
6060
pendingAssignments;
6161

62-
virtual void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &);
62+
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &);
6363
void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
6464
void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
6565
void emitInstructionImpl(const MCInst &Inst, const MCSubtargetInfo &STI);
@@ -127,9 +127,6 @@ class MCObjectStreamer : public MCStreamer {
127127
/// can change its size during relaxation.
128128
void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &);
129129

130-
void emitBundleAlignMode(Align Alignment) override;
131-
void emitBundleLock(bool AlignToEnd) override;
132-
void emitBundleUnlock() override;
133130
void emitBytes(StringRef Data) override;
134131
void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
135132
uint8_t FillLen = 1,

llvm/include/llvm/MC/MCSection.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ class LLVM_ABI MCSection {
6161
SV_DXContainer,
6262
};
6363

64-
/// Express the state of bundle locked groups while emitting code.
65-
enum BundleLockStateType {
66-
NotBundleLocked,
67-
BundleLocked,
68-
BundleLockedAlignToEnd
69-
};
70-
7164
struct iterator {
7265
MCFragment *F = nullptr;
7366
iterator() = default;
@@ -94,16 +87,6 @@ class LLVM_ABI MCSection {
9487
/// The section index in the assemblers section list.
9588
unsigned Ordinal = 0;
9689

97-
/// Keeping track of bundle-locked state.
98-
BundleLockStateType BundleLockState = NotBundleLocked;
99-
100-
/// Current nesting depth of bundle_lock directives.
101-
unsigned BundleLockNestingDepth = 0;
102-
103-
/// We've seen a bundle_lock directive but not its first instruction
104-
/// yet.
105-
bool BundleGroupBeforeFirstInst : 1;
106-
10790
/// Whether this section has had instructions emitted into it.
10891
bool HasInstructions : 1;
10992

@@ -169,17 +152,6 @@ class LLVM_ABI MCSection {
169152
unsigned getOrdinal() const { return Ordinal; }
170153
void setOrdinal(unsigned Value) { Ordinal = Value; }
171154

172-
BundleLockStateType getBundleLockState() const { return BundleLockState; }
173-
void setBundleLockState(BundleLockStateType NewState);
174-
bool isBundleLocked() const { return BundleLockState != NotBundleLocked; }
175-
176-
bool isBundleGroupBeforeFirstInst() const {
177-
return BundleGroupBeforeFirstInst;
178-
}
179-
void setBundleGroupBeforeFirstInst(bool IsFirst) {
180-
BundleGroupBeforeFirstInst = IsFirst;
181-
}
182-
183155
bool hasInstructions() const { return HasInstructions; }
184156
void setHasInstructions(bool Value) { HasInstructions = Value; }
185157

@@ -259,7 +231,6 @@ class MCFragment {
259231
///
260232
/// MCEncodedFragment
261233
bool HasInstructions : 1;
262-
bool AlignToBundleEnd : 1;
263234
/// MCDataFragment
264235
bool LinkerRelaxable : 1;
265236
/// MCRelaxableFragment: x86-specific
@@ -297,7 +268,6 @@ class MCFragment {
297268
/// Interface implemented by fragments that contain encoded instructions and/or
298269
/// data.
299270
class MCEncodedFragment : public MCFragment {
300-
uint8_t BundlePadding = 0;
301271
uint32_t ContentStart = 0;
302272
uint32_t ContentEnd = 0;
303273
uint32_t FixupStart = 0;
@@ -329,21 +299,6 @@ class MCEncodedFragment : public MCFragment {
329299
}
330300
}
331301

332-
/// Should this fragment be placed at the end of an aligned bundle?
333-
bool alignToBundleEnd() const { return AlignToBundleEnd; }
334-
void setAlignToBundleEnd(bool V) { AlignToBundleEnd = V; }
335-
336-
/// Get the padding size that must be inserted before this fragment.
337-
/// Used for bundling. By default, no padding is inserted.
338-
/// Note that padding size is restricted to 8 bits. This is an optimization
339-
/// to reduce the amount of space used for each fragment. In practice, larger
340-
/// padding should never be required.
341-
uint8_t getBundlePadding() const { return BundlePadding; }
342-
343-
/// Set the padding size for this fragment. By default it's a no-op,
344-
/// and only some fragments have a meaningful implementation.
345-
void setBundlePadding(uint8_t N) { BundlePadding = N; }
346-
347302
/// Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
348303
/// Guaranteed to be non-null if hasInstructions() == true
349304
const MCSubtargetInfo *getSubtargetInfo() const { return STI; }

llvm/include/llvm/MC/MCStreamer.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,19 +1068,6 @@ class LLVM_ABI MCStreamer {
10681068
const MCPseudoProbeInlineStack &InlineStack,
10691069
MCSymbol *FnSym);
10701070

1071-
/// Set the bundle alignment mode from now on in the section.
1072-
/// The value 1 means turn the bundle alignment off.
1073-
virtual void emitBundleAlignMode(Align Alignment);
1074-
1075-
/// The following instructions are a bundle-locked group.
1076-
///
1077-
/// \param AlignToEnd - If true, the bundle-locked group will be aligned to
1078-
/// the end of a bundle.
1079-
virtual void emitBundleLock(bool AlignToEnd);
1080-
1081-
/// Ends a bundle-locked group.
1082-
virtual void emitBundleUnlock();
1083-
10841071
/// If this file is backed by a assembly streamer, this dumps the
10851072
/// specified string in the output .s file. This capability is indicated by
10861073
/// the hasRawTextSupport() predicate. By default this aborts.

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,6 @@ class MCAsmStreamer final : public MCStreamer {
407407
const MCPseudoProbeInlineStack &InlineStack,
408408
MCSymbol *FnSym) override;
409409

410-
void emitBundleAlignMode(Align Alignment) override;
411-
void emitBundleLock(bool AlignToEnd) override;
412-
void emitBundleUnlock() override;
413-
414410
std::optional<std::pair<bool, std::string>>
415411
emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr,
416412
SMLoc Loc, const MCSubtargetInfo &STI) override;
@@ -2472,23 +2468,6 @@ void MCAsmStreamer::emitPseudoProbe(uint64_t Guid, uint64_t Index,
24722468
EmitEOL();
24732469
}
24742470

2475-
void MCAsmStreamer::emitBundleAlignMode(Align Alignment) {
2476-
OS << "\t.bundle_align_mode " << Log2(Alignment);
2477-
EmitEOL();
2478-
}
2479-
2480-
void MCAsmStreamer::emitBundleLock(bool AlignToEnd) {
2481-
OS << "\t.bundle_lock";
2482-
if (AlignToEnd)
2483-
OS << " align_to_end";
2484-
EmitEOL();
2485-
}
2486-
2487-
void MCAsmStreamer::emitBundleUnlock() {
2488-
OS << "\t.bundle_unlock";
2489-
EmitEOL();
2490-
}
2491-
24922471
std::optional<std::pair<bool, std::string>>
24932472
MCAsmStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
24942473
const MCExpr *Expr, SMLoc,

0 commit comments

Comments
 (0)