This patch adds the codegen support for atomic compare capture in clang.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
11852 | I think we don't need that as D and E are supposed to be rvalue, and as shown here I only ignore implicit casts for rvalue. |
clang/include/clang/AST/StmtOpenMP.h | ||
---|---|---|
2829–2855 | Will do in another patch. |
clang/lib/CodeGen/CGStmtOpenMP.cpp | ||
---|---|---|
6205 | Please avoid adding new calls to getPointerElementType(). See https://github.com/llvm/llvm-project/commit/b1863d82454b2905db8b492bea0ce8a260362645 for a way to avoid it in this context. |
clang/lib/CodeGen/CGStmtOpenMP.cpp | ||
---|---|---|
6205 | Got it. Thanks for the info. |
clang/include/clang/AST/StmtOpenMP.h | ||
---|---|---|
2935–2942 | Sure, we could do that. | |
clang/lib/CodeGen/CGStmtOpenMP.cpp | ||
6358 | Well, I think it's part of this patch because we can't tell if it's compare or compare capture before, but now we can. If we really want to do that, we can have another patch including all changes in this patch related to OMPAtomicDirective. |
clang/lib/CodeGen/CGStmtOpenMP.cpp | ||
---|---|---|
6358 | Kind of NFC? Would be good |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
11719 | Why do we need to use IgnoreImpCasts() here and in other places? |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
11719 | Clang usually inserts implicit casts. For example, if we have: char a, b, c; #pragma omp atomic compare capture { r = a; if (a > c) { a = b; } } Clang inserts an implicit cast from char to int for all statements except r = a. In this case, what should be the right solution? I'm not quite sure actually. |
ping
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
11719 | https://godbolt.org/z/a6WWdx581 |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
11719 | I don't see casts to int in a=b (BO points to this expression,right?). The only cast, that maybe should be removed here, is LValueToRValue |
clang/lib/CodeGen/CGStmtOpenMP.cpp | ||
---|---|---|
6189 |
I'm thinking of a similar case. void foo() { int e, d; char x, v; if (x == e) x = d; } In this case, there are two casts:
We cannot ignore both of them. For the 2nd, no question. For the expression x == e, the problem is in e instead of x. e here is always int, further causing issue in codegen. I'm thinking for those lvalues, we can only set them where they are used as lvalues in case any type lifting. For those rvalues, if their types are not same as x, but compatible with x, we have to insert cast, including truncate, before feed them into codegen. Does it sound good? |
Transform these booleans to bitfields?