aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-17 05:39:39 +0000
committerChris Lattner <sabre@nondot.org>2009-10-17 05:39:39 +0000
commit6128df525501c333a650d097703c18d7e878f5e8 (patch)
treefe9b1eae457d127c217791d9efd7392636810cda /lib
parent704ac9022b275a1f665f1f0a5b975f6795080179 (diff)
downloadexternal_llvm-6128df525501c333a650d097703c18d7e878f5e8.zip
external_llvm-6128df525501c333a650d097703c18d7e878f5e8.tar.gz
external_llvm-6128df525501c333a650d097703c18d7e878f5e8.tar.bz2
Simplify some code (first hunk) and fix PR5208 (second hunk) by
updating the callgraph when introducing a call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84310 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 0d00d69..619c939 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -444,18 +444,15 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD,
if (InlinedFunctionInfo.ContainsDynamicAllocas) {
Module *M = Caller->getParent();
// Get the two intrinsics we care about.
- Constant *StackSave, *StackRestore;
- StackSave = Intrinsic::getDeclaration(M, Intrinsic::stacksave);
- StackRestore = Intrinsic::getDeclaration(M, Intrinsic::stackrestore);
+ Function *StackSave = Intrinsic::getDeclaration(M, Intrinsic::stacksave);
+ Function *StackRestore=Intrinsic::getDeclaration(M,Intrinsic::stackrestore);
// If we are preserving the callgraph, add edges to the stacksave/restore
// functions for the calls we insert.
CallGraphNode *StackSaveCGN = 0, *StackRestoreCGN = 0, *CallerNode = 0;
if (CG) {
- // We know that StackSave/StackRestore are Function*'s, because they are
- // intrinsics which must have the right types.
- StackSaveCGN = CG->getOrInsertFunction(cast<Function>(StackSave));
- StackRestoreCGN = CG->getOrInsertFunction(cast<Function>(StackRestore));
+ StackSaveCGN = CG->getOrInsertFunction(StackSave);
+ StackRestoreCGN = CG->getOrInsertFunction(StackRestore);
CallerNode = (*CG)[Caller];
}
@@ -480,7 +477,8 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD,
for (Function::iterator BB = FirstNewBlock, E = Caller->end();
BB != E; ++BB)
if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator())) {
- CallInst::Create(StackRestore, SavedPtr, "", UI);
+ CallInst *CI = CallInst::Create(StackRestore, SavedPtr, "", UI);
+ if (CG) CallerNode->addCalledFunction(CI, StackRestoreCGN);
++NumStackRestores;
}
}