bug 122:
authorReid Spencer <rspencer@reidspencer.com>
Sun, 18 Jul 2004 00:29:57 +0000 (00:29 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 18 Jul 2004 00:29:57 +0000 (00:29 +0000)
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14946 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/CorrelatedExprs.cpp
lib/Transforms/Scalar/LowerGC.cpp

index aeeade40cce8cbbbc7d6cca19ef733c70aad413c..9738879e28284eae4cc7b44a97a13c9446d5d541 100644 (file)
@@ -243,7 +243,7 @@ namespace {
 
     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
@@ -476,7 +476,8 @@ bool CEE::ForwardCorrelatedEdgeDestination(TerminatorInst *TI, unsigned SuccNo,
 
   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.
index 98ff0428f67577bb38155173f62bbf7f87a9e647..ce67d0e7a177395244b3279ca01c5003b87cb57d 100644 (file)
@@ -140,7 +140,8 @@ bool LowerGC::doInitialization(Module &M) {
 /// 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);
@@ -252,8 +253,7 @@ bool LowerGC::runOnFunction(Function &F) {
     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.