Clang now asserts for the below case:
void clang::CodeGen::CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata(): Assertion `std::get<0>(E) && "All ordered entries must exist!"' failed.
The reason why Clang hit the assert is because in
emitTargetDataCalls, both BeginThenGen and BeginElseGen call
registerTargetRegionEntryInfo and try to register the Entry in
OffloadEntriesTargetRegion with same key. If changing the expression in
if clause to any constant expression, then the assert disappear. (https://godbolt.org/z/TW7haj)
The assert itself is to avoid
user from accessing elements out of bound inside OrderedEntries in
createOffloadEntriesAndInfoMetadata.
In this patch, I add a check in registerTargetRegionEntryInfo to avoid
register the target region more than once.
A test case that triggers assert: https://godbolt.org/z/4cnGW8
clang-format suggested style edits found: