mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
Revert 52223.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52243 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/Analysis/LoopInfo.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@@ -51,12 +50,10 @@ namespace {
|
|||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
TailDup() : FunctionPass((intptr_t)&ID) {}
|
TailDup() : FunctionPass((intptr_t)&ID) {}
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
|
||||||
private:
|
private:
|
||||||
inline bool shouldEliminateUnconditionalBranch(TerminatorInst *, unsigned);
|
inline bool shouldEliminateUnconditionalBranch(TerminatorInst *, unsigned);
|
||||||
inline void eliminateUnconditionalBranch(BranchInst *BI);
|
inline void eliminateUnconditionalBranch(BranchInst *BI);
|
||||||
SmallPtrSet<BasicBlock*, 4> CycleDetector;
|
SmallPtrSet<BasicBlock*, 4> 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.
|
/// a place it already pointed to earlier; see PR 2323.
|
||||||
bool TailDup::runOnFunction(Function &F) {
|
bool TailDup::runOnFunction(Function &F) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
LI = &getAnalysis<LoopInfo>();
|
|
||||||
|
|
||||||
CycleDetector.clear();
|
CycleDetector.clear();
|
||||||
for (Function::iterator I = F.begin(), E = F.end(); I != E; ) {
|
for (Function::iterator I = F.begin(), E = F.end(); I != E; ) {
|
||||||
if (shouldEliminateUnconditionalBranch(I->getTerminator(),
|
if (shouldEliminateUnconditionalBranch(I->getTerminator(),
|
||||||
@@ -89,10 +83,6 @@ bool TailDup::runOnFunction(Function &F) {
|
|||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TailDup::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
||||||
AU.addRequired<LoopInfo>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// shouldEliminateUnconditionalBranch - Return true if this branch looks
|
/// shouldEliminateUnconditionalBranch - Return true if this branch looks
|
||||||
/// attractive to eliminate. We eliminate the branch if the destination basic
|
/// attractive to eliminate. We eliminate the branch if the destination basic
|
||||||
/// block has <= 5 instructions in it, not counting PHI nodes. In practice,
|
/// 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))
|
if (!CycleDetector.insert(Dest))
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
; RUN: llvm-as < %s | opt -tailduplicate -taildup-threshold=3 -stats -disable-output |& \
|
; RUN: llvm-as < %s | opt -tailduplicate -taildup-threshold=3 -stats -disable-output | not grep tailduplicate
|
||||||
; RUN: not grep tailduplicate
|
; XFAIL: *
|
||||||
|
|
||||||
define i32 @foo(i32 %l) nounwind {
|
define i32 @foo(i32 %l) nounwind {
|
||||||
entry:
|
entry:
|
||||||
|
Reference in New Issue
Block a user