[PATCH] D64646: [OPENMP]Add support for analysis of if clauses.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 15:58:00 PDT 2019


NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks great! Thank you for improving the tests even further.



================
Comment at: test/Analysis/cfg-openmp.cpp:58-67
 #pragma omp distribute simd
   for (int i = 0; i < 10; ++i)
     argc = x;
-// CHECK-NEXT:  27: x
-// CHECK-NEXT:  28: [B1.27] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  29: argc
-// CHECK-NEXT:  30: [B1.29] = [B1.28]
-// CHECK-NEXT:  31: #pragma omp for
+// CHECK-NEXT:  [[#FOR:]]: x
+// CHECK-NEXT:  [[#FOR+1]]: [B1.[[#FOR]]] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  [[#FOR+2]]: argc
+// CHECK-NEXT:  [[#FOR+3]]: [B1.[[#FOR+2]]] = [B1.[[#FOR+1]]]
----------------
I'm slowly updating my mental model of these CFGs. Just to confirm my understanding - tried the following example:

```lang=c++
int main(int argc, char **argv) {
  int x = 0;
#pragma omp for
  for (int i = 0; i < 10; ++i)
    x += argv[i];
}
```

The CFG was as follows:

```
   1: 0
   2: int x = 0;
   3: x
   4: argv
   5: [B1.4] (ImplicitCastExpr, LValueToRValue, char **)
   6: i
   7: [B1.6] (ImplicitCastExpr, LValueToRValue, int)
   8: [B1.5][[B1.7]]
   9: [B1.8] (ImplicitCastExpr, LValueToRValue, char *)
  10: [B1.3] += [B1.9]
  11: #pragma omp for
    for (int i = 0; i < 10; ++i)
        [B1.10];
```

Do i understand correctly that `[B1.10]` aka `argv[0]` is going to act like an "argument" to the "outlined function" and then it's going to be re-used (as if it was a "local" "variable") on subsequent iterations of the loop (i.e., assigned values `argv[1]`, ..., `argv[9]`)? I.e., the "function" is going to be responsible for computing `argv[1]` and storing it in the "parameter variable" (`OMPCapturedExprDecl` which is a sub-class of `VarDecl`) that previously contained `argv[0]`, but it's not responsible for computing `argv[0]` itself, right?


Repository:
  rC Clang

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

https://reviews.llvm.org/D64646





More information about the cfe-commits mailing list