[clang] [Clang][CodeGen] Emit dereferenceable and nofree for indirect arguments (PR #213347)

via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 1 20:37:01 PDT 2026


github-actions[bot] wrote:

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

* 55903 tests passed
* 1453 tests skipped
* 2 tests failed

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

### Clang
<details>
<summary>Clang.CodeGenCXX/aix-alignment.cpp</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple powerpc-unknown-aix      -emit-llvm -o - -x c++ C:\_work\llvm-project\llvm-project\clang\test\CodeGenCXX\aix-alignment.cpp |    c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGenCXX\aix-alignment.cpp --check-prefixes=AIX,AIX32
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple powerpc-unknown-aix -emit-llvm -o - -x c++ 'C:\_work\llvm-project\llvm-project\clang\test\CodeGenCXX\aix-alignment.cpp'
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGenCXX\aix-alignment.cpp' --check-prefixes=AIX,AIX32
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\CodeGenCXX\aix-alignment.cpp:32:9: error: AIX: expected string not found in input
# | // AIX: define void @_Z3foo1D(ptr dead_on_unwind noalias writable sret(%struct.D) align 4 %agg.result, ptr noundef align 4 %x)
# |         ^
# | <stdin>:32:23: note: scanning from here
# |  %2 = load i32, ptr %1, align 4
# |                       ^
# | <stdin>:68:1: note: possible intended match here
# | define void @_Z3foo1D(ptr dead_on_unwind noalias writable sret(%struct.D) align 4 %agg.result, ptr nofree noundef align 4 dereferenceable(12) %x) #0 {
# | ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\CodeGenCXX\aix-alignment.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            27:  br i1 %isnull, label %delete.end2, label %delete.notnull 
# |            28:  
# |            29: delete.notnull: ; preds = %entry 
# |            30:  %0 = getelementptr inbounds i8, ptr %call, i32 -8 
# |            31:  %1 = getelementptr inbounds i8, ptr %0, i32 4 
# |            32:  %2 = load i32, ptr %1, align 4 
# | check:32'0                          {            search range start (exclusive)
# | check:32'1                                       error: no match found in search range
# |            33:  %delete.end = getelementptr inbounds %struct.B, ptr %call, i32 %2 
# |            34:  %arraydestroy.isempty = icmp eq ptr %call, %delete.end 
# |            35:  br i1 %arraydestroy.isempty, label %arraydestroy.done1, label %arraydestroy.body 
# |            36:  
# |            37: arraydestroy.body: ; preds = %arraydestroy.body, %delete.notnull 
# |             .
# |             .
# |             .
# |            63:  
# |            64: ; Function Attrs: nobuiltin nounwind 
# |            65: declare void @_ZdaPvm(ptr noundef, i32 noundef) #2 
# |            66:  
# |            67: ; Function Attrs: mustprogress noinline nounwind optnone 
# |            68: define void @_Z3foo1D(ptr dead_on_unwind noalias writable sret(%struct.D) align 4 %agg.result, ptr nofree noundef align 4 dereferenceable(12) %x) #0 { 
# | check:32'2     ?                                                                                                                                                        possible intended match
# |            69: entry: 
# |            70:  %result.ptr = alloca ptr, align 4 
# |            71:  %x.indirect_addr = alloca ptr, align 4 
# |            72:  store ptr %agg.result, ptr %result.ptr, align 4 
# |            73:  store ptr %x, ptr %x.indirect_addr, align 4 
# |             .
# |             .
# |             .
# |            95: attributes #5 = { nounwind } 
# |            96: attributes #6 = { builtin nounwind } 
# |            97:  
# |            98: !llvm.ident = !{!0} 
# |            99:  
# |           100: !0 = !{!"clang version 24.0.0git (https://github.com/llvm/llvm-project e7d37d6426ace09e5bdf78ab19bc51e9d0dadd0a)"} 
# | check:32'3                                                                                                                        } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

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

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -DCHECK -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp -o - | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe --allow-unused-prefixes -allow-deprecated-dag-overlap  C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp --check-prefix=CHECK1
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -DCHECK -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm 'C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp' -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 -allow-deprecated-dag-overlap 'C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp' --check-prefix=CHECK1
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp:423:17: error: CHECK1-NEXT: expected string not found in input
# | // CHECK1-NEXT: call void @_ZN1SIfEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) [[OMP_ARRAYCPY_DESTELEMENTPAST]], ptr noundef nonnull align 4 dereferenceable(4) [[OMP_ARRAYCPY_SRCELEMENTPAST]], ptr noundef align 4 [[AGG_TMP]])
# |                 ^
# | <stdin>:368:80: note: scanning from here
# |  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp)
# |                                                                                ^
# | <stdin>:368:80: note: with "OMP_ARRAYCPY_DESTELEMENTPAST" equal to "%omp.arraycpy.destElementPast"
# |  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp)
# |                                                                                ^
# | <stdin>:368:80: note: with "OMP_ARRAYCPY_SRCELEMENTPAST" equal to "%omp.arraycpy.srcElementPast"
# |  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp)
# |                                                                                ^
# | <stdin>:368:80: note: with "AGG_TMP" equal to "%agg.tmp"
# |  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp)
# |                                                                                ^
# | <stdin>:378:2: note: possible intended match here
# |  call void @_ZN1SIfEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %var4, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr nofree noundef align 4 dereferenceable(8) %agg.tmp5)
# |  ^
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp:521:17: error: CHECK1-SAME: expected string not found in input
# | // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[S:%.*]], ptr noundef align 4 [[T:%.*]]) unnamed_addr #[[ATTR1]] comdat {
# |                 ^
# | <stdin>:485:46: note: scanning from here
# | define linkonce_odr void @_ZN1SIfEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | <stdin>:485:46: note: with "ATTR1" equal to "1"
# | define linkonce_odr void @_ZN1SIfEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | <stdin>:485:46: note: pattern attempts to capture variables: "S", "T", "THIS"
# | define linkonce_odr void @_ZN1SIfEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp:669:17: error: CHECK1-SAME: expected string not found in input
# | // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[S:%.*]], ptr noundef align 4 [[T:%.*]]) unnamed_addr #[[ATTR1]] comdat {
# |                 ^
# | <stdin>:649:46: note: scanning from here
# | define linkonce_odr void @_ZN1SIfEC2ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | <stdin>:649:46: note: with "ATTR1" equal to "1"
# | define linkonce_odr void @_ZN1SIfEC2ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | <stdin>:649:46: note: pattern attempts to capture variables: "S", "T", "THIS"
# | define linkonce_odr void @_ZN1SIfEC2ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp:795:17: error: CHECK1-NEXT: expected string not found in input
# | // CHECK1-NEXT: call void @_ZN1SIiEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) [[OMP_ARRAYCPY_DESTELEMENTPAST]], ptr noundef nonnull align 4 dereferenceable(4) [[OMP_ARRAYCPY_SRCELEMENTPAST]], ptr noundef align 4 [[AGG_TMP]])
# |                 ^
# | <stdin>:775:80: note: scanning from here
# |  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp)
# |                                                                                ^
# | <stdin>:775:80: note: with "OMP_ARRAYCPY_DESTELEMENTPAST" equal to "%omp.arraycpy.destElementPast"
# |  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp)
# |                                                                                ^
# | <stdin>:775:80: note: with "OMP_ARRAYCPY_SRCELEMENTPAST" equal to "%omp.arraycpy.srcElementPast"
# |  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp)
# |                                                                                ^
# | <stdin>:775:80: note: with "AGG_TMP" equal to "%agg.tmp"
# |  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp)
# |                                                                                ^
# | <stdin>:786:2: note: possible intended match here
# |  call void @_ZN1SIiEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %var5, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr nofree noundef align 4 dereferenceable(8) %agg.tmp6)
# |  ^
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp:882:17: error: CHECK1-SAME: expected string not found in input
# | // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[S:%.*]], ptr noundef align 4 [[T:%.*]]) unnamed_addr #[[ATTR1]] comdat {
# |                 ^
# | <stdin>:878:46: note: scanning from here
# | define linkonce_odr void @_ZN1SIiEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | <stdin>:878:46: note: with "ATTR1" equal to "1"
# | define linkonce_odr void @_ZN1SIiEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | <stdin>:878:46: note: pattern attempts to capture variables: "S", "T", "THIS"
# | define linkonce_odr void @_ZN1SIiEC1ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp:935:17: error: CHECK1-SAME: expected string not found in input
# | // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[S:%.*]], ptr noundef align 4 [[T:%.*]]) unnamed_addr #[[ATTR1]] comdat {
# |                 ^
# | <stdin>:931:46: note: scanning from here
# | define linkonce_odr void @_ZN1SIiEC2ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | <stdin>:931:46: note: with "ATTR1" equal to "1"
# | define linkonce_odr void @_ZN1SIiEC2ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | <stdin>:931:46: note: pattern attempts to capture variables: "S", "T", "THIS"
# | define linkonce_odr void @_ZN1SIiEC2ERKS0_2St(ptr noundef nonnull align 4 dereferenceable(4) %this, ptr noundef nonnull align 4 dereferenceable(4) %s, ptr nofree noundef align 4 dereferenceable(8) %t) unnamed_addr #1 comdat {
# |                                              ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\OpenMP\target_teams_distribute_simd_firstprivate_codegen.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |           363:  br i1 %omp.arraycpy.isempty, label %omp.arraycpy.done3, label %omp.arraycpy.body 
# |           364:  
# |           365: omp.arraycpy.body: ; preds = %omp.arraycpy.body, %entry 
# |           366:  %omp.arraycpy.srcElementPast = phi ptr [ %1, %entry ], [ %omp.arraycpy.src.element, %omp.arraycpy.body ] 
# |           367:  %omp.arraycpy.destElementPast = phi ptr [ %array.begin, %entry ], [ %omp.arraycpy.dest.element, %omp.arraycpy.body ] 
# |           368:  call void @_ZN2StC1Ev(ptr noundef nonnull align 4 dereferenceable(8) %agg.tmp) 
# | next:423'0                                                                                   {   search range start (exclusive)
# | next:423'1                                                                                       error: no match found in search range
# | next:423'2                                                                                       with "OMP_ARRAYCPY_DESTELEMENTPAST" equal to "%omp.arraycpy.destElementPast"
# | next:423'3                                                                                       with "OMP_ARRAYCPY_SRCELEMENTPAST" equal to "%omp.arraycpy.srcElementPast"
# | next:423'4                                                                                       with "AGG_TMP" eq
# | ...
# `---data was truncated (10240/27456) (change limit with -D output_limit=N)
# 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/213347


More information about the cfe-commits mailing list