mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
More LLVMContext-ification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74807 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "llvm/Analysis/Dominators.h"
|
||||
#include "llvm/Analysis/AliasSetTracker.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
@@ -181,6 +182,8 @@ namespace {
|
||||
/// AST - An AliasSetTracker object to update. If null, don't update it.
|
||||
///
|
||||
AliasSetTracker *AST;
|
||||
|
||||
LLVMContext* Context;
|
||||
|
||||
/// AllocaLookup - Reverse mapping of Allocas.
|
||||
///
|
||||
@@ -212,8 +215,9 @@ namespace {
|
||||
DenseMap<const BasicBlock*, unsigned> BBNumPreds;
|
||||
public:
|
||||
PromoteMem2Reg(const std::vector<AllocaInst*> &A, DominatorTree &dt,
|
||||
DominanceFrontier &df, AliasSetTracker *ast)
|
||||
: Allocas(A), DT(dt), DF(df), AST(ast) {}
|
||||
DominanceFrontier &df, AliasSetTracker *ast,
|
||||
LLVMContext* C)
|
||||
: Allocas(A), DT(dt), DF(df), AST(ast), Context(C) {}
|
||||
|
||||
void run();
|
||||
|
||||
@@ -445,7 +449,7 @@ void PromoteMem2Reg::run() {
|
||||
//
|
||||
RenamePassData::ValVector Values(Allocas.size());
|
||||
for (unsigned i = 0, e = Allocas.size(); i != e; ++i)
|
||||
Values[i] = UndefValue::get(Allocas[i]->getAllocatedType());
|
||||
Values[i] = Context->getUndef(Allocas[i]->getAllocatedType());
|
||||
|
||||
// Walks all basic blocks in the function performing the SSA rename algorithm
|
||||
// and inserting the phi nodes we marked as necessary
|
||||
@@ -472,7 +476,7 @@ void PromoteMem2Reg::run() {
|
||||
// Just delete the users now.
|
||||
//
|
||||
if (!A->use_empty())
|
||||
A->replaceAllUsesWith(UndefValue::get(A->getType()));
|
||||
A->replaceAllUsesWith(Context->getUndef(A->getType()));
|
||||
if (AST) AST->deleteValue(A);
|
||||
A->eraseFromParent();
|
||||
}
|
||||
@@ -558,7 +562,7 @@ void PromoteMem2Reg::run() {
|
||||
BasicBlock::iterator BBI = BB->begin();
|
||||
while ((SomePHI = dyn_cast<PHINode>(BBI++)) &&
|
||||
SomePHI->getNumIncomingValues() == NumBadPreds) {
|
||||
Value *UndefVal = UndefValue::get(SomePHI->getType());
|
||||
Value *UndefVal = Context->getUndef(SomePHI->getType());
|
||||
for (unsigned pred = 0, e = Preds.size(); pred != e; ++pred)
|
||||
SomePHI->addIncoming(UndefVal, Preds[pred]);
|
||||
}
|
||||
@@ -804,7 +808,7 @@ void PromoteMem2Reg::PromoteSingleBlockAlloca(AllocaInst *AI, AllocaInfo &Info,
|
||||
if (StoresByIndex.empty()) {
|
||||
for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end(); UI != E;)
|
||||
if (LoadInst *LI = dyn_cast<LoadInst>(*UI++)) {
|
||||
LI->replaceAllUsesWith(UndefValue::get(LI->getType()));
|
||||
LI->replaceAllUsesWith(Context->getUndef(LI->getType()));
|
||||
if (AST && isa<PointerType>(LI->getType()))
|
||||
AST->deleteValue(LI);
|
||||
LBI.deleteValue(LI);
|
||||
@@ -995,9 +999,9 @@ NextIteration:
|
||||
///
|
||||
void llvm::PromoteMemToReg(const std::vector<AllocaInst*> &Allocas,
|
||||
DominatorTree &DT, DominanceFrontier &DF,
|
||||
AliasSetTracker *AST) {
|
||||
LLVMContext* Context, AliasSetTracker *AST) {
|
||||
// If there is nothing to do, bail out...
|
||||
if (Allocas.empty()) return;
|
||||
|
||||
PromoteMem2Reg(Allocas, DT, DF, AST).run();
|
||||
PromoteMem2Reg(Allocas, DT, DF, AST, Context).run();
|
||||
}
|
||||
|
Reference in New Issue
Block a user