[llvm-commits] [llvm] r126963 - in /llvm/trunk: lib/MC/ test/CodeGen/ARM/ test/CodeGen/Blackfin/ test/CodeGen/CellSPU/ test/CodeGen/Mips/ test/CodeGen/PowerPC/ test/CodeGen/X86/ test/CodeGen/XCore/ test/MC/ELF/

Rafael Avila de Espindola rafael.espindola at gmail.com
Fri Mar 4 07:31:06 PST 2011


On 11-03-04 09:20 AM, Richard Osborne wrote:
> This breaks on the XCore - the toolchain doesn't use gas and the XMOS
> assembler doesn't accept strings as section names. Would it be possible
> to make the quoting conditional on whether the section name actually
> requires quoting?

Yes, that is probably the best thing to do.

>> ==============================================================================
>> --- llvm/trunk/lib/MC/MCSectionELF.cpp (original)
>> +++ llvm/trunk/lib/MC/MCSectionELF.cpp Thu Mar  3 16:31:08 2011
>> @@ -39,8 +39,22 @@
>>        return;
>>      }
>>
>> -  OS<<   "\t.section\t"<<   getSectionName();
>> -
>> +  StringRef name = getSectionName();
>> +  OS<<   "\t.section\t\"";
>> +  for (const char *b = name.begin(), *e = name.end(); b<   e; ++b) {
>> +    if (*b == '"') // Unquoted "
>> +      OS<<   "\\\"";
>> +    else if (*b != '\\') // Neither " or backslash
>> +      OS<<   *b;
>> +    else if (b + 1 == e) // Trailing backslash
>> +      OS<<   "\\\\";
>> +    else {
>> +      OS<<   b[0]<<   b[1]; // Quoted character
>> +      ++b;
>> +    }
>> +  }
>> +  OS<<   '"';


It should be fairly simple to adapt this into a predicate. Joerg, do you 
think you can do it before the 2.9 branch?

Thanks,
Rafael



More information about the llvm-commits mailing list