[llvm-commits] [llvm] r84310 - in /llvm/trunk: lib/Transforms/Utils/InlineFunction.cpp test/Transforms/Inline/crash.ll

Chris Lattner sabre at nondot.org
Fri Oct 16 22:39:39 PDT 2009


Author: lattner
Date: Sat Oct 17 00:39:39 2009
New Revision: 84310

URL: http://llvm.org/viewvc/llvm-project?rev=84310&view=rev
Log:
Simplify some code (first hunk) and fix PR5208 (second hunk) by
updating the callgraph when introducing a call.

Modified:
    llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
    llvm/trunk/test/Transforms/Inline/crash.ll

Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=84310&r1=84309&r2=84310&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Sat Oct 17 00:39:39 2009
@@ -444,18 +444,15 @@
   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 @@
       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;
         }
     }

Modified: llvm/trunk/test/Transforms/Inline/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/crash.ll?rev=84310&r1=84309&r2=84310&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/Inline/crash.ll (original)
+++ llvm/trunk/test/Transforms/Inline/crash.ll Sat Oct 17 00:39:39 2009
@@ -51,7 +51,38 @@
   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
+}





More information about the llvm-commits mailing list