[PATCH] D141589: [AVR] Fix a bug in AsmPrinter when printing inline-asm operands
    Ben Shi via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Jan 12 19:06:18 PST 2023
    
    
  
benshi001 added inline comments.
================
Comment at: llvm/lib/Target/AVR/AVRAsmPrinter.cpp:132
+      if (RegIdx >= NumOpRegs)
+        return true;
       Reg = MI->getOperand(OpNum + RegIdx).getReg();
----------------
It would be better to `return true` and the upper llvm assembler handle the error.
For example, with the following c code
```
void fooa(void);
int foob(void) {
        int result;
        fooa();
        __asm (";; %C0" : "=d" (result));
        fooa();
        return result;
}
```
Built it with clang, the clang will give detailed errors.
```
benshi at BJSW-T026:~/llvm-project/build$ ./bin/clang a.c -O3 -Wall --target=avr -mmcu=atmega328 -S
a.c:6:9: error: invalid operand in inline asm: ';; ${0:C}'
        __asm (";; %C0" : "=d" (result));
               ^
1 error generated.
```
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141589/new/
https://reviews.llvm.org/D141589
    
    
More information about the llvm-commits
mailing list