mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-01 13:17:01 +00:00
Add DCE as integral part of the level raising to avoid processing instructions that are dead
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
#include "llvm/ConstPoolVals.h"
|
#include "llvm/ConstPoolVals.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Optimizations/ConstantHandling.h"
|
#include "llvm/Optimizations/ConstantHandling.h"
|
||||||
|
#include "llvm/Optimizations/DCE.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -137,7 +138,8 @@ static const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
|
|||||||
if (Offset >= SL->MemberOffsets[i] && Offset < SL->MemberOffsets[i+1])
|
if (Offset >= SL->MemberOffsets[i] && Offset < SL->MemberOffsets[i+1])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
assert(Offset >= SL->MemberOffsets[i] && Offset < SL->MemberOffsets[i+1]);
|
assert(Offset >= SL->MemberOffsets[i] &&
|
||||||
|
(i == SL->MemberOffsets.size()-1 || Offset < SL->MemberOffsets[i+1]));
|
||||||
|
|
||||||
// Make sure to save the current index...
|
// Make sure to save the current index...
|
||||||
Offsets.push_back(ConstPoolUInt::get(Type::UByteTy, i));
|
Offsets.push_back(ConstPoolUInt::get(Type::UByteTy, i));
|
||||||
@@ -459,8 +461,6 @@ static bool PeepholeMallocInst(BasicBlock *BB, BasicBlock::iterator &BI) {
|
|||||||
|
|
||||||
static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
|
static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
|
||||||
Instruction *I = *BI;
|
Instruction *I = *BI;
|
||||||
// TODO: replace this with a DCE call
|
|
||||||
if (I->use_size() == 0 && I->getType() != Type::VoidTy) return false;
|
|
||||||
|
|
||||||
if (CastInst *CI = dyn_cast<CastInst>(I)) {
|
if (CastInst *CI = dyn_cast<CastInst>(I)) {
|
||||||
Value *Src = CI->getOperand(0);
|
Value *Src = CI->getOperand(0);
|
||||||
@@ -642,7 +642,8 @@ static bool DoRaisePass(Method *M) {
|
|||||||
BasicBlock::InstListType &BIL = BB->getInstList();
|
BasicBlock::InstListType &BIL = BB->getInstList();
|
||||||
|
|
||||||
for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) {
|
for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) {
|
||||||
if (PeepholeOptimize(BB, BI))
|
if (opt::DeadCodeElimination::dceInstruction(BIL, BI) ||
|
||||||
|
PeepholeOptimize(BB, BI))
|
||||||
Changed = true;
|
Changed = true;
|
||||||
else
|
else
|
||||||
++BI;
|
++BI;
|
||||||
@@ -659,6 +660,10 @@ bool RaisePointerReferences::doit(Method *M) {
|
|||||||
if (M->isExternal()) return false;
|
if (M->isExternal()) return false;
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
|
#ifdef DEBUG_PEEPHOLE_INSTS
|
||||||
|
cerr << "\n\n\nStarting to work on Method '" << M->getName() << "'\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
while (DoRaisePass(M)) Changed = true;
|
while (DoRaisePass(M)) Changed = true;
|
||||||
|
|
||||||
// PtrCasts - Keep a mapping between the pointer values (the key of the
|
// PtrCasts - Keep a mapping between the pointer values (the key of the
|
||||||
|
Reference in New Issue
Block a user