Description
Minimum 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;
}
Compiler Explorer: https://godbolt.org/z/9W6vEvvz4
Assertion failure here:
This is due to that in example()
's return type is const qualified and therefore didn't pass this check for DirectEmit
, and that it's NRVO optimized. Emission of NRVO optimized variables don't have their Pointer
be an AllocaInst
.
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.