[llvm-commits] [llvm] r71150 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/CMakeLists.txt lib/CodeGen/CodePlacementOpt.cpp lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/LoopAligner.cpp
Evan Cheng
evan.cheng at apple.com
Wed May 6 22:42:24 PDT 2009
Author: evancheng
Date: Thu May 7 00:42:24 2009
New Revision: 71150
URL: http://llvm.org/viewvc/llvm-project?rev=71150&view=rev
Log:
Rename "loop aligner" pass to "code placement optimization" pass.
Added:
llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp
- copied, changed from r71116, llvm/trunk/lib/CodeGen/LoopAligner.cpp
Removed:
llvm/trunk/lib/CodeGen/LoopAligner.cpp
Modified:
llvm/trunk/include/llvm/CodeGen/Passes.h
llvm/trunk/lib/CodeGen/CMakeLists.txt
llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
Modified: llvm/trunk/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=71150&r1=71149&r2=71150&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/Passes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/Passes.h Thu May 7 00:42:24 2009
@@ -146,9 +146,9 @@
/// IfConverter Pass - This pass performs machine code if conversion.
FunctionPass *createIfConverterPass();
- /// LoopAligner Pass - This pass aligns loop headers to target specific
- /// alignment boundary.
- FunctionPass *createLoopAlignerPass();
+ /// Code Placement Pass - This pass optimize code placement and aligns loop
+ /// headers to target specific alignment boundary.
+ FunctionPass *createCodePlacementOptPass();
/// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This
/// allows a debug emitter to determine if the range of two labels is empty,
Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=71150&r1=71149&r2=71150&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/CMakeLists.txt Thu May 7 00:42:24 2009
@@ -1,5 +1,6 @@
add_llvm_library(LLVMCodeGen
BranchFolding.cpp
+ CodePlacementOpt.cpp
DeadMachineInstructionElim.cpp
ELFWriter.cpp
GCMetadata.cpp
@@ -13,7 +14,6 @@
LiveIntervalAnalysis.cpp
LiveStackAnalysis.cpp
LiveVariables.cpp
- LoopAligner.cpp
LowerSubregs.cpp
MachOWriter.cpp
MachineBasicBlock.cpp
Copied: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (from r71116, llvm/trunk/lib/CodeGen/LoopAligner.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?p2=llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp&p1=llvm/trunk/lib/CodeGen/LoopAligner.cpp&r1=71116&r2=71150&rev=71150&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LoopAligner.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Thu May 7 00:42:24 2009
@@ -1,4 +1,4 @@
-//===-- LoopAligner.cpp - Loop aligner pass. ------------------------------===//
+//===-- CodePlacementOpt.cpp - Code Placement pass. -----------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the pass that align loop headers to target specific
-// alignment boundary.
+// This file implements the pass that optimize code placement and align loop
+// headers to target specific alignment boundary.
//
//===----------------------------------------------------------------------===//
-#define DEBUG_TYPE "loopalign"
+#define DEBUG_TYPE "code-placement"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/Passes.h"
@@ -23,13 +23,15 @@
using namespace llvm;
namespace {
- class LoopAligner : public MachineFunctionPass {
+ class CodePlacementOpt : public MachineFunctionPass {
public:
static char ID;
- LoopAligner() : MachineFunctionPass(&ID) {}
+ CodePlacementOpt() : MachineFunctionPass(&ID) {}
virtual bool runOnMachineFunction(MachineFunction &MF);
- virtual const char *getPassName() const { return "Loop aligner"; }
+ virtual const char *getPassName() const {
+ return "Code Placement Optimizater";
+ }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<MachineLoopInfo>();
@@ -39,12 +41,14 @@
}
};
- char LoopAligner::ID = 0;
+ char CodePlacementOpt::ID = 0;
} // end anonymous namespace
-FunctionPass *llvm::createLoopAlignerPass() { return new LoopAligner(); }
+FunctionPass *llvm::createCodePlacementOptPass() {
+ return new CodePlacementOpt();
+}
-bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
+bool CodePlacementOpt::runOnMachineFunction(MachineFunction &MF) {
const MachineLoopInfo *MLI = &getAnalysis<MachineLoopInfo>();
if (MLI->empty())
Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=71150&r1=71149&r2=71150&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Thu May 7 00:42:24 2009
@@ -70,7 +70,7 @@
PM.add(createMachineFunctionPrinterPass(cerr));
if (OptLevel != CodeGenOpt::None)
- PM.add(createLoopAlignerPass());
+ PM.add(createCodePlacementOptPass());
switch (FileType) {
default:
Removed: llvm/trunk/lib/CodeGen/LoopAligner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LoopAligner.cpp?rev=71149&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/LoopAligner.cpp (original)
+++ llvm/trunk/lib/CodeGen/LoopAligner.cpp (removed)
@@ -1,78 +0,0 @@
-//===-- LoopAligner.cpp - Loop aligner pass. ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the pass that align loop headers to target specific
-// alignment boundary.
-//
-//===----------------------------------------------------------------------===//
-
-#define DEBUG_TYPE "loopalign"
-#include "llvm/CodeGen/MachineLoopInfo.h"
-#include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/CodeGen/Passes.h"
-#include "llvm/Target/TargetLowering.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/Debug.h"
-using namespace llvm;
-
-namespace {
- class LoopAligner : public MachineFunctionPass {
- public:
- static char ID;
- LoopAligner() : MachineFunctionPass(&ID) {}
-
- virtual bool runOnMachineFunction(MachineFunction &MF);
- virtual const char *getPassName() const { return "Loop aligner"; }
-
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.addRequired<MachineLoopInfo>();
- AU.addPreserved<MachineLoopInfo>();
- AU.addPreservedID(MachineDominatorsID);
- MachineFunctionPass::getAnalysisUsage(AU);
- }
- };
-
- char LoopAligner::ID = 0;
-} // end anonymous namespace
-
-FunctionPass *llvm::createLoopAlignerPass() { return new LoopAligner(); }
-
-bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
- const MachineLoopInfo *MLI = &getAnalysis<MachineLoopInfo>();
-
- if (MLI->empty())
- return false; // No loops.
-
- const TargetLowering *TLI = MF.getTarget().getTargetLowering();
- if (!TLI)
- return false;
-
- unsigned Align = TLI->getPrefLoopAlignment();
- if (!Align)
- return false; // Don't care about loop alignment.
-
- const Function *F = MF.getFunction();
- if (F->hasFnAttr(Attribute::OptimizeForSize))
- return false;
-
- for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
- MachineBasicBlock *MBB = I;
- if (MLI->isLoopHeader(MBB)) {
- MachineBasicBlock *PredBB = prior(I);
- if (MLI->getLoopFor(MBB) == MLI->getLoopFor(PredBB))
- // If previously BB is in the same loop, don't align this BB. We want
- // to prevent adding noop's inside a loop.
- continue;
- MBB->setAlignment(Align);
- }
- }
-
- return true;
-}
More information about the llvm-commits
mailing list