[LLVMdev] Reporting errors in inline assembly

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jul 1 16:36:07 PDT 2011


On Jul 1, 2011, at 4:22 PM, Eli Friedman wrote:

> On Fri, Jul 1, 2011 at 4:09 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
>> I want to report a problem with an inline assembly instruction from a code generator pass?
>> 
>> How can I do that with the proper diagnostic format and source location?
>> 
>> Right now we only get:
>> 
>> clang -c /d/g/clang-tests/gcc-4_2-testsuite/src/gcc.target/i386/pr30848.c
>> fatal error: error in backend: Inline asm output regs must be last on the x87 stack
>> 
>> But gcc-4-2 can:
>> 
>> $ gcc-4.2 -c /d/g/clang-tests/gcc-4_2-testsuite/src/gcc.target/i386/pr30848.c
>> /d/g/clang-tests/gcc-4_2-testsuite/src/gcc.target/i386/pr30848.c: In function ‘foo’:
>> /d/g/clang-tests/gcc-4_2-testsuite/src/gcc.target/i386/pr30848.c:5: error: output regs must be grouped at top of stack
>> 
>> Didn't we add support for source locations for the integrated assembler?
> 
> Found it; see http://llvm.org/viewvc/llvm-project?rev=100723&view=rev .

> -          Msg << "Invalid operand found in inline asm: '" << AsmStr << "'\n";
> -          MI->print(Msg);
> -          report_fatal_error(Msg.str());
> +          Msg << "invalid operand in inline asm: '" << AsmStr << "'";
> +          MMI->getModule()->getContext().emitError(LocCookie, Msg.str());

Thanks!

Now, where is my cookie?

Here:

>   unsigned LocCookie = 0;
>   const MDNode *LocMD = 0;
>   for (unsigned i = MI->getNumOperands(); i != 0; --i) {
>     if (MI->getOperand(i-1).isMetadata() &&
>         (LocMD = MI->getOperand(i-1).getMetadata()) &&
>         LocMD->getNumOperands() != 0) {
>       if (const ConstantInt *CI = dyn_cast<ConstantInt>(LocMD->getOperand(0))) {
>         LocCookie = CI->getZExtValue();
>         break;
>       }
>     }
>   }




More information about the llvm-dev mailing list