summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-09-05 23:36:01 +0000
committerOwen Anderson <resistor@mac.com>2008-09-05 23:36:01 +0000
commit6e6074508c2f781c3e52dfe0e301cb1c7f395a91 (patch)
tree78acc35e61261c50375bff374e13984acdcdce54
parentd0c0fae63bbbdb2d26e62736f0654bfdc5193ccc (diff)
downloadllvm-6e6074508c2f781c3e52dfe0e301cb1c7f395a91.tar.gz
llvm-6e6074508c2f781c3e52dfe0e301cb1c7f395a91.tar.bz2
llvm-6e6074508c2f781c3e52dfe0e301cb1c7f395a91.tar.xz
Revert r55859. This is breaking the build in the abscence of its companion commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55865 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/CallGraph.h7
-rw-r--r--lib/Analysis/IPA/CallGraph.cpp10
-rw-r--r--lib/CodeGen/SelectionDAG/FastISel.cpp16
-rw-r--r--lib/Transforms/IPO/PruneEH.cpp11
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp13
5 files changed, 41 insertions, 16 deletions
diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h
index a04c775755..5fd0bdc8a0 100644
--- a/include/llvm/Analysis/CallGraph.h
+++ b/include/llvm/Analysis/CallGraph.h
@@ -214,12 +214,17 @@ public:
CalledFunctions.clear();
}
- /// addCalledFunction - Add a function to the list of functions called by this
+ /// addCalledFunction add a function to the list of functions called by this
/// one.
void addCalledFunction(CallSite CS, CallGraphNode *M) {
CalledFunctions.push_back(std::make_pair(CS, M));
}
+ /// removeCallEdgeTo - This method removes a *single* edge to the specified
+ /// callee function. Note that this method takes linear time, so it should be
+ /// used sparingly.
+ void removeCallEdgeTo(CallGraphNode *Callee);
+
/// removeCallEdgeFor - This method removes the edge in the node for the
/// specified call site. Note that this method takes linear time, so it
/// should be used sparingly.
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp
index 4a31295a72..5616ee9a4b 100644
--- a/lib/Analysis/IPA/CallGraph.cpp
+++ b/lib/Analysis/IPA/CallGraph.cpp
@@ -282,6 +282,16 @@ void CallGraphNode::print(std::ostream &OS) const {
void CallGraphNode::dump() const { print(cerr); }
+void CallGraphNode::removeCallEdgeTo(CallGraphNode *Callee) {
+ for (unsigned i = CalledFunctions.size(); ; --i) {
+ assert(i && "Cannot find callee to remove!");
+ if (CalledFunctions[i-1].second == Callee) {
+ CalledFunctions.erase(CalledFunctions.begin()+i-1);
+ return;
+ }
+ }
+}
+
/// removeCallEdgeFor - This method removes the edge in the node for the
/// specified call site. Note that this method takes linear time, so it
/// should be used sparingly.
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index 992b8edba4..c109a096a1 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -35,7 +35,8 @@ unsigned FastISel::getRegForValue(Value *V) {
MVT::SimpleValueType VT = TLI.getValueType(V->getType()).getSimpleVT();
if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
if (CI->getValue().getActiveBits() > 64)
- return 0;
+ return TargetMaterializeConstant(CI,
+ MBB->getParent()->getConstantPool());
// Don't cache constant materializations. To do so would require
// tracking what uses they dominate.
Reg = FastEmit_i(VT, VT, ISD::Constant, CI->getZExtValue());
@@ -52,16 +53,19 @@ unsigned FastISel::getRegForValue(Value *V) {
uint32_t IntBitWidth = IntVT.getSizeInBits();
if (Flt.convertToInteger(x, IntBitWidth, /*isSigned=*/true,
APFloat::rmTowardZero) != APFloat::opOK)
- return 0;
+ return TargetMaterializeConstant(CF,
+ MBB->getParent()->getConstantPool());
APInt IntVal(IntBitWidth, 2, x);
unsigned IntegerReg = FastEmit_i(IntVT.getSimpleVT(), IntVT.getSimpleVT(),
ISD::Constant, IntVal.getZExtValue());
if (IntegerReg == 0)
- return 0;
+ return TargetMaterializeConstant(CF,
+ MBB->getParent()->getConstantPool());
Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP, IntegerReg);
if (Reg == 0)
- return 0;
+ return TargetMaterializeConstant(CF,
+ MBB->getParent()->getConstantPool());;
}
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
if (!SelectOperator(CE, CE->getOpcode())) return 0;
@@ -73,6 +77,10 @@ unsigned FastISel::getRegForValue(Value *V) {
return 0;
}
+ if (!Reg && isa<Constant>(V))
+ return TargetMaterializeConstant(cast<Constant>(V),
+ MBB->getParent()->getConstantPool());
+
LocalValueMap[V] = Reg;
return Reg;
}
diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp
index 94d6331ddd..8fb904b1ea 100644
--- a/lib/Transforms/IPO/PruneEH.cpp
+++ b/lib/Transforms/IPO/PruneEH.cpp
@@ -222,10 +222,13 @@ void PruneEH::DeleteBasicBlock(BasicBlock *BB) {
CallGraphNode *CGN = CG[BB->getParent()];
for (BasicBlock::iterator I = BB->end(), E = BB->begin(); I != E; ) {
--I;
- if (CallInst *CI = dyn_cast<CallInst>(I))
- CGN->removeCallEdgeFor(CI);
- else if (InvokeInst *II = dyn_cast<InvokeInst>(I))
- CGN->removeCallEdgeFor(II);
+ if (CallInst *CI = dyn_cast<CallInst>(I)) {
+ if (Function *Callee = CI->getCalledFunction())
+ CGN->removeCallEdgeTo(CG[Callee]);
+ } else if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
+ if (Function *Callee = II->getCalledFunction())
+ CGN->removeCallEdgeTo(CG[Callee]);
+ }
if (!I->use_empty())
I->replaceAllUsesWith(UndefValue::get(I->getType()));
}
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index b0e70bb89a..cb9c28dcab 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -143,18 +143,16 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
/// UpdateCallGraphAfterInlining - Once we have cloned code over from a callee
/// into the caller, update the specified callgraph to reflect the changes we
/// made. Note that it's possible that not all code was copied over, so only
-/// some edges of the callgraph may remain.
-static void UpdateCallGraphAfterInlining(CallSite CS,
+/// some edges of the callgraph will be remain.
+static void UpdateCallGraphAfterInlining(const Function *Caller,
+ const Function *Callee,
Function::iterator FirstNewBlock,
DenseMap<const Value*, Value*> &ValueMap,
CallGraph &CG) {
- const Function *Caller = CS.getInstruction()->getParent()->getParent();
- const Function *Callee = CS.getCalledFunction();
-
// Update the call graph by deleting the edge from Callee to Caller
CallGraphNode *CalleeNode = CG[Callee];
CallGraphNode *CallerNode = CG[Caller];
- CallerNode->removeCallEdgeFor(CS);
+ CallerNode->removeCallEdgeTo(CalleeNode);
// Since we inlined some uninlined call sites in the callee into the caller,
// add edges from the caller to all of the callees of the callee.
@@ -304,7 +302,8 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// Update the callgraph if requested.
if (CG)
- UpdateCallGraphAfterInlining(CS, FirstNewBlock, ValueMap, *CG);
+ UpdateCallGraphAfterInlining(Caller, CalledFunc, FirstNewBlock, ValueMap,
+ *CG);
}
// If there are any alloca instructions in the block that used to be the entry