From 0d0ca8572f3847f38af8dec4ad4328ec7a170ec9 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 12 Jun 2008 20:55:39 +0000 Subject: [PATCH] Revert 52223. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52243 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/TailDuplication.cpp | 18 ------------------ .../TailDup/2008-06-11-AvoidDupLoopHeader.ll | 4 ++-- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 4e0949a2b47..d0998ab5a65 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -33,7 +33,6 @@ #include "llvm/Support/Debug.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/SmallPtrSet.h" -#include "llvm/Analysis/LoopInfo.h" #include using namespace llvm; @@ -51,12 +50,10 @@ namespace { static char ID; // Pass identification, replacement for typeid TailDup() : FunctionPass((intptr_t)&ID) {} - virtual void getAnalysisUsage(AnalysisUsage &AU) const; private: inline bool shouldEliminateUnconditionalBranch(TerminatorInst *, unsigned); inline void eliminateUnconditionalBranch(BranchInst *BI); SmallPtrSet CycleDetector; - LoopInfo *LI; // The current loop information }; } @@ -72,9 +69,6 @@ FunctionPass *llvm::createTailDuplicationPass() { return new TailDup(); } /// a place it already pointed to earlier; see PR 2323. bool TailDup::runOnFunction(Function &F) { bool Changed = false; - - LI = &getAnalysis(); - CycleDetector.clear(); for (Function::iterator I = F.begin(), E = F.end(); I != E; ) { if (shouldEliminateUnconditionalBranch(I->getTerminator(), @@ -89,10 +83,6 @@ bool TailDup::runOnFunction(Function &F) { return Changed; } -void TailDup::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); -} - /// shouldEliminateUnconditionalBranch - Return true if this branch looks /// attractive to eliminate. We eliminate the branch if the destination basic /// block has <= 5 instructions in it, not counting PHI nodes. In practice, @@ -196,14 +186,6 @@ bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI, if (!CycleDetector.insert(Dest)) return false; - // Avoid non-natural loops: - // If a loop header is duplicated, the former natural loop will contain two - // paths into the loop --> the loop it not natural anymore. We want to avoid - // this, because other optimizaions may fail to improve the loop because of - // this. - if (LI->isLoopHeader(Dest)) - return false; - return true; } diff --git a/test/Transforms/TailDup/2008-06-11-AvoidDupLoopHeader.ll b/test/Transforms/TailDup/2008-06-11-AvoidDupLoopHeader.ll index 7014f744a80..c29e7d45c6a 100644 --- a/test/Transforms/TailDup/2008-06-11-AvoidDupLoopHeader.ll +++ b/test/Transforms/TailDup/2008-06-11-AvoidDupLoopHeader.ll @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | opt -tailduplicate -taildup-threshold=3 -stats -disable-output |& \ -; RUN: not grep tailduplicate +; RUN: llvm-as < %s | opt -tailduplicate -taildup-threshold=3 -stats -disable-output | not grep tailduplicate +; XFAIL: * define i32 @foo(i32 %l) nounwind { entry: