Fix PR1335 and Transforms/Inline/2007-04-15-InlineEH.ll
[oota-llvm.git] / lib / Transforms / Utils / InlineFunction.cpp
index 07194e38ad23d5826b80b69e3477dd5dca722bf6..9735a2fcda444b0502fbfd83cc6f5cc5b69a47b6 100644 (file)
@@ -69,10 +69,11 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
           if (!isa<CallInst>(I)) continue;
           CallInst *CI = cast<CallInst>(I);
 
-          // If this is an intrinsic function call, don't convert it to an
-          // invoke.
-          if (CI->getCalledFunction() &&
-              CI->getCalledFunction()->getIntrinsicID())
+          // If this is an intrinsic function call or an inline asm, don't
+          // convert it to an invoke.
+          if ((CI->getCalledFunction() &&
+               CI->getCalledFunction()->getIntrinsicID()) ||
+              isa<InlineAsm>(CI->getCalledValue()))
             continue;
           
           // Convert this function call into an invoke instruction.
@@ -263,11 +264,12 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
             ++I;
 
           // Transfer all of the allocas over in a block.  Using splice means
-          // that they instructions aren't removed from the symbol table, then
+          // that the instructions aren't removed from the symbol table, then
           // reinserted.
-          Caller->front().getInstList().splice(InsertPoint,
-                                               FirstNewBlock->getInstList(),
-                                               AI, I);
+          Caller->getEntryBlock().getInstList().splice(
+              InsertPoint,
+              FirstNewBlock->getInstList(),
+              AI, I);
         }
       }
   }