From: Chad Rosier Date: Tue, 29 Dec 2015 18:18:07 +0000 (+0000) Subject: Add command line options to force function/loop alignments. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=8b2e79cb091f956da7d26f791daf2bf85f7b0867 Add command line options to force function/loop alignments. These are being added for testing purposes. http://reviews.llvm.org/D15648 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256571 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/MachineBlockPlacement.cpp b/lib/CodeGen/MachineBlockPlacement.cpp index fcddf346cf6..f5e30564501 100644 --- a/lib/CodeGen/MachineBlockPlacement.cpp +++ b/lib/CodeGen/MachineBlockPlacement.cpp @@ -62,6 +62,11 @@ static cl::opt AlignAllBlock("align-all-blocks", "blocks in the function."), cl::init(0), cl::Hidden); +static cl::opt + 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 ExitBlockBias( "block-placement-exit-block-bias", @@ -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. diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 80d30a5b131..ca4bb1c6ad4 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -47,6 +47,11 @@ using namespace llvm; #define DEBUG_TYPE "codegen" +static cl::opt + AlignAllFunctions("align-all-functions", + cl::desc("Force the alignment of all functions."), + cl::init(0), cl::Hidden); + void MachineFunctionInitializer::anchor() {} //===----------------------------------------------------------------------===// @@ -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;