Skip to content

Commit 67dee05

Browse files
author
John Criswell
committed
Merged in changes Chris commited over the weekend. Merge done on August 9,
2004. llvm-svn: 15576
1 parent 0ccbe35 commit 67dee05

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

llvm/lib/Transforms/ExprTypeConvert.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ bool llvm::ExpressionConvertibleToType(Value *V, const Type *Ty,
151151
// If it's a constant... all constants can be converted to a different
152152
// type.
153153
//
154-
if (Constant *CPV = dyn_cast<Constant>(V))
154+
if (isa<Constant>(V) && !isa<GlobalValue>(V))
155155
return true;
156156

157157
CTMap[V] = Ty;
@@ -984,10 +984,9 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
984984

985985
unsigned OtherIdx = (OldVal == I->getOperand(0)) ? 1 : 0;
986986
Value *OtherOp = I->getOperand(OtherIdx);
987+
Res->setOperand(!OtherIdx, NewVal);
987988
Value *NewOther = ConvertExpressionToType(OtherOp, NewTy, VMC, TD);
988-
989989
Res->setOperand(OtherIdx, NewOther);
990-
Res->setOperand(!OtherIdx, NewVal);
991990
break;
992991
}
993992
case Instruction::Shl:

llvm/lib/Transforms/IPO/Inliner.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
5454
E = CalleeNode->end(); I != E; ++I)
5555
CallerNode->addCalledFunction(*I);
5656

57-
// If we inlined the last possible call site to the function,
58-
// delete the function body now.
57+
// If we inlined the last possible call site to the function, delete the
58+
// function body now.
5959
if (Callee->use_empty() && Callee->hasInternalLinkage() &&
6060
!SCCFunctions.count(Callee)) {
6161
DEBUG(std::cerr << " -> Deleting dead function: "
@@ -64,7 +64,7 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
6464
// Remove any call graph edges from the callee to its callees.
6565
while (CalleeNode->begin() != CalleeNode->end())
6666
CalleeNode->removeCallEdgeTo(*(CalleeNode->end()-1));
67-
67+
6868
// Removing the node for callee from the call graph and delete it.
6969
delete CG.removeFunctionFromModule(CalleeNode);
7070
++NumDeleted;
@@ -167,27 +167,27 @@ bool Inliner::doFinalization(CallGraph &CG) {
167167
// from the program. Insert the dead ones in the FunctionsToRemove set.
168168
for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ++I) {
169169
CallGraphNode *CGN = I->second;
170-
Function *F = CGN ? CGN->getFunction() : 0;
171-
172-
// If the only remaining users of the function are dead constants,
173-
// remove them.
174-
if (F) F->removeDeadConstantUsers();
175-
176-
if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
177-
F->use_empty()) {
178-
179-
// Remove any call graph edges from the function to its callees.
180-
while (CGN->begin() != CGN->end())
181-
CGN->removeCallEdgeTo(*(CGN->end()-1));
182-
183-
// If the function has external linkage (basically if it's a linkonce
184-
// function) remove the edge from the external node to the callee
185-
// node.
186-
if (!F->hasInternalLinkage())
187-
CG.getExternalCallingNode()->removeCallEdgeTo(CGN);
188-
189-
// Removing the node for callee from the call graph and delete it.
190-
FunctionsToRemove.insert(CGN);
170+
if (Function *F = CGN ? CGN->getFunction() : 0) {
171+
// If the only remaining users of the function are dead constants,
172+
// remove them.
173+
bool HadDeadConstantUsers = !F->use_empty();
174+
F->removeDeadConstantUsers();
175+
176+
if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
177+
F->use_empty()) {
178+
// Remove any call graph edges from the function to its callees.
179+
while (CGN->begin() != CGN->end())
180+
CGN->removeCallEdgeTo(*(CGN->end()-1));
181+
182+
// If the function has external linkage (basically if it's a linkonce
183+
// function) remove the edge from the external node to the callee
184+
// node.
185+
if (!F->hasInternalLinkage() || HadDeadConstantUsers)
186+
CG.getExternalCallingNode()->removeCallEdgeTo(CGN);
187+
188+
// Removing the node for callee from the call graph and delete it.
189+
FunctionsToRemove.insert(CGN);
190+
}
191191
}
192192
}
193193

llvm/lib/Transforms/LevelRaise.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
302302
// Make sure the source doesn't change type
303303
ConvertedTypes[Src] = Src->getType();
304304
if (ValueConvertibleToType(CI, Src->getType(), ConvertedTypes, TD)) {
305-
PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", *Src, *CI, *BB->getParent());
305+
//PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", *Src, *CI,
306+
// *BB->getParent());
306307

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

0 commit comments

Comments
 (0)