https://bugs.llvm.org/show_bug.cgi?id=51081

            Bug ID: 51081
           Summary: clang crash with inline asm that has function type as
                    input operand
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangb...@nondot.org
          Reporter: jasonliu.developm...@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Reduced test case:
```
void callee(void);

void caller() {
    asm volatile("rcall %0"::"n"(callee));
}
```

Without assertion, compiler crashes in llvm and getting stack dump:
https://godbolt.org/z/hb4acs8aG

With assertion turned on, compiler hit
`assert(!LV.getType()->isFunctionType());` in
`CodeGenFunction::EmitLoadOfLValue()` clang/lib/CodeGen/CGExpr.cpp.

So it seems we might already generated wrong IR from clang which leads to the
crash in LLVM (in non-assert mode).

The easy change would be to reverse part of this fix:
https://github.com/llvm/llvm-project/commit/d68b2d043865e1c106432f2ab9c1b99a5a2ba86e
i.e. to remove the assertion and bring back the if statement.

But it seems that we might prefer to have a sema component change (i.e. detect
if it's a function then do a function to pointer decay) instead of waiting to
change it in the last minute of clang code gen.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to