3 Could not move globalized variable to the stack. Variable is potentially captured in call. Mark parameter as `__attribute__((noescape))` to override. [OMP113]
4 ==============================================================================================================================================================
6 This missed remark indicates that a globalized value could not be moved to the
7 stack because it is potentially captured by a call to a function we cannot
8 analyze. In order for a globalized variable to be moved to the stack, copies to
9 its pointer cannot be stored. Otherwise it is considered captured and could
10 potentially be shared between the threads. This can be overridden using a
11 parameter level attribute as suggested in the remark text.
13 Globalization will occur when a pointer to a thread-local variable escapes the
14 current scope. In most cases it can be determined that the variable cannot be
15 shared if a copy of its pointer is never made. However, this remark indicates a
16 copy of the pointer is present or that sharing is possible because it is used
17 outside the current translation unit.
22 If a pointer to a thread-local variable is passed to a function not visible in
23 the current translation unit we need to assume a copy is made of it that can be
24 shared between the threads. This prevents :ref:`OMP110 <omp110>` from
25 triggering, which will result in a performance penalty when executing on the
30 extern void use(int *x);
38 #pragma omp target parallel
42 .. code-block:: console
44 $ clang++ -fopenmp -fopenmp-targets=nvptx64 -O2 -Rpass-missed=openmp-opt omp113.cpp
45 missed.cpp:4:7: remark: Could not move globalized variable to the stack. Variable is
46 potentially captured in call. Mark parameter as `__attribute__((noescape))` to
51 As the remark suggests, this behaviour can be overridden using the ``noescape``
52 attribute. This tells the compiler that no reference to the object the pointer
53 points to that is derived from the parameter value will survive after the
54 function returns. The user is responsible for verifying that this assertion is
59 extern void use(__attribute__((noescape)) int *x);
67 #pragma omp target parallel
71 .. code-block:: console
73 $ clang++ -fopenmp -fopenmp-targets=nvptx64 -O2 -Rpass=openmp-opt omp113.cpp
74 missed.cpp:4:7: remark: Moving globalized variable to the stack. [OMP110]
81 OpenMP target offloading missed remark.