mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-24 04:32:09 +00:00
changes to make it compatible with 64bit gcc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2792 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cfb22d3c14
commit
5ba99bd124
@ -27,6 +27,7 @@
|
|||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include "Support/StatisticReporter.h"
|
#include "Support/StatisticReporter.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
@ -168,7 +169,7 @@ Value *MutateStructTypes::ConvertValue(const Value *V) {
|
|||||||
return LocalValueMap[V] = new BasicBlock(BB->getName());
|
return LocalValueMap[V] = new BasicBlock(BB->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(cerr << "NPH: " << V << "\n");
|
DEBUG(std::cerr << "NPH: " << V << "\n");
|
||||||
|
|
||||||
// Otherwise make a constant to represent it
|
// Otherwise make a constant to represent it
|
||||||
return LocalValueMap[V] = new ValuePlaceHolder(ConvertType(V->getType()));
|
return LocalValueMap[V] = new ValuePlaceHolder(ConvertType(V->getType()));
|
||||||
@ -227,7 +228,7 @@ void MutateStructTypes::setTransforms(const TransformsType &XForm) {
|
|||||||
Transforms.insert(std::make_pair(OldTy,
|
Transforms.insert(std::make_pair(OldTy,
|
||||||
std::make_pair(cast<StructType>(NSTy.get()), InVec)));
|
std::make_pair(cast<StructType>(NSTy.get()), InVec)));
|
||||||
|
|
||||||
DEBUG(cerr << "Mutate " << OldTy << "\nTo " << NSTy << "\n");
|
DEBUG(std::cerr << "Mutate " << OldTy << "\nTo " << NSTy << "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,12 @@
|
|||||||
#include "Support/DepthFirstIterator.h"
|
#include "Support/DepthFirstIterator.h"
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
using std::vector;
|
||||||
|
using std::cerr;
|
||||||
|
using std::map;
|
||||||
|
using std::string;
|
||||||
|
using std::set;
|
||||||
|
|
||||||
// DEBUG_CREATE_POOLS - Enable this to turn on debug output for the pool
|
// DEBUG_CREATE_POOLS - Enable this to turn on debug output for the pool
|
||||||
// creation phase in the top level function of a transformed data structure.
|
// creation phase in the top level function of a transformed data structure.
|
||||||
@ -171,7 +177,7 @@ namespace {
|
|||||||
// argument records, in order. Note that this must be a stable sort so
|
// argument records, in order. Note that this must be a stable sort so
|
||||||
// that the entries with the same sorting criteria (ie they are multiple
|
// that the entries with the same sorting criteria (ie they are multiple
|
||||||
// pool entries for the same argument) are kept in depth first order.
|
// pool entries for the same argument) are kept in depth first order.
|
||||||
stable_sort(ArgInfo.begin(), ArgInfo.end());
|
std::stable_sort(ArgInfo.begin(), ArgInfo.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// addCallInfo - For a specified function call CI, figure out which pool
|
// addCallInfo - For a specified function call CI, figure out which pool
|
||||||
@ -335,7 +341,7 @@ bool PoolAllocate::processFunction(Function *F) {
|
|||||||
// variable sized array allocations and alloca's (which we do not want to
|
// variable sized array allocations and alloca's (which we do not want to
|
||||||
// pool allocate)
|
// pool allocate)
|
||||||
//
|
//
|
||||||
Allocs.erase(remove_if(Allocs.begin(), Allocs.end(), isNotPoolableAlloc),
|
Allocs.erase(std::remove_if(Allocs.begin(), Allocs.end(), isNotPoolableAlloc),
|
||||||
Allocs.end());
|
Allocs.end());
|
||||||
|
|
||||||
|
|
||||||
@ -771,7 +777,7 @@ public:
|
|||||||
LI.getOperand(3) == Constant::getNullValue(Type::UByteTy));
|
LI.getOperand(3) == Constant::getNullValue(Type::UByteTy));
|
||||||
|
|
||||||
// If it is a load of a pool base, keep track of it for future reference
|
// If it is a load of a pool base, keep track of it for future reference
|
||||||
PoolDescMap.insert(make_pair(LoadAddr, &LI));
|
PoolDescMap.insert(std::make_pair(LoadAddr, &LI));
|
||||||
++Remaining;
|
++Remaining;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1256,7 +1262,7 @@ void PoolAllocate::transformFunctionBody(Function *F, FunctionDSGraph &IPFGraph,
|
|||||||
// we can safely delete Arguments whose types have changed...
|
// we can safely delete Arguments whose types have changed...
|
||||||
//
|
//
|
||||||
for_each(InstToFix.begin(), InstToFix.end(),
|
for_each(InstToFix.begin(), InstToFix.end(),
|
||||||
mem_fun(&Instruction::dropAllReferences));
|
std::mem_fun(&Instruction::dropAllReferences));
|
||||||
|
|
||||||
// Loop through all of the pointer arguments coming into the function,
|
// Loop through all of the pointer arguments coming into the function,
|
||||||
// replacing them with arguments of POINTERTYPE to match the function type of
|
// replacing them with arguments of POINTERTYPE to match the function type of
|
||||||
@ -1475,7 +1481,7 @@ void PoolAllocate::transformFunction(TransformFunctionInfo &TFI,
|
|||||||
// Add the descriptor. We already know everything about it by now, much
|
// Add the descriptor. We already know everything about it by now, much
|
||||||
// of it is the same as the caller info.
|
// of it is the same as the caller info.
|
||||||
//
|
//
|
||||||
PoolDescs.insert(make_pair(CalleeNode,
|
PoolDescs.insert(std::make_pair(CalleeNode,
|
||||||
PoolInfo(CalleeNode, CalleeValue,
|
PoolInfo(CalleeNode, CalleeValue,
|
||||||
CallerPI.NewType,
|
CallerPI.NewType,
|
||||||
CallerPI.PoolType)));
|
CallerPI.PoolType)));
|
||||||
@ -1542,7 +1548,7 @@ void PoolAllocate::CreatePools(Function *F, const vector<AllocDSNode*> &Allocs,
|
|||||||
// except the node & NewType fields.
|
// except the node & NewType fields.
|
||||||
//
|
//
|
||||||
map<DSNode*, PoolInfo>::iterator PI =
|
map<DSNode*, PoolInfo>::iterator PI =
|
||||||
PoolDescs.insert(make_pair(Allocs[i], PoolInfo(Allocs[i]))).first;
|
PoolDescs.insert(std::make_pair(Allocs[i], PoolInfo(Allocs[i]))).first;
|
||||||
|
|
||||||
// Add a symbol table entry for the new type if there was one for the old
|
// Add a symbol table entry for the new type if there was one for the old
|
||||||
// type...
|
// type...
|
||||||
@ -1573,7 +1579,7 @@ void PoolAllocate::CreatePools(Function *F, const vector<AllocDSNode*> &Allocs,
|
|||||||
CurModule->addTypeName(OldName+".pool", PoolType);
|
CurModule->addTypeName(OldName+".pool", PoolType);
|
||||||
|
|
||||||
// Create the pool type, with opaque values for pointers...
|
// Create the pool type, with opaque values for pointers...
|
||||||
AbsPoolTyMap.insert(make_pair(Allocs[i], PoolType));
|
AbsPoolTyMap.insert(std::make_pair(Allocs[i], PoolType));
|
||||||
#ifdef DEBUG_CREATE_POOLS
|
#ifdef DEBUG_CREATE_POOLS
|
||||||
cerr << "POOL TY: " << AbsPoolTyMap.find(Allocs[i])->second.get() << "\n";
|
cerr << "POOL TY: " << AbsPoolTyMap.find(Allocs[i])->second.get() << "\n";
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
static Statistic<> NumBlockRemoved("adce\t\t- Number of basic blocks removed");
|
static Statistic<> NumBlockRemoved("adce\t\t- Number of basic blocks removed");
|
||||||
static Statistic<> NumInstRemoved ("adce\t\t- Number of instructions removed");
|
static Statistic<> NumInstRemoved ("adce\t\t- Number of instructions removed");
|
||||||
|
@ -66,6 +66,7 @@ bool DecomposePass::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
// uses the last ptr2 generated in the loop and a single index.
|
// uses the last ptr2 generated in the loop and a single index.
|
||||||
// If any index is (uint) 0, we omit the getElementPtr instruction.
|
// If any index is (uint) 0, we omit the getElementPtr instruction.
|
||||||
//
|
//
|
||||||
|
|
||||||
void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
|
void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
|
||||||
MemAccessInst &MAI = cast<MemAccessInst>(*BBI);
|
MemAccessInst &MAI = cast<MemAccessInst>(*BBI);
|
||||||
BasicBlock *BB = MAI.getParent();
|
BasicBlock *BB = MAI.getParent();
|
||||||
@ -74,10 +75,11 @@ void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
|
|||||||
// Remove the instruction from the stream
|
// Remove the instruction from the stream
|
||||||
BB->getInstList().remove(BBI);
|
BB->getInstList().remove(BBI);
|
||||||
|
|
||||||
vector<Instruction*> NewInsts;
|
std::vector<Instruction*> NewInsts;
|
||||||
|
|
||||||
// Process each index except the last one.
|
// Process each index except the last one.
|
||||||
//
|
//
|
||||||
|
|
||||||
User::const_op_iterator OI = MAI.idx_begin(), OE = MAI.idx_end();
|
User::const_op_iterator OI = MAI.idx_begin(), OE = MAI.idx_end();
|
||||||
for (; OI+1 != OE; ++OI) {
|
for (; OI+1 != OE; ++OI) {
|
||||||
assert(isa<PointerType>(LastPtr->getType()));
|
assert(isa<PointerType>(LastPtr->getType()));
|
||||||
@ -92,8 +94,10 @@ void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
|
|||||||
// and the next index is a structure offset (i.e., not an array offset),
|
// and the next index is a structure offset (i.e., not an array offset),
|
||||||
// we need to include an initial [0] to index into the pointer.
|
// we need to include an initial [0] to index into the pointer.
|
||||||
//
|
//
|
||||||
vector<Value*> Indices;
|
|
||||||
|
std::vector<Value*> Indices;
|
||||||
const PointerType *PtrTy = cast<PointerType>(LastPtr->getType());
|
const PointerType *PtrTy = cast<PointerType>(LastPtr->getType());
|
||||||
|
|
||||||
if (isa<StructType>(PtrTy->getElementType())
|
if (isa<StructType>(PtrTy->getElementType())
|
||||||
&& !PtrTy->indexValid(*OI))
|
&& !PtrTy->indexValid(*OI))
|
||||||
Indices.push_back(Constant::getNullValue(Type::UIntTy));
|
Indices.push_back(Constant::getNullValue(Type::UIntTy));
|
||||||
@ -117,6 +121,7 @@ void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
|
|||||||
NewInsts.push_back(cast<Instruction>(LastPtr));
|
NewInsts.push_back(cast<Instruction>(LastPtr));
|
||||||
++NumAdded;
|
++NumAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Instruction 2: nextPtr2 = cast nextPtr1 to NextPtrTy
|
// Instruction 2: nextPtr2 = cast nextPtr1 to NextPtrTy
|
||||||
// This is not needed if the two types are identical.
|
// This is not needed if the two types are identical.
|
||||||
@ -134,7 +139,8 @@ void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
|
|||||||
const PointerType *PtrTy = cast<PointerType>(LastPtr->getType());
|
const PointerType *PtrTy = cast<PointerType>(LastPtr->getType());
|
||||||
|
|
||||||
// First, get the final index vector. As above, we may need an initial [0].
|
// First, get the final index vector. As above, we may need an initial [0].
|
||||||
vector<Value*> Indices;
|
|
||||||
|
std::vector<Value*> Indices;
|
||||||
if (isa<StructType>(PtrTy->getElementType())
|
if (isa<StructType>(PtrTy->getElementType())
|
||||||
&& !PtrTy->indexValid(*OI))
|
&& !PtrTy->indexValid(*OI))
|
||||||
Indices.push_back(Constant::getNullValue(Type::UIntTy));
|
Indices.push_back(Constant::getNullValue(Type::UIntTy));
|
||||||
@ -156,6 +162,7 @@ void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
|
|||||||
assert(0 && "Unrecognized memory access instruction");
|
assert(0 && "Unrecognized memory access instruction");
|
||||||
}
|
}
|
||||||
NewInsts.push_back(NewI);
|
NewInsts.push_back(NewI);
|
||||||
|
|
||||||
|
|
||||||
// Replace all uses of the old instruction with the new
|
// Replace all uses of the old instruction with the new
|
||||||
MAI.replaceAllUsesWith(NewI);
|
MAI.replaceAllUsesWith(NewI);
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "Support/StatisticReporter.h"
|
#include "Support/StatisticReporter.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
using std::set;
|
||||||
|
using std::map;
|
||||||
|
|
||||||
|
|
||||||
static Statistic<> NumInstRemoved("gcse\t\t- Number of instructions removed");
|
static Statistic<> NumInstRemoved("gcse\t\t- Number of instructions removed");
|
||||||
static Statistic<> NumLoadRemoved("gcse\t\t- Number of loads removed");
|
static Statistic<> NumLoadRemoved("gcse\t\t- Number of loads removed");
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include "Support/StatisticReporter.h"
|
#include "Support/StatisticReporter.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
static Statistic<> NumRemoved ("indvars\t\t- Number of aux indvars removed");
|
static Statistic<> NumRemoved ("indvars\t\t- Number of aux indvars removed");
|
||||||
static Statistic<> NumInserted("indvars\t\t- Number of cannonical indvars added");
|
static Statistic<> NumInserted("indvars\t\t- Number of cannonical indvars added");
|
||||||
@ -114,7 +115,7 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
|
|||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(cerr << "Induction variables:\n");
|
DEBUG(std::cerr << "Induction variables:\n");
|
||||||
|
|
||||||
// Get the current loop iteration count, which is always the value of the
|
// Get the current loop iteration count, which is always the value of the
|
||||||
// cannonical phi node...
|
// cannonical phi node...
|
||||||
@ -127,7 +128,7 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
|
|||||||
for (unsigned i = 0; i < IndVars.size(); ++i) {
|
for (unsigned i = 0; i < IndVars.size(); ++i) {
|
||||||
InductionVariable *IV = &IndVars[i];
|
InductionVariable *IV = &IndVars[i];
|
||||||
|
|
||||||
DEBUG(cerr << IV);
|
DEBUG(std::cerr << IV);
|
||||||
|
|
||||||
// Don't modify the cannonical indvar or unrecognized indvars...
|
// Don't modify the cannonical indvar or unrecognized indvars...
|
||||||
if (IV != Cannonical && IV->InductionType != InductionVariable::Unknown) {
|
if (IV != Cannonical && IV->InductionType != InductionVariable::Unknown) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include "Support/StatisticReporter.h"
|
#include "Support/StatisticReporter.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
using std::string;
|
||||||
|
|
||||||
static Statistic<> NumHoistedNPH("licm\t\t- Number of insts hoisted to multiple"
|
static Statistic<> NumHoistedNPH("licm\t\t- Number of insts hoisted to multiple"
|
||||||
" loop preds (bad, no loop pre-header)");
|
" loop preds (bad, no loop pre-header)");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user