Skip to content

Commit

Permalink
Add command line options to force function/loop alignments.
Browse files Browse the repository at this point in the history
These are being added for testing purposes.
http://reviews.llvm.org/D15648

llvm-svn: 256571
  • Loading branch information
Chad Rosier committed Dec 29, 2015
1 parent e7d8228 commit 6b43263
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions llvm/lib/CodeGen/MachineBlockPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ static cl::opt<unsigned> AlignAllBlock("align-all-blocks",
"blocks in the function."),
cl::init(0), cl::Hidden);

static cl::opt<unsigned>
AlignAllLoops("align-all-loops",
cl::desc("Force the alignment of all loops in the function."),
cl::init(0), cl::Hidden);

// FIXME: Find a good default for this flag and remove the flag.
static cl::opt<unsigned> ExitBlockBias(
"block-placement-exit-block-bias",
Expand Down Expand Up @@ -1329,6 +1334,11 @@ void MachineBlockPlacement::buildCFGChains(MachineFunction &F) {
if (!L)
continue;

if (AlignAllLoops) {
ChainBB->setAlignment(AlignAllLoops);
continue;
}

unsigned Align = TLI->getPrefLoopAlignment(L);
if (!Align)
continue; // Don't care about loop alignment.
Expand Down
8 changes: 8 additions & 0 deletions llvm/lib/CodeGen/MachineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ using namespace llvm;

#define DEBUG_TYPE "codegen"

static cl::opt<unsigned>
AlignAllFunctions("align-all-functions",
cl::desc("Force the alignment of all functions."),
cl::init(0), cl::Hidden);

void MachineFunctionInitializer::anchor() {}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -87,6 +92,9 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
Alignment = std::max(Alignment,
STI->getTargetLowering()->getPrefFunctionAlignment());

if (AlignAllFunctions)
Alignment = AlignAllFunctions;

FunctionNumber = FunctionNum;
JumpTableInfo = nullptr;

Expand Down

0 comments on commit 6b43263

Please sign in to comment.