Print variable's display name in dwarf DIE.
[oota-llvm.git] / lib / CodeGen / LoopAligner.cpp
index 906e888242862913a9184dba591d50e3173c5269..b67f5c3bf9192e0a9a444a813a4331d26a316102 100644 (file)
@@ -34,7 +34,7 @@ namespace {
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.addRequired<MachineLoopInfo>();
       AU.addPreserved<MachineLoopInfo>();
-      AU.setPreservesAll();
+      AU.addPreservedID(MachineDominatorsID);
       MachineFunctionPass::getAnalysisUsage(AU);
     }
   };
@@ -58,10 +58,20 @@ bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
   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))
+    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;