This is an archive of the discontinued LLVM Phabricator instance.

[AVR] Fix a bug in AsmPrinter when printing inline-asm operands
ClosedPublic

Authored by benshi001 on Jan 12 2023, 3:16 AM.

Diff Detail

Event Timeline

benshi001 created this revision.Jan 12 2023, 3:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 3:16 AM
benshi001 requested review of this revision.Jan 12 2023, 3:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 3:16 AM
benshi001 edited the summary of this revision. (Show Details)Jan 12 2023, 4:04 AM
Miss_Grape accepted this revision.Jan 12 2023, 7:00 PM
This revision is now accepted and ready to land.Jan 12 2023, 7:00 PM
benshi001 added inline comments.Jan 12 2023, 7:06 PM
llvm/lib/Target/AVR/AVRAsmPrinter.cpp
132

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@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.
This revision was landed with ongoing or failed builds.Jan 12 2023, 10:24 PM
This revision was automatically updated to reflect the committed changes.