[PATCH] D118632: [Clang]OpenMP] Add the codegen support for `atomic compare`

Shilei Tian via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 7 14:04:22 PST 2022


tianshilei1992 added inline comments.


================
Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:6041
+  llvm::Value *EVal = CGF.EmitScalarExpr(E->IgnoreImpCasts());
+  llvm::Value *DVal = D ? CGF.EmitScalarExpr(D->IgnoreImpCasts()) : nullptr;
+
----------------
Using `D->IgnoreImpCasts()` can make sure to avoid the case that `char` is casted to `int` in binary operation. However, say, if user writes the following code:
```
int x;
#pragma omp atomic compare
  x = x > 1.01 ? 1.01 : x;
```
`1.01` here will be casted to `1` by clang, and a warning will be emitted. Because we ignore the implicit cast, in Sema, it is taken as floating point value. However, we already told user that it is casted to `1`, which is a little weird to emit an error then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118632/new/

https://reviews.llvm.org/D118632



More information about the llvm-commits mailing list