Commit 67dee05f authored by John Criswell's avatar John Criswell
Browse files

Merged in changes Chris commited over the weekend. Merge done on August 9,

2004.

llvm-svn: 15576
parent 0ccbe35d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ bool llvm::ExpressionConvertibleToType(Value *V, const Type *Ty,
  // If it's a constant... all constants can be converted to a different
  // type.
  //
  if (Constant *CPV = dyn_cast<Constant>(V))
  if (isa<Constant>(V) && !isa<GlobalValue>(V))
    return true;
  
  CTMap[V] = Ty;
@@ -984,10 +984,9 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,

    unsigned OtherIdx = (OldVal == I->getOperand(0)) ? 1 : 0;
    Value *OtherOp    = I->getOperand(OtherIdx);
    Res->setOperand(!OtherIdx, NewVal);
    Value *NewOther   = ConvertExpressionToType(OtherOp, NewTy, VMC, TD);

    Res->setOperand(OtherIdx, NewOther);
    Res->setOperand(!OtherIdx, NewVal);
    break;
  }
  case Instruction::Shl:
+24 −24
Original line number Diff line number Diff line
@@ -54,8 +54,8 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
         E = CalleeNode->end(); I != E; ++I)
    CallerNode->addCalledFunction(*I);
  
  // If we inlined the last possible call site to the function,
  // delete the function body now.
  // If we inlined the last possible call site to the function, delete the
  // function body now.
  if (Callee->use_empty() && Callee->hasInternalLinkage() &&
      !SCCFunctions.count(Callee)) {
    DEBUG(std::cerr << "    -> Deleting dead function: "
@@ -167,15 +167,14 @@ bool Inliner::doFinalization(CallGraph &CG) {
  // from the program.  Insert the dead ones in the FunctionsToRemove set.
  for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ++I) {
    CallGraphNode *CGN = I->second;
    Function *F = CGN ? CGN->getFunction() : 0;

    if (Function *F = CGN ? CGN->getFunction() : 0) {
      // If the only remaining users of the function are dead constants,
      // remove them.
    if (F) F->removeDeadConstantUsers();
      bool HadDeadConstantUsers = !F->use_empty();
      F->removeDeadConstantUsers();

    if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
      if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
          F->use_empty()) {

        // Remove any call graph edges from the function to its callees.
        while (CGN->begin() != CGN->end())
          CGN->removeCallEdgeTo(*(CGN->end()-1));
@@ -183,13 +182,14 @@ bool Inliner::doFinalization(CallGraph &CG) {
        // If the function has external linkage (basically if it's a linkonce
        // function) remove the edge from the external node to the callee
        // node.
      if (!F->hasInternalLinkage())
        if (!F->hasInternalLinkage() || HadDeadConstantUsers)
          CG.getExternalCallingNode()->removeCallEdgeTo(CGN);
        
        // Removing the node for callee from the call graph and delete it.
        FunctionsToRemove.insert(CGN);
      }
    }
  }

  // Now that we know which functions to delete, do so.  We didn't want to do
  // this inline, because that would invalidate our CallGraph::iterator
+2 −1
Original line number Diff line number Diff line
@@ -302,7 +302,8 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
      // Make sure the source doesn't change type
      ConvertedTypes[Src] = Src->getType();
      if (ValueConvertibleToType(CI, Src->getType(), ConvertedTypes, TD)) {
        PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", *Src, *CI, *BB->getParent());
        //PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", *Src, *CI,
        //                *BB->getParent());

        DEBUG(std::cerr << "\nCONVERTING EXPR TYPE:\n");
        { // ValueMap must be destroyed before function verified!