blob: 9142f3ed9b27a78bc3230963e44732dff1e91e7f [file] [log] [blame]
Tim Northover3b0846e2014-05-24 12:50:23 +00001//===-- AArch64BranchRelaxation.cpp - AArch64 branch relaxation -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Tim Northover3b0846e2014-05-24 12:50:23 +00009
10#include "AArch64.h"
11#include "AArch64InstrInfo.h"
12#include "AArch64MachineFunctionInfo.h"
Eric Christopherd9134482014-08-04 21:25:23 +000013#include "AArch64Subtarget.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000014#include "llvm/ADT/SmallVector.h"
Benjamin Kramer1f8930e2014-07-25 11:42:14 +000015#include "llvm/ADT/Statistic.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000016#include "llvm/CodeGen/MachineFunctionPass.h"
17#include "llvm/CodeGen/MachineInstrBuilder.h"
Benjamin Kramer1f8930e2014-07-25 11:42:14 +000018#include "llvm/Support/CommandLine.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000019#include "llvm/Support/Debug.h"
20#include "llvm/Support/ErrorHandling.h"
21#include "llvm/Support/Format.h"
22#include "llvm/Support/raw_ostream.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000023using namespace llvm;
24
25#define DEBUG_TYPE "aarch64-branch-relax"
26
Tim Northover3b0846e2014-05-24 12:50:23 +000027STATISTIC(NumSplit, "Number of basic blocks split");
Matt Arsenault567631b2016-08-23 01:30:30 +000028STATISTIC(NumConditionalRelaxed, "Number of conditional branches relaxed");
Tim Northover3b0846e2014-05-24 12:50:23 +000029
Chad Rosier1c814322015-08-05 16:12:10 +000030namespace llvm {
31void initializeAArch64BranchRelaxationPass(PassRegistry &);
32}
33
34#define AARCH64_BR_RELAX_NAME "AArch64 branch relaxation pass"
35
Tim Northover3b0846e2014-05-24 12:50:23 +000036namespace {
37class AArch64BranchRelaxation : public MachineFunctionPass {
38 /// BasicBlockInfo - Information about the offset and size of a single
39 /// basic block.
40 struct BasicBlockInfo {
41 /// Offset - Distance from the beginning of the function to the beginning
42 /// of this basic block.
43 ///
44 /// The offset is always aligned as required by the basic block.
45 unsigned Offset;
46
47 /// Size - Size of the basic block in bytes. If the block contains
48 /// inline assembly, this is a worst case estimate.
49 ///
50 /// The size does not include any alignment padding whether from the
51 /// beginning of the block, or from an aligned jump table at the end.
52 unsigned Size;
53
54 BasicBlockInfo() : Offset(0), Size(0) {}
55
56 /// Compute the offset immediately following this block. If LogAlign is
57 /// specified, return the offset the successor block will get if it has
58 /// this alignment.
59 unsigned postOffset(unsigned LogAlign = 0) const {
60 unsigned PO = Offset + Size;
61 unsigned Align = 1 << LogAlign;
62 return (PO + Align - 1) / Align * Align;
63 }
64 };
65
66 SmallVector<BasicBlockInfo, 16> BlockInfo;
67
68 MachineFunction *MF;
69 const AArch64InstrInfo *TII;
70
71 bool relaxBranchInstructions();
72 void scanFunction();
Matt Arsenaultf7065e12016-08-02 07:20:09 +000073 MachineBasicBlock *splitBlockBeforeInstr(MachineInstr &MI);
Tim Northover3b0846e2014-05-24 12:50:23 +000074 void adjustBlockOffsets(MachineBasicBlock &MBB);
Matt Arsenaulte8da1452016-08-02 08:06:17 +000075 bool isBlockInRange(const MachineInstr &MI, const MachineBasicBlock &BB) const;
Matt Arsenault5b549712016-08-02 08:30:06 +000076
Matt Arsenaultf7065e12016-08-02 07:20:09 +000077 bool fixupConditionalBranch(MachineInstr &MI);
Tim Northover3b0846e2014-05-24 12:50:23 +000078 void computeBlockSize(const MachineBasicBlock &MBB);
Matt Arsenaulte8da1452016-08-02 08:06:17 +000079 unsigned getInstrOffset(const MachineInstr &MI) const;
Tim Northover3b0846e2014-05-24 12:50:23 +000080 void dumpBBs();
81 void verify();
82
83public:
84 static char ID;
Chad Rosier1c814322015-08-05 16:12:10 +000085 AArch64BranchRelaxation() : MachineFunctionPass(ID) {
86 initializeAArch64BranchRelaxationPass(*PassRegistry::getPassRegistry());
87 }
Tim Northover3b0846e2014-05-24 12:50:23 +000088
89 bool runOnMachineFunction(MachineFunction &MF) override;
90
91 const char *getPassName() const override {
Chad Rosier1c814322015-08-05 16:12:10 +000092 return AARCH64_BR_RELAX_NAME;
Tim Northover3b0846e2014-05-24 12:50:23 +000093 }
94};
95char AArch64BranchRelaxation::ID = 0;
Alexander Kornienkof00654e2015-06-23 09:49:53 +000096}
Tim Northover3b0846e2014-05-24 12:50:23 +000097
Chad Rosier1c814322015-08-05 16:12:10 +000098INITIALIZE_PASS(AArch64BranchRelaxation, "aarch64-branch-relax",
99 AARCH64_BR_RELAX_NAME, false, false)
100
Tim Northover3b0846e2014-05-24 12:50:23 +0000101/// verify - check BBOffsets, BBSizes, alignment of islands
102void AArch64BranchRelaxation::verify() {
103#ifndef NDEBUG
104 unsigned PrevNum = MF->begin()->getNumber();
105 for (MachineBasicBlock &MBB : *MF) {
106 unsigned Align = MBB.getAlignment();
107 unsigned Num = MBB.getNumber();
108 assert(BlockInfo[Num].Offset % (1u << Align) == 0);
109 assert(!Num || BlockInfo[PrevNum].postOffset() <= BlockInfo[Num].Offset);
110 PrevNum = Num;
111 }
112#endif
113}
114
115/// print block size and offset information - debugging
116void AArch64BranchRelaxation::dumpBBs() {
117 for (auto &MBB : *MF) {
118 const BasicBlockInfo &BBI = BlockInfo[MBB.getNumber()];
119 dbgs() << format("BB#%u\toffset=%08x\t", MBB.getNumber(), BBI.Offset)
120 << format("size=%#x\n", BBI.Size);
121 }
122}
123
Tim Northover3b0846e2014-05-24 12:50:23 +0000124/// scanFunction - Do the initial scan of the function, building up
125/// information about each block.
126void AArch64BranchRelaxation::scanFunction() {
127 BlockInfo.clear();
128 BlockInfo.resize(MF->getNumBlockIDs());
129
130 // First thing, compute the size of all basic blocks, and see if the function
131 // has any inline assembly in it. If so, we have to be conservative about
132 // alignment assumptions, as we don't know for sure the size of any
133 // instructions in the inline assembly.
134 for (MachineBasicBlock &MBB : *MF)
135 computeBlockSize(MBB);
136
137 // Compute block offsets and known bits.
138 adjustBlockOffsets(*MF->begin());
139}
140
141/// computeBlockSize - Compute the size for MBB.
142/// This function updates BlockInfo directly.
143void AArch64BranchRelaxation::computeBlockSize(const MachineBasicBlock &MBB) {
144 unsigned Size = 0;
145 for (const MachineInstr &MI : MBB)
Sjoerd Meijer89217f82016-07-28 16:32:22 +0000146 Size += TII->getInstSizeInBytes(MI);
Tim Northover3b0846e2014-05-24 12:50:23 +0000147 BlockInfo[MBB.getNumber()].Size = Size;
148}
149
150/// getInstrOffset - Return the current offset of the specified machine
151/// instruction from the start of the function. This offset changes as stuff is
152/// moved around inside the function.
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000153unsigned AArch64BranchRelaxation::getInstrOffset(const MachineInstr &MI) const {
154 const MachineBasicBlock *MBB = MI.getParent();
Tim Northover3b0846e2014-05-24 12:50:23 +0000155
156 // The offset is composed of two things: the sum of the sizes of all MBB's
157 // before this instruction's block, and the offset from the start of the block
158 // it is in.
159 unsigned Offset = BlockInfo[MBB->getNumber()].Offset;
160
161 // Sum instructions before MI in MBB.
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000162 for (MachineBasicBlock::const_iterator I = MBB->begin(); &*I != &MI; ++I) {
Tim Northover3b0846e2014-05-24 12:50:23 +0000163 assert(I != MBB->end() && "Didn't find MI in its own basic block?");
Sjoerd Meijer89217f82016-07-28 16:32:22 +0000164 Offset += TII->getInstSizeInBytes(*I);
Tim Northover3b0846e2014-05-24 12:50:23 +0000165 }
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000166
Tim Northover3b0846e2014-05-24 12:50:23 +0000167 return Offset;
168}
169
170void AArch64BranchRelaxation::adjustBlockOffsets(MachineBasicBlock &Start) {
171 unsigned PrevNum = Start.getNumber();
172 for (auto &MBB : make_range(MachineFunction::iterator(Start), MF->end())) {
173 unsigned Num = MBB.getNumber();
174 if (!Num) // block zero is never changed from offset zero.
175 continue;
176 // Get the offset and known bits at the end of the layout predecessor.
177 // Include the alignment of the current block.
178 unsigned LogAlign = MBB.getAlignment();
179 BlockInfo[Num].Offset = BlockInfo[PrevNum].postOffset(LogAlign);
180 PrevNum = Num;
181 }
182}
183
184/// Split the basic block containing MI into two blocks, which are joined by
185/// an unconditional branch. Update data structures and renumber blocks to
186/// account for this change and returns the newly created block.
187/// NOTE: Successor list of the original BB is out of date after this function,
188/// and must be updated by the caller! Other transforms follow using this
189/// utility function, so no point updating now rather than waiting.
190MachineBasicBlock *
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000191AArch64BranchRelaxation::splitBlockBeforeInstr(MachineInstr &MI) {
192 MachineBasicBlock *OrigBB = MI.getParent();
Tim Northover3b0846e2014-05-24 12:50:23 +0000193
194 // Create a new MBB for the code after the OrigBB.
195 MachineBasicBlock *NewBB =
196 MF->CreateMachineBasicBlock(OrigBB->getBasicBlock());
Duncan P. N. Exon Smithd3b9df02015-10-13 20:02:15 +0000197 MF->insert(++OrigBB->getIterator(), NewBB);
Tim Northover3b0846e2014-05-24 12:50:23 +0000198
199 // Splice the instructions starting with MI over to NewBB.
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000200 NewBB->splice(NewBB->end(), OrigBB, MI.getIterator(), OrigBB->end());
Tim Northover3b0846e2014-05-24 12:50:23 +0000201
202 // Add an unconditional branch from OrigBB to NewBB.
203 // Note the new unconditional branch is not being recorded.
204 // There doesn't seem to be meaningful DebugInfo available; this doesn't
205 // correspond to anything in the source.
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000206 TII->insertUnconditionalBranch(*OrigBB, NewBB, DebugLoc());
Tim Northover3b0846e2014-05-24 12:50:23 +0000207
208 // Insert an entry into BlockInfo to align it properly with the block numbers.
209 BlockInfo.insert(BlockInfo.begin() + NewBB->getNumber(), BasicBlockInfo());
210
211 // Figure out how large the OrigBB is. As the first half of the original
212 // block, it cannot contain a tablejump. The size includes
213 // the new jump we added. (It should be possible to do this without
214 // recounting everything, but it's very confusing, and this is rarely
215 // executed.)
216 computeBlockSize(*OrigBB);
217
218 // Figure out how large the NewMBB is. As the second half of the original
219 // block, it may contain a tablejump.
220 computeBlockSize(*NewBB);
221
222 // All BBOffsets following these blocks must be modified.
223 adjustBlockOffsets(*OrigBB);
224
225 ++NumSplit;
226
227 return NewBB;
228}
229
230/// isBlockInRange - Returns true if the distance between specific MI and
231/// specific BB can fit in MI's displacement field.
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000232bool AArch64BranchRelaxation::isBlockInRange(
233 const MachineInstr &MI, const MachineBasicBlock &DestBB) const {
Tim Northover3b0846e2014-05-24 12:50:23 +0000234 unsigned BrOffset = getInstrOffset(MI);
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000235 unsigned DestOffset = BlockInfo[DestBB.getNumber()].Offset;
Tim Northover3b0846e2014-05-24 12:50:23 +0000236
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000237 if (TII->isBranchInRange(MI.getOpcode(), BrOffset, DestOffset))
Tim Northover3b0846e2014-05-24 12:50:23 +0000238 return true;
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000239
240 DEBUG(
241 dbgs() << "Out of range branch to destination BB#" << DestBB.getNumber()
242 << " from BB#" << MI.getParent()->getNumber()
243 << " to " << DestOffset
244 << " offset " << static_cast<int>(DestOffset - BrOffset)
245 << '\t' << MI
246 );
247
248 return false;
Tim Northover3b0846e2014-05-24 12:50:23 +0000249}
250
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000251static MachineBasicBlock *getDestBlock(const MachineInstr &MI) {
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000252 switch (MI.getOpcode()) {
Tim Northover3b0846e2014-05-24 12:50:23 +0000253 default:
Craig Topper2a30d782014-06-18 05:05:13 +0000254 llvm_unreachable("unexpected opcode!");
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000255 case AArch64::B:
256 return MI.getOperand(0).getMBB();
Tim Northover3b0846e2014-05-24 12:50:23 +0000257 case AArch64::TBZW:
258 case AArch64::TBNZW:
259 case AArch64::TBZX:
260 case AArch64::TBNZX:
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000261 return MI.getOperand(2).getMBB();
Tim Northover3b0846e2014-05-24 12:50:23 +0000262 case AArch64::CBZW:
263 case AArch64::CBNZW:
264 case AArch64::CBZX:
265 case AArch64::CBNZX:
266 case AArch64::Bcc:
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000267 return MI.getOperand(1).getMBB();
Tim Northover3b0846e2014-05-24 12:50:23 +0000268 }
269}
270
Tim Northover3b0846e2014-05-24 12:50:23 +0000271/// fixupConditionalBranch - Fix up a conditional branch whose destination is
272/// too far away to fit in its displacement field. It is converted to an inverse
273/// conditional branch + an unconditional branch to the destination.
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000274bool AArch64BranchRelaxation::fixupConditionalBranch(MachineInstr &MI) {
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000275 DebugLoc DL = MI.getDebugLoc();
276 MachineBasicBlock *MBB = MI.getParent();
277 MachineBasicBlock *TBB = nullptr, *FBB = nullptr;
278 SmallVector<MachineOperand, 4> Cond;
279
280 bool Fail = TII->analyzeBranch(*MBB, TBB, FBB, Cond);
281 assert(!Fail && "branches to be relaxed must be analyzable");
282 (void)Fail;
Tim Northover3b0846e2014-05-24 12:50:23 +0000283
284 // Add an unconditional branch to the destination and invert the branch
285 // condition to jump over it:
286 // tbz L1
287 // =>
288 // tbnz L2
289 // b L1
290 // L2:
291
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000292 if (FBB && isBlockInRange(MI, *FBB)) {
293 // Last MI in the BB is an unconditional branch. We can simply invert the
294 // condition and swap destinations:
295 // beq L1
296 // b L2
297 // =>
298 // bne L2
299 // b L1
300 DEBUG(dbgs() << " Invert condition and swap "
301 "its destination with " << MBB->back());
Tim Northover3b0846e2014-05-24 12:50:23 +0000302
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +0000303 TII->reverseBranchCondition(Cond);
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000304 int OldSize = 0, NewSize = 0;
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +0000305 TII->removeBranch(*MBB, &OldSize);
Matt Arsenaulte8e0f5c2016-09-14 17:24:15 +0000306 TII->insertBranch(*MBB, FBB, TBB, Cond, DL, &NewSize);
Matt Arsenault5b549712016-08-02 08:30:06 +0000307
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000308 BlockInfo[MBB->getNumber()].Size += (NewSize - OldSize);
309 return true;
310 } else if (FBB) {
311 // We need to split the basic block here to obtain two long-range
312 // unconditional branches.
313 auto &NewBB = *MF->CreateMachineBasicBlock(MBB->getBasicBlock());
314 MF->insert(++MBB->getIterator(), &NewBB);
Tim Northover3b0846e2014-05-24 12:50:23 +0000315
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000316 // Insert an entry into BlockInfo to align it properly with the block
317 // numbers.
318 BlockInfo.insert(BlockInfo.begin() + NewBB.getNumber(), BasicBlockInfo());
Tim Northover3b0846e2014-05-24 12:50:23 +0000319
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000320 unsigned &NewBBSize = BlockInfo[NewBB.getNumber()].Size;
321 int NewBrSize;
322 TII->insertUnconditionalBranch(NewBB, FBB, DL, &NewBrSize);
323 NewBBSize += NewBrSize;
Tim Northover3b0846e2014-05-24 12:50:23 +0000324
325 // Update the successor lists according to the transformation to follow.
326 // Do it here since if there's no split, no update is needed.
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000327 MBB->replaceSuccessor(FBB, &NewBB);
328 NewBB.addSuccessor(FBB);
Tim Northover3b0846e2014-05-24 12:50:23 +0000329 }
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000330
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000331 // We now have an appropriate fall-through block in place (either naturally or
332 // just created), so we can invert the condition.
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000333 MachineBasicBlock &NextBB = *std::next(MachineFunction::iterator(MBB));
Tim Northover3b0846e2014-05-24 12:50:23 +0000334
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000335 DEBUG(dbgs() << " Insert B to BB#" << TBB->getNumber()
Tim Northover3b0846e2014-05-24 12:50:23 +0000336 << ", invert condition and change dest. to BB#"
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000337 << NextBB.getNumber() << '\n');
Tim Northover3b0846e2014-05-24 12:50:23 +0000338
Matt Arsenault5b549712016-08-02 08:30:06 +0000339 unsigned &MBBSize = BlockInfo[MBB->getNumber()].Size;
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000340
Matt Arsenault5b549712016-08-02 08:30:06 +0000341 // Insert a new conditional branch and a new unconditional branch.
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000342 int RemovedSize = 0;
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +0000343 TII->reverseBranchCondition(Cond);
344 TII->removeBranch(*MBB, &RemovedSize);
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000345 MBBSize -= RemovedSize;
Matt Arsenault5b549712016-08-02 08:30:06 +0000346
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000347 int AddedSize = 0;
Matt Arsenaulte8e0f5c2016-09-14 17:24:15 +0000348 TII->insertBranch(*MBB, &NextBB, TBB, Cond, DL, &AddedSize);
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000349 MBBSize += AddedSize;
Tim Northover3b0846e2014-05-24 12:50:23 +0000350
351 // Finally, keep the block offsets up to date.
352 adjustBlockOffsets(*MBB);
353 return true;
354}
355
356bool AArch64BranchRelaxation::relaxBranchInstructions() {
357 bool Changed = false;
358 // Relaxing branches involves creating new basic blocks, so re-eval
359 // end() for termination.
Matt Arsenaultf1c39062016-06-16 21:21:49 +0000360 for (MachineFunction::iterator I = MF->begin(); I != MF->end(); ++I) {
361 MachineBasicBlock &MBB = *I;
Matt Arsenaultf7065e12016-08-02 07:20:09 +0000362 MachineBasicBlock::iterator J = MBB.getFirstTerminator();
363 if (J == MBB.end())
364 continue;
365
Matt Arsenault567631b2016-08-23 01:30:30 +0000366 MachineBasicBlock::iterator Next;
367 for (MachineBasicBlock::iterator J = MBB.getFirstTerminator();
368 J != MBB.end(); J = Next) {
369 Next = std::next(J);
370 MachineInstr &MI = *J;
371
372 if (MI.isConditionalBranch()) {
373 MachineBasicBlock *DestBB = getDestBlock(MI);
374 if (!isBlockInRange(MI, *DestBB)) {
375 if (Next != MBB.end() && Next->isConditionalBranch()) {
376 // If there are multiple conditional branches, this isn't an
377 // analyzable block. Split later terminators into a new block so
378 // each one will be analyzable.
379
380 MachineBasicBlock *NewBB = splitBlockBeforeInstr(*Next);
381 NewBB->transferSuccessors(&MBB);
382 MBB.addSuccessor(NewBB);
383 MBB.addSuccessor(DestBB);
384
385 // Cleanup potential unconditional branch to successor block.
386 NewBB->updateTerminator();
387 MBB.updateTerminator();
388 } else {
389 fixupConditionalBranch(MI);
390 ++NumConditionalRelaxed;
391 }
392
393 Changed = true;
394
395 // This may have modified all of the terminators, so start over.
396 Next = MBB.getFirstTerminator();
397 }
398
399 }
Tim Northover3b0846e2014-05-24 12:50:23 +0000400 }
401 }
Matt Arsenault567631b2016-08-23 01:30:30 +0000402
Tim Northover3b0846e2014-05-24 12:50:23 +0000403 return Changed;
404}
405
406bool AArch64BranchRelaxation::runOnMachineFunction(MachineFunction &mf) {
407 MF = &mf;
408
Tim Northover3b0846e2014-05-24 12:50:23 +0000409 DEBUG(dbgs() << "***** AArch64BranchRelaxation *****\n");
410
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000411 TII = MF->getSubtarget<AArch64Subtarget>().getInstrInfo();
Tim Northover3b0846e2014-05-24 12:50:23 +0000412
413 // Renumber all of the machine basic blocks in the function, guaranteeing that
414 // the numbers agree with the position of the block in the function.
415 MF->RenumberBlocks();
416
417 // Do the initial scan of the function, building up information about the
418 // sizes of each block.
419 scanFunction();
420
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000421 DEBUG(dbgs() << " Basic blocks before relaxation\n"; dumpBBs(););
Tim Northover3b0846e2014-05-24 12:50:23 +0000422
423 bool MadeChange = false;
424 while (relaxBranchInstructions())
425 MadeChange = true;
426
427 // After a while, this might be made debug-only, but it is not expensive.
428 verify();
429
Matt Arsenaulte8da1452016-08-02 08:06:17 +0000430 DEBUG(dbgs() << " Basic blocks after relaxation\n\n"; dumpBBs());
Tim Northover3b0846e2014-05-24 12:50:23 +0000431
432 BlockInfo.clear();
433
434 return MadeChange;
435}
436
Chad Rosier59bcbba2016-03-25 14:37:43 +0000437/// Returns an instance of the AArch64 Branch Relaxation pass.
Tim Northover3b0846e2014-05-24 12:50:23 +0000438FunctionPass *llvm::createAArch64BranchRelaxation() {
439 return new AArch64BranchRelaxation();
440}