Issue |
148953
|
Summary |
[Clang] FE Crash in CGCoroutine: NRVO var emission didn't result in an AllocaInst
|
Labels |
clang
|
Assignees |
yuxuanchen1997
|
Reporter |
yuxuanchen1997
|
Repro:
```
#include <coroutine>
struct Task {
struct promise_type {
Task get_return_object();
std::suspend_always initial_suspend() { return {}; }
std::suspend_always final_suspend() noexcept { return {}; }
void return_void() {}
void unhandled_exception() {}
};
Task() {}
Task(const Task&) {};
};
// Example usage
const Task example() {
co_return;
}
```
https://godbolt.org/z/9W6vEvvz4
Assertion failure here: https://github.com/llvm/llvm-project/blob/1a940bfff9176fb38a71b0045d7ae25df9a4ca7d/clang/lib/CodeGen/CGCoroutine.cpp#L712
This is due to that in `example()`'s return type is const qualified and therefore didn't pass [this check](https://github.com/llvm/llvm-project/blob/1a940bfff9176fb38a71b0045d7ae25df9a4ca7d/clang/lib/CodeGen/CGCoroutine.cpp#L683) for `DirectEmit`, and that it's NRVO optimized.
The fix is either don't compare Qualified Types in `DirectEmit` or just don't attach the metadata when the return value is NRVO optimized, in which case the `AllocaInst` doesn't exist.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs