void BuildRankMap(Function &F);
unsigned getRank(Value *V) const {
- if (isa<Constant>(V) || isa<GlobalValue>(V)) return 0;
+ if (isa<Constant>(V)) return 0;
std::map<Value*, unsigned>::const_iterator I = RankMap.find(V);
if (I != RankMap.end()) return I->second;
return 0; // Must be some other global thing
ValueInfo &PredicateVI = NewRI.getValueInfo(BI->getCondition());
if (PredicateVI.getReplacement() &&
- isa<Constant>(PredicateVI.getReplacement())) {
+ isa<Constant>(PredicateVI.getReplacement()) &&
+ !isa<GlobalValue>(PredicateVI.getReplacement())) {
ConstantBool *CB = cast<ConstantBool>(PredicateVI.getReplacement());
// Forward to the successor that corresponds to the branch we will take.
/// not have the specified type, insert a cast.
static void Coerce(Instruction *I, unsigned OpNum, Type *Ty) {
if (I->getOperand(OpNum)->getType() != Ty) {
- if (Constant *C = dyn_cast<Constant>(I->getOperand(OpNum)))
+ Constant *C = dyn_cast<Constant>(I->getOperand(OpNum));
+ if (C && !isa<GlobalValue>(I->getOperand(OpNum)))
I->setOperand(OpNum, ConstantExpr::getCast(C, Ty));
else {
CastInst *C = new CastInst(I->getOperand(OpNum), Ty, "", I);
Par[2] = ConstantUInt::get(Type::UIntTy, i);
Par[3] = One;
Value *MetaDataPtr = new GetElementPtrInst(AI, Par, "MetaDataPtr", IP);
- assert(isa<Constant>(GCRoots[i]->getOperand(2)) ||
- isa<GlobalValue>(GCRoots[i]->getOperand(2)));
+ assert(isa<Constant>(GCRoots[i]->getOperand(2)) && "Must be a constant");
new StoreInst(GCRoots[i]->getOperand(2), MetaDataPtr, IP);
// Initialize the root pointer to null on entry to the function.