1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Simplify some code (first hunk) and fix PR5208 (second hunk) by

updating the callgraph when introducing a call.

llvm-svn: 84310
This commit is contained in:
Chris Lattner 2009-10-17 05:39:39 +00:00
parent fa8927e20c
commit 7f32b72975
2 changed files with 40 additions and 11 deletions

View File

@ -444,18 +444,15 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD,
if (InlinedFunctionInfo.ContainsDynamicAllocas) { if (InlinedFunctionInfo.ContainsDynamicAllocas) {
Module *M = Caller->getParent(); Module *M = Caller->getParent();
// Get the two intrinsics we care about. // Get the two intrinsics we care about.
Constant *StackSave, *StackRestore; Function *StackSave = Intrinsic::getDeclaration(M, Intrinsic::stacksave);
StackSave = Intrinsic::getDeclaration(M, Intrinsic::stacksave); Function *StackRestore=Intrinsic::getDeclaration(M,Intrinsic::stackrestore);
StackRestore = Intrinsic::getDeclaration(M, Intrinsic::stackrestore);
// If we are preserving the callgraph, add edges to the stacksave/restore // If we are preserving the callgraph, add edges to the stacksave/restore
// functions for the calls we insert. // functions for the calls we insert.
CallGraphNode *StackSaveCGN = 0, *StackRestoreCGN = 0, *CallerNode = 0; CallGraphNode *StackSaveCGN = 0, *StackRestoreCGN = 0, *CallerNode = 0;
if (CG) { if (CG) {
// We know that StackSave/StackRestore are Function*'s, because they are StackSaveCGN = CG->getOrInsertFunction(StackSave);
// intrinsics which must have the right types. StackRestoreCGN = CG->getOrInsertFunction(StackRestore);
StackSaveCGN = CG->getOrInsertFunction(cast<Function>(StackSave));
StackRestoreCGN = CG->getOrInsertFunction(cast<Function>(StackRestore));
CallerNode = (*CG)[Caller]; 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(); for (Function::iterator BB = FirstNewBlock, E = Caller->end();
BB != E; ++BB) BB != E; ++BB)
if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator())) { 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; ++NumStackRestores;
} }
} }

View File

@ -51,7 +51,38 @@ entry:
unreachable unreachable
} }
declare fastcc void @list_Rplacd1284() nounwind ssp declare fastcc void @list_Rplacd1284() nounwind ssp
;============================
; PR5208
define void @AAA() {
entry:
%A = alloca i8, i32 undef, align 1
invoke fastcc void @XXX()
to label %invcont98 unwind label %lpad156
invcont98:
unreachable
lpad156:
unreachable
}
declare fastcc void @YYY()
define internal fastcc void @XXX() {
entry:
%B = alloca i8, i32 undef, align 1
invoke fastcc void @YYY()
to label %bb260 unwind label %lpad
bb260:
ret void
lpad:
unwind
}