[all-commits] [llvm/llvm-project] d0d43b: [OpenMP] target nested `use_device_ptr() if()` and...

Chi-Chun, Chen via All-commits all-commits at lists.llvm.org
Wed Nov 4 10:37:21 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d0d43b58b109c2945e30d0bfabe77d3dcf1e4ad5
      https://github.com/llvm/llvm-project/commit/d0d43b58b109c2945e30d0bfabe77d3dcf1e4ad5
  Author: cchen <chichunchen844 at gmail.com>
  Date:   2020-11-04 (Wed, 04 Nov 2020)

  Changed paths:
    M clang/lib/CodeGen/CGOpenMPRuntime.cpp
    M clang/lib/CodeGen/CGOpenMPRuntime.h
    A clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp

  Log Message:
  -----------
  [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

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

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D90704




More information about the All-commits mailing list