Skip to content

[asm goto] support outputs along indirect branches #53562

Closed
@josephcsible

Description

@josephcsible

Consider this C code:

int main(void) {
    int x = 123;
    asm goto("mov %1, %0\n\tjmp %l[label]" : "=r" (x) : "r" (45) : : label);
    x = 6;
    label:
    return x;
}

It's supposed to return 45. But when you compile it in Clang, it returns 123 instead. I tested this on both trunk (01b52f7) and 13.0.0, and both with -O3 and without optimizations, and the bug happens in all of those cases.

https://godbolt.org/z/vKeYrfYY5

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.enhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions