~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to lib/Transforms/Utils/InlineFunction.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
758
758
 
759
759
    // If the call site was an invoke instruction, add a branch to the normal
760
760
    // destination.
761
 
    if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
762
 
      BranchInst::Create(II->getNormalDest(), TheCall);
 
761
    if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
 
762
      BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), TheCall);
 
763
      NewBr->setDebugLoc(Returns[0]->getDebugLoc());
 
764
    }
763
765
 
764
766
    // If the return instruction returned a value, replace uses of the call with
765
767
    // uses of the returned value.
787
789
  // "starter" and "ender" blocks.  How we accomplish this depends on whether
788
790
  // this is an invoke instruction or a call instruction.
789
791
  BasicBlock *AfterCallBB;
 
792
  BranchInst *CreatedBranchToNormalDest = NULL;
790
793
  if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
791
794
 
792
795
    // Add an unconditional branch to make this look like the CallInst case...
793
 
    BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), TheCall);
 
796
    CreatedBranchToNormalDest = BranchInst::Create(II->getNormalDest(), TheCall);
794
797
 
795
798
    // Split the basic block.  This guarantees that no PHI nodes will have to be
796
799
    // updated due to new incoming edges, and make the invoke case more
797
800
    // symmetric to the call case.
798
 
    AfterCallBB = OrigBB->splitBasicBlock(NewBr,
 
801
    AfterCallBB = OrigBB->splitBasicBlock(CreatedBranchToNormalDest,
799
802
                                          CalledFunc->getName()+".exit");
800
803
 
801
804
  } else {  // It's a call
850
853
 
851
854
 
852
855
    // Add a branch to the merge points and remove return instructions.
 
856
    DebugLoc Loc;
853
857
    for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
854
858
      ReturnInst *RI = Returns[i];
855
 
      BranchInst::Create(AfterCallBB, RI);
 
859
      BranchInst* BI = BranchInst::Create(AfterCallBB, RI);
 
860
      Loc = RI->getDebugLoc();
 
861
      BI->setDebugLoc(Loc);
856
862
      RI->eraseFromParent();
857
863
    }
 
864
    // We need to set the debug location to *somewhere* inside the
 
865
    // inlined function. The line number may be nonsensical, but the
 
866
    // instruction will at least be associated with the right
 
867
    // function.
 
868
    if (CreatedBranchToNormalDest)
 
869
      CreatedBranchToNormalDest->setDebugLoc(Loc);
858
870
  } else if (!Returns.empty()) {
859
871
    // Otherwise, if there is exactly one return value, just replace anything
860
872
    // using the return value of the call with the computed value.
874
886
    AfterCallBB->getInstList().splice(AfterCallBB->begin(),
875
887
                                      ReturnBB->getInstList());
876
888
 
 
889
    if (CreatedBranchToNormalDest)
 
890
      CreatedBranchToNormalDest->setDebugLoc(Returns[0]->getDebugLoc());
 
891
 
877
892
    // Delete the return instruction now and empty ReturnBB now.
878
893
    Returns[0]->eraseFromParent();
879
894
    ReturnBB->eraseFromParent();