mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa<GlobalValue> usage - Correct isa<Constant> for GlobalValue subclass git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14942 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e0125b6785
commit
e840434755
@ -143,8 +143,8 @@ static const Value *getUnderlyingObject(const Value *V) {
|
|||||||
if (CE->getOpcode() == Instruction::Cast ||
|
if (CE->getOpcode() == Instruction::Cast ||
|
||||||
CE->getOpcode() == Instruction::GetElementPtr)
|
CE->getOpcode() == Instruction::GetElementPtr)
|
||||||
return getUnderlyingObject(CE->getOperand(0));
|
return getUnderlyingObject(CE->getOperand(0));
|
||||||
} else if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V)) {
|
} else if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
|
||||||
return CPR->getValue();
|
return GV;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ static const Value *GetGEPOperands(const Value *V, std::vector<Value*> &GEPOps){
|
|||||||
V = cast<User>(V)->getOperand(0);
|
V = cast<User>(V)->getOperand(0);
|
||||||
|
|
||||||
while (const User *G = isGEP(V)) {
|
while (const User *G = isGEP(V)) {
|
||||||
if (!isa<Constant>(GEPOps[0]) ||
|
if (!isa<Constant>(GEPOps[0]) || isa<GlobalValue>(GEPOps[0]) ||
|
||||||
!cast<Constant>(GEPOps[0])->isNullValue())
|
!cast<Constant>(GEPOps[0])->isNullValue())
|
||||||
break; // Don't handle folding arbitrary pointer offsets yet...
|
break; // Don't handle folding arbitrary pointer offsets yet...
|
||||||
GEPOps.erase(GEPOps.begin()); // Drop the zero index
|
GEPOps.erase(GEPOps.begin()); // Drop the zero index
|
||||||
@ -217,7 +217,7 @@ static bool AddressMightEscape(const Value *V) {
|
|||||||
//
|
//
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
||||||
if (!isa<Constant>(P) && !isa<GlobalValue>(P))
|
if (!isa<Constant>(P))
|
||||||
if (const AllocationInst *AI =
|
if (const AllocationInst *AI =
|
||||||
dyn_cast_or_null<AllocationInst>(getUnderlyingObject(P))) {
|
dyn_cast_or_null<AllocationInst>(getUnderlyingObject(P))) {
|
||||||
// Okay, the pointer is to a stack allocated object. If we can prove that
|
// Okay, the pointer is to a stack allocated object. If we can prove that
|
||||||
@ -246,12 +246,6 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
|
|||||||
if (CE->getOpcode() == Instruction::Cast)
|
if (CE->getOpcode() == Instruction::Cast)
|
||||||
V2 = CE->getOperand(0);
|
V2 = CE->getOperand(0);
|
||||||
|
|
||||||
// Strip off constant pointer refs if they exist
|
|
||||||
if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V1))
|
|
||||||
V1 = CPR->getValue();
|
|
||||||
if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V2))
|
|
||||||
V2 = CPR->getValue();
|
|
||||||
|
|
||||||
// Are we checking for alias of the same value?
|
// Are we checking for alias of the same value?
|
||||||
if (V1 == V2) return MustAlias;
|
if (V1 == V2) return MustAlias;
|
||||||
|
|
||||||
@ -380,7 +374,7 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
|
|||||||
// the arguments provided, except substitute 0's for any variable
|
// the arguments provided, except substitute 0's for any variable
|
||||||
// indexes we find...
|
// indexes we find...
|
||||||
for (unsigned i = 0; i != GEPOperands.size(); ++i)
|
for (unsigned i = 0; i != GEPOperands.size(); ++i)
|
||||||
if (!isa<Constant>(GEPOperands[i]) ||
|
if (!isa<Constant>(GEPOperands[i]) || isa<GlobalValue>(GEPOperands[i]) ||
|
||||||
isa<ConstantExpr>(GEPOperands[i]))
|
isa<ConstantExpr>(GEPOperands[i]))
|
||||||
GEPOperands[i] =Constant::getNullValue(GEPOperands[i]->getType());
|
GEPOperands[i] =Constant::getNullValue(GEPOperands[i]->getType());
|
||||||
int64_t Offset = getTargetData().getIndexedOffset(BasePtr->getType(),
|
int64_t Offset = getTargetData().getIndexedOffset(BasePtr->getType(),
|
||||||
@ -453,7 +447,7 @@ CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops,
|
|||||||
|
|
||||||
bool AllAreZeros = true;
|
bool AllAreZeros = true;
|
||||||
for (unsigned i = UnequalOper; i != MaxOperands; ++i)
|
for (unsigned i = UnequalOper; i != MaxOperands; ++i)
|
||||||
if (!isa<Constant>(GEP1Ops[i]) ||
|
if (!isa<Constant>(GEP1Ops[i]) ||
|
||||||
!cast<Constant>(GEP1Ops[i])->isNullValue()) {
|
!cast<Constant>(GEP1Ops[i])->isNullValue()) {
|
||||||
AllAreZeros = false;
|
AllAreZeros = false;
|
||||||
break;
|
break;
|
||||||
|
@ -102,7 +102,7 @@ void DSGraphStats::countCallees(const Function& F) {
|
|||||||
|
|
||||||
DSNode *DSGraphStats::getNodeForValue(Value *V) {
|
DSNode *DSGraphStats::getNodeForValue(Value *V) {
|
||||||
const DSGraph *G = TDGraph;
|
const DSGraph *G = TDGraph;
|
||||||
if (isa<GlobalValue>(V) || isa<Constant>(V))
|
if (isa<Constant>(V))
|
||||||
G = TDGraph->getGlobalsGraph();
|
G = TDGraph->getGlobalsGraph();
|
||||||
|
|
||||||
const DSGraph::ScalarMapTy &ScalarMap = G->getScalarMap();
|
const DSGraph::ScalarMapTy &ScalarMap = G->getScalarMap();
|
||||||
|
@ -220,10 +220,13 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
|
|||||||
// Otherwise we need to create a new node to point to.
|
// Otherwise we need to create a new node to point to.
|
||||||
// Check first for constant expressions that must be traversed to
|
// Check first for constant expressions that must be traversed to
|
||||||
// extract the actual value.
|
// extract the actual value.
|
||||||
if (Constant *C = dyn_cast<Constant>(V))
|
DSNode* N;
|
||||||
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
|
if (GlobalValue* GV = dyn_cast<GlobalValue>(V)) {
|
||||||
return NH = getValueDest(*CPR->getValue());
|
// Create a new global node for this global variable...
|
||||||
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
N = createNode(GV->getType()->getElementType());
|
||||||
|
N->addGlobal(GV);
|
||||||
|
} else if (Constant *C = dyn_cast<Constant>(V)) {
|
||||||
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
||||||
if (CE->getOpcode() == Instruction::Cast)
|
if (CE->getOpcode() == Instruction::Cast)
|
||||||
NH = getValueDest(*CE->getOperand(0));
|
NH = getValueDest(*CE->getOperand(0));
|
||||||
else if (CE->getOpcode() == Instruction::GetElementPtr) {
|
else if (CE->getOpcode() == Instruction::GetElementPtr) {
|
||||||
@ -247,13 +250,7 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
|
|||||||
} else {
|
} else {
|
||||||
assert(0 && "Unknown constant type!");
|
assert(0 && "Unknown constant type!");
|
||||||
}
|
}
|
||||||
|
N = createNode(); // just create a shadow node
|
||||||
// Otherwise we need to create a new node to point to...
|
|
||||||
DSNode *N;
|
|
||||||
if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
|
|
||||||
// Create a new global node for this global variable...
|
|
||||||
N = createNode(GV->getType()->getElementType());
|
|
||||||
N->addGlobal(GV);
|
|
||||||
} else {
|
} else {
|
||||||
// Otherwise just create a shadow node
|
// Otherwise just create a shadow node
|
||||||
N = createNode();
|
N = createNode();
|
||||||
@ -491,8 +488,6 @@ void GraphBuilder::visitInvokeInst(InvokeInst &II) {
|
|||||||
|
|
||||||
void GraphBuilder::visitCallSite(CallSite CS) {
|
void GraphBuilder::visitCallSite(CallSite CS) {
|
||||||
Value *Callee = CS.getCalledValue();
|
Value *Callee = CS.getCalledValue();
|
||||||
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Callee))
|
|
||||||
Callee = CPR->getValue();
|
|
||||||
|
|
||||||
// Special case handling of certain libc allocation functions here.
|
// Special case handling of certain libc allocation functions here.
|
||||||
if (Function *F = dyn_cast<Function>(Callee))
|
if (Function *F = dyn_cast<Function>(Callee))
|
||||||
|
@ -138,7 +138,7 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
|
|||||||
// Add scalar nodes to the graph...
|
// Add scalar nodes to the graph...
|
||||||
const DSGraph::ScalarMapTy &VM = G->getScalarMap();
|
const DSGraph::ScalarMapTy &VM = G->getScalarMap();
|
||||||
for (DSGraph::ScalarMapTy::const_iterator I = VM.begin(); I != VM.end();++I)
|
for (DSGraph::ScalarMapTy::const_iterator I = VM.begin(); I != VM.end();++I)
|
||||||
if (!isa<GlobalValue>(I->first) && !isa<ConstantPointerRef>(I->first)) {
|
if (!isa<GlobalValue>(I->first)) {
|
||||||
std::stringstream OS;
|
std::stringstream OS;
|
||||||
WriteAsOperand(OS, I->first, false, true, CurMod);
|
WriteAsOperand(OS, I->first, false, true, CurMod);
|
||||||
GW.emitSimpleNode(I->first, "", OS.str());
|
GW.emitSimpleNode(I->first, "", OS.str());
|
||||||
|
@ -479,8 +479,8 @@ Andersens::Node *Andersens::getNodeForConstantPointer(Constant *C) {
|
|||||||
|
|
||||||
if (isa<ConstantPointerNull>(C))
|
if (isa<ConstantPointerNull>(C))
|
||||||
return &GraphNodes[NullPtr];
|
return &GraphNodes[NullPtr];
|
||||||
else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C))
|
else if (GlobalValue *GV = dyn_cast<GlobalValue>(C))
|
||||||
return getNode(CPR->getValue());
|
return getNode(GV);
|
||||||
else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
||||||
switch (CE->getOpcode()) {
|
switch (CE->getOpcode()) {
|
||||||
case Instruction::GetElementPtr:
|
case Instruction::GetElementPtr:
|
||||||
@ -507,8 +507,8 @@ Andersens::Node *Andersens::getNodeForConstantPointerTarget(Constant *C) {
|
|||||||
|
|
||||||
if (isa<ConstantPointerNull>(C))
|
if (isa<ConstantPointerNull>(C))
|
||||||
return &GraphNodes[NullObject];
|
return &GraphNodes[NullObject];
|
||||||
else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C))
|
else if (GlobalValue *GV = dyn_cast<GlobalValue>(C))
|
||||||
return getObject(CPR->getValue());
|
return getObject(GV);
|
||||||
else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
||||||
switch (CE->getOpcode()) {
|
switch (CE->getOpcode()) {
|
||||||
case Instruction::GetElementPtr:
|
case Instruction::GetElementPtr:
|
||||||
|
@ -73,10 +73,8 @@ void CallGraph::addToCallGraph(Function *F) {
|
|||||||
getNodeFor(Inst->getParent()->getParent())->addCalledFunction(Node);
|
getNodeFor(Inst->getParent()->getParent())->addCalledFunction(Node);
|
||||||
else
|
else
|
||||||
isUsedExternally = true;
|
isUsedExternally = true;
|
||||||
} else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(*I)) {
|
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(*I)) {
|
||||||
// THIS IS A DISGUSTING HACK. Brought to you by the power of
|
for (Value::use_iterator I = GV->use_begin(), E = GV->use_end();
|
||||||
// ConstantPointerRefs!
|
|
||||||
for (Value::use_iterator I = CPR->use_begin(), E = CPR->use_end();
|
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (Instruction *Inst = dyn_cast<Instruction>(*I)) {
|
if (Instruction *Inst = dyn_cast<Instruction>(*I)) {
|
||||||
if (isOnlyADirectCall(F, CallSite::get(Inst)))
|
if (isOnlyADirectCall(F, CallSite::get(Inst)))
|
||||||
|
@ -48,9 +48,10 @@ void FindUsedTypes::IncorporateValue(const Value *V) {
|
|||||||
|
|
||||||
// If this is a constant, it could be using other types...
|
// If this is a constant, it could be using other types...
|
||||||
if (const Constant *C = dyn_cast<Constant>(V)) {
|
if (const Constant *C = dyn_cast<Constant>(V)) {
|
||||||
for (User::const_op_iterator OI = C->op_begin(), OE = C->op_end();
|
if (!isa<GlobalValue>(C))
|
||||||
OI != OE; ++OI)
|
for (User::const_op_iterator OI = C->op_begin(), OE = C->op_end();
|
||||||
IncorporateValue(*OI);
|
OI != OE; ++OI)
|
||||||
|
IncorporateValue(*OI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,8 +165,8 @@ bool GlobalsModRef::AnalyzeUsesOfGlobal(Value *V,
|
|||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(*UI)) {
|
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(*UI)) {
|
||||||
if (AnalyzeUsesOfGlobal(CPR, Readers, Writers)) return true;
|
if (AnalyzeUsesOfGlobal(GV, Readers, Writers)) return true;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -257,8 +257,6 @@ static const GlobalValue *getUnderlyingObject(const Value *V) {
|
|||||||
if (CE->getOpcode() == Instruction::Cast ||
|
if (CE->getOpcode() == Instruction::Cast ||
|
||||||
CE->getOpcode() == Instruction::GetElementPtr)
|
CE->getOpcode() == Instruction::GetElementPtr)
|
||||||
return getUnderlyingObject(CE->getOperand(0));
|
return getUnderlyingObject(CE->getOperand(0));
|
||||||
} else if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V)) {
|
|
||||||
return CPR->getValue();
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1498,9 +1498,9 @@ static Constant *ConstantFold(const Instruction *I,
|
|||||||
case Instruction::Select:
|
case Instruction::Select:
|
||||||
return ConstantExpr::getSelect(Operands[0], Operands[1], Operands[2]);
|
return ConstantExpr::getSelect(Operands[0], Operands[1], Operands[2]);
|
||||||
case Instruction::Call:
|
case Instruction::Call:
|
||||||
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Operands[0])) {
|
if (Function *GV = dyn_cast<Function>(Operands[0])) {
|
||||||
Operands.erase(Operands.begin());
|
Operands.erase(Operands.begin());
|
||||||
return ConstantFoldCall(cast<Function>(CPR->getValue()), Operands);
|
return ConstantFoldCall(cast<Function>(GV), Operands);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1560,9 +1560,9 @@ static PHINode *getConstantEvolvingPHI(Value *V, const Loop *L) {
|
|||||||
/// reason, return null.
|
/// reason, return null.
|
||||||
static Constant *EvaluateExpression(Value *V, Constant *PHIVal) {
|
static Constant *EvaluateExpression(Value *V, Constant *PHIVal) {
|
||||||
if (isa<PHINode>(V)) return PHIVal;
|
if (isa<PHINode>(V)) return PHIVal;
|
||||||
if (Constant *C = dyn_cast<Constant>(V)) return C;
|
|
||||||
if (GlobalValue *GV = dyn_cast<GlobalValue>(V))
|
if (GlobalValue *GV = dyn_cast<GlobalValue>(V))
|
||||||
return ConstantPointerRef::get(GV);
|
return GV;
|
||||||
|
if (Constant *C = dyn_cast<Constant>(V)) return C;
|
||||||
Instruction *I = cast<Instruction>(V);
|
Instruction *I = cast<Instruction>(V);
|
||||||
|
|
||||||
std::vector<Constant*> Operands;
|
std::vector<Constant*> Operands;
|
||||||
@ -1718,8 +1718,6 @@ SCEVHandle ScalarEvolutionsImpl::getSCEVAtScope(SCEV *V, const Loop *L) {
|
|||||||
Value *Op = I->getOperand(i);
|
Value *Op = I->getOperand(i);
|
||||||
if (Constant *C = dyn_cast<Constant>(Op)) {
|
if (Constant *C = dyn_cast<Constant>(Op)) {
|
||||||
Operands.push_back(C);
|
Operands.push_back(C);
|
||||||
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(Op)) {
|
|
||||||
Operands.push_back(ConstantPointerRef::get(GV));
|
|
||||||
} else {
|
} else {
|
||||||
SCEVHandle OpV = getSCEVAtScope(getSCEV(Op), L);
|
SCEVHandle OpV = getSCEVAtScope(getSCEV(Op), L);
|
||||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(OpV))
|
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(OpV))
|
||||||
|
@ -77,8 +77,6 @@ SlotCalculator::SlotCalculator(const Function *M ) {
|
|||||||
unsigned SlotCalculator::getGlobalSlot(const Value *V) const {
|
unsigned SlotCalculator::getGlobalSlot(const Value *V) const {
|
||||||
assert(!CompactionTable.empty() &&
|
assert(!CompactionTable.empty() &&
|
||||||
"This method can only be used when compaction is enabled!");
|
"This method can only be used when compaction is enabled!");
|
||||||
if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
|
|
||||||
V = CPR->getValue();
|
|
||||||
std::map<const Value*, unsigned>::const_iterator I = NodeMap.find(V);
|
std::map<const Value*, unsigned>::const_iterator I = NodeMap.find(V);
|
||||||
assert(I != NodeMap.end() && "Didn't find global slot entry!");
|
assert(I != NodeMap.end() && "Didn't find global slot entry!");
|
||||||
return I->second;
|
return I->second;
|
||||||
@ -169,17 +167,14 @@ void SlotCalculator::processModule() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are emitting a bytecode file, scan all of the functions for their
|
// Scan all of the functions for their constants, which allows us to emit
|
||||||
// constants, which allows us to emit more compact modules. This is optional,
|
// more compact modules. This is optional, and is just used to compactify
|
||||||
// and is just used to compactify the constants used by different functions
|
// the constants used by different functions together.
|
||||||
// together.
|
|
||||||
//
|
|
||||||
// This functionality is completely optional for the bytecode writer, but
|
|
||||||
// tends to produce smaller bytecode files. This should not be used in the
|
|
||||||
// future by clients that want to, for example, build and emit functions on
|
|
||||||
// the fly. For now, however, it is unconditionally enabled when building
|
|
||||||
// bytecode information.
|
|
||||||
//
|
//
|
||||||
|
// This functionality tends to produce smaller bytecode files. This should
|
||||||
|
// not be used in the future by clients that want to, for example, build and
|
||||||
|
// emit functions on the fly. For now, however, it is unconditionally
|
||||||
|
// enabled.
|
||||||
ModuleContainsAllFunctionConstants = true;
|
ModuleContainsAllFunctionConstants = true;
|
||||||
|
|
||||||
SC_DEBUG("Inserting function constants:\n");
|
SC_DEBUG("Inserting function constants:\n");
|
||||||
@ -187,7 +182,8 @@ void SlotCalculator::processModule() {
|
|||||||
F != E; ++F) {
|
F != E; ++F) {
|
||||||
for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I){
|
for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I){
|
||||||
for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op)
|
for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op)
|
||||||
if (isa<Constant>(I->getOperand(op)))
|
if (isa<Constant>(I->getOperand(op)) &&
|
||||||
|
!isa<GlobalValue>(I->getOperand(op)))
|
||||||
getOrCreateSlot(I->getOperand(op));
|
getOrCreateSlot(I->getOperand(op));
|
||||||
getOrCreateSlot(I->getType());
|
getOrCreateSlot(I->getType());
|
||||||
if (const VANextInst *VAN = dyn_cast<VANextInst>(&*I))
|
if (const VANextInst *VAN = dyn_cast<VANextInst>(&*I))
|
||||||
@ -265,7 +261,8 @@ void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
|
|||||||
PE = ST->plane_end(); PI != PE; ++PI)
|
PE = ST->plane_end(); PI != PE; ++PI)
|
||||||
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
|
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
|
||||||
VE = PI->second.end(); VI != VE; ++VI)
|
VE = PI->second.end(); VI != VE; ++VI)
|
||||||
if (isa<Constant>(VI->second))
|
if (isa<Constant>(VI->second) &&
|
||||||
|
!isa<GlobalValue>(VI->second))
|
||||||
getOrCreateSlot(VI->second);
|
getOrCreateSlot(VI->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,8 +394,6 @@ static inline bool hasNullValue(unsigned TyID) {
|
|||||||
/// getOrCreateCompactionTableSlot - This method is used to build up the initial
|
/// getOrCreateCompactionTableSlot - This method is used to build up the initial
|
||||||
/// approximation of the compaction table.
|
/// approximation of the compaction table.
|
||||||
unsigned SlotCalculator::getOrCreateCompactionTableSlot(const Value *V) {
|
unsigned SlotCalculator::getOrCreateCompactionTableSlot(const Value *V) {
|
||||||
if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
|
|
||||||
V = CPR->getValue();
|
|
||||||
std::map<const Value*, unsigned>::iterator I =
|
std::map<const Value*, unsigned>::iterator I =
|
||||||
CompactionNodeMap.lower_bound(V);
|
CompactionNodeMap.lower_bound(V);
|
||||||
if (I != CompactionNodeMap.end() && I->first == V)
|
if (I != CompactionNodeMap.end() && I->first == V)
|
||||||
@ -473,8 +468,7 @@ void SlotCalculator::buildCompactionTable(const Function *F) {
|
|||||||
for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
|
for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
|
||||||
getOrCreateCompactionTableSlot(I->getType());
|
getOrCreateCompactionTableSlot(I->getType());
|
||||||
for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op)
|
for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op)
|
||||||
if (isa<Constant>(I->getOperand(op)) ||
|
if (isa<Constant>(I->getOperand(op)))
|
||||||
isa<GlobalValue>(I->getOperand(op)))
|
|
||||||
getOrCreateCompactionTableSlot(I->getOperand(op));
|
getOrCreateCompactionTableSlot(I->getOperand(op));
|
||||||
if (const VANextInst *VAN = dyn_cast<VANextInst>(&*I))
|
if (const VANextInst *VAN = dyn_cast<VANextInst>(&*I))
|
||||||
getOrCreateCompactionTableSlot(VAN->getArgType());
|
getOrCreateCompactionTableSlot(VAN->getArgType());
|
||||||
@ -491,7 +485,7 @@ void SlotCalculator::buildCompactionTable(const Function *F) {
|
|||||||
PE = ST.plane_end(); PI != PE; ++PI)
|
PE = ST.plane_end(); PI != PE; ++PI)
|
||||||
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
|
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
|
||||||
VE = PI->second.end(); VI != VE; ++VI)
|
VE = PI->second.end(); VI != VE; ++VI)
|
||||||
if (isa<Constant>(VI->second) || isa<GlobalValue>(VI->second))
|
if (isa<Constant>(VI->second) && !isa<GlobalValue>(VI->second))
|
||||||
getOrCreateCompactionTableSlot(VI->second);
|
getOrCreateCompactionTableSlot(VI->second);
|
||||||
|
|
||||||
// Now that we have all of the values in the table, and know what types are
|
// Now that we have all of the values in the table, and know what types are
|
||||||
@ -643,10 +637,6 @@ int SlotCalculator::getSlot(const Value *V) const {
|
|||||||
if (I != NodeMap.end())
|
if (I != NodeMap.end())
|
||||||
return (int)I->second;
|
return (int)I->second;
|
||||||
|
|
||||||
// Do not number ConstantPointerRef's at all. They are an abomination.
|
|
||||||
if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
|
|
||||||
return getSlot(CPR->getValue());
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,10 +664,6 @@ int SlotCalculator::getOrCreateSlot(const Value *V) {
|
|||||||
int SlotNo = getSlot(V); // Check to see if it's already in!
|
int SlotNo = getSlot(V); // Check to see if it's already in!
|
||||||
if (SlotNo != -1) return SlotNo;
|
if (SlotNo != -1) return SlotNo;
|
||||||
|
|
||||||
// Do not number ConstantPointerRef's at all. They are an abomination.
|
|
||||||
if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
|
|
||||||
return getOrCreateSlot(CPR->getValue());
|
|
||||||
|
|
||||||
if (!isa<GlobalValue>(V)) // Initializers for globals are handled explicitly
|
if (!isa<GlobalValue>(V)) // Initializers for globals are handled explicitly
|
||||||
if (const Constant *C = dyn_cast<Constant>(V)) {
|
if (const Constant *C = dyn_cast<Constant>(V)) {
|
||||||
assert(CompactionNodeMap.empty() &&
|
assert(CompactionNodeMap.empty() &&
|
||||||
@ -720,8 +706,8 @@ int SlotCalculator::insertValue(const Value *D, bool dontIgnore) {
|
|||||||
// insert the value into the compaction map, not into the global map.
|
// insert the value into the compaction map, not into the global map.
|
||||||
if (!CompactionNodeMap.empty()) {
|
if (!CompactionNodeMap.empty()) {
|
||||||
if (D->getType() == Type::VoidTy) return -1; // Do not insert void values
|
if (D->getType() == Type::VoidTy) return -1; // Do not insert void values
|
||||||
assert(!isa<Constant>(D) && !isa<GlobalValue>(D) &&
|
assert(!isa<Constant>(D) &&
|
||||||
"Types, constants, and globals should be in global SymTab!");
|
"Types, constants, and globals should be in global table!");
|
||||||
|
|
||||||
int Plane = getSlot(D->getType());
|
int Plane = getSlot(D->getType());
|
||||||
assert(Plane != -1 && CompactionTable.size() > (unsigned)Plane &&
|
assert(Plane != -1 && CompactionTable.size() > (unsigned)Plane &&
|
||||||
@ -774,7 +760,7 @@ int SlotCalculator::insertType(const Type *Ty, bool dontIgnore) {
|
|||||||
if (getSlot(SubTy) == -1) {
|
if (getSlot(SubTy) == -1) {
|
||||||
SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n");
|
SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n");
|
||||||
doInsertType(SubTy);
|
doInsertType(SubTy);
|
||||||
SC_DEBUG(" Inserted subtype: " << SubTy->getDescription());
|
SC_DEBUG(" Inserted subtype: " << SubTy->getDescription() << "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user