[llvm] r175317 - c[ms-inline asm] It's possible to have a SizeDirective rewrite and an

Timur Iskhodzhanov timurrrr at google.com
Fri Feb 15 23:33:06 PST 2013


Do you think you should also add a small repro test for this case?
It looked like the assertion didn't fire on the existing set of tests.

2013/2/16 Chad Rosier <mcrosier at apple.com>:
> Author: mcrosier
> Date: Fri Feb 15 16:54:16 2013
> New Revision: 175317
>
> URL: http://llvm.org/viewvc/llvm-project?rev=175317&view=rev
> Log:
> c[ms-inline asm] It's possible to have a SizeDirective rewrite and an
> Input/Output rewrite to the same location.  Make sure the SizeDirective rewrite
> is performed first.  This also ensure the sort algorithm is stable.
>
> Modified:
>     llvm/trunk/lib/MC/MCParser/AsmParser.cpp
>
> Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=175317&r1=175316&r2=175317&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
> +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Fri Feb 15 16:54:16 2013
> @@ -4041,7 +4041,21 @@ static int RewritesSort(const void *A, c
>      return -1;
>    if (AsmRewriteB->Loc.getPointer() < AsmRewriteA->Loc.getPointer())
>      return 1;
> -  return 0;
> +
> +  // It's possible to have a SizeDirective rewrite and an Input/Output rewrite
> +  // to the same location.  Make sure the SizeDirective rewrite is performed
> +  // first.  This also ensure the sort algorithm is stable.
> +  if (AsmRewriteA->Kind == AOK_SizeDirective) {
> +    assert ((AsmRewriteB->Kind == AOK_Input || AsmRewriteB->Kind == AOK_Output) &&
> +            "Expected an Input/Output rewrite!");
> +    return -1;
> +  }
> +  if (AsmRewriteB->Kind == AOK_SizeDirective) {
> +    assert ((AsmRewriteA->Kind == AOK_Input || AsmRewriteA->Kind == AOK_Output) &&
> +            "Expected an Input/Output rewrite!");
> +    return 1;
> +  }
> +  llvm_unreachable ("Unstable rewrite sort.");
>  }
>
>  bool
> @@ -4174,6 +4188,7 @@ AsmParser::ParseMSInlineAsm(void *AsmLoc
>                                               E = AsmStrRewrites.end();
>         I != E; ++I) {
>      const char *Loc = (*I).Loc.getPointer();
> +    assert(Loc >= Start && "Expected Loc to be after Start!");
>
>      unsigned AdditionalSkip = 0;
>      AsmRewriteKind Kind = (*I).Kind;
>
>
> _______________________________________________
> 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