[PATCH] D142096: [AVR] Fix incorrectly printed global symbol operands in inline assembly

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 06:22:20 PST 2023


aykevl accepted this revision.
aykevl added a comment.
This revision is now accepted and ready to land.

Looks good to me, with just a single comment. Feel free to fix this while committing.



================
Comment at: llvm/lib/Target/AVR/AVRAsmPrinter.cpp:147
+  const auto &MO = MI->getOperand(OpNum);
+  if (MO.getType() == MachineOperand::MO_GlobalAddress) {
+    PrintSymbolOperand(MO, O);
----------------
I think this should be the following, to be consistent with the rest of the code:

```
if (Error && MO.getType() == MachineOperand::MO_GlobalAddress) {
```

Even better would be to refactor the code to be more like RISC-V, to avoid the `Error` check (perhaps in a separate patch):

```
bool RISCVAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
                                      const char *ExtraCode, raw_ostream &OS) {
  // First try the generic code, which knows about modifiers like 'c' and 'n'.
  if (!AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS))
    return false;
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142096/new/

https://reviews.llvm.org/D142096



More information about the llvm-commits mailing list