[llvm-commits] [llvm-gcc-4.2] r94759 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Nick Lewycky nicholas at mxc.ca
Thu Jan 28 21:03:08 PST 2010


Stuart Hastings wrote:
> Author: stuart
> Date: Thu Jan 28 17:08:38 2010
> New Revision: 94759
>
> URL: http://llvm.org/viewvc/llvm-project?rev=94759&view=rev
> Log:
> Fix an off-by-one error when the insertion point wanders past a
> terminating branch.  Radar 7548753.
>
> Modified:
>      llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=94759&r1=94758&r2=94759&view=diff
>
> ==============================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Jan 28 17:08:38 2010
> @@ -2978,6 +2978,7 @@
>     if (Instruction *I = dyn_cast<Instruction>(FirstVal)) {
>       InsertPt = I;                      // Insert after the init instruction.
>
> +    bool InsertPtFinal = false;
>       // If the instruction is an alloca in the entry block, the insert point
>       // will be before the alloca.  Advance to the AllocaInsertionPoint if we are
>       // before it.
> @@ -2987,18 +2988,22 @@
>           if (&*CI == AllocaInsertionPoint) {
>             InsertPt = AllocaInsertionPoint;
>             ++InsertPt;
> +	  InsertPtFinal = true;		// This is the spot; stop searching.

Tab!

Nick

>             break;
>           }
>         }
>       }
>
> -    // If the instruction is an invoke, the init is inserted on the normal edge.
> -    if (InvokeInst *II = dyn_cast<InvokeInst>(InsertPt)) {
> -      InsertPt = II->getNormalDest()->begin();
> -      while (isa<PHINode>(InsertPt))
> -        ++InsertPt;
> -    } else
> -      ++InsertPt; // Insert after the init instruction.
> +    if (!InsertPtFinal) {
> +      // If the instruction is an invoke, the init is inserted on the normal edge.
> +      if (InvokeInst *II = dyn_cast<InvokeInst>(InsertPt)) {
> +	InsertPt = II->getNormalDest()->begin();
> +	while (isa<PHINode>(InsertPt))
> +	  ++InsertPt;
> +      }
> +      else
> +	++InsertPt; // Insert after the init instruction.
> +    }
>     } else {
>       InsertPt = AllocaInsertionPoint;   // Insert after the allocas.
>       ++InsertPt;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list