[llvm-commits] [llvm] r106816 - /llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp

Chris Lattner clattner at apple.com
Thu Jun 24 21:45:10 PDT 2010


On Jun 24, 2010, at 5:49 PM, Dale Johannesen wrote:

> Author: johannes
> Date: Thu Jun 24 19:49:43 2010
> New Revision: 106816
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=106816&view=rev
> Log:
> Fix a case where an earlyclobber operand of an asm
> is reused as an input.  PR 4118.  Testcase is too big,
> as usual with bugs in this area, but there's one in
> the PR.

Hi Dale,

Please use the MachineInstr::isInlineAsm() predicate instead of checking the opcode.

-Chris

> 
> 
> Modified:
>    llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
> 
> Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=106816&r1=106815&r2=106816&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Thu Jun 24 19:49:43 2010
> @@ -2033,6 +2033,21 @@
>           CanReuse = !ReusedOperands.isClobbered(PhysReg) &&
>             Spills.canClobberPhysReg(PhysReg);
>         }
> +        // If this is an asm, and PhysReg is used elsewhere as an earlyclobber
> +        // operand, we can't also use it as an input.  (Outputs always come
> +        // before inputs, so we can stop looking at i.)
> +        if (MI.getOpcode()==TargetOpcode::INLINEASM) {
> +          for (unsigned k=0; k<i; ++k) {
> +            MachineOperand &MOk = MI.getOperand(k);
> +            if (!MOk.isReg() || MOk.getReg()==0)
> +              continue;
> +            unsigned VirtRegk = MOk.getReg();
> +            if (VirtRegk == PhysReg && MOk.isEarlyClobber()) {
> +              CanReuse = false;
> +              break;
> +            }
> +          }
> +        }
> 
>         if (CanReuse) {
>           // If this stack slot value is already available, reuse it!
> @@ -2103,6 +2118,8 @@
>         // To avoid this problem, and to avoid doing a load right after a store,
>         // we emit a copy from PhysReg into the designated register for this
>         // operand.
> +        //
> +        // This case also applies to an earlyclobber'd PhysReg.
>         unsigned DesignatedReg = VRM->getPhys(VirtReg);
>         assert(DesignatedReg && "Must map virtreg to physreg!");
> 
> 
> 
> _______________________________________________
> 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