[PATCH] Fix inline assembly that switches between ARM and Thumb modes

Renato Golin renato.golin at linaro.org
Mon Dec 16 06:25:57 PST 2013


  Hi Greg,

  As Jim said, this works for binary output:

    if (OutStreamer.hasRawTextSupport()) {
      OutStreamer.EmitRawText(Str);
      return;
    }

  In the case of textual output, not only you're not checking for the error, but also you're not fixing anything. So, in that context, in half of the cases where this patch would be useful, it's not.

  Jim's proposal was to change the FeatureBits to its original state (and I add, emit a warning with the new inline asm warning system if changed), so that, at least, the common case is caught.

  I imagine there are cases (which would give anyone nightmares) for valid .arm/.thumb usage inside inline asm, but I think those cases are unstable, and a lot worse than the common case, so breaking them to fix this would make a bit of sense. I wouldn't cry over it, myself...

  The (better) alternative would be to parse the inline ASM on both output formats, but only add the instructions to the streamer on the binary one. Parsing inline ASM without output (in ASM mode) would serve two purposes:

  1. Validation of inline ASM, as an early warning system when the user included the wrong instruction set, or added invalid instructions, etc.
  2. To identify changes that could impact further code generation, such as .code .text etc. and revert the changes before continue.

  This should make use of the new warning call back mechanism.

http://llvm-reviews.chandlerc.com/D2255



More information about the llvm-commits mailing list