[clang] [OpenMP] Mark critical region lock variables dso_local for static relocation model (PR #201157)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 3 12:08:22 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results

* 54102 tests passed
* 1289 tests skipped
* 2 tests failed

## Failed Tests
(click on a test name to see its output)

### Clang
<details>
<summary>Clang.OpenMP/critical_codegen.cpp</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\23\include -nostdsysteminc -verify -fopenmp -x c++ -emit-llvm C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen.cpp -fexceptions -fcxx-exceptions -o - | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe --allow-unused-prefixes C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen.cpp --check-prefixes=ALL,NORMAL
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\23\include' -nostdsysteminc -verify -fopenmp -x c++ -emit-llvm 'C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen.cpp' -fexceptions -fcxx-exceptions -o -
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' --allow-unused-prefixes 'C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen.cpp' --check-prefixes=ALL,NORMAL
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen.cpp:19:9: error: ALL: expected string not found in input
# | // ALL: [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
# |         ^
# | <stdin>:6:51: note: scanning from here
# | %struct.ident_t = type { i32, i32, i32, i32, ptr }
# |                                                   ^
# | <stdin>:11:29: note: possible intended match here
# | @.gomp_critical_user_.var = common dso_local global [8 x i32] zeroinitializer, align 8
# |                             ^
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen.cpp:34:83: error: undefined variable: UNNAMED_LOCK
# | // ALL: call {{.*}}void @__kmpc_critical(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[UNNAMED_LOCK]])
# |                                                                                   ^
# | <stdin>:31:49: note: with "DEFAULT_LOC" equal to "@1"
# |  %0 = call i32 @__kmpc_global_thread_num(ptr @1)
# |                                                 ^
# | <stdin>:31:49: note: with "GTID" equal to "%0"
# |  %0 = call i32 @__kmpc_global_thread_num(ptr @1)
# |                                                 ^
# | <stdin>:33:2: note: possible intended match here
# |  call void @__kmpc_critical(ptr @1, i32 %0, ptr @.gomp_critical_user_.var)
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             1: ; ModuleID = 'C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen.cpp' 
# |             2: source_filename = "C:\\_work\\llvm-project\\llvm-project\\clang\\test\\OpenMP\\critical_codegen.cpp" 
# |             3: target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 
# |             4: target triple = "x86_64-pc-windows-msvc" 
# |             5:  
# |             6: %struct.ident_t = type { i32, i32, i32, i32, ptr } 
# | check:19'0                                                       X error: no match found
# |             7: %class.anon = type { i32, i32 } 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             8: %class.anon.0 = type { i32, i32 } 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             9: %struct.S = type { i32 } 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |            10:  
# | check:19'0     ~
# |            11: @.gomp_critical_user_.var = common dso_local global [8 x i32] zeroinitializer, align 8 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:19'1                                 ?                                                           possible intended match
# |            12: @0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            13: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @0 }, align 8 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            14: @.gomp_critical_user_the_name.var = common dso_local global [8 x i32] zeroinitializer, align 8 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            15: @.gomp_critical_user_the_name1.var = common dso_local global [8 x i32] zeroinitializer, align 8 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            16:  
# | check:19'0     ~
# |             .
# |             .
# |             .
# |            26: ; Function Attrs: noinline norecurse optnone 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            27: define dso_local noundef i32 @main() #2 personality ptr @__CxxFrameHandler3 { 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            28: entry: 
# |            29:  %retval = alloca i32, align 4 
# |            30:  %a = alloca i8, align 1 
# |            31:  %0 = call i32 @__kmpc_global_thread_num(ptr @1) 
# | check:34'0                                                     X error: match failed for invalid pattern
# | check:34'1                                                       undefined variable: UNNAMED_LOCK
# | check:34'2                                                       with "DEFAULT_LOC" equal to "@1"
# | check:34'3                                                       with "GTID" equal to "%0"
# |            32:  store i32 0, ptr %retval, align 4 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            33:  call void @__kmpc_critical(ptr @1, i32 %0, ptr @.gomp_critical_user_.var) 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:34'4      ?                                                                          possible intended match
# |            34:  store i8 2, ptr %a, align 1 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            35:  call void @__kmpc_end_critical(ptr @1, i32 %0, ptr @.gomp_critical_user_.var) 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            36:  call void @__kmpc_critical(ptr @1, i32 %0, ptr @.gomp_critical_user_the_name.var) 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            37:  invoke void @"?foo@@YAXXZ"() 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            38:  to label %invoke.cont unwind label %terminate 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>Clang.OpenMP/critical_codegen_attr.cpp</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\23\include -nostdsysteminc -verify -fopenmp -emit-llvm C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen_attr.cpp -fexceptions -fcxx-exceptions -o - | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe --allow-unused-prefixes C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen_attr.cpp --check-prefixes=ALL,NORMAL
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\23\include' -nostdsysteminc -verify -fopenmp -emit-llvm 'C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen_attr.cpp' -fexceptions -fcxx-exceptions -o -
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' --allow-unused-prefixes 'C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen_attr.cpp' --check-prefixes=ALL,NORMAL
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen_attr.cpp:19:9: error: ALL: expected string not found in input
# | // ALL: [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
# |         ^
# | <stdin>:6:51: note: scanning from here
# | %struct.ident_t = type { i32, i32, i32, i32, ptr }
# |                                                   ^
# | <stdin>:11:29: note: possible intended match here
# | @.gomp_critical_user_.var = common dso_local global [8 x i32] zeroinitializer, align 8
# |                             ^
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen_attr.cpp:34:83: error: undefined variable: UNNAMED_LOCK
# | // ALL: call {{.*}}void @__kmpc_critical(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[UNNAMED_LOCK]])
# |                                                                                   ^
# | <stdin>:31:49: note: with "DEFAULT_LOC" equal to "@1"
# |  %0 = call i32 @__kmpc_global_thread_num(ptr @1)
# |                                                 ^
# | <stdin>:31:49: note: with "GTID" equal to "%0"
# |  %0 = call i32 @__kmpc_global_thread_num(ptr @1)
# |                                                 ^
# | <stdin>:33:2: note: possible intended match here
# |  call void @__kmpc_critical(ptr @1, i32 %0, ptr @.gomp_critical_user_.var)
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen_attr.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             1: ; ModuleID = 'C:\_work\llvm-project\llvm-project\clang\test\OpenMP\critical_codegen_attr.cpp' 
# |             2: source_filename = "C:\\_work\\llvm-project\\llvm-project\\clang\\test\\OpenMP\\critical_codegen_attr.cpp" 
# |             3: target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 
# |             4: target triple = "x86_64-pc-windows-msvc" 
# |             5:  
# |             6: %struct.ident_t = type { i32, i32, i32, i32, ptr } 
# | check:19'0                                                       X error: no match found
# |             7: %class.anon = type { i32, i32 } 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             8: %class.anon.0 = type { i32, i32 } 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             9: %struct.S = type { i32 } 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |            10:  
# | check:19'0     ~
# |            11: @.gomp_critical_user_.var = common dso_local global [8 x i32] zeroinitializer, align 8 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:19'1                                 ?                                                           possible intended match
# |            12: @0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            13: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @0 }, align 8 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            14: @.gomp_critical_user_the_name.var = common dso_local global [8 x i32] zeroinitializer, align 8 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            15: @.gomp_critical_user_the_name1.var = common dso_local global [8 x i32] zeroinitializer, align 8 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            16:  
# | check:19'0     ~
# |             .
# |             .
# |             .
# |            26: ; Function Attrs: noinline norecurse optnone 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            27: define dso_local noundef i32 @main() #2 personality ptr @__CxxFrameHandler3 { 
# | check:19'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            28: entry: 
# |            29:  %retval = alloca i32, align 4 
# |            30:  %a = alloca i8, align 1 
# |            31:  %0 = call i32 @__kmpc_global_thread_num(ptr @1) 
# | check:34'0                                                     X error: match failed for invalid pattern
# | check:34'1                                                       undefined variable: UNNAMED_LOCK
# | check:34'2                                                       with "DEFAULT_LOC" equal to "@1"
# | check:34'3                                                       with "GTID" equal to "%0"
# |            32:  store i32 0, ptr %retval, align 4 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            33:  call void @__kmpc_critical(ptr @1, i32 %0, ptr @.gomp_critical_user_.var) 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:34'4      ?                                                                          possible intended match
# |            34:  store i8 2, ptr %a, align 1 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            35:  call void @__kmpc_end_critical(ptr @1, i32 %0, ptr @.gomp_critical_user_.var) 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            36:  call void @__kmpc_critical(ptr @1, i32 %0, ptr @.gomp_critical_user_the_name.var) 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            37:  invoke void @"?foo@@YAXXZ"() 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            38:  to label %invoke.cont unwind label %terminate 
# | check:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

https://github.com/llvm/llvm-project/pull/201157


More information about the cfe-commits mailing list