[llvm-branch-commits] [clang] [HLSL] Constant buffers codegen (PR #124886)

2025-02-07 Thread Damyan Pepper via llvm-branch-commits


@@ -5032,6 +5032,11 @@ class HLSLBufferDecl final : public NamedDecl, public 
DeclContext {
   SourceLocation KwLoc;
   /// IsCBuffer - Whether the buffer is a cbuffer (and not a tbuffer).
   bool IsCBuffer;
+  /// HasValidPackoffset - Whether the buffer has valid packoffset annotations
+  //   on all declarations
+  bool HasPackoffset;

damyanp wrote:

I was looking around here because I was confused about why a validity check was 
calling `setHasPackoffset(IsValid)`.  The name in the comment - 
`HasValidPackoffset` - would not have confused me!

https://github.com/llvm/llvm-project/pull/124886
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [HLSL] Constant buffers codegen (PR #124886)

2025-02-07 Thread Damyan Pepper via llvm-branch-commits


@@ -0,0 +1,199 @@
+// RUN: %clang_cc1 -finclude-default-header -triple 
dxil-pc-shadermodel6.3-compute \
+// RUN:   -fnative-half-type -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s
+
+// CHECK: %struct.__cblayout_CBScalars = type <{ float, double, half, i64, 
i32, i16, i32, i64 }>
+// CHECK: %struct.__cblayout_CBVectors = type <{ <3 x float>, <3 x double>, <2 
x half>, <3 x i64>, <4 x i32>, <3 x i16>, <3 x i64> }>
+// CHECK: %struct.__cblayout_CBArrays = type <{ [3 x float], [2 x <3 x 
double>], [2 x [2 x half]], [3 x i64], [2 x [3 x [4 x <4 x i32>]]], [1 x i16], 
[2 x i64], [4 x i32] }>
+// CHECK: %struct.__cblayout_CBStructs = type { %struct.A, %struct.B, 
%struct.C, [5 x %struct.A], %struct.__cblayout_D, half, %struct.B, <3 x i16> }
+// CHECK: %struct.A = type { <2 x float> }
+// CHECK: %struct.C = type { i32, %struct.A }
+// CHECK: %struct.__cblayout_D = type { [2 x [3 x %struct.B]] }
+// CHECK: %struct.B = type { %struct.A, <3 x i16> }
+
+cbuffer CBScalars : register(b1, space5) {
+  float a1;
+  double a2;
+  float16_t a3;
+  uint64_t a4;
+  int a5;
+  uint16_t a6;
+  bool a7;
+  int64_t a8;
+}
+
+// CHECK: @CBScalars.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBScalars)
+// CHECK: @a1 = external addrspace(2) global float, align 4
+// CHECK: @a2 = external addrspace(2) global double, align 8
+// CHECK: @a3 = external addrspace(2) global half, align 2
+// CHECK: @a4 = external addrspace(2) global i64, align 8
+// CHECK: @a5 = external addrspace(2) global i32, align 4
+// CHECK: @a6 = external addrspace(2) global i16, align 2
+// CHECK: @a7 = external addrspace(2) global i32, align 4
+// CHECK: @a8 = external addrspace(2) global i64, align 8
+
+cbuffer CBVectors {
+  float3 b1;
+  double3 b2;
+  float16_t2 b3;
+  uint64_t3 b4;
+  int4 b5;
+  uint16_t3 b6;
+  int64_t3 b7;
+  // FIXME: add s bool vectors after llvm-project/llvm#91639 is added
+}
+
+// CHECK: @CBVectors.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBVectors)
+// CHECK: @b1 = external addrspace(2) global <3 x float>, align 16
+// CHECK: @b2 = external addrspace(2) global <3 x double>, align 32
+// CHECK: @b3 = external addrspace(2) global <2 x half>, align 4
+// CHECK: @b4 = external addrspace(2) global <3 x i64>, align 32
+// CHECK: @b5 = external addrspace(2) global <4 x i32>, align 16
+// CHECK: @b6 = external addrspace(2) global <3 x i16>, align 8
+// CHECK: @b7 = external addrspace(2) global <3 x i64>, align 32
+
+cbuffer CBArrays : register(b2) {
+  float c1[3];
+  double3 c2[2];
+  float16_t c3[2][2];
+  uint64_t c4[3];
+  int4 c5[2][3][4];
+  uint16_t c6[1];
+  int64_t c7[2];
+  bool c8[4];
+}
+
+// CHECK: @CBArrays.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBArrays)
+// CHECK: @c1 = external addrspace(2) global [3 x float], align 4
+// CHECK: @c2 = external addrspace(2) global [2 x <3 x double>], align 32
+// CHECK: @c3 = external addrspace(2) global [2 x [2 x half]], align 2
+// CHECK: @c4 = external addrspace(2) global [3 x i64], align 8
+// CHECK: @c5 = external addrspace(2) global [2 x [3 x [4 x <4 x i32>]]], 
align 16
+// CHECK: @c6 = external addrspace(2) global [1 x i16], align 2
+// CHECK: @c7 = external addrspace(2) global [2 x i64], align 8
+// CHECK: @c8 = external addrspace(2) global [4 x i32], align 4
+
+struct Empty {};
+
+struct A {
+  float2 f1;
+};
+
+struct B : A {
+  uint16_t3 f2;
+};
+
+struct C {
+  int i;
+  A f3;
+};
+
+struct D {
+  B array_of_B[2][3];
+  Empty es;
+};
+
+// CHECK: @CBStructs.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBStructs)
+// CHECK: @a = external addrspace(2) global %struct.A, align 8
+// CHECK: @b = external addrspace(2) global %struct.B, align 8
+// CHECK: @c = external addrspace(2) global %struct.C, align 8
+// CHECK: @array_of_A = external addrspace(2) global [5 x %struct.A], align 8
+// CHECK: @d = external addrspace(2) global %struct.__cblayout_D, align 8
+// CHECK: @e = external addrspace(2) global half, align 2
+
+cbuffer CBStructs {
+  A a;
+  B b;
+  C c;
+  A array_of_A[5];
+  D d;
+  half e;
+  B f;
+  uint16_t3 g;
+};
+
+struct Test {
+float a, b;
+};
+
+// CHECK: @CBMix.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBMix)
+// CHECK: @test = external addrspace(2) global [2 x %struct.Test], align 4
+// CHECK: @f1 = external addrspace(2) global float, align 4
+// CHECK: @f2 = external addrspace(2) global [3 x [2 x <2 x float>]], align 8
+// CHECK: @f3 = external addrspace(2) global float, align 4
+// CHECK: @s = external addrspace(2) global %struct.anon, align 4
+// CHECK: @dd = external addrspace(2) global double, align 8
+// CHECK: @f4 = external addrspace(2) global float, align 4
+// CHECK: @dv = external addrspace(2) global <1 x double>, align 8
+// CHECK: @uv = external addrspace(2) global i16, align 2
+
+cbuffer CBMix {
+Test test[2];
+float f1;
+float2 f2[3][2];
+float f3;
+struct { float c; } s;
+double dd;
+  

[llvm-branch-commits] [clang] [HLSL] Constant buffers codegen (PR #124886)

2025-02-07 Thread Damyan Pepper via llvm-branch-commits


@@ -0,0 +1,199 @@
+// RUN: %clang_cc1 -finclude-default-header -triple 
dxil-pc-shadermodel6.3-compute \
+// RUN:   -fnative-half-type -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s
+
+// CHECK: %struct.__cblayout_CBScalars = type <{ float, double, half, i64, 
i32, i16, i32, i64 }>
+// CHECK: %struct.__cblayout_CBVectors = type <{ <3 x float>, <3 x double>, <2 
x half>, <3 x i64>, <4 x i32>, <3 x i16>, <3 x i64> }>
+// CHECK: %struct.__cblayout_CBArrays = type <{ [3 x float], [2 x <3 x 
double>], [2 x [2 x half]], [3 x i64], [2 x [3 x [4 x <4 x i32>]]], [1 x i16], 
[2 x i64], [4 x i32] }>
+// CHECK: %struct.__cblayout_CBStructs = type { %struct.A, %struct.B, 
%struct.C, [5 x %struct.A], %struct.__cblayout_D, half, %struct.B, <3 x i16> }
+// CHECK: %struct.A = type { <2 x float> }
+// CHECK: %struct.C = type { i32, %struct.A }
+// CHECK: %struct.__cblayout_D = type { [2 x [3 x %struct.B]] }
+// CHECK: %struct.B = type { %struct.A, <3 x i16> }
+
+cbuffer CBScalars : register(b1, space5) {
+  float a1;
+  double a2;
+  float16_t a3;
+  uint64_t a4;
+  int a5;
+  uint16_t a6;
+  bool a7;
+  int64_t a8;
+}
+
+// CHECK: @CBScalars.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBScalars)
+// CHECK: @a1 = external addrspace(2) global float, align 4
+// CHECK: @a2 = external addrspace(2) global double, align 8
+// CHECK: @a3 = external addrspace(2) global half, align 2
+// CHECK: @a4 = external addrspace(2) global i64, align 8
+// CHECK: @a5 = external addrspace(2) global i32, align 4
+// CHECK: @a6 = external addrspace(2) global i16, align 2
+// CHECK: @a7 = external addrspace(2) global i32, align 4
+// CHECK: @a8 = external addrspace(2) global i64, align 8
+
+cbuffer CBVectors {
+  float3 b1;
+  double3 b2;
+  float16_t2 b3;
+  uint64_t3 b4;
+  int4 b5;
+  uint16_t3 b6;
+  int64_t3 b7;
+  // FIXME: add s bool vectors after llvm-project/llvm#91639 is added
+}
+
+// CHECK: @CBVectors.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBVectors)
+// CHECK: @b1 = external addrspace(2) global <3 x float>, align 16
+// CHECK: @b2 = external addrspace(2) global <3 x double>, align 32
+// CHECK: @b3 = external addrspace(2) global <2 x half>, align 4
+// CHECK: @b4 = external addrspace(2) global <3 x i64>, align 32
+// CHECK: @b5 = external addrspace(2) global <4 x i32>, align 16
+// CHECK: @b6 = external addrspace(2) global <3 x i16>, align 8
+// CHECK: @b7 = external addrspace(2) global <3 x i64>, align 32
+
+cbuffer CBArrays : register(b2) {
+  float c1[3];
+  double3 c2[2];
+  float16_t c3[2][2];
+  uint64_t c4[3];
+  int4 c5[2][3][4];
+  uint16_t c6[1];
+  int64_t c7[2];
+  bool c8[4];
+}
+
+// CHECK: @CBArrays.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBArrays)
+// CHECK: @c1 = external addrspace(2) global [3 x float], align 4
+// CHECK: @c2 = external addrspace(2) global [2 x <3 x double>], align 32
+// CHECK: @c3 = external addrspace(2) global [2 x [2 x half]], align 2
+// CHECK: @c4 = external addrspace(2) global [3 x i64], align 8
+// CHECK: @c5 = external addrspace(2) global [2 x [3 x [4 x <4 x i32>]]], 
align 16
+// CHECK: @c6 = external addrspace(2) global [1 x i16], align 2
+// CHECK: @c7 = external addrspace(2) global [2 x i64], align 8
+// CHECK: @c8 = external addrspace(2) global [4 x i32], align 4
+
+struct Empty {};
+
+struct A {
+  float2 f1;
+};
+
+struct B : A {
+  uint16_t3 f2;
+};
+
+struct C {
+  int i;
+  A f3;
+};
+
+struct D {
+  B array_of_B[2][3];
+  Empty es;
+};
+
+// CHECK: @CBStructs.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBStructs)
+// CHECK: @a = external addrspace(2) global %struct.A, align 8
+// CHECK: @b = external addrspace(2) global %struct.B, align 8
+// CHECK: @c = external addrspace(2) global %struct.C, align 8
+// CHECK: @array_of_A = external addrspace(2) global [5 x %struct.A], align 8
+// CHECK: @d = external addrspace(2) global %struct.__cblayout_D, align 8
+// CHECK: @e = external addrspace(2) global half, align 2
+
+cbuffer CBStructs {
+  A a;
+  B b;
+  C c;
+  A array_of_A[5];
+  D d;
+  half e;
+  B f;
+  uint16_t3 g;
+};
+
+struct Test {
+float a, b;
+};
+
+// CHECK: @CBMix.cb = external constant target("dx.CBuffer", 
%struct.__cblayout_CBMix)
+// CHECK: @test = external addrspace(2) global [2 x %struct.Test], align 4
+// CHECK: @f1 = external addrspace(2) global float, align 4
+// CHECK: @f2 = external addrspace(2) global [3 x [2 x <2 x float>]], align 8
+// CHECK: @f3 = external addrspace(2) global float, align 4
+// CHECK: @s = external addrspace(2) global %struct.anon, align 4
+// CHECK: @dd = external addrspace(2) global double, align 8
+// CHECK: @f4 = external addrspace(2) global float, align 4
+// CHECK: @dv = external addrspace(2) global <1 x double>, align 8
+// CHECK: @uv = external addrspace(2) global i16, align 2
+
+cbuffer CBMix {
+Test test[2];
+float f1;
+float2 f2[3][2];
+float f3;
+struct { float c; } s;
+double dd;
+  

[llvm-branch-commits] [clang] [HLSL] Constant buffers codegen (PR #124886)

2025-02-07 Thread Damyan Pepper via llvm-branch-commits


@@ -257,8 +258,10 @@ static void validatePackoffset(Sema &S, HLSLBufferDecl 
*BufDecl) {
   VarDecl *NextVar = PackOffsetVec[i + 1].first;
   S.Diag(NextVar->getLocation(), diag::err_hlsl_packoffset_overlap)
   << NextVar << Var;
+  IsValid = false;
 }
   }
+  BufDecl->setHasPackoffset(IsValid);

damyanp wrote:

What is this for?  If I change this to `BufDecl->setHasPackoffset(true)` then 
the tests still pass.

https://github.com/llvm/llvm-project/pull/124886
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libclc] e2426cd - [libclc] Allow default path when looking for llvm-spirv (#126071)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2025-02-07T14:50:35-08:00
New Revision: e2426cd9e9b47a771f2aaaef8c48f8dbea8b7d49

URL: 
https://github.com/llvm/llvm-project/commit/e2426cd9e9b47a771f2aaaef8c48f8dbea8b7d49
DIFF: 
https://github.com/llvm/llvm-project/commit/e2426cd9e9b47a771f2aaaef8c48f8dbea8b7d49.diff

LOG: [libclc] Allow default path when looking for llvm-spirv (#126071)

This is an external tool, so I don't think there is an expectation that
it has to be in the LLVM tools bindir. It may also be in the default
system bindir (which is not necessarily the same).

(cherry picked from commit 26ecddb05d13c101ccd840a6710eb5f8b82de841)

Added: 


Modified: 
libclc/CMakeLists.txt

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 2c2c7f16e29442f..43e213b385f5dd6 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -114,7 +114,7 @@ endforeach()
 if( TARGET llvm-spirv )
   get_host_tool_path( llvm-spirv LLVM_SPIRV llvm-spirv_exe llvm-spirv_target )
 else()
-  find_program( LLVM_SPIRV llvm-spirv PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
+  find_program( LLVM_SPIRV llvm-spirv HINTS ${LLVM_TOOLS_BINARY_DIR} )
   set( llvm-spirv_exe "${LLVM_SPIRV}" )
   set( llvm-spirv_target )
 endif()



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: workflows/premerge: Move concurrency definition to workflow level (#126308) (PR #126310)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/126310

>From 3c011c65f618a058b0be483223f4158bb269deea Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 7 Feb 2025 13:09:58 -0800
Subject: [PATCH] workflows/premerge: Move concurrency definition to workflow
 level (#126308)

Prior workflow runs were not being cancelled when the pull request was
closed, and I think this was why. Also, there is no advantage to having
the definitions at the job level.

(cherry picked from commit 6e5988863177e1d53e7a7abb7a3db2b85376f0f5)
---
 .github/workflows/premerge.yaml | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 45e6bb763a0efae..9b6a1236823d7ed 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -19,15 +19,16 @@ on:
   - 'main'
   - 'release/**'
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || 
github.sha }}
+  cancel-in-progress: true
+
 jobs:
   premerge-checks-linux:
 if: >-
 false && github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
 runs-on: llvm-premerge-linux-runners
-concurrency:
-  group: ${{ github.workflow }}-linux-${{ github.event.pull_request.number 
|| github.sha }}
-  cancel-in-progress: true
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@v4
@@ -86,9 +87,6 @@ jobs:
 false && github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
 runs-on: llvm-premerge-windows-runners
-concurrency:
-  group: ${{ github.workflow }}-windows-${{ 
github.event.pull_request.number || github.sha }}
-  cancel-in-progress: true
 defaults:
   run:
 shell: bash
@@ -146,9 +144,6 @@ jobs:
 
   permerge-check-macos:
 runs-on: macos-14
-concurrency:
-  group: ${{ github.workflow }}-macos-${{ github.event.pull_request.number 
|| github.sha }}
-  cancel-in-progress: true
 if: >-
   github.repository_owner == 'llvm' &&
   (startswith(github.ref_name, 'release/') ||

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [X86] Do not combine LRINT and TRUNC (#125848) (PR #125995)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/125995

>From 454d7c10f1869e0c109c733b2385b8c16c6a7756 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Thu, 6 Feb 2025 10:58:37 +0800
Subject: [PATCH] [X86] Do not combine LRINT and TRUNC (#125848)

Per to discussions in #125324, most participants are opposed to this
optimization. So remove the combination to address the concerns.

Fixes #125324

(cherry picked from commit 8c222c122f1a8edb1be96e482511ad547f7db7b3)
---
 llvm/lib/Target/X86/X86ISelLowering.cpp |  5 -
 llvm/test/CodeGen/X86/lrint-conv-i64.ll | 18 ++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 8f904209d8a3ad9..627cef9ead7ffac 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -53899,11 +53899,6 @@ static SDValue combineTruncate(SDNode *N, SelectionDAG 
&DAG,
   return DAG.getNode(X86ISD::MMX_MOVD2W, DL, MVT::i32, BCSrc);
   }
 
-  // Try to combine (trunc (vNi64 (lrint x))) to (vNi32 (lrint x)).
-  if (Src.getOpcode() == ISD::LRINT && VT.getScalarType() == MVT::i32 &&
-  Src.hasOneUse())
-return DAG.getNode(ISD::LRINT, DL, VT, Src.getOperand(0));
-
   return SDValue();
 }
 
diff --git a/llvm/test/CodeGen/X86/lrint-conv-i64.ll 
b/llvm/test/CodeGen/X86/lrint-conv-i64.ll
index 01b0af2f807f200..38fa09085e1898d 100644
--- a/llvm/test/CodeGen/X86/lrint-conv-i64.ll
+++ b/llvm/test/CodeGen/X86/lrint-conv-i64.ll
@@ -45,6 +45,24 @@ entry:
   ret i64 %0
 }
 
+define i32 @PR125324(float %x) {
+; SSE-LABEL: PR125324:
+; SSE:   # %bb.0: # %entry
+; SSE-NEXT:cvtss2si %xmm0, %rax
+; SSE-NEXT:# kill: def $eax killed $eax killed $rax
+; SSE-NEXT:retq
+;
+; AVX-LABEL: PR125324:
+; AVX:   # %bb.0: # %entry
+; AVX-NEXT:vcvtss2si %xmm0, %rax
+; AVX-NEXT:# kill: def $eax killed $eax killed $rax
+; AVX-NEXT:retq
+entry:
+  %0 = tail call i64 @llvm.lrint.i64.f32(float %x)
+  %1 = trunc i64 %0 to i32
+  ret i32 %1
+}
+
 declare i64 @llvm.lrint.i64.f32(float) nounwind readnone
 declare i64 @llvm.lrint.i64.f64(double) nounwind readnone
 declare i64 @llvm.lrint.i64.f80(x86_fp80) nounwind readnone

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [DXIL] Add support for root signature flag element in DXContainer (PR #123147)

2025-02-07 Thread via llvm-branch-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/123147

>From aabdfe7d6c6b6e27e9c2150c10199baa6638b6df Mon Sep 17 00:00:00 2001
From: joaosaffran 
Date: Wed, 15 Jan 2025 17:30:00 +
Subject: [PATCH 01/21] adding metadata extraction

---
 .../llvm/Analysis/DXILMetadataAnalysis.h  |  3 +
 llvm/lib/Analysis/DXILMetadataAnalysis.cpp| 89 +++
 .../lib/Target/DirectX/DXContainerGlobals.cpp | 24 +
 3 files changed, 116 insertions(+)

diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h 
b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index cb535ac14f1c613..f420244ba111a45 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -11,9 +11,11 @@
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/MC/DXContainerRootSignature.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/Triple.h"
+#include 
 
 namespace llvm {
 
@@ -37,6 +39,7 @@ struct ModuleMetadataInfo {
   Triple::EnvironmentType ShaderProfile{Triple::UnknownEnvironment};
   VersionTuple ValidatorVersion{};
   SmallVector EntryPropertyVec{};
+  std::optional RootSignatureDesc;
   void print(raw_ostream &OS) const;
 };
 
diff --git a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp 
b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
index a7f666a3f8b48f2..388e3853008eaec 100644
--- a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
+++ b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
@@ -15,12 +15,91 @@
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/MC/DXContainerRootSignature.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
 
 #define DEBUG_TYPE "dxil-metadata-analysis"
 
 using namespace llvm;
 using namespace dxil;
+using namespace llvm::mcdxbc;
+
+static bool parseRootFlags(MDNode *RootFlagNode, RootSignatureDesc *Desc) {
+
+  assert(RootFlagNode->getNumOperands() == 2 &&
+ "Invalid format for RootFlag Element");
+  auto *Flag = mdconst::extract(RootFlagNode->getOperand(1));
+  auto Value = (RootSignatureFlags)Flag->getZExtValue();
+
+  if ((Value & ~RootSignatureFlags::ValidFlags) != RootSignatureFlags::None)
+return true;
+
+  Desc->Flags = Value;
+  return false;
+}
+
+static bool parseRootSignatureElement(MDNode *Element,
+  RootSignatureDesc *Desc) {
+  MDString *ElementText = cast(Element->getOperand(0));
+
+  assert(ElementText != nullptr && "First preoperty of element is not ");
+
+  RootSignatureElementKind ElementKind =
+  StringSwitch(ElementText->getString())
+  .Case("RootFlags", RootSignatureElementKind::RootFlags)
+  .Case("RootConstants", RootSignatureElementKind::RootConstants)
+  .Case("RootCBV", RootSignatureElementKind::RootDescriptor)
+  .Case("RootSRV", RootSignatureElementKind::RootDescriptor)
+  .Case("RootUAV", RootSignatureElementKind::RootDescriptor)
+  .Case("Sampler", RootSignatureElementKind::RootDescriptor)
+  .Case("DescriptorTable", RootSignatureElementKind::DescriptorTable)
+  .Case("StaticSampler", RootSignatureElementKind::StaticSampler)
+  .Default(RootSignatureElementKind::None);
+
+  switch (ElementKind) {
+
+  case RootSignatureElementKind::RootFlags: {
+return parseRootFlags(Element, Desc);
+break;
+  }
+
+  case RootSignatureElementKind::RootConstants:
+  case RootSignatureElementKind::RootDescriptor:
+  case RootSignatureElementKind::DescriptorTable:
+  case RootSignatureElementKind::StaticSampler:
+  case RootSignatureElementKind::None:
+llvm_unreachable("Not Implemented yet");
+break;
+  }
+
+  return true;
+}
+
+bool parseRootSignature(RootSignatureDesc *Desc, int32_t Version,
+NamedMDNode *Root) {
+  Desc->Version = Version;
+  bool HasError = false;
+
+  for (unsigned int Sid = 0; Sid < Root->getNumOperands(); Sid++) {
+// This should be an if, for error handling
+MDNode *Node = cast(Root->getOperand(Sid));
+
+// Not sure what use this for...
+Metadata *Func = Node->getOperand(0).get();
+
+// This should be an if, for error handling
+MDNode *Elements = cast(Node->getOperand(1).get());
+
+for (unsigned int Eid = 0; Eid < Elements->getNumOperands(); Eid++) {
+  MDNode *Element = cast(Elements->getOperand(Eid));
+
+  HasError = HasError || parseRootSignatureElement(Element, Desc);
+}
+  }
+  return HasError;
+}
 
 static ModuleMetadataInfo collectMetadataInfo(Module &M) {
   ModuleMetadataInfo MMDAI;
@@ -28,6 +107,7 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
   MMDAI.DXILVersion = TT.getDXILVersion();
   MMDAI.ShaderModelVersion = TT.getOSVersion();
   MMDAI.ShaderProfile = TT.getEnvironment();
+
   NamedMDNode *ValidatorVerNode = M.getNamedMetadata("dx.valver");
   if (ValidatorVerNode) {

[llvm-branch-commits] [llvm] release/20.x: [TableGen] Don't use inline storage for ReferenceLocs (NFC) (#125231) (PR #125287)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/125287

>From 14c5784ee4c03c5a7aa6f483486985d2c24a2407 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Fri, 31 Jan 2025 17:37:17 +0100
Subject: [PATCH 1/2] [TableGen] Reduce size of MatchTableRecord (NFC)
 (#125221)

MatchTableRecord stores a 64-bit RawValue. However, this field is only
needed by a small part of the code (jump table generation).

Create a separate RecordAndValue structure that is used in just the
necessary places.

Based on massif, this reduces memory usage on RISCVGenGlobalISel.inc by
about 100MB (to 2.15GB).

(cherry picked from commit e2301d674976b84ba505065a9702f3376e05bc43)
---
 .../GlobalISel/GlobalISelMatchTable.cpp   | 46 +++
 .../Common/GlobalISel/GlobalISelMatchTable.h  | 42 -
 2 files changed, 38 insertions(+), 50 deletions(-)

diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp 
b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
index f0cd98dd2dee084..8564bf8d2d91ba5 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
@@ -227,26 +227,12 @@ MatchTableRecord MatchTable::NamedValue(unsigned NumBytes,
   MatchTableRecord::MTRF_CommaFollows);
 }
 
-MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef 
NamedValue,
-int64_t RawValue) {
-  return MatchTableRecord(std::nullopt, NamedValue, NumBytes,
-  MatchTableRecord::MTRF_CommaFollows, RawValue);
-}
-
 MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
 StringRef NamedValue) {
   return MatchTableRecord(std::nullopt, (Namespace + "::" + NamedValue).str(),
   NumBytes, MatchTableRecord::MTRF_CommaFollows);
 }
 
-MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
-StringRef NamedValue,
-int64_t RawValue) {
-  return MatchTableRecord(std::nullopt, (Namespace + "::" + NamedValue).str(),
-  NumBytes, MatchTableRecord::MTRF_CommaFollows,
-  RawValue);
-}
-
 MatchTableRecord MatchTable::IntValue(unsigned NumBytes, int64_t IntValue) {
   assert(isUIntN(NumBytes * 8, IntValue) || isIntN(NumBytes * 8, IntValue));
   auto Str = llvm::to_string(IntValue);
@@ -651,8 +637,8 @@ void SwitchMatcher::emit(MatchTable &Table) {
 [&Table]() { return Table.allocateLabelID(); });
   const unsigned Default = Table.allocateLabelID();
 
-  const int64_t LowerBound = Values.begin()->getRawValue();
-  const int64_t UpperBound = Values.rbegin()->getRawValue() + 1;
+  const int64_t LowerBound = Values.begin()->RawValue;
+  const int64_t UpperBound = Values.rbegin()->RawValue + 1;
 
   emitPredicateSpecificOpcodes(*Condition, Table);
 
@@ -664,10 +650,11 @@ void SwitchMatcher::emit(MatchTable &Table) {
   auto VI = Values.begin();
   for (unsigned I = 0, E = Values.size(); I < E; ++I) {
 auto V = *VI++;
-while (J++ < V.getRawValue())
+while (J++ < V.RawValue)
   Table << MatchTable::IntValue(4, 0);
-V.turnIntoComment();
-Table << MatchTable::LineBreak << V << MatchTable::JumpTarget(LabelIDs[I]);
+V.Record.turnIntoComment();
+Table << MatchTable::LineBreak << V.Record
+  << MatchTable::JumpTarget(LabelIDs[I]);
   }
   Table << MatchTable::LineBreak;
 
@@ -1145,11 +1132,11 @@ void 
SameOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
 
 std::map LLTOperandMatcher::TypeIDValues;
 
-MatchTableRecord LLTOperandMatcher::getValue() const {
+RecordAndValue LLTOperandMatcher::getValue() const {
   const auto VI = TypeIDValues.find(Ty);
   if (VI == TypeIDValues.end())
 return MatchTable::NamedValue(1, getTy().getCxxEnumValue());
-  return MatchTable::NamedValue(1, getTy().getCxxEnumValue(), VI->second);
+  return {MatchTable::NamedValue(1, getTy().getCxxEnumValue()), VI->second};
 }
 
 bool LLTOperandMatcher::hasValue() const {
@@ -1167,7 +1154,8 @@ void LLTOperandMatcher::emitPredicateOpcodes(MatchTable 
&Table,
   << MatchTable::ULEB128Value(InsnVarID);
   }
   Table << MatchTable::Comment("Op") << MatchTable::ULEB128Value(OpIdx)
-<< MatchTable::Comment("Type") << getValue() << MatchTable::LineBreak;
+<< MatchTable::Comment("Type") << getValue().Record
+<< MatchTable::LineBreak;
 }
 
 //===- PointerToAnyOperandMatcher 
-===//
@@ -1411,12 +1399,12 @@ Error OperandMatcher::addTypeCheckPredicate(const 
TypeSetByHwMode &VTy,
 DenseMap
 InstructionOpcodeMatcher::OpcodeValues;
 
-MatchTableRecord
+RecordAndValue
 InstructionOpcodeMatcher::getInstValue(const CodeGenInstruction *I) const {
   const auto VI = OpcodeValues.find(I);
   if (VI != Opco

[llvm-branch-commits] [llvm] 14c5784 - [TableGen] Reduce size of MatchTableRecord (NFC) (#125221)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2025-02-07T12:03:05-08:00
New Revision: 14c5784ee4c03c5a7aa6f483486985d2c24a2407

URL: 
https://github.com/llvm/llvm-project/commit/14c5784ee4c03c5a7aa6f483486985d2c24a2407
DIFF: 
https://github.com/llvm/llvm-project/commit/14c5784ee4c03c5a7aa6f483486985d2c24a2407.diff

LOG: [TableGen] Reduce size of MatchTableRecord (NFC) (#125221)

MatchTableRecord stores a 64-bit RawValue. However, this field is only
needed by a small part of the code (jump table generation).

Create a separate RecordAndValue structure that is used in just the
necessary places.

Based on massif, this reduces memory usage on RISCVGenGlobalISel.inc by
about 100MB (to 2.15GB).

(cherry picked from commit e2301d674976b84ba505065a9702f3376e05bc43)

Added: 


Modified: 
llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h

Removed: 




diff  --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp 
b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
index f0cd98dd2dee084..8564bf8d2d91ba5 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
@@ -227,26 +227,12 @@ MatchTableRecord MatchTable::NamedValue(unsigned NumBytes,
   MatchTableRecord::MTRF_CommaFollows);
 }
 
-MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef 
NamedValue,
-int64_t RawValue) {
-  return MatchTableRecord(std::nullopt, NamedValue, NumBytes,
-  MatchTableRecord::MTRF_CommaFollows, RawValue);
-}
-
 MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
 StringRef NamedValue) {
   return MatchTableRecord(std::nullopt, (Namespace + "::" + NamedValue).str(),
   NumBytes, MatchTableRecord::MTRF_CommaFollows);
 }
 
-MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
-StringRef NamedValue,
-int64_t RawValue) {
-  return MatchTableRecord(std::nullopt, (Namespace + "::" + NamedValue).str(),
-  NumBytes, MatchTableRecord::MTRF_CommaFollows,
-  RawValue);
-}
-
 MatchTableRecord MatchTable::IntValue(unsigned NumBytes, int64_t IntValue) {
   assert(isUIntN(NumBytes * 8, IntValue) || isIntN(NumBytes * 8, IntValue));
   auto Str = llvm::to_string(IntValue);
@@ -651,8 +637,8 @@ void SwitchMatcher::emit(MatchTable &Table) {
 [&Table]() { return Table.allocateLabelID(); });
   const unsigned Default = Table.allocateLabelID();
 
-  const int64_t LowerBound = Values.begin()->getRawValue();
-  const int64_t UpperBound = Values.rbegin()->getRawValue() + 1;
+  const int64_t LowerBound = Values.begin()->RawValue;
+  const int64_t UpperBound = Values.rbegin()->RawValue + 1;
 
   emitPredicateSpecificOpcodes(*Condition, Table);
 
@@ -664,10 +650,11 @@ void SwitchMatcher::emit(MatchTable &Table) {
   auto VI = Values.begin();
   for (unsigned I = 0, E = Values.size(); I < E; ++I) {
 auto V = *VI++;
-while (J++ < V.getRawValue())
+while (J++ < V.RawValue)
   Table << MatchTable::IntValue(4, 0);
-V.turnIntoComment();
-Table << MatchTable::LineBreak << V << MatchTable::JumpTarget(LabelIDs[I]);
+V.Record.turnIntoComment();
+Table << MatchTable::LineBreak << V.Record
+  << MatchTable::JumpTarget(LabelIDs[I]);
   }
   Table << MatchTable::LineBreak;
 
@@ -1145,11 +1132,11 @@ void 
SameOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
 
 std::map LLTOperandMatcher::TypeIDValues;
 
-MatchTableRecord LLTOperandMatcher::getValue() const {
+RecordAndValue LLTOperandMatcher::getValue() const {
   const auto VI = TypeIDValues.find(Ty);
   if (VI == TypeIDValues.end())
 return MatchTable::NamedValue(1, getTy().getCxxEnumValue());
-  return MatchTable::NamedValue(1, getTy().getCxxEnumValue(), VI->second);
+  return {MatchTable::NamedValue(1, getTy().getCxxEnumValue()), VI->second};
 }
 
 bool LLTOperandMatcher::hasValue() const {
@@ -1167,7 +1154,8 @@ void LLTOperandMatcher::emitPredicateOpcodes(MatchTable 
&Table,
   << MatchTable::ULEB128Value(InsnVarID);
   }
   Table << MatchTable::Comment("Op") << MatchTable::ULEB128Value(OpIdx)
-<< MatchTable::Comment("Type") << getValue() << MatchTable::LineBreak;
+<< MatchTable::Comment("Type") << getValue().Record
+<< MatchTable::LineBreak;
 }
 
 //===- PointerToAnyOperandMatcher 
-===//
@@ -1411,12 +1399,12 @@ Error OperandMatcher::addTypeCheckPredicate(const 
TypeSetByHwMode &VTy,
 DenseMap
 InstructionOpcodeMatcher::OpcodeValues;
 
-MatchTableRecord
+RecordAndValue
 Instructio

[llvm-branch-commits] [llvm] release/20.x: [TableGen] Don't use inline storage for ReferenceLocs (NFC) (#125231) (PR #125287)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/125287
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 4d04a40 - [TableGen] Don't use inline storage for ReferenceLocs (NFC) (#125231)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2025-02-07T12:03:05-08:00
New Revision: 4d04a406a5a5e13af679018b116fc9975eb85579

URL: 
https://github.com/llvm/llvm-project/commit/4d04a406a5a5e13af679018b116fc9975eb85579
DIFF: 
https://github.com/llvm/llvm-project/commit/4d04a406a5a5e13af679018b116fc9975eb85579.diff

LOG: [TableGen] Don't use inline storage for ReferenceLocs (NFC) (#125231)

The ReferenceLocs are not enabled by default (they are used by the
tablegen lsp server), and as such always empty, but still allocate
inline storage for the SmallVector. Disabling it saves about 200MB on
RISCVGenGlobalISel.inc.

(The equivalent field in Record already disables inline storage.)

(cherry picked from commit c640f97ccf723e64ff24af225cb995c905538406)

Added: 


Modified: 
llvm/include/llvm/TableGen/Record.h

Removed: 




diff  --git a/llvm/include/llvm/TableGen/Record.h 
b/llvm/include/llvm/TableGen/Record.h
index d9930a48e80840e..e04ed3482314876 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1523,7 +1523,7 @@ class RecordVal {
   bool IsUsed = false;
 
   /// Reference locations to this record value.
-  SmallVector ReferenceLocs;
+  SmallVector ReferenceLocs;
 
 public:
   RecordVal(const Init *N, const RecTy *T, FieldKind K);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [TableGen] Don't use inline storage for ReferenceLocs (NFC) (#125231) (PR #125287)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@nikic (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/125287
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][cmake] Fix build race condition in Pass Manager tests (PR #125834)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

@nikic does this look OK?

https://github.com/llvm/llvm-project/pull/125834
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [flang] release/20.x: [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (#125998) (PR #126038)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/126038

>From 7bcfaa1c4d9ca11eabd1d80b9e3007f1640b2da1 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Thu, 6 Feb 2025 04:36:47 -0500
Subject: [PATCH] [flang][Driver] When linking with the Fortran runtime also
 link with libexecinfo (#125998)

Also link with libexecinfo on FreeBSD, NetBSD, OpenBSD and DragonFly
for the backtrace functions.

(cherry picked from commit d1de75acea0da55316cd7827563e064105868f0f)
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp |  5 +
 flang/test/Driver/linker-flags.f90 | 16 
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 2c4b082bcce4a62..4ed4dbc1a8d1bc9 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1340,6 +1340,11 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, 
const ArgList &Args,
 CmdArgs.push_back("-lFortranRuntime");
 CmdArgs.push_back("-lFortranDecimal");
 addArchSpecificRPath(TC, Args, CmdArgs);
+
+// needs libexecinfo for backtrace functions
+if (TC.getTriple().isOSFreeBSD() || TC.getTriple().isOSNetBSD() ||
+TC.getTriple().isOSOpenBSD() || TC.getTriple().isOSDragonFly())
+  CmdArgs.push_back("-lexecinfo");
   }
 
   // libomp needs libatomic for atomic operations if using libgcc
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index ac9500d7c45cecd..b998cbaa6227c35 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -5,10 +5,10 @@
 ! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
 ! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib
 ! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib
-! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
-! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
-! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
-! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 
| FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
+! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib
+! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib
+! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib
+! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 
| FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib
 ! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,HAIKU,HAIKU-F128%f128-lib
 ! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW,MINGW-F128%f128-lib
 ! RUN: %flang -### -rtlib=compiler-rt --target=aarch64-linux-gnu 
%S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,COMPILER-RT
@@ -36,6 +36,14 @@
 ! UNIX-SAME: "-lFortranRuntime" "-lFortranDecimal" "-lm"
 ! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
 
+! BSD-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! BSD-SAME: "[[object_file]]"
+! BSD-F128NONE-NOT: FortranFloat128Math
+! BSD-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" 
"--no-as-needed"
+! BSD-SAME: -lFortranRuntime
+! BSD-SAME: -lFortranDecimal
+! BSD-SAME: -lexecinfo
+
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"
 ! DARWIN-F128NONE-NOT: FortranFloat128Math

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] 7bcfaa1 - [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (#125998)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Brad Smith
Date: 2025-02-07T13:08:01-08:00
New Revision: 7bcfaa1c4d9ca11eabd1d80b9e3007f1640b2da1

URL: 
https://github.com/llvm/llvm-project/commit/7bcfaa1c4d9ca11eabd1d80b9e3007f1640b2da1
DIFF: 
https://github.com/llvm/llvm-project/commit/7bcfaa1c4d9ca11eabd1d80b9e3007f1640b2da1.diff

LOG: [flang][Driver] When linking with the Fortran runtime also link with 
libexecinfo (#125998)

Also link with libexecinfo on FreeBSD, NetBSD, OpenBSD and DragonFly
for the backtrace functions.

(cherry picked from commit d1de75acea0da55316cd7827563e064105868f0f)

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
flang/test/Driver/linker-flags.f90

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 2c4b082bcce4a62..4ed4dbc1a8d1bc9 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1340,6 +1340,11 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, 
const ArgList &Args,
 CmdArgs.push_back("-lFortranRuntime");
 CmdArgs.push_back("-lFortranDecimal");
 addArchSpecificRPath(TC, Args, CmdArgs);
+
+// needs libexecinfo for backtrace functions
+if (TC.getTriple().isOSFreeBSD() || TC.getTriple().isOSNetBSD() ||
+TC.getTriple().isOSOpenBSD() || TC.getTriple().isOSDragonFly())
+  CmdArgs.push_back("-lexecinfo");
   }
 
   // libomp needs libatomic for atomic operations if using libgcc

diff  --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index ac9500d7c45cecd..b998cbaa6227c35 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -5,10 +5,10 @@
 ! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
 ! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib
 ! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib
-! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
-! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
-! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
-! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 
| FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
+! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib
+! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib
+! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib
+! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 
| FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib
 ! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,HAIKU,HAIKU-F128%f128-lib
 ! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW,MINGW-F128%f128-lib
 ! RUN: %flang -### -rtlib=compiler-rt --target=aarch64-linux-gnu 
%S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,COMPILER-RT
@@ -36,6 +36,14 @@
 ! UNIX-SAME: "-lFortranRuntime" "-lFortranDecimal" "-lm"
 ! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
 
+! BSD-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! BSD-SAME: "[[object_file]]"
+! BSD-F128NONE-NOT: FortranFloat128Math
+! BSD-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" 
"--no-as-needed"
+! BSD-SAME: -lFortranRuntime
+! BSD-SAME: -lFortranDecimal
+! BSD-SAME: -lexecinfo
+
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"
 ! DARWIN-F128NONE-NOT: FortranFloat128Math



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [flang] release/20.x: [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (#125998) (PR #126038)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126038
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [flang] release/20.x: [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (#125998) (PR #126038)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@brad0 (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126038
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [SPARC][IAS] Add IAS flag handling for ISA levels (PR #125151)

2025-02-07 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/125151
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [SPARC][IAS] Add IAS flag handling for ISA levels (PR #125151)

2025-02-07 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay approved this pull request.

We try to support very few -Wa,... options for the integrated assembler, since 
as you can see, the number of lines increases quite a lot. if this option is so 
frequently used, i think this is ok.

https://github.com/llvm/llvm-project/pull/125151
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [SPARC][IAS] Add IAS flag handling for ISA levels (PR #125151)

2025-02-07 Thread Fangrui Song via llvm-branch-commits


@@ -2842,6 +2868,12 @@ static void 
CollectArgsForIntegratedAssembler(Compilation &C,
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back(MipsTargetFeature);
   }
+  if (!SparcTargetFeatures.empty()) {

MaskRay wrote:

`if` can be dropped

https://github.com/llvm/llvm-project/pull/125151
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [BOLT, test] Link against a shared object to test PLT (#125625) (PR #126351)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/126351

Backport a907008bcb8dcc093f8aa5c0450d92cd63473b81

Requested by: @MaskRay

>From 8d73587c26e03a5ce0c599bb8c47dae73577825f Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 5 Feb 2025 09:31:58 -0800
Subject: [PATCH] [BOLT,test] Link against a shared object to test PLT
 (#125625)

A few tests generate a statically-linked position-independent executable
with `-nostdlib -Wl,--unresolved-symbols=ignore-all -pie` (`%clang`) and
test PLT handling. (--unresolved-symbols=ignore-all suppresses undefined
symbol errors and serves as a convenience hack.)

This relies on an unguaranteed linker behavior: a statically-linked PIE
does not necessarily generate PLT entries.
While current lld generates a PLT entry, it will change to suppress the
PLT entry to simplify internal handling and improve consistency.

(The behavior has no consistency in GNU ld, some ports generated a
.dynsym entry while some don't. While most seem to generate a PLT entry
but some ports use a weird `R_*_NONE` relocation.)

(cherry picked from commit a907008bcb8dcc093f8aa5c0450d92cd63473b81)
---
 bolt/test/AArch64/exceptions-plt.cpp | 4 +++-
 bolt/test/AArch64/plt-call.test  | 4 +++-
 bolt/test/X86/callcont-fallthru.s| 4 +++-
 bolt/test/X86/cfi-instrs-reordered.s | 4 +++-
 bolt/test/X86/plt-call.test  | 4 +++-
 bolt/test/runtime/exceptions-plt.cpp | 4 +++-
 bolt/test/runtime/plt-lld.test   | 7 ---
 7 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/bolt/test/AArch64/exceptions-plt.cpp 
b/bolt/test/AArch64/exceptions-plt.cpp
index 576f0fc91a9d848..33c28406ca8d6b9 100644
--- a/bolt/test/AArch64/exceptions-plt.cpp
+++ b/bolt/test/AArch64/exceptions-plt.cpp
@@ -2,7 +2,9 @@
 
 // REQUIRES: system-linux
 
-// RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s -o %t.exe
+// RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+// Link against a DSO to ensure PLT entries.
+// RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s %t.so -o %t.exe
 // RUN: llvm-bolt %t.exe -o %t.bolt.exe --plt=all --print-only=.*main.* \
 // RUN:   --print-finalized 2>&1 | FileCheck %s
 
diff --git a/bolt/test/AArch64/plt-call.test b/bolt/test/AArch64/plt-call.test
index da307d4a6c01e6a..1fa62c4a36aafa1 100644
--- a/bolt/test/AArch64/plt-call.test
+++ b/bolt/test/AArch64/plt-call.test
@@ -1,6 +1,8 @@
 // Verify that PLTCall optimization works.
 
-RUN: %clang %cflags %p/../Inputs/plt-tailcall.c \
+RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+// Link against a DSO to ensure PLT entries.
+RUN: %clang %cflags %p/../Inputs/plt-tailcall.c %t.so \
 RUN:-o %t -Wl,-q
 RUN: llvm-bolt %t -o %t.bolt --plt=all --print-plt  --print-only=foo | 
FileCheck %s
 
diff --git a/bolt/test/X86/callcont-fallthru.s 
b/bolt/test/X86/callcont-fallthru.s
index 31a7910d7fa3f42..d76f869c971fd16 100644
--- a/bolt/test/X86/callcont-fallthru.s
+++ b/bolt/test/X86/callcont-fallthru.s
@@ -1,7 +1,9 @@
 ## Ensures that a call continuation fallthrough count is set when using
 ## pre-aggregated perf data.
 
-# RUN: %clangxx %cxxflags %s -o %t -Wl,-q -nostdlib
+# RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+## Link against a DSO to ensure PLT entries.
+# RUN: %clangxx %cxxflags %s %t.so -o %t -Wl,-q -nostdlib
 # RUN: link_fdata %s %t %t.pa1 PREAGG
 # RUN: link_fdata %s %t %t.pa2 PREAGG2
 # RUN: link_fdata %s %t %t.pa3 PREAGG3
diff --git a/bolt/test/X86/cfi-instrs-reordered.s 
b/bolt/test/X86/cfi-instrs-reordered.s
index c325aaf1ad8b18a..5173fa6c3c7d0a5 100644
--- a/bolt/test/X86/cfi-instrs-reordered.s
+++ b/bolt/test/X86/cfi-instrs-reordered.s
@@ -3,7 +3,9 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: llvm-strip --strip-unneeded %t.o
-# RUN: %clangxx %cflags %t.o -o %t.exe
+# RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+## Link against a DSO to ensure PLT entries.
+# RUN: %clangxx %cflags %t.o %t.so -o %t.exe
 # RUN: llvm-bolt %t.exe -o %t --reorder-blocks=cache --print-after-lowering \
 # RUN:   --print-only=_Z10SolveCubicPiPd 2>&1 | FileCheck %s
 #
diff --git a/bolt/test/X86/plt-call.test b/bolt/test/X86/plt-call.test
index e6ae86c179d279b..aeee3024ac17086 100644
--- a/bolt/test/X86/plt-call.test
+++ b/bolt/test/X86/plt-call.test
@@ -1,6 +1,8 @@
 // Verify that PLTCall optimization works.
 
-RUN: %clang %cflags %p/../Inputs/plt-tailcall.c \
+RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+// Link against a DSO to ensure PLT entries.
+RUN: %clang %cflags %p/../Inputs/plt-tailcall.c %t.so \
 RUN:-o %t -Wl,-q
 RUN: llvm-bolt %t -o %t.bolt --plt=all --print-plt  --print-only=foo | 
FileCheck %s
 
diff --git a/bolt/test/runtime/exceptions-plt.cpp 
b/bolt/test/runtime/exceptions-plt.cpp
index 8a75a3cb384b90a..3d8e7a5133e2c1f 100644
--- a/bolt/test/runtime/exceptions-plt.cpp
+++ b/bolt/test/runtime/exceptions-plt.cpp
@@ -2,7 +2,9 @@
 
 // REQUIRES: system-linux
 
-// RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s 

[llvm-branch-commits] [llvm] release/20.x: [BOLT, test] Link against a shared object to test PLT (#125625) (PR #126351)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/126351
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [BOLT, test] Link against a shared object to test PLT (#125625) (PR #126351)

2025-02-07 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-bolt

Author: None (llvmbot)


Changes

Backport a907008bcb8dcc093f8aa5c0450d92cd63473b81

Requested by: @MaskRay

---
Full diff: https://github.com/llvm/llvm-project/pull/126351.diff


7 Files Affected:

- (modified) bolt/test/AArch64/exceptions-plt.cpp (+3-1) 
- (modified) bolt/test/AArch64/plt-call.test (+3-1) 
- (modified) bolt/test/X86/callcont-fallthru.s (+3-1) 
- (modified) bolt/test/X86/cfi-instrs-reordered.s (+3-1) 
- (modified) bolt/test/X86/plt-call.test (+3-1) 
- (modified) bolt/test/runtime/exceptions-plt.cpp (+3-1) 
- (modified) bolt/test/runtime/plt-lld.test (+4-3) 


``diff
diff --git a/bolt/test/AArch64/exceptions-plt.cpp 
b/bolt/test/AArch64/exceptions-plt.cpp
index 576f0fc91a9d848..33c28406ca8d6b9 100644
--- a/bolt/test/AArch64/exceptions-plt.cpp
+++ b/bolt/test/AArch64/exceptions-plt.cpp
@@ -2,7 +2,9 @@
 
 // REQUIRES: system-linux
 
-// RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s -o %t.exe
+// RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+// Link against a DSO to ensure PLT entries.
+// RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s %t.so -o %t.exe
 // RUN: llvm-bolt %t.exe -o %t.bolt.exe --plt=all --print-only=.*main.* \
 // RUN:   --print-finalized 2>&1 | FileCheck %s
 
diff --git a/bolt/test/AArch64/plt-call.test b/bolt/test/AArch64/plt-call.test
index da307d4a6c01e6a..1fa62c4a36aafa1 100644
--- a/bolt/test/AArch64/plt-call.test
+++ b/bolt/test/AArch64/plt-call.test
@@ -1,6 +1,8 @@
 // Verify that PLTCall optimization works.
 
-RUN: %clang %cflags %p/../Inputs/plt-tailcall.c \
+RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+// Link against a DSO to ensure PLT entries.
+RUN: %clang %cflags %p/../Inputs/plt-tailcall.c %t.so \
 RUN:-o %t -Wl,-q
 RUN: llvm-bolt %t -o %t.bolt --plt=all --print-plt  --print-only=foo | 
FileCheck %s
 
diff --git a/bolt/test/X86/callcont-fallthru.s 
b/bolt/test/X86/callcont-fallthru.s
index 31a7910d7fa3f42..d76f869c971fd16 100644
--- a/bolt/test/X86/callcont-fallthru.s
+++ b/bolt/test/X86/callcont-fallthru.s
@@ -1,7 +1,9 @@
 ## Ensures that a call continuation fallthrough count is set when using
 ## pre-aggregated perf data.
 
-# RUN: %clangxx %cxxflags %s -o %t -Wl,-q -nostdlib
+# RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+## Link against a DSO to ensure PLT entries.
+# RUN: %clangxx %cxxflags %s %t.so -o %t -Wl,-q -nostdlib
 # RUN: link_fdata %s %t %t.pa1 PREAGG
 # RUN: link_fdata %s %t %t.pa2 PREAGG2
 # RUN: link_fdata %s %t %t.pa3 PREAGG3
diff --git a/bolt/test/X86/cfi-instrs-reordered.s 
b/bolt/test/X86/cfi-instrs-reordered.s
index c325aaf1ad8b18a..5173fa6c3c7d0a5 100644
--- a/bolt/test/X86/cfi-instrs-reordered.s
+++ b/bolt/test/X86/cfi-instrs-reordered.s
@@ -3,7 +3,9 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: llvm-strip --strip-unneeded %t.o
-# RUN: %clangxx %cflags %t.o -o %t.exe
+# RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+## Link against a DSO to ensure PLT entries.
+# RUN: %clangxx %cflags %t.o %t.so -o %t.exe
 # RUN: llvm-bolt %t.exe -o %t --reorder-blocks=cache --print-after-lowering \
 # RUN:   --print-only=_Z10SolveCubicPiPd 2>&1 | FileCheck %s
 #
diff --git a/bolt/test/X86/plt-call.test b/bolt/test/X86/plt-call.test
index e6ae86c179d279b..aeee3024ac17086 100644
--- a/bolt/test/X86/plt-call.test
+++ b/bolt/test/X86/plt-call.test
@@ -1,6 +1,8 @@
 // Verify that PLTCall optimization works.
 
-RUN: %clang %cflags %p/../Inputs/plt-tailcall.c \
+RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+// Link against a DSO to ensure PLT entries.
+RUN: %clang %cflags %p/../Inputs/plt-tailcall.c %t.so \
 RUN:-o %t -Wl,-q
 RUN: llvm-bolt %t -o %t.bolt --plt=all --print-plt  --print-only=foo | 
FileCheck %s
 
diff --git a/bolt/test/runtime/exceptions-plt.cpp 
b/bolt/test/runtime/exceptions-plt.cpp
index 8a75a3cb384b90a..3d8e7a5133e2c1f 100644
--- a/bolt/test/runtime/exceptions-plt.cpp
+++ b/bolt/test/runtime/exceptions-plt.cpp
@@ -2,7 +2,9 @@
 
 // REQUIRES: system-linux
 
-// RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s -o %t.exe
+// RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
+// Link against a DSO to ensure PLT entries.
+// RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s %t.so -o %t.exe
 // RUN: llvm-bolt %t.exe -o %t.bolt.exe --plt=all
 // RUN: %t.bolt.exe
 
diff --git a/bolt/test/runtime/plt-lld.test b/bolt/test/runtime/plt-lld.test
index b505a191f90abfd..3432e18bf4daf40 100644
--- a/bolt/test/runtime/plt-lld.test
+++ b/bolt/test/runtime/plt-lld.test
@@ -1,14 +1,15 @@
 // This test checks that the pointers to PLT are properly updated.
-// The test is using lld linker.
+// The test uses lld and links against a DSO to ensure PLT entries.
+RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
 
 // Non-PIE:
-RUN: %clang %cflags -no-pie %p/../Inputs/plt.c -fuse-ld=lld \
+RUN: %clang %cflags -no-pie %p/../Inputs/plt.c %t.so -fuse-ld=lld \
 RUN:-o %t.lld.exe -Wl,-q
 RUN: llvm-bolt %t.ll

[llvm-branch-commits] [llvm] release/20.x: [BOLT, test] Link against a shared object to test PLT (#125625) (PR #126351)

2025-02-07 Thread via llvm-branch-commits

llvmbot wrote:

@maksfb What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/126351
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [AArch64] Enable AvoidLDAPUR for cpu=generic between armv8.4 and armv9.3. (#125261) (PR #126253)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@davemgreen (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126253
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] release/20.x: [mlir][CMake] Fix dependency on MLIRTestDialect in Transforms tests (#125894) (PR #126211)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@DavidSpickett (or anyone else). If you would like to add a note about this fix 
in the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126211
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/20.x: [libc++] Replace __is_trivially_relocatable by is_trivially_copyable (#124970) (PR #125996)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/125996

>From f92369f2591f986c69a5b189d22da64aceb5b33d Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Wed, 5 Feb 2025 22:32:51 -0500
Subject: [PATCH] [libc++] Replace __is_trivially_relocatable by
 is_trivially_copyable (#124970)

The __is_trivially_relocatable builtin has semantics that do not
correspond to any current or future notion of trivial relocation.
Furthermore, it currently leads to incorrect optimizations for some
types on supported compilers:
- Clang on Windows where types with non-trivial destructors get
  incorrectly optimized
- AppleClang where types with non-trivial move constructors get
  incorrectly optimized

Until there is an agreed upon and bugfree implementation of what it
means to be trivially relocatable, it is safer to simply use trivially
copyable instead. This doesn't leave a lot of types behind and is
definitely correct.

(cherry picked from commit accfbd4cb327411ad66c0109ba1841482b871967)
---
 .../__type_traits/is_trivially_relocatable.h  |  8 ++-
 .../is_trivially_relocatable.compile.pass.cpp | 14 ++--
 .../vector/trivial_relocation.pass.cpp| 71 +++
 3 files changed, 86 insertions(+), 7 deletions(-)
 create mode 100644 
libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp

diff --git a/libcxx/include/__type_traits/is_trivially_relocatable.h 
b/libcxx/include/__type_traits/is_trivially_relocatable.h
index c0871731cc0016b..9b0e240de55f4ec 100644
--- a/libcxx/include/__type_traits/is_trivially_relocatable.h
+++ b/libcxx/include/__type_traits/is_trivially_relocatable.h
@@ -11,7 +11,6 @@
 
 #include <__config>
 #include <__type_traits/enable_if.h>
-#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/is_trivially_copyable.h>
 
@@ -23,8 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // A type is trivially relocatable if a move construct + destroy of the 
original object is equivalent to
 // `memcpy(dst, src, sizeof(T))`.
-
-#if __has_builtin(__is_trivially_relocatable)
+//
+// Note that we don't use the __is_trivially_relocatable Clang builtin right 
now because it does not
+// implement the semantics of any current or future trivial relocation 
proposal and it can lead to
+// incorrect optimizations on some platforms (Windows) and supported compilers 
(AppleClang).
+#if __has_builtin(__is_trivially_relocatable) && 0
 template 
 struct __libcpp_is_trivially_relocatable : integral_constant {};
 #else
diff --git 
a/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp 
b/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp
index 674df1d0219057d..213d06d314a075f 100644
--- a/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp
+++ b/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp
@@ -54,11 +54,17 @@ struct MoveOnlyTriviallyCopyable {
   MoveOnlyTriviallyCopyable(MoveOnlyTriviallyCopyable&&) = 
default;
   MoveOnlyTriviallyCopyable& operator=(MoveOnlyTriviallyCopyable&&)  = 
default;
 };
-#ifndef _MSC_VER
 
static_assert(std::__libcpp_is_trivially_relocatable::value,
 "");
-#else
-static_assert(!std::__libcpp_is_trivially_relocatable::value,
 "");
-#endif
+
+struct NonTrivialMoveConstructor {
+  NonTrivialMoveConstructor(NonTrivialMoveConstructor&&);
+};
+static_assert(!std::__libcpp_is_trivially_relocatable::value,
 "");
+
+struct NonTrivialDestructor {
+  ~NonTrivialDestructor() {}
+};
+static_assert(!std::__libcpp_is_trivially_relocatable::value,
 "");
 
 // library-internal types
 // --
diff --git 
a/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp 
b/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
new file mode 100644
index 000..fbd597d07d6e32e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
@@ -0,0 +1,71 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// Make sure we don't miscompile vector operations for types that shouldn't be 
considered
+// trivially relocatable.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+struct Tracker {
+  std::size_t move_constructs = 0;
+};
+
+struct [[clang::trivial_abi]] Inner {
+  TEST_CONSTEXPR_CXX20 explicit Inner(Tracker* tracker) : tracker_(tracker) {}
+  TEST_CONSTEXPR_CXX20 Inner(const Inner& rhs) : tracker_(rhs.tracker_) { 
tracker_->move_constructs += 1; }
+  TEST_CONSTEXPR_CXX20 Inner(Inner&& rhs) : tracker_(rhs.tracker_) { 
tracker_->move_constructs += 1; }
+  Tracker* t

[llvm-branch-commits] [libcxx] release/20.x: [libc++] Replace __is_trivially_relocatable by is_trivially_copyable (#124970) (PR #125996)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/125996
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] f92369f - [libc++] Replace __is_trivially_relocatable by is_trivially_copyable (#124970)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Louis Dionne
Date: 2025-02-07T18:24:57-08:00
New Revision: f92369f2591f986c69a5b189d22da64aceb5b33d

URL: 
https://github.com/llvm/llvm-project/commit/f92369f2591f986c69a5b189d22da64aceb5b33d
DIFF: 
https://github.com/llvm/llvm-project/commit/f92369f2591f986c69a5b189d22da64aceb5b33d.diff

LOG: [libc++] Replace __is_trivially_relocatable by is_trivially_copyable 
(#124970)

The __is_trivially_relocatable builtin has semantics that do not
correspond to any current or future notion of trivial relocation.
Furthermore, it currently leads to incorrect optimizations for some
types on supported compilers:
- Clang on Windows where types with non-trivial destructors get
  incorrectly optimized
- AppleClang where types with non-trivial move constructors get
  incorrectly optimized

Until there is an agreed upon and bugfree implementation of what it
means to be trivially relocatable, it is safer to simply use trivially
copyable instead. This doesn't leave a lot of types behind and is
definitely correct.

(cherry picked from commit accfbd4cb327411ad66c0109ba1841482b871967)

Added: 
libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp

Modified: 
libcxx/include/__type_traits/is_trivially_relocatable.h
libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp

Removed: 




diff  --git a/libcxx/include/__type_traits/is_trivially_relocatable.h 
b/libcxx/include/__type_traits/is_trivially_relocatable.h
index c0871731cc0016b..9b0e240de55f4ec 100644
--- a/libcxx/include/__type_traits/is_trivially_relocatable.h
+++ b/libcxx/include/__type_traits/is_trivially_relocatable.h
@@ -11,7 +11,6 @@
 
 #include <__config>
 #include <__type_traits/enable_if.h>
-#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/is_trivially_copyable.h>
 
@@ -23,8 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // A type is trivially relocatable if a move construct + destroy of the 
original object is equivalent to
 // `memcpy(dst, src, sizeof(T))`.
-
-#if __has_builtin(__is_trivially_relocatable)
+//
+// Note that we don't use the __is_trivially_relocatable Clang builtin right 
now because it does not
+// implement the semantics of any current or future trivial relocation 
proposal and it can lead to
+// incorrect optimizations on some platforms (Windows) and supported compilers 
(AppleClang).
+#if __has_builtin(__is_trivially_relocatable) && 0
 template 
 struct __libcpp_is_trivially_relocatable : integral_constant {};
 #else

diff  --git 
a/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp 
b/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp
index 674df1d0219057d..213d06d314a075f 100644
--- a/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp
+++ b/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp
@@ -54,11 +54,17 @@ struct MoveOnlyTriviallyCopyable {
   MoveOnlyTriviallyCopyable(MoveOnlyTriviallyCopyable&&) = 
default;
   MoveOnlyTriviallyCopyable& operator=(MoveOnlyTriviallyCopyable&&)  = 
default;
 };
-#ifndef _MSC_VER
 
static_assert(std::__libcpp_is_trivially_relocatable::value,
 "");
-#else
-static_assert(!std::__libcpp_is_trivially_relocatable::value,
 "");
-#endif
+
+struct NonTrivialMoveConstructor {
+  NonTrivialMoveConstructor(NonTrivialMoveConstructor&&);
+};
+static_assert(!std::__libcpp_is_trivially_relocatable::value,
 "");
+
+struct NonTrivialDestructor {
+  ~NonTrivialDestructor() {}
+};
+static_assert(!std::__libcpp_is_trivially_relocatable::value,
 "");
 
 // library-internal types
 // --

diff  --git 
a/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp 
b/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
new file mode 100644
index 000..fbd597d07d6e32e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
@@ -0,0 +1,71 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// Make sure we don't miscompile vector operations for types that shouldn't be 
considered
+// trivially relocatable.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+struct Tracker {
+  std::size_t move_constructs = 0;
+};
+
+struct [[clang::trivial_abi]] Inner {
+  TEST_CONSTEXPR_CXX20 explicit Inner(Tracker* tracker) : tracker_(tracker) {}
+  TEST_CONSTEXPR_CXX20 Inner(const Inner& rhs) : tracker_(rhs.tracker_) { 
tracker_->move_constructs += 1; }
+  TEST_CONSTEXPR_CXX20 Inner(Inner&& rhs) 

[llvm-branch-commits] [libcxx] release/20.x: [libc++] Replace __is_trivially_relocatable by is_trivially_copyable (#124970) (PR #125996)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ldionne (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/125996
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (#121245) (PR #126289)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@mpark (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126289
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 3351e1b - [AArch64] Enable AvoidLDAPUR for cpu=generic between armv8.4 and armv9.3. (#125261)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: David Green
Date: 2025-02-07T16:27:47-08:00
New Revision: 3351e1b142a8ef097f15766e363c2ecb5b8f7e5f

URL: 
https://github.com/llvm/llvm-project/commit/3351e1b142a8ef097f15766e363c2ecb5b8f7e5f
DIFF: 
https://github.com/llvm/llvm-project/commit/3351e1b142a8ef097f15766e363c2ecb5b8f7e5f.diff

LOG: [AArch64] Enable AvoidLDAPUR for cpu=generic between armv8.4 and armv9.3. 
(#125261)

As added in #124274, CPUs in this range can suffer from performance
issues with ldapur. As the gain from ldar->ldapr is expected to be
greater than the minor gain from ldapr->ldapur, this opts to avoid the
instruction under the default -mcpu=generic when the -march is less that
armv8.8 / armv9.3.

I renamed AArch64Subtarget::Others to AArch64Subtarget::Generic to be
clearer what it means.

(cherry picked from commit 6424abcd6c9c6aa8171c79d0fe0369d3a10da3d5)

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp 
b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
index bc921f07e1dbf89..809e658e6538017 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -125,7 +125,12 @@ void AArch64Subtarget::initializeProperties(bool 
HasMinSize) {
   // this in the future so we can specify it together with the subtarget
   // features.
   switch (ARMProcFamily) {
-  case Others:
+  case Generic:
+// Using TuneCPU=generic we avoid ldapur instructions to line up with the
+// cpus that use the AvoidLDAPUR feature. We don't want this to be on
+// forever, so it is enabled between armv8.4 and armv8.7/armv9.2.
+if (hasV8_4aOps() && !hasV8_8aOps())
+  AvoidLDAPUR = true;
 break;
   case Carmel:
 CacheLineSize = 64;

diff  --git a/llvm/lib/Target/AArch64/AArch64Subtarget.h 
b/llvm/lib/Target/AArch64/AArch64Subtarget.h
index d22991224d496d9..dca5f5393fe47b3 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -38,7 +38,7 @@ class Triple;
 class AArch64Subtarget final : public AArch64GenSubtargetInfo {
 public:
   enum ARMProcFamilyEnum : uint8_t {
-Others,
+Generic,
 #define ARM_PROCESSOR_FAMILY(ENUM) ENUM,
 #include "llvm/TargetParser/AArch64TargetParserDef.inc"
 #undef ARM_PROCESSOR_FAMILY
@@ -46,7 +46,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo 
{
 
 protected:
   /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
-  ARMProcFamilyEnum ARMProcFamily = Others;
+  ARMProcFamilyEnum ARMProcFamily = Generic;
 
   // Enable 64-bit vectorization in SLP.
   unsigned MinVectorRegisterBitWidth = 64;

diff  --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index 4af3c482e65984b..cd994d53a60088f 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -4272,7 +4272,7 @@ void AArch64TTIImpl::getUnrollingPreferences(Loop *L, 
ScalarEvolution &SE,
   // If mcpu is omitted, getProcFamily() returns AArch64Subtarget::Others, so 
by
   // checking for that case, we can ensure that the default behaviour is
   // unchanged
-  if (ST->getProcFamily() != AArch64Subtarget::Others &&
+  if (ST->getProcFamily() != AArch64Subtarget::Generic &&
   !ST->getSchedModel().isOutOfOrder()) {
 UP.Runtime = true;
 UP.Partial = true;

diff  --git 
a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll 
b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll
index b475e68db411a42..02ff12c27fcda9d 100644
--- a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll
@@ -1,12 +1,15 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --filter-out "(?!^\s*lda.*\bsp\b)^\s*.*\bsp\b" --filter 
"^\s*(ld|st[^r]|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
-; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+v8.4a 
-mattr=+rcpc-immo -global-isel=true -global-isel-abort=2 -O0 | FileCheck %s 
--check-prefixes=CHECK,GISEL
-; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+v8.4a 
-mattr=+rcpc-immo -global-isel=false -O1 | FileCheck %s 
--check-prefixes=CHECK,SDAG,SDAG-NOAVOIDLDAPUR
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+v8.8a 
-mattr=+rcpc-immo -global-isel=true -global-isel-abort=2 -O0 | FileCheck %s 
--check-prefixes=CHECK,GISEL
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+v8.4a 
-mattr=+rcpc-immo -global-isel=false -O1 | FileCheck %s 
--check-prefixes=CH

[llvm-branch-commits] [llvm] release/20.x: [AArch64] Enable AvoidLDAPUR for cpu=generic between armv8.4 and armv9.3. (#125261) (PR #126253)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126253
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] 898089b - [mlir][CMake] Fix dependency on MLIRTestDialect in Transforms tests (#125894)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: David Spickett
Date: 2025-02-07T18:19:57-08:00
New Revision: 898089b76e1c9f6bb9c61a4f43e287b07c67eadb

URL: 
https://github.com/llvm/llvm-project/commit/898089b76e1c9f6bb9c61a4f43e287b07c67eadb
DIFF: 
https://github.com/llvm/llvm-project/commit/898089b76e1c9f6bb9c61a4f43e287b07c67eadb.diff

LOG: [mlir][CMake] Fix dependency on MLIRTestDialect in Transforms tests 
(#125894)

Another follow up fix to
https://github.com/llvm/llvm-project/pull/123910 to fix a build failure
that sometimes happens in shared library builds:
https://lab.llvm.org/buildbot/#/builders/50/builds/9724

In file included from
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/Transforms/TestInlining.cpp:16:
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/Transforms/../Dialect/Test/TestOps.h:148:10:
fatal error: 'TestOps.h.inc' file not found
  148 | #include "TestOps.h.inc"
  |  ^~~
1 error generated.

(cherry picked from commit ebd23f25c8936db3dd917567737a067d6878e2f4)

Added: 


Modified: 
mlir/test/lib/Transforms/CMakeLists.txt

Removed: 




diff  --git a/mlir/test/lib/Transforms/CMakeLists.txt 
b/mlir/test/lib/Transforms/CMakeLists.txt
index b91265d20fb4812..1b9b9bffa52792e 100644
--- a/mlir/test/lib/Transforms/CMakeLists.txt
+++ b/mlir/test/lib/Transforms/CMakeLists.txt
@@ -34,12 +34,14 @@ add_mlir_library(MLIRTestTransforms
 
   DEPENDS
   ${MLIRTestTransformsPDLDep}
+
+  LINK_LIBS PUBLIC
+  MLIRTestDialect
   )
 mlir_target_link_libraries(MLIRTestTransforms PUBLIC
   MLIRAnalysis
   MLIRFuncDialect
   MLIRInferIntRangeInterface
-  MLIRTestDialect
   MLIRTransforms
   )
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] release/20.x: [mlir][CMake] Fix dependency on MLIRTestDialect in Transforms tests (#125894) (PR #126211)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/126211

>From 898089b76e1c9f6bb9c61a4f43e287b07c67eadb Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 5 Feb 2025 17:49:52 +
Subject: [PATCH] [mlir][CMake] Fix dependency on MLIRTestDialect in Transforms
 tests (#125894)

Another follow up fix to
https://github.com/llvm/llvm-project/pull/123910 to fix a build failure
that sometimes happens in shared library builds:
https://lab.llvm.org/buildbot/#/builders/50/builds/9724

In file included from
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/Transforms/TestInlining.cpp:16:
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/Transforms/../Dialect/Test/TestOps.h:148:10:
fatal error: 'TestOps.h.inc' file not found
  148 | #include "TestOps.h.inc"
  |  ^~~
1 error generated.

(cherry picked from commit ebd23f25c8936db3dd917567737a067d6878e2f4)
---
 mlir/test/lib/Transforms/CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mlir/test/lib/Transforms/CMakeLists.txt 
b/mlir/test/lib/Transforms/CMakeLists.txt
index b91265d20fb4812..1b9b9bffa52792e 100644
--- a/mlir/test/lib/Transforms/CMakeLists.txt
+++ b/mlir/test/lib/Transforms/CMakeLists.txt
@@ -34,12 +34,14 @@ add_mlir_library(MLIRTestTransforms
 
   DEPENDS
   ${MLIRTestTransformsPDLDep}
+
+  LINK_LIBS PUBLIC
+  MLIRTestDialect
   )
 mlir_target_link_libraries(MLIRTestTransforms PUBLIC
   MLIRAnalysis
   MLIRFuncDialect
   MLIRInferIntRangeInterface
-  MLIRTestDialect
   MLIRTransforms
   )
 

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] release/20.x: [mlir][CMake] Fix dependency on MLIRTestDialect in Transforms tests (#125894) (PR #126211)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126211
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: Fix `llvm/test/DebugInfo/Generic/discriminated-union.ll` on big-endian targets (#125849) (PR #126029)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/126029

>From e5ea8f0a4855acd532db6beab8944a6226287a5f Mon Sep 17 00:00:00 2001
From: Tom Tromey 
Date: Tue, 4 Feb 2025 14:36:22 -0700
Subject: [PATCH 1/2] Allow 128-bit discriminants in DWARF variants (#125578)

If a variant part has a 128-bit discriminator, then
DwarfUnit::constructTypeDIE will assert.  This patch fixes the problem
by allowing any size of integer to be used here.  This is largely
accomplished by moving part of DwarfUnit::addConstantValue to a new
method.

Fixes #119655

(cherry picked from commit 3c2807624d2006fa8aacf9c6441c9a3034a52b44)
---
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 64 +++
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h   |  8 +++
 .../DebugInfo/Generic/discriminated-union.ll  |  4 +-
 3 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index d3450b8b0556fde..5a17aa3bc9dc52e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -232,6 +232,42 @@ void DwarfUnit::addUInt(DIEValueList &Block, dwarf::Form 
Form,
   addUInt(Block, (dwarf::Attribute)0, Form, Integer);
 }
 
+void DwarfUnit::addIntAsBlock(DIE &Die, dwarf::Attribute Attribute, const 
APInt &Val) {
+  DIEBlock *Block = new (DIEValueAllocator) DIEBlock;
+
+  // Get the raw data form of the large APInt.
+  const uint64_t *Ptr64 = Val.getRawData();
+
+  int NumBytes = Val.getBitWidth() / 8; // 8 bits per byte.
+  bool LittleEndian = Asm->getDataLayout().isLittleEndian();
+
+  // Output the constant to DWARF one byte at a time.
+  for (int i = 0; i < NumBytes; i++) {
+uint8_t c;
+if (LittleEndian)
+  c = Ptr64[i / 8] >> (8 * (i & 7));
+else
+  c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
+addUInt(*Block, dwarf::DW_FORM_data1, c);
+  }
+
+  addBlock(Die, Attribute, Block);
+}
+
+void DwarfUnit::addInt(DIE &Die, dwarf::Attribute Attribute,
+  const APInt &Val, bool Unsigned) {
+  unsigned CIBitWidth = Val.getBitWidth();
+  if (CIBitWidth <= 64) {
+if (Unsigned)
+  addUInt(Die, Attribute, std::nullopt, Val.getZExtValue());
+else
+  addSInt(Die, Attribute, std::nullopt, Val.getSExtValue());
+return;
+  }
+
+  addIntAsBlock(Die, Attribute, Val);
+}
+
 void DwarfUnit::addSInt(DIEValueList &Die, dwarf::Attribute Attribute,
 std::optional Form, int64_t Integer) {
   if (!Form)
@@ -484,25 +520,7 @@ void DwarfUnit::addConstantValue(DIE &Die, const APInt 
&Val, bool Unsigned) {
 return;
   }
 
-  DIEBlock *Block = new (DIEValueAllocator) DIEBlock;
-
-  // Get the raw data form of the large APInt.
-  const uint64_t *Ptr64 = Val.getRawData();
-
-  int NumBytes = Val.getBitWidth() / 8; // 8 bits per byte.
-  bool LittleEndian = Asm->getDataLayout().isLittleEndian();
-
-  // Output the constant to DWARF one byte at a time.
-  for (int i = 0; i < NumBytes; i++) {
-uint8_t c;
-if (LittleEndian)
-  c = Ptr64[i / 8] >> (8 * (i & 7));
-else
-  c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
-addUInt(*Block, dwarf::DW_FORM_data1, c);
-  }
-
-  addBlock(Die, dwarf::DW_AT_const_value, Block);
+  addIntAsBlock(Die, dwarf::DW_AT_const_value, Val);
 }
 
 void DwarfUnit::addLinkageName(DIE &Die, StringRef LinkageName) {
@@ -980,12 +998,8 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const 
DICompositeType *CTy) {
   DIE &Variant = createAndAddDIE(dwarf::DW_TAG_variant, Buffer);
   if (const ConstantInt *CI =
   dyn_cast_or_null(DDTy->getDiscriminantValue())) {
-if (DD->isUnsignedDIType(Discriminator->getBaseType()))
-  addUInt(Variant, dwarf::DW_AT_discr_value, std::nullopt,
-  CI->getZExtValue());
-else
-  addSInt(Variant, dwarf::DW_AT_discr_value, std::nullopt,
-  CI->getSExtValue());
+   addInt(Variant, dwarf::DW_AT_discr_value, CI->getValue(),
+  DD->isUnsignedDIType(Discriminator->getBaseType()));
   }
   constructMemberDIE(Variant, DDTy);
 } else {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h 
b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 7a5295d826a483b..842a8d6ad53b107 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -167,6 +167,10 @@ class DwarfUnit : public DIEUnit {
 
   void addSInt(DIELoc &Die, std::optional Form, int64_t Integer);
 
+  /// Add an integer attribute data and value; value may be any width.
+  void addInt(DIE &Die, dwarf::Attribute Attribute, const APInt &Integer,
+ bool Unsigned);
+
   /// Add a string attribute data and value.
   ///
   /// We always emit a reference to the string pool instead of immediate
@@ -336,6 +340,10 @@ class DwarfUnit : public DIEUnit {
   void emitC

[llvm-branch-commits] [llvm] e5ea8f0 - Allow 128-bit discriminants in DWARF variants (#125578)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Tom Tromey
Date: 2025-02-07T18:28:44-08:00
New Revision: e5ea8f0a4855acd532db6beab8944a6226287a5f

URL: 
https://github.com/llvm/llvm-project/commit/e5ea8f0a4855acd532db6beab8944a6226287a5f
DIFF: 
https://github.com/llvm/llvm-project/commit/e5ea8f0a4855acd532db6beab8944a6226287a5f.diff

LOG: Allow 128-bit discriminants in DWARF variants (#125578)

If a variant part has a 128-bit discriminator, then
DwarfUnit::constructTypeDIE will assert.  This patch fixes the problem
by allowing any size of integer to be used here.  This is largely
accomplished by moving part of DwarfUnit::addConstantValue to a new
method.

Fixes #119655

(cherry picked from commit 3c2807624d2006fa8aacf9c6441c9a3034a52b44)

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
llvm/test/DebugInfo/Generic/discriminated-union.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index d3450b8b0556fde..5a17aa3bc9dc52e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -232,6 +232,42 @@ void DwarfUnit::addUInt(DIEValueList &Block, dwarf::Form 
Form,
   addUInt(Block, (dwarf::Attribute)0, Form, Integer);
 }
 
+void DwarfUnit::addIntAsBlock(DIE &Die, dwarf::Attribute Attribute, const 
APInt &Val) {
+  DIEBlock *Block = new (DIEValueAllocator) DIEBlock;
+
+  // Get the raw data form of the large APInt.
+  const uint64_t *Ptr64 = Val.getRawData();
+
+  int NumBytes = Val.getBitWidth() / 8; // 8 bits per byte.
+  bool LittleEndian = Asm->getDataLayout().isLittleEndian();
+
+  // Output the constant to DWARF one byte at a time.
+  for (int i = 0; i < NumBytes; i++) {
+uint8_t c;
+if (LittleEndian)
+  c = Ptr64[i / 8] >> (8 * (i & 7));
+else
+  c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
+addUInt(*Block, dwarf::DW_FORM_data1, c);
+  }
+
+  addBlock(Die, Attribute, Block);
+}
+
+void DwarfUnit::addInt(DIE &Die, dwarf::Attribute Attribute,
+  const APInt &Val, bool Unsigned) {
+  unsigned CIBitWidth = Val.getBitWidth();
+  if (CIBitWidth <= 64) {
+if (Unsigned)
+  addUInt(Die, Attribute, std::nullopt, Val.getZExtValue());
+else
+  addSInt(Die, Attribute, std::nullopt, Val.getSExtValue());
+return;
+  }
+
+  addIntAsBlock(Die, Attribute, Val);
+}
+
 void DwarfUnit::addSInt(DIEValueList &Die, dwarf::Attribute Attribute,
 std::optional Form, int64_t Integer) {
   if (!Form)
@@ -484,25 +520,7 @@ void DwarfUnit::addConstantValue(DIE &Die, const APInt 
&Val, bool Unsigned) {
 return;
   }
 
-  DIEBlock *Block = new (DIEValueAllocator) DIEBlock;
-
-  // Get the raw data form of the large APInt.
-  const uint64_t *Ptr64 = Val.getRawData();
-
-  int NumBytes = Val.getBitWidth() / 8; // 8 bits per byte.
-  bool LittleEndian = Asm->getDataLayout().isLittleEndian();
-
-  // Output the constant to DWARF one byte at a time.
-  for (int i = 0; i < NumBytes; i++) {
-uint8_t c;
-if (LittleEndian)
-  c = Ptr64[i / 8] >> (8 * (i & 7));
-else
-  c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
-addUInt(*Block, dwarf::DW_FORM_data1, c);
-  }
-
-  addBlock(Die, dwarf::DW_AT_const_value, Block);
+  addIntAsBlock(Die, dwarf::DW_AT_const_value, Val);
 }
 
 void DwarfUnit::addLinkageName(DIE &Die, StringRef LinkageName) {
@@ -980,12 +998,8 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const 
DICompositeType *CTy) {
   DIE &Variant = createAndAddDIE(dwarf::DW_TAG_variant, Buffer);
   if (const ConstantInt *CI =
   dyn_cast_or_null(DDTy->getDiscriminantValue())) {
-if (DD->isUnsignedDIType(Discriminator->getBaseType()))
-  addUInt(Variant, dwarf::DW_AT_discr_value, std::nullopt,
-  CI->getZExtValue());
-else
-  addSInt(Variant, dwarf::DW_AT_discr_value, std::nullopt,
-  CI->getSExtValue());
+   addInt(Variant, dwarf::DW_AT_discr_value, CI->getValue(),
+  DD->isUnsignedDIType(Discriminator->getBaseType()));
   }
   constructMemberDIE(Variant, DDTy);
 } else {

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h 
b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 7a5295d826a483b..842a8d6ad53b107 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -167,6 +167,10 @@ class DwarfUnit : public DIEUnit {
 
   void addSInt(DIELoc &Die, std::optional Form, int64_t Integer);
 
+  /// Add an integer attribute data and value; value may be any width.
+  void addInt(DIE &Die, dwarf::Attribute Attribute, const APInt &Integer,
+ bool Unsigned);
+
   /// Add a string attribute data and value.
   ///
   /// We always emit a reference to the st

[llvm-branch-commits] [llvm] 5e36383 - Fix `llvm/test/DebugInfo/Generic/discriminated-union.ll` on big-endian targets (#125849)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: beetrees
Date: 2025-02-07T18:28:44-08:00
New Revision: 5e36383513a57704b513732b4b152b67933c37d9

URL: 
https://github.com/llvm/llvm-project/commit/5e36383513a57704b513732b4b152b67933c37d9
DIFF: 
https://github.com/llvm/llvm-project/commit/5e36383513a57704b513732b4b152b67933c37d9.diff

LOG: Fix `llvm/test/DebugInfo/Generic/discriminated-union.ll` on big-endian 
targets (#125849)

Fixes the failure of the [Solaris/sparcv9
buildbot](https://lab.llvm.org/buildbot/#/builders/13/builds/5103)
caused by #125578.

cc @rorth @tromey @dwblaikie

(cherry picked from commit 34929853bc39d28943373b8a96371a7e81e98917)

Added: 


Modified: 
llvm/test/DebugInfo/Generic/discriminated-union.ll

Removed: 




diff  --git a/llvm/test/DebugInfo/Generic/discriminated-union.ll 
b/llvm/test/DebugInfo/Generic/discriminated-union.ll
index 592f2152ae68201..0267580eb0cbf36 100644
--- a/llvm/test/DebugInfo/Generic/discriminated-union.ll
+++ b/llvm/test/DebugInfo/Generic/discriminated-union.ll
@@ -1,8 +1,8 @@
 ; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
-; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
+; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s --check-prefix %if 
target-byteorder-big-endian %{ CHECK-BE %} %else %{ CHECK-LE %}
 
 ; RUN: %llc_dwarf --try-experimental-debuginfo-iterators -O0 -filetype=obj < 
%s > %t
-; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
+; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s --check-prefix %if 
target-byteorder-big-endian %{ CHECK-BE %} %else %{ CHECK-LE %}
 
 ; Check for a variant part that has two members, one of which has a
 ; discriminant value.
@@ -22,7 +22,8 @@
 ; CHECK: DW_AT_alignment
 ; CHECK: DW_AT_data_member_location [DW_FORM_data1](0x00)
 ; CHECK: DW_TAG_variant
-;   CHECK: DW_AT_discr_value [DW_FORM_block1]  (<0x10> 00 00 00 00 00 
00 00 00 01 00 00 00 00 00 00 00 )
+;   CHECK-LE: DW_AT_discr_value [DW_FORM_block1]   (<0x10> 00 00 00 00 00 
00 00 00 01 00 00 00 00 00 00 00 )
+;   CHECK-BE: DW_AT_discr_value [DW_FORM_block1]   (<0x10> 00 00 00 00 00 
00 00 01 00 00 00 00 00 00 00 00 )
 ;   CHECK: DW_TAG_member
 ; CHECK: DW_AT_type
 ; CHECK: DW_AT_alignment



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: Fix `llvm/test/DebugInfo/Generic/discriminated-union.ll` on big-endian targets (#125849) (PR #126029)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126029
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: Fix `llvm/test/DebugInfo/Generic/discriminated-union.ll` on big-endian targets (#125849) (PR #126029)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@beetrees (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126029
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (#121245) (PR #126289)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/126289

>From b2b41544eefa71f97fad492100617aab90d024fb Mon Sep 17 00:00:00 2001
From: Michael Park 
Date: Mon, 3 Feb 2025 11:22:02 -0800
Subject: [PATCH] [C++20][Modules][Serialization] Delay marking pending
 incomplete decl chains until the end of `finishPendingActions`. (#121245)

The call to `hasBody` inside `finishPendingActions` that bumps the 
`PendingIncompleteDeclChains`
size from `0` to `1`, and also sets the `LazyVal->LastGeneration` to `6` which 
matches
the `LazyVal->ExternalSource->getGeneration()` value of `6`. Later, the 
iterations over `redecls()`
(which calls `getNextRedeclaration`) is expected to trigger the reload, but it 
**does not** since
the generation numbers match.

The proposed solution is to perform the marking of incomplete decl chains at 
the end of `finishPendingActions`.
This way, **all** of the incomplete decls are marked incomplete as a 
post-condition of `finishPendingActions`.
It's also safe to delay this operation since any operation being done within 
`finishPendingActions` has
`NumCurrentElementsDeserializing == 1`, which means that any calls to 
`CompleteDeclChain` would simply
add to the `PendingIncompleteDeclChains` without doing anything anyway.

(cherry picked from commit a9e249f64e800fbb20a3b26c0cfb68c1a1aee5e1)
---
 clang/lib/Serialization/ASTReader.cpp | 25 ---
 clang/test/Modules/pr121245.cpp   | 93 +++
 2 files changed, 105 insertions(+), 13 deletions(-)
 create mode 100644 clang/test/Modules/pr121245.cpp

diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index f524251c48ddd71..24acd6e297e7125 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10186,12 +10186,12 @@ void ASTReader::visitTopLevelModuleMaps(
 }
 
 void ASTReader::finishPendingActions() {
-  while (
-  !PendingIdentifierInfos.empty() || !PendingDeducedFunctionTypes.empty() 
||
-  !PendingDeducedVarTypes.empty() || !PendingIncompleteDeclChains.empty() 
||
-  !PendingDeclChains.empty() || !PendingMacroIDs.empty() ||
-  !PendingDeclContextInfos.empty() || !PendingUpdateRecords.empty() ||
-  !PendingObjCExtensionIvarRedeclarations.empty()) {
+  while (!PendingIdentifierInfos.empty() ||
+ !PendingDeducedFunctionTypes.empty() ||
+ !PendingDeducedVarTypes.empty() || !PendingDeclChains.empty() ||
+ !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
+ !PendingUpdateRecords.empty() ||
+ !PendingObjCExtensionIvarRedeclarations.empty()) {
 // If any identifiers with corresponding top-level declarations have
 // been loaded, load those declarations now.
 using TopLevelDeclsMap =
@@ -10239,13 +10239,6 @@ void ASTReader::finishPendingActions() {
 }
 PendingDeducedVarTypes.clear();
 
-// For each decl chain that we wanted to complete while deserializing, mark
-// it as "still needs to be completed".
-for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
-  markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
-}
-PendingIncompleteDeclChains.clear();
-
 // Load pending declaration chains.
 for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
   loadPendingDeclChain(PendingDeclChains[I].first,
@@ -10483,6 +10476,12 @@ void ASTReader::finishPendingActions() {
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // For each decl chain that we wanted to complete while deserializing, mark
+  // it as "still needs to be completed".
+  for (Decl *D : PendingIncompleteDeclChains)
+markIncompleteDeclChain(D);
+  PendingIncompleteDeclChains.clear();
 }
 
 void ASTReader::diagnoseOdrViolations() {
diff --git a/clang/test/Modules/pr121245.cpp b/clang/test/Modules/pr121245.cpp
new file mode 100644
index 000..0e276ad0e435d11
--- /dev/null
+++ b/clang/test/Modules/pr121245.cpp
@@ -0,0 +1,93 @@
+// If this test fails, it should be investigated under Debug builds.
+// Before the PR, this test was encountering an `llvm_unreachable()`.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
+// RUN:  -fcxx-exceptions -o %t/hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exception

[llvm-branch-commits] [clang] release/20.x: [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (#121245) (PR #126289)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126289
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2025-02-07 Thread via llvm-branch-commits

h-vetinari wrote:

Thanks for the in-depth response, and trying to help fix this!

> Ideas for causes for it not working:

It's none of these, unfortunately.

> I ask you to send a reproducer that works without conda. If you cannot 
> reproduce it without conda, I am assuming the problem is with conda.

It's not a function of conda the tool, but of packaging LLVM for the purpose of 
shipping it as pre-compiled binaries. These need to be split into components 
that may depend on each other, because it's imperative that things like 
`libllvm`, `clang`, `compiler-rt` etc. are shared across all their dependents, 
and not (for example) that a packaged `flang` repackages the already-existing 
bits again. Plus, as mentioned, timing constraints in CI.

So the reproducer is pretty simple ("fully stand-alone components").
* build `../llvm` and install into `$PREFIX`
* build `../runtimes` (using 
`-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"`) and install into 
`$PREFIX`
* build `../clang` (while reusing the bits from llvm/libcxx in `$PREFIX`) and 
install into `$PREFIX`
* build `../compiler-rt` (while reusing the bits from clang in `$PREFIX`) and 
install into `$PREFIX`
* build `../mlir` (while reusing the bits from llvm in `$PREFIX`) and install 
into `$PREFIX`
* build `../flang` (while reusing all the other bits in `$PREFIX`) and install 
into `$PREFIX`
* build `../flang-rt`

If you want I can work out a full script that does this, but this is why we 
might arrive in a different place, conceptually speaking.

https://github.com/llvm/llvm-project/pull/110217
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [PassBuilder][CodeGen] Add callback style pass buider (PR #116913)

2025-02-07 Thread Arthur Eubanks via llvm-branch-commits

aeubanks wrote:

I think I'm having a hard time reviewing these patches because I'm not 
confident of the design. I've started writing up the current state of the new 
pass manager for codegen and will send it out to LLVM discourse in hopes of 
more eyes and discussion on the high-level design, and people can hopefully 
agree on something. I will try my hardest to finish the RFC and send it out 
next week. Sorry for the slow responses

https://github.com/llvm/llvm-project/pull/116913
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (#121245) (PR #126289)

2025-02-07 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov approved this pull request.


https://github.com/llvm/llvm-project/pull/126289
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 9611deb - Revert "[Fuchsia] Support PGO (#120323)"

2025-02-07 Thread via llvm-branch-commits

Author: Paul Kirth
Date: 2025-02-07T11:25:29-08:00
New Revision: 9611deb1401eb27477ae438ed257fccc87a395b7

URL: 
https://github.com/llvm/llvm-project/commit/9611deb1401eb27477ae438ed257fccc87a395b7
DIFF: 
https://github.com/llvm/llvm-project/commit/9611deb1401eb27477ae438ed257fccc87a395b7.diff

LOG: Revert "[Fuchsia] Support PGO (#120323)"

This reverts commit 1438c8d68ddaacba4a95a02b66ffbae2ea586993.

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 
clang/cmake/caches/Fuchsia-stage2-instrumented.cmake



diff  --git a/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake 
b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake
deleted file mode 100644
index b3c3b63066363c4..000
--- a/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake
+++ /dev/null
@@ -1,44 +0,0 @@
-# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain 
build.
-
-include(${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake)
-
-if(NOT APPLE)
-  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
-endif()
-
-set(CLANG_BOOTSTRAP_TARGETS
-  check-all
-  check-clang
-  check-lld
-  check-llvm
-  clang
-  clang-test-depends
-  toolchain-distribution
-  install-toolchain-distribution
-  install-toolchain-distribution-stripped
-  install-toolchain-distribution-toolchain
-  lld-test-depends
-  llvm-config
-  llvm-test-depends
-  test-depends
-  test-suite CACHE STRING "")
-
-get_cmake_property(variableNames VARIABLES)
-foreach(variableName ${variableNames})
-  if(variableName MATCHES "^STAGE2_")
-string(REPLACE "STAGE2_" "" new_name ${variableName})
-list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}")
-  endif()
-endforeach()
-
-set(CLANG_PGO_TRAINING_DEPS
-  builtins
-  runtimes
-  CACHE STRING "")
-
-# Setup the bootstrap build.
-set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
-set(CLANG_BOOTSTRAP_CMAKE_ARGS
-  ${EXTRA_ARGS}
-  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
-  CACHE STRING "")

diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 373b7ddd6e3449d..83336589da305d2 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -126,16 +126,6 @@ else()
   set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
   set(LIBCXX_HARDENING_MODE "none" CACHE STRING "")
   set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
-  set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
-  set(COMPILER_RT_BUILD_PROFILE ON CACHE BOOL "")
-  set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
-  set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
-  set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
-  set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
-  set(SANITIZER_CXX_ABI "libc++" CACHE STRING "")
-  set(SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
-  set(SANITIZER_TEST_CXX "libc++" CACHE STRING "")
-  set(SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE 
STRING "")
   set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" 
CACHE STRING "")
 endif()
@@ -174,29 +164,34 @@ endif()
 
 set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
-set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")
 
 set(_FUCHSIA_BOOTSTRAP_TARGETS
-  generate-profdata
-  stage2
-  stage2-toolchain-distribution
-  stage2-install-toolchain-distribution
-  stage2-install-toolchain-distribution-stripped
-  stage2-install-toolchain-distribution-toolchain
-  stage2-check-all
-  stage2-check-lld
-  stage2-check-llvm
-  stage2-check-clang
-  stage2-test-suite)
+  check-all
+  check-clang
+  check-lld
+  check-llvm
+  check-polly
+  llvm-config
+  clang-test-depends
+  lld-test-depends
+  llvm-test-depends
+  test-suite
+  test-depends
+  toolchain-distribution
+  install-toolchain-distribution
+  install-toolchain-distribution-stripped
+  install-toolchain-distribution-toolchain
+  clang)
 
 if(FUCHSIA_ENABLE_LLDB)
   list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb)
   list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS
-stage2-check-lldb
-stage2-debugger-distribution
-stage2-install-debugger-distribution
-stage2-install-debugger-distribution-stripped
-stage2-install-debugger-distribution-toolchain)
+check-lldb
+lldb-test-depends
+debugger-distribution
+install-debugger-distribution
+install-debugger-distribution-stripped
+install-debugger-distribution-toolchain)
 endif()
 
 set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "")
@@ -205,7 +200,6 @@ set(CLANG_BOOTSTRAP_TARGETS ${_FUCHSIA_BOOTSTRAP_TARGETS} 
CACHE STRING "")
 get_cmake_property(variableNames VARIABLES)
 foreach(variableName ${variableNames})
   if(variableName MATCHES "^STAGE2_")
-list(APPEND EXTRA_ARGS "-D${variableName}=${${variableName}}")
 string(REPLACE "STAGE2_" "" new_name ${variableName})
 string(REPLA

[llvm-branch-commits] [clang] release/20.x: [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (#121245) (PR #126289)

2025-02-07 Thread via llvm-branch-commits

llvmbot wrote:

@mizvekov What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/126289
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] release/20.x: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193) (PR #126284)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/126284

Backport 51759ffc4408e9eb5c2d40c9489ce3b98de233d5

Requested by: @jhuber6

>From 3a3a3230d171e11842a9940b6da0f72022b1c5b3 Mon Sep 17 00:00:00 2001
From: "s.vgys" <83276820+samvangyse...@users.noreply.github.com>
Date: Fri, 7 Feb 2025 18:45:38 +0100
Subject: [PATCH] fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC
 namespace (#126193)

Resolves #125831

(cherry picked from commit 51759ffc4408e9eb5c2d40c9489ce3b98de233d5)
---
 libc/CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index c061e2a05ebd8f5..1c4c0cd5aa22ba7 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -51,7 +51,8 @@ set(LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to 
Linux kernel header
 # Defining a global namespace to enclose all libc functions.
 set(default_namespace "__llvm_libc")
 if(LLVM_VERSION_MAJOR)
-  set(default_namespace 
"__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${LLVM_VERSION_SUFFIX}")
+  string(REPLACE "-" "" NS_LLVM_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
+  set(default_namespace 
"__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${NS_LLVM_VERSION_SUFFIX}")
 endif()
 set(LIBC_NAMESPACE ${default_namespace}
   CACHE STRING "The namespace to use to enclose internal implementations. Must 
start with '__llvm_libc'."

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] release/20.x: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193) (PR #126284)

2025-02-07 Thread via llvm-branch-commits

llvmbot wrote:

@nickdesaulniers What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/126284
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] release/20.x: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193) (PR #126284)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/126284
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] release/20.x: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193) (PR #126284)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

⚠️ We detected that you are using a GitHub private e-mail address to contribute 
to the repo. Please turn off [Keep my email addresses 
private](https://github.com/settings/emails) setting in your account. See 
[LLVM 
Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
 for more information.

https://github.com/llvm/llvm-project/pull/126284
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 454d7c1 - [X86] Do not combine LRINT and TRUNC (#125848)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Phoebe Wang
Date: 2025-02-07T15:14:36-08:00
New Revision: 454d7c10f1869e0c109c733b2385b8c16c6a7756

URL: 
https://github.com/llvm/llvm-project/commit/454d7c10f1869e0c109c733b2385b8c16c6a7756
DIFF: 
https://github.com/llvm/llvm-project/commit/454d7c10f1869e0c109c733b2385b8c16c6a7756.diff

LOG: [X86] Do not combine LRINT and TRUNC (#125848)

Per to discussions in #125324, most participants are opposed to this
optimization. So remove the combination to address the concerns.

Fixes #125324

(cherry picked from commit 8c222c122f1a8edb1be96e482511ad547f7db7b3)

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/lrint-conv-i64.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 8f904209d8a3ad9..627cef9ead7ffac 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -53899,11 +53899,6 @@ static SDValue combineTruncate(SDNode *N, SelectionDAG 
&DAG,
   return DAG.getNode(X86ISD::MMX_MOVD2W, DL, MVT::i32, BCSrc);
   }
 
-  // Try to combine (trunc (vNi64 (lrint x))) to (vNi32 (lrint x)).
-  if (Src.getOpcode() == ISD::LRINT && VT.getScalarType() == MVT::i32 &&
-  Src.hasOneUse())
-return DAG.getNode(ISD::LRINT, DL, VT, Src.getOperand(0));
-
   return SDValue();
 }
 

diff  --git a/llvm/test/CodeGen/X86/lrint-conv-i64.ll 
b/llvm/test/CodeGen/X86/lrint-conv-i64.ll
index 01b0af2f807f200..38fa09085e1898d 100644
--- a/llvm/test/CodeGen/X86/lrint-conv-i64.ll
+++ b/llvm/test/CodeGen/X86/lrint-conv-i64.ll
@@ -45,6 +45,24 @@ entry:
   ret i64 %0
 }
 
+define i32 @PR125324(float %x) {
+; SSE-LABEL: PR125324:
+; SSE:   # %bb.0: # %entry
+; SSE-NEXT:cvtss2si %xmm0, %rax
+; SSE-NEXT:# kill: def $eax killed $eax killed $rax
+; SSE-NEXT:retq
+;
+; AVX-LABEL: PR125324:
+; AVX:   # %bb.0: # %entry
+; AVX-NEXT:vcvtss2si %xmm0, %rax
+; AVX-NEXT:# kill: def $eax killed $eax killed $rax
+; AVX-NEXT:retq
+entry:
+  %0 = tail call i64 @llvm.lrint.i64.f32(float %x)
+  %1 = trunc i64 %0 to i32
+  ret i32 %1
+}
+
 declare i64 @llvm.lrint.i64.f32(float) nounwind readnone
 declare i64 @llvm.lrint.i64.f64(double) nounwind readnone
 declare i64 @llvm.lrint.i64.f80(x86_fp80) nounwind readnone



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [X86] Do not combine LRINT and TRUNC (#125848) (PR #125995)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/125995
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [X86] Do not combine LRINT and TRUNC (#125848) (PR #125995)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@phoebewang (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/125995
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 3542150 - [LoopVectorize] Fix cost model assert when vectorising calls (#125716)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: David Sherwood
Date: 2025-02-07T13:28:37-08:00
New Revision: 3542150f05a1f32796d2258f679b9190b7d1f825

URL: 
https://github.com/llvm/llvm-project/commit/3542150f05a1f32796d2258f679b9190b7d1f825
DIFF: 
https://github.com/llvm/llvm-project/commit/3542150f05a1f32796d2258f679b9190b7d1f825.diff

LOG: [LoopVectorize] Fix cost model assert when vectorising calls (#125716)

The legacy and vplan cost models did not agree because
VPWidenCallRecipe::computeCost only calculates the cost of the
call instruction, whereas
LoopVectorizationCostModel::setVectorizedCallDecision in some
cases adds on the cost of a synthesised mask argument. However,
this mask is always 'splat(i1 true)' which should be hoisted out
of the loop during codegen. In order to synchronise the two cost
models I have two options:

1) Also add the cost of the splat to the vplan model, or
2) Remove the cost of the splat from the legacy model.

I chose 2) because I feel this more closely represents what the
final code will look like. There is an argument that we should
take account of such broadcast costs in the preheader when
deciding if it's profitable to vectorise a loop, however there
isn't currently a mechanism to do this. We currently only take
account of the runtime checks when assessing profitability and
what the minimum trip count should be. However, I don't believe
this work needs doing as part of this PR.

(cherry picked from commit 1930524bbde3cd26ff527bbdb5e1f937f484edd6)

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c4b159117e2e84e..318e4809d97eea1 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6331,19 +6331,8 @@ void 
LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
 break;
   }
 
-  // Add in the cost of synthesizing a mask if one wasn't required.
-  InstructionCost MaskCost = 0;
-  if (VecFunc && UsesMask && !MaskRequired)
-MaskCost = TTI.getShuffleCost(
-TargetTransformInfo::SK_Broadcast,
-VectorType::get(IntegerType::getInt1Ty(
-VecFunc->getFunctionType()->getContext()),
-VF),
-{}, CostKind);
-
   if (TLI && VecFunc && !CI->isNoBuiltin())
-VectorCost =
-TTI.getCallInstrCost(nullptr, RetTy, Tys, CostKind) + MaskCost;
+VectorCost = TTI.getCallInstrCost(nullptr, RetTy, Tys, CostKind);
 
   // Find the cost of an intrinsic; some targets may have instructions that
   // perform the operation without needing an actual call.

diff  --git a/llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll
index 61bbae0b3f16a40..5b0f0961a6297c3 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll
@@ -39,7 +39,7 @@ define void @test_widen(ptr noalias %a, ptr readnone %b) #4 {
 ; TFNONE-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], 
[[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
 ; TFNONE-NEXT:[[GEP:%.*]] = getelementptr i64, ptr [[B]], i64 
[[INDVARS_IV]]
 ; TFNONE-NEXT:[[LOAD:%.*]] = load i64, ptr [[GEP]], align 8
-; TFNONE-NEXT:[[CALL:%.*]] = call i64 @foo(i64 [[LOAD]]) #[[ATTR3:[0-9]+]]
+; TFNONE-NEXT:[[CALL:%.*]] = call i64 @foo(i64 [[LOAD]]) #[[ATTR4:[0-9]+]]
 ; TFNONE-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i64, ptr [[A]], 
i64 [[INDVARS_IV]]
 ; TFNONE-NEXT:store i64 [[CALL]], ptr [[ARRAYIDX]], align 8
 ; TFNONE-NEXT:[[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
@@ -177,7 +177,7 @@ define void @test_if_then(ptr noalias %a, ptr readnone %b) 
#4 {
 ; TFNONE-NEXT:[[CMP:%.*]] = icmp ugt i64 [[TMP12]], 50
 ; TFNONE-NEXT:br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END]]
 ; TFNONE:   if.then:
-; TFNONE-NEXT:[[TMP13:%.*]] = call i64 @foo(i64 [[TMP12]]) #[[ATTR3]]
+; TFNONE-NEXT:[[TMP13:%.*]] = call i64 @foo(i64 [[TMP12]]) #[[ATTR4]]
 ; TFNONE-NEXT:br label [[IF_END]]
 ; TFNONE:   if.end:
 ; TFNONE-NEXT:[[TMP14:%.*]] = phi i64 [ [[TMP13]], [[IF_THEN]] ], [ 0, 
[[FOR_BODY]] ]
@@ -339,10 +339,10 @@ define void @test_widen_if_then_else(ptr noalias %a, ptr 
readnone %b) #4 {
 ; TFNONE-NEXT:[[CMP:%.*]] = icmp ugt i64 [[TMP13]], 50
 ; TFNONE-NEXT:br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
 ; TFNONE:   if.then:
-; TFNONE-NEXT:[[TMP14:%.*]] = call i64 @foo(i64 [[TMP13]]) 
#[[ATTR4:[0-9]+]]
+; TFNONE-NEXT:[[TMP14:%.*]] = call i64 @foo(i64 [[TMP13]]) 
#[[ATTR5:[0-9]+]]
 ; TFNONE-NEXT:br label [[IF_END]]
 ; 

[llvm-branch-commits] [llvm] [AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments (PR #126147)

2025-02-07 Thread Scott Linder via llvm-branch-commits


@@ -1,7 +1,7 @@
-; RUN: not --crash opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 
-passes='amdgpu-attributor,function(amdgpu-lower-kernel-arguments)' 
-amdgpu-kernarg-preload-count=16 -S < %s 2>&1 | FileCheck %s
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 
-passes='amdgpu-attributor,function(amdgpu-lower-kernel-arguments)' 
-amdgpu-kernarg-preload-count=16 -S < %s 2>&1 | FileCheck %s
 
-; CHECK: function declaration may only have a unique !dbg attachment
-; CHECK-NEXT: ptr @0
+; CHECK: define amdgpu_kernel void @preload_block_count_x{{.*}} !dbg ![[#]]
+; CHECK-NOT: declare void @0{{.*}} !dbg ![[#]]

slinder1 wrote:

Scratch this, I will likely just abandon this in favor of 
https://github.com/llvm/llvm-project/pull/123547 which removes the declare 
altogether

https://github.com/llvm/llvm-project/pull/126147
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libclc] release/20.x: [libclc] Allow default path when looking for llvm-spirv (#126071) (PR #126201)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/126201

>From e2426cd9e9b47a771f2aaaef8c48f8dbea8b7d49 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Fri, 7 Feb 2025 09:18:18 +0100
Subject: [PATCH] [libclc] Allow default path when looking for llvm-spirv
 (#126071)

This is an external tool, so I don't think there is an expectation that
it has to be in the LLVM tools bindir. It may also be in the default
system bindir (which is not necessarily the same).

(cherry picked from commit 26ecddb05d13c101ccd840a6710eb5f8b82de841)
---
 libclc/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 2c2c7f16e29442f..43e213b385f5dd6 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -114,7 +114,7 @@ endforeach()
 if( TARGET llvm-spirv )
   get_host_tool_path( llvm-spirv LLVM_SPIRV llvm-spirv_exe llvm-spirv_target )
 else()
-  find_program( LLVM_SPIRV llvm-spirv PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
+  find_program( LLVM_SPIRV llvm-spirv HINTS ${LLVM_TOOLS_BINARY_DIR} )
   set( llvm-spirv_exe "${LLVM_SPIRV}" )
   set( llvm-spirv_target )
 endif()

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libclc] release/20.x: [libclc] Allow default path when looking for llvm-spirv (#126071) (PR #126201)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126201
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libclc] release/20.x: [libclc] Allow default path when looking for llvm-spirv (#126071) (PR #126201)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@nikic (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126201
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: workflows/premerge: Move concurrency definition to workflow level (#126308) (PR #126310)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126310
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: workflows/premerge: Move concurrency definition to workflow level (#126308) (PR #126310)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@tstellar (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126310
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] release/20.x: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193) (PR #126284)

2025-02-07 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: None (llvmbot)


Changes

Backport 51759ffc4408e9eb5c2d40c9489ce3b98de233d5

Requested by: @jhuber6

---
Full diff: https://github.com/llvm/llvm-project/pull/126284.diff


1 Files Affected:

- (modified) libc/CMakeLists.txt (+2-1) 


``diff
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index c061e2a05ebd8f5..1c4c0cd5aa22ba7 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -51,7 +51,8 @@ set(LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to 
Linux kernel header
 # Defining a global namespace to enclose all libc functions.
 set(default_namespace "__llvm_libc")
 if(LLVM_VERSION_MAJOR)
-  set(default_namespace 
"__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${LLVM_VERSION_SUFFIX}")
+  string(REPLACE "-" "" NS_LLVM_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
+  set(default_namespace 
"__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${NS_LLVM_VERSION_SUFFIX}")
 endif()
 set(LIBC_NAMESPACE ${default_namespace}
   CACHE STRING "The namespace to use to enclose internal implementations. Must 
start with '__llvm_libc'."

``




https://github.com/llvm/llvm-project/pull/126284
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] release/20.x: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193) (PR #126284)

2025-02-07 Thread Nick Desaulniers via llvm-branch-commits

https://github.com/nickdesaulniers approved this pull request.


https://github.com/llvm/llvm-project/pull/126284
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [DXIL] Add support for root signature flag element in DXContainer (PR #123147)

2025-02-07 Thread via llvm-branch-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/123147

>From aabdfe7d6c6b6e27e9c2150c10199baa6638b6df Mon Sep 17 00:00:00 2001
From: joaosaffran 
Date: Wed, 15 Jan 2025 17:30:00 +
Subject: [PATCH 01/22] adding metadata extraction

---
 .../llvm/Analysis/DXILMetadataAnalysis.h  |  3 +
 llvm/lib/Analysis/DXILMetadataAnalysis.cpp| 89 +++
 .../lib/Target/DirectX/DXContainerGlobals.cpp | 24 +
 3 files changed, 116 insertions(+)

diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h 
b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index cb535ac14f1c613..f420244ba111a45 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -11,9 +11,11 @@
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/MC/DXContainerRootSignature.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/Triple.h"
+#include 
 
 namespace llvm {
 
@@ -37,6 +39,7 @@ struct ModuleMetadataInfo {
   Triple::EnvironmentType ShaderProfile{Triple::UnknownEnvironment};
   VersionTuple ValidatorVersion{};
   SmallVector EntryPropertyVec{};
+  std::optional RootSignatureDesc;
   void print(raw_ostream &OS) const;
 };
 
diff --git a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp 
b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
index a7f666a3f8b48f2..388e3853008eaec 100644
--- a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
+++ b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
@@ -15,12 +15,91 @@
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/MC/DXContainerRootSignature.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
 
 #define DEBUG_TYPE "dxil-metadata-analysis"
 
 using namespace llvm;
 using namespace dxil;
+using namespace llvm::mcdxbc;
+
+static bool parseRootFlags(MDNode *RootFlagNode, RootSignatureDesc *Desc) {
+
+  assert(RootFlagNode->getNumOperands() == 2 &&
+ "Invalid format for RootFlag Element");
+  auto *Flag = mdconst::extract(RootFlagNode->getOperand(1));
+  auto Value = (RootSignatureFlags)Flag->getZExtValue();
+
+  if ((Value & ~RootSignatureFlags::ValidFlags) != RootSignatureFlags::None)
+return true;
+
+  Desc->Flags = Value;
+  return false;
+}
+
+static bool parseRootSignatureElement(MDNode *Element,
+  RootSignatureDesc *Desc) {
+  MDString *ElementText = cast(Element->getOperand(0));
+
+  assert(ElementText != nullptr && "First preoperty of element is not ");
+
+  RootSignatureElementKind ElementKind =
+  StringSwitch(ElementText->getString())
+  .Case("RootFlags", RootSignatureElementKind::RootFlags)
+  .Case("RootConstants", RootSignatureElementKind::RootConstants)
+  .Case("RootCBV", RootSignatureElementKind::RootDescriptor)
+  .Case("RootSRV", RootSignatureElementKind::RootDescriptor)
+  .Case("RootUAV", RootSignatureElementKind::RootDescriptor)
+  .Case("Sampler", RootSignatureElementKind::RootDescriptor)
+  .Case("DescriptorTable", RootSignatureElementKind::DescriptorTable)
+  .Case("StaticSampler", RootSignatureElementKind::StaticSampler)
+  .Default(RootSignatureElementKind::None);
+
+  switch (ElementKind) {
+
+  case RootSignatureElementKind::RootFlags: {
+return parseRootFlags(Element, Desc);
+break;
+  }
+
+  case RootSignatureElementKind::RootConstants:
+  case RootSignatureElementKind::RootDescriptor:
+  case RootSignatureElementKind::DescriptorTable:
+  case RootSignatureElementKind::StaticSampler:
+  case RootSignatureElementKind::None:
+llvm_unreachable("Not Implemented yet");
+break;
+  }
+
+  return true;
+}
+
+bool parseRootSignature(RootSignatureDesc *Desc, int32_t Version,
+NamedMDNode *Root) {
+  Desc->Version = Version;
+  bool HasError = false;
+
+  for (unsigned int Sid = 0; Sid < Root->getNumOperands(); Sid++) {
+// This should be an if, for error handling
+MDNode *Node = cast(Root->getOperand(Sid));
+
+// Not sure what use this for...
+Metadata *Func = Node->getOperand(0).get();
+
+// This should be an if, for error handling
+MDNode *Elements = cast(Node->getOperand(1).get());
+
+for (unsigned int Eid = 0; Eid < Elements->getNumOperands(); Eid++) {
+  MDNode *Element = cast(Elements->getOperand(Eid));
+
+  HasError = HasError || parseRootSignatureElement(Element, Desc);
+}
+  }
+  return HasError;
+}
 
 static ModuleMetadataInfo collectMetadataInfo(Module &M) {
   ModuleMetadataInfo MMDAI;
@@ -28,6 +107,7 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
   MMDAI.DXILVersion = TT.getDXILVersion();
   MMDAI.ShaderModelVersion = TT.getOSVersion();
   MMDAI.ShaderProfile = TT.getEnvironment();
+
   NamedMDNode *ValidatorVerNode = M.getNamedMetadata("dx.valver");
   if (ValidatorVerNode) {

[llvm-branch-commits] [clang] release/20.x: [Driver] Add DragonFly for handling of libdl and libexecinfo (#125179) (PR #125212)

2025-02-07 Thread Brad Smith via llvm-branch-commits

https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/125212
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: workflows/premerge: Move concurrency definition to workflow level (#126308) (PR #126310)

2025-02-07 Thread via llvm-branch-commits

llvmbot wrote:

@boomanaiden154 What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/126310
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: workflows/premerge: Move concurrency definition to workflow level (#126308) (PR #126310)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/126310

Backport 6e5988863177e1d53e7a7abb7a3db2b85376f0f5

Requested by: @tstellar

>From 8c9f343575f6cba87ffbcbc17ef15ba4a3bd00a0 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 7 Feb 2025 13:09:58 -0800
Subject: [PATCH] workflows/premerge: Move concurrency definition to workflow
 level (#126308)

Prior workflow runs were not being cancelled when the pull request was
closed, and I think this was why. Also, there is no advantage to having
the definitions at the job level.

(cherry picked from commit 6e5988863177e1d53e7a7abb7a3db2b85376f0f5)
---
 .github/workflows/premerge.yaml | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 45e6bb763a0efae..9b6a1236823d7ed 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -19,15 +19,16 @@ on:
   - 'main'
   - 'release/**'
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || 
github.sha }}
+  cancel-in-progress: true
+
 jobs:
   premerge-checks-linux:
 if: >-
 false && github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
 runs-on: llvm-premerge-linux-runners
-concurrency:
-  group: ${{ github.workflow }}-linux-${{ github.event.pull_request.number 
|| github.sha }}
-  cancel-in-progress: true
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@v4
@@ -86,9 +87,6 @@ jobs:
 false && github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
 runs-on: llvm-premerge-windows-runners
-concurrency:
-  group: ${{ github.workflow }}-windows-${{ 
github.event.pull_request.number || github.sha }}
-  cancel-in-progress: true
 defaults:
   run:
 shell: bash
@@ -146,9 +144,6 @@ jobs:
 
   permerge-check-macos:
 runs-on: macos-14
-concurrency:
-  group: ${{ github.workflow }}-macos-${{ github.event.pull_request.number 
|| github.sha }}
-  cancel-in-progress: true
 if: >-
   github.repository_owner == 'llvm' &&
   (startswith(github.ref_name, 'release/') ||

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: workflows/premerge: Move concurrency definition to workflow level (#126308) (PR #126310)

2025-02-07 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 approved this pull request.


https://github.com/llvm/llvm-project/pull/126310
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [LoopVectorize] Fix cost model assert when vectorising calls (#125716) (PR #126209)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/126209

>From 3542150f05a1f32796d2258f679b9190b7d1f825 Mon Sep 17 00:00:00 2001
From: David Sherwood 
Date: Fri, 7 Feb 2025 09:36:52 +
Subject: [PATCH 1/2] [LoopVectorize] Fix cost model assert when vectorising
 calls (#125716)

The legacy and vplan cost models did not agree because
VPWidenCallRecipe::computeCost only calculates the cost of the
call instruction, whereas
LoopVectorizationCostModel::setVectorizedCallDecision in some
cases adds on the cost of a synthesised mask argument. However,
this mask is always 'splat(i1 true)' which should be hoisted out
of the loop during codegen. In order to synchronise the two cost
models I have two options:

1) Also add the cost of the splat to the vplan model, or
2) Remove the cost of the splat from the legacy model.

I chose 2) because I feel this more closely represents what the
final code will look like. There is an argument that we should
take account of such broadcast costs in the preheader when
deciding if it's profitable to vectorise a loop, however there
isn't currently a mechanism to do this. We currently only take
account of the runtime checks when assessing profitability and
what the minimum trip count should be. However, I don't believe
this work needs doing as part of this PR.

(cherry picked from commit 1930524bbde3cd26ff527bbdb5e1f937f484edd6)
---
 .../Transforms/Vectorize/LoopVectorize.cpp|  13 +-
 .../LoopVectorize/AArch64/masked-call.ll  | 272 +-
 2 files changed, 262 insertions(+), 23 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c4b159117e2e84e..318e4809d97eea1 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6331,19 +6331,8 @@ void 
LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
 break;
   }
 
-  // Add in the cost of synthesizing a mask if one wasn't required.
-  InstructionCost MaskCost = 0;
-  if (VecFunc && UsesMask && !MaskRequired)
-MaskCost = TTI.getShuffleCost(
-TargetTransformInfo::SK_Broadcast,
-VectorType::get(IntegerType::getInt1Ty(
-VecFunc->getFunctionType()->getContext()),
-VF),
-{}, CostKind);
-
   if (TLI && VecFunc && !CI->isNoBuiltin())
-VectorCost =
-TTI.getCallInstrCost(nullptr, RetTy, Tys, CostKind) + MaskCost;
+VectorCost = TTI.getCallInstrCost(nullptr, RetTy, Tys, CostKind);
 
   // Find the cost of an intrinsic; some targets may have instructions that
   // perform the operation without needing an actual call.
diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll
index 61bbae0b3f16a40..5b0f0961a6297c3 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll
@@ -39,7 +39,7 @@ define void @test_widen(ptr noalias %a, ptr readnone %b) #4 {
 ; TFNONE-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], 
[[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
 ; TFNONE-NEXT:[[GEP:%.*]] = getelementptr i64, ptr [[B]], i64 
[[INDVARS_IV]]
 ; TFNONE-NEXT:[[LOAD:%.*]] = load i64, ptr [[GEP]], align 8
-; TFNONE-NEXT:[[CALL:%.*]] = call i64 @foo(i64 [[LOAD]]) #[[ATTR3:[0-9]+]]
+; TFNONE-NEXT:[[CALL:%.*]] = call i64 @foo(i64 [[LOAD]]) #[[ATTR4:[0-9]+]]
 ; TFNONE-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i64, ptr [[A]], 
i64 [[INDVARS_IV]]
 ; TFNONE-NEXT:store i64 [[CALL]], ptr [[ARRAYIDX]], align 8
 ; TFNONE-NEXT:[[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
@@ -177,7 +177,7 @@ define void @test_if_then(ptr noalias %a, ptr readnone %b) 
#4 {
 ; TFNONE-NEXT:[[CMP:%.*]] = icmp ugt i64 [[TMP12]], 50
 ; TFNONE-NEXT:br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END]]
 ; TFNONE:   if.then:
-; TFNONE-NEXT:[[TMP13:%.*]] = call i64 @foo(i64 [[TMP12]]) #[[ATTR3]]
+; TFNONE-NEXT:[[TMP13:%.*]] = call i64 @foo(i64 [[TMP12]]) #[[ATTR4]]
 ; TFNONE-NEXT:br label [[IF_END]]
 ; TFNONE:   if.end:
 ; TFNONE-NEXT:[[TMP14:%.*]] = phi i64 [ [[TMP13]], [[IF_THEN]] ], [ 0, 
[[FOR_BODY]] ]
@@ -339,10 +339,10 @@ define void @test_widen_if_then_else(ptr noalias %a, ptr 
readnone %b) #4 {
 ; TFNONE-NEXT:[[CMP:%.*]] = icmp ugt i64 [[TMP13]], 50
 ; TFNONE-NEXT:br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
 ; TFNONE:   if.then:
-; TFNONE-NEXT:[[TMP14:%.*]] = call i64 @foo(i64 [[TMP13]]) 
#[[ATTR4:[0-9]+]]
+; TFNONE-NEXT:[[TMP14:%.*]] = call i64 @foo(i64 [[TMP13]]) 
#[[ATTR5:[0-9]+]]
 ; TFNONE-NEXT:br label [[IF_END]]
 ; TFNONE:   if.else:
-; TFNONE-NEXT:[[TMP15:%.*]] = call i64 @foo(i64 0) #[[ATTR4]]
+; TFNONE-NEXT:[[TMP15:%.*]]

[llvm-branch-commits] [llvm] b5f41cc - [LoopVectorize] Fix build error (#126218)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: David Sherwood
Date: 2025-02-07T13:28:37-08:00
New Revision: b5f41cc50c9db7e3c155e5c1e8114678baa6bce9

URL: 
https://github.com/llvm/llvm-project/commit/b5f41cc50c9db7e3c155e5c1e8114678baa6bce9
DIFF: 
https://github.com/llvm/llvm-project/commit/b5f41cc50c9db7e3c155e5c1e8114678baa6bce9.diff

LOG: [LoopVectorize] Fix build error (#126218)

Fixes issue caused by 1930524bbde3cd26ff527bbdb5e1f937f484edd6

Unused variable UsesMask in LoopVectorize.cpp

(cherry picked from commit 3872e55758a5de035c032a975f244302c3ddacc3)

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 318e4809d97eea..06c2a91f89b1c5 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6262,7 +6262,6 @@ void 
LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
 
   // Find the cost of vectorizing the call, if we can find a suitable
   // vector variant of the function.
-  bool UsesMask = false;
   VFInfo FuncInfo;
   Function *VecFunc = nullptr;
   // Search through any available variants for one we can use at this VF.
@@ -6314,7 +6313,6 @@ void 
LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
 break;
   }
   case VFParamKind::GlobalPredicate:
-UsesMask = true;
 break;
   default:
 ParamsOk = false;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [LoopVectorize] Fix cost model assert when vectorising calls (#125716) (PR #126209)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126209
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [LoopVectorize] Fix cost model assert when vectorising calls (#125716) (PR #126209)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@david-arm (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126209
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [LoopVectorize] Fix cost model assert when vectorising calls (#125716) (PR #126209)

2025-02-07 Thread Florian Hahn via llvm-branch-commits

https://github.com/fhahn approved this pull request.

LGTM, thanks

https://github.com/llvm/llvm-project/pull/126209
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [DXIL] Add support for root signature flag element in DXContainer (PR #123147)

2025-02-07 Thread via llvm-branch-commits

https://github.com/joaosaffran edited 
https://github.com/llvm/llvm-project/pull/123147
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [AArch64] Enable AvoidLDAPUR for cpu=generic between armv8.4 and armv9.3. (#125261) (PR #126253)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/126253

>From 3351e1b142a8ef097f15766e363c2ecb5b8f7e5f Mon Sep 17 00:00:00 2001
From: David Green 
Date: Fri, 7 Feb 2025 10:16:57 +
Subject: [PATCH] [AArch64] Enable AvoidLDAPUR for cpu=generic between armv8.4
 and armv9.3. (#125261)

As added in #124274, CPUs in this range can suffer from performance
issues with ldapur. As the gain from ldar->ldapr is expected to be
greater than the minor gain from ldapr->ldapur, this opts to avoid the
instruction under the default -mcpu=generic when the -march is less that
armv8.8 / armv9.3.

I renamed AArch64Subtarget::Others to AArch64Subtarget::Generic to be
clearer what it means.

(cherry picked from commit 6424abcd6c9c6aa8171c79d0fe0369d3a10da3d5)
---
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp   | 7 ++-
 llvm/lib/Target/AArch64/AArch64Subtarget.h | 4 ++--
 llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp | 2 +-
 .../AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll   | 7 +--
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp 
b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
index bc921f07e1dbf89..809e658e6538017 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -125,7 +125,12 @@ void AArch64Subtarget::initializeProperties(bool 
HasMinSize) {
   // this in the future so we can specify it together with the subtarget
   // features.
   switch (ARMProcFamily) {
-  case Others:
+  case Generic:
+// Using TuneCPU=generic we avoid ldapur instructions to line up with the
+// cpus that use the AvoidLDAPUR feature. We don't want this to be on
+// forever, so it is enabled between armv8.4 and armv8.7/armv9.2.
+if (hasV8_4aOps() && !hasV8_8aOps())
+  AvoidLDAPUR = true;
 break;
   case Carmel:
 CacheLineSize = 64;
diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.h 
b/llvm/lib/Target/AArch64/AArch64Subtarget.h
index d22991224d496d9..dca5f5393fe47b3 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -38,7 +38,7 @@ class Triple;
 class AArch64Subtarget final : public AArch64GenSubtargetInfo {
 public:
   enum ARMProcFamilyEnum : uint8_t {
-Others,
+Generic,
 #define ARM_PROCESSOR_FAMILY(ENUM) ENUM,
 #include "llvm/TargetParser/AArch64TargetParserDef.inc"
 #undef ARM_PROCESSOR_FAMILY
@@ -46,7 +46,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo 
{
 
 protected:
   /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
-  ARMProcFamilyEnum ARMProcFamily = Others;
+  ARMProcFamilyEnum ARMProcFamily = Generic;
 
   // Enable 64-bit vectorization in SLP.
   unsigned MinVectorRegisterBitWidth = 64;
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index 4af3c482e65984b..cd994d53a60088f 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -4272,7 +4272,7 @@ void AArch64TTIImpl::getUnrollingPreferences(Loop *L, 
ScalarEvolution &SE,
   // If mcpu is omitted, getProcFamily() returns AArch64Subtarget::Others, so 
by
   // checking for that case, we can ensure that the default behaviour is
   // unchanged
-  if (ST->getProcFamily() != AArch64Subtarget::Others &&
+  if (ST->getProcFamily() != AArch64Subtarget::Generic &&
   !ST->getSchedModel().isOutOfOrder()) {
 UP.Runtime = true;
 UP.Partial = true;
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll 
b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll
index b475e68db411a42..02ff12c27fcda9d 100644
--- a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-rcpc_immo.ll
@@ -1,12 +1,15 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --filter-out "(?!^\s*lda.*\bsp\b)^\s*.*\bsp\b" --filter 
"^\s*(ld|st[^r]|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
-; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+v8.4a 
-mattr=+rcpc-immo -global-isel=true -global-isel-abort=2 -O0 | FileCheck %s 
--check-prefixes=CHECK,GISEL
-; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+v8.4a 
-mattr=+rcpc-immo -global-isel=false -O1 | FileCheck %s 
--check-prefixes=CHECK,SDAG,SDAG-NOAVOIDLDAPUR
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+v8.8a 
-mattr=+rcpc-immo -global-isel=true -global-isel-abort=2 -O0 | FileCheck %s 
--check-prefixes=CHECK,GISEL
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+v8.4a 
-mattr=+rcpc-immo -global-isel=false -O1 | FileCheck %s 
--check-prefixes=CHECK,SDAG,SDAG-AVOIDLDAPUR
 ; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+

[llvm-branch-commits] [clang] [HLSL] Define the HLSLRootSignature Attr (PR #123985)

2025-02-07 Thread Finn Plummer via llvm-branch-commits

https://github.com/inbelic updated 
https://github.com/llvm/llvm-project/pull/123985

>From 05c9523adaf9cc3e1585c02bed036ad83667b722 Mon Sep 17 00:00:00 2001
From: Finn Plummer 
Date: Wed, 22 Jan 2025 17:53:59 +
Subject: [PATCH 1/6] [HLSL] Define the HLSLRootSignature Attr

- Defines HLSLRootSignature Attr in `Attr.td`
- Define and implement handleHLSLRootSignature in `SemaHLSL`
- Adds sample test case to show AST Node is generated in
`RootSignatures-AST.hlsl`

This commit will "hook-up" the seperately defined RootSignature parser
and invoke it to create the RootElements, then store them on the
ASTContext and finally store the reference to the Elements in
RootSignatureAttr
---
 clang/include/clang/AST/Attr.h  |  1 +
 clang/include/clang/Basic/Attr.td   | 20 
 clang/include/clang/Basic/AttrDocs.td   |  4 +++
 clang/include/clang/Sema/SemaHLSL.h |  1 +
 clang/lib/Sema/SemaDeclAttr.cpp |  3 ++
 clang/lib/Sema/SemaHLSL.cpp | 36 +
 clang/test/AST/HLSL/RootSignatures-AST.hlsl | 28 
 7 files changed, 93 insertions(+)
 create mode 100644 clang/test/AST/HLSL/RootSignatures-AST.hlsl

diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 3365ebe4d9012be..d45b8891cf1a72a 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -26,6 +26,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Support/Compiler.h"
 #include "llvm/Frontend/HLSL/HLSLResource.h"
+#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/VersionTuple.h"
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52ad72eb608c319..36ae98730db031c 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4643,6 +4643,26 @@ def Error : InheritableAttr {
   let Documentation = [ErrorAttrDocs];
 }
 
+/// HLSL Root Signature Attribute
+def HLSLRootSignature : Attr {
+  /// [RootSignature(Signature)]
+  let Spellings = [Microsoft<"RootSignature">];
+  let Args = [StringArgument<"Signature">];
+  let Subjects = SubjectList<[Function],
+ ErrorDiag, "'function'">;
+  let LangOpts = [HLSL];
+  let Documentation = [HLSLRootSignatureDocs];
+  let AdditionalMembers = [{
+private:
+  ArrayRef RootElements;
+public:
+  void setElements(ArrayRef Elements) 
{
+RootElements = Elements;
+  }
+  auto getElements() const { return RootElements; }
+}];
+}
+
 def HLSLNumThreads: InheritableAttr {
   let Spellings = [Microsoft<"numthreads">];
   let Args = [IntArgument<"X">, IntArgument<"Y">, IntArgument<"Z">];
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index fdad4c9a3ea1910..bb0934a11f9f3f0 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7783,6 +7783,10 @@ and 
https://microsoft.github.io/hlsl-specs/proposals/0013-wave-size-range.html
   }];
 }
 
+def HLSLRootSignatureDocs : Documentation {
+  let Category = DocCatUndocumented;
+}
+
 def NumThreadsDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
diff --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
index f4cd11f423a84a0..df4a5c8d88ba9e2 100644
--- a/clang/include/clang/Sema/SemaHLSL.h
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -116,6 +116,7 @@ class SemaHLSL : public SemaBase {
bool IsCompAssign);
   void emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS, BinaryOperatorKind Opc);
 
+  void handleRootSignatureAttr(Decl *D, const ParsedAttr &AL);
   void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL);
   void handleWaveSizeAttr(Decl *D, const ParsedAttr &AL);
   void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL);
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index bb4d33560b93b8d..c594d6e54ddbcd2 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7149,6 +7149,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
 break;
 
   // HLSL attributes:
+  case ParsedAttr::AT_HLSLRootSignature:
+S.HLSL().handleRootSignatureAttr(D, AL);
+break;
   case ParsedAttr::AT_HLSLNumThreads:
 S.HLSL().handleNumThreadsAttr(D, AL);
 break;
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 600c800029fd05a..ab8aa6f5a351be6 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -24,6 +24,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Parse/ParseHLSLRootSignature.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/ParsedAttr.h"
 #include "clang/Sema/Sema.h"
@@ -647,6 +648,41 @@ void SemaHLSL::emitLogicalOperatorFi

[llvm-branch-commits] [mlir] [mlir][cmake] Fix build race condition in Pass Manager tests (PR #125834)

2025-02-07 Thread Nikita Popov via llvm-branch-commits

https://github.com/nikic approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/125834
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments (PR #126147)

2025-02-07 Thread Scott Linder via llvm-branch-commits


@@ -1,7 +1,7 @@
-; RUN: not --crash opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 
-passes='amdgpu-attributor,function(amdgpu-lower-kernel-arguments)' 
-amdgpu-kernarg-preload-count=16 -S < %s 2>&1 | FileCheck %s
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 
-passes='amdgpu-attributor,function(amdgpu-lower-kernel-arguments)' 
-amdgpu-kernarg-preload-count=16 -S < %s 2>&1 | FileCheck %s
 
-; CHECK: function declaration may only have a unique !dbg attachment
-; CHECK-NEXT: ptr @0
+; CHECK: define amdgpu_kernel void @preload_block_count_x{{.*}} !dbg ![[#]]
+; CHECK-NOT: declare void @0{{.*}} !dbg ![[#]]

slinder1 wrote:

Do you happen to know of how to get generated checks to include an unreferenced 
declare? I suppose in general some extra declares are benign, but in this case 
it is the primary thing being tested.

I've tried `update_test_checks.py --check-globals all 
--include-generated-funcs` but no luck

https://github.com/llvm/llvm-project/pull/126147
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU] Push amdgpu-preload-kern-arg-prolog after livedebugvalues (PR #126148)

2025-02-07 Thread Austin Kerbow via llvm-branch-commits

https://github.com/kerbowa approved this pull request.

This LGTM but I think previous PR in stack should be obsolete after #123547

https://github.com/llvm/llvm-project/pull/126148
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: workflows/premerge: Move concurrency definition to workflow level (#126308) (PR #126310)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/126310
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: workflows/premerge: Move concurrency definition to workflow level (#126308) (PR #126310)

2025-02-07 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-github-workflow

Author: None (llvmbot)


Changes

Backport 6e5988863177e1d53e7a7abb7a3db2b85376f0f5

Requested by: @tstellar

---
Full diff: https://github.com/llvm/llvm-project/pull/126310.diff


1 Files Affected:

- (modified) .github/workflows/premerge.yaml (+4-9) 


``diff
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 45e6bb763a0efae..9b6a1236823d7ed 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -19,15 +19,16 @@ on:
   - 'main'
   - 'release/**'
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || 
github.sha }}
+  cancel-in-progress: true
+
 jobs:
   premerge-checks-linux:
 if: >-
 false && github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
 runs-on: llvm-premerge-linux-runners
-concurrency:
-  group: ${{ github.workflow }}-linux-${{ github.event.pull_request.number 
|| github.sha }}
-  cancel-in-progress: true
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@v4
@@ -86,9 +87,6 @@ jobs:
 false && github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
 runs-on: llvm-premerge-windows-runners
-concurrency:
-  group: ${{ github.workflow }}-windows-${{ 
github.event.pull_request.number || github.sha }}
-  cancel-in-progress: true
 defaults:
   run:
 shell: bash
@@ -146,9 +144,6 @@ jobs:
 
   permerge-check-macos:
 runs-on: macos-14
-concurrency:
-  group: ${{ github.workflow }}-macos-${{ github.event.pull_request.number 
|| github.sha }}
-  cancel-in-progress: true
 if: >-
   github.repository_owner == 'llvm' &&
   (startswith(github.ref_name, 'release/') ||

``




https://github.com/llvm/llvm-project/pull/126310
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [mlir] [MLIR][OpenMP] Add OMP Mapper field to MapInfoOp (PR #120994)

2025-02-07 Thread Akash Banerjee via llvm-branch-commits

https://github.com/TIFitis updated 
https://github.com/llvm/llvm-project/pull/120994

>From f7c3a6505a3affa159b178852c67cff5739f2c26 Mon Sep 17 00:00:00 2001
From: Akash Banerjee 
Date: Mon, 23 Dec 2024 20:53:47 +
Subject: [PATCH 1/2] Add mapper field to mapInfoOp.

---
 flang/lib/Lower/OpenMP/Utils.cpp| 3 ++-
 flang/lib/Lower/OpenMP/Utils.h  | 3 ++-
 flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp  | 5 -
 flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp | 1 +
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td   | 2 ++
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp| 2 +-
 mlir/test/Dialect/OpenMP/ops.mlir   | 4 ++--
 7 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index 35722fa7d1b1206..fa1975dac789b12 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -125,7 +125,7 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location 
loc,
 llvm::ArrayRef members,
 mlir::ArrayAttr membersIndex, uint64_t mapType,
 mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type 
retTy,
-bool partialMap) {
+bool partialMap, mlir::FlatSymbolRefAttr mapperId) {
   if (auto boxTy = llvm::dyn_cast(baseAddr.getType())) {
 baseAddr = builder.create(loc, baseAddr);
 retTy = baseAddr.getType();
@@ -144,6 +144,7 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location 
loc,
   mlir::omp::MapInfoOp op = builder.create(
   loc, retTy, baseAddr, varType, varPtrPtr, members, membersIndex, bounds,
   builder.getIntegerAttr(builder.getIntegerType(64, false), mapType),
+  mapperId,
   builder.getAttr(mapCaptureType),
   builder.getStringAttr(name), builder.getBoolAttr(partialMap));
   return op;
diff --git a/flang/lib/Lower/OpenMP/Utils.h b/flang/lib/Lower/OpenMP/Utils.h
index f2e378443e5f295..3943eb633b04e36 100644
--- a/flang/lib/Lower/OpenMP/Utils.h
+++ b/flang/lib/Lower/OpenMP/Utils.h
@@ -116,7 +116,8 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location 
loc,
 llvm::ArrayRef members,
 mlir::ArrayAttr membersIndex, uint64_t mapType,
 mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type 
retTy,
-bool partialMap = false);
+bool partialMap = false,
+mlir::FlatSymbolRefAttr mapperId = mlir::FlatSymbolRefAttr());
 
 void insertChildMapInfoIntoParent(
 Fortran::lower::AbstractConverter &converter,
diff --git a/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp 
b/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
index e7c1d1d9d560f87..beea7543e54b324 100644
--- a/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
+++ b/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
@@ -184,6 +184,7 @@ class MapInfoFinalizationPass
 /*members=*/mlir::SmallVector{},
 /*membersIndex=*/mlir::ArrayAttr{}, bounds,
 builder.getIntegerAttr(builder.getIntegerType(64, false), mapType),
+/*mapperId*/ mlir::FlatSymbolRefAttr(),
 builder.getAttr(
 mlir::omp::VariableCaptureKind::ByRef),
 /*name=*/builder.getStringAttr(""),
@@ -329,7 +330,8 @@ class MapInfoFinalizationPass
 builder.getIntegerAttr(
 builder.getIntegerType(64, false),
 getDescriptorMapType(op.getMapType().value_or(0), target)),
-op.getMapCaptureTypeAttr(), op.getNameAttr(),
+/*mapperId*/ mlir::FlatSymbolRefAttr(), op.getMapCaptureTypeAttr(),
+op.getNameAttr(),
 /*partial_map=*/builder.getBoolAttr(false));
 op.replaceAllUsesWith(newDescParentMapOp.getResult());
 op->erase();
@@ -623,6 +625,7 @@ class MapInfoFinalizationPass
   /*members=*/mlir::ValueRange{},
   /*members_index=*/mlir::ArrayAttr{},
   /*bounds=*/bounds, op.getMapTypeAttr(),
+  /*mapperId*/ mlir::FlatSymbolRefAttr(),
   builder.getAttr(
   mlir::omp::VariableCaptureKind::ByRef),
   builder.getStringAttr(op.getNameAttr().strref() + "." +
diff --git a/flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp 
b/flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp
index 963ae863c1fc5cb..97ea463a3c495df 100644
--- a/flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp
+++ b/flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp
@@ -91,6 +91,7 @@ class MapsForPrivatizedSymbolsPass
 /*bounds=*/ValueRange{},
 builder.getIntegerAttr(builder.getIntegerType(64, /*isSigned=*/false),
mapTypeTo),
+/*mapperId*/ mlir::FlatSymbolRefAttr(),
 builder.getAttr(
 omp::VariableCaptureKind::ByRef),
 StringAttr(), builder.getBoolAttr(false));
diff --git a/ml

[llvm-branch-commits] [flang] [MLIR][OpenMP] Add Lowering support for OpenMP custom mappers in map clause (PR #121001)

2025-02-07 Thread Akash Banerjee via llvm-branch-commits

https://github.com/TIFitis updated 
https://github.com/llvm/llvm-project/pull/121001

>From 64e17c3992cc89aa02148b2b0e9319552a9ca63f Mon Sep 17 00:00:00 2001
From: Akash Banerjee 
Date: Mon, 23 Dec 2024 21:13:42 +
Subject: [PATCH 1/3] Add flang lowering changes for mapper field in map
 clause.

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp  | 32 +
 flang/lib/Lower/OpenMP/ClauseProcessor.h|  3 +-
 flang/test/Lower/OpenMP/Todo/map-mapper.f90 | 16 ---
 flang/test/Lower/OpenMP/map-mapper.f90  | 23 +++
 4 files changed, 52 insertions(+), 22 deletions(-)
 delete mode 100644 flang/test/Lower/OpenMP/Todo/map-mapper.f90
 create mode 100644 flang/test/Lower/OpenMP/map-mapper.f90

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index febc6adcf9d6ff4..467a0dcebf2b8a9 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -969,8 +969,10 @@ void ClauseProcessor::processMapObjects(
 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
 std::map &parentMemberIndices,
 llvm::SmallVectorImpl &mapVars,
-llvm::SmallVectorImpl &mapSyms) const {
+llvm::SmallVectorImpl &mapSyms,
+std::string mapperIdName) const {
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
+  mlir::FlatSymbolRefAttr mapperId;
 
   for (const omp::Object &object : objects) {
 llvm::SmallVector bounds;
@@ -1003,6 +1005,20 @@ void ClauseProcessor::processMapObjects(
   }
 }
 
+if (!mapperIdName.empty()) {
+  if (mapperIdName == "default") {
+auto &typeSpec = object.sym()->owner().IsDerivedType()
+ ? *object.sym()->owner().derivedTypeSpec()
+ : object.sym()->GetType()->derivedTypeSpec();
+mapperIdName = typeSpec.name().ToString() + ".default";
+mapperIdName = converter.mangleName(mapperIdName, 
*typeSpec.GetScope());
+  }
+  assert(converter.getMLIRSymbolTable()->lookup(mapperIdName) &&
+ "mapper not found");
+  mapperId = mlir::FlatSymbolRefAttr::get(&converter.getMLIRContext(),
+  mapperIdName);
+  mapperIdName.clear();
+}
 // Explicit map captures are captured ByRef by default,
 // optimisation passes may alter this to ByCopy or other capture
 // types to optimise
@@ -1016,7 +1032,8 @@ void ClauseProcessor::processMapObjects(
 static_cast<
 std::underlying_type_t>(
 mapTypeBits),
-mlir::omp::VariableCaptureKind::ByRef, baseOp.getType());
+mlir::omp::VariableCaptureKind::ByRef, baseOp.getType(), false,
+mapperId);
 
 if (parentObj.has_value()) {
   parentMemberIndices[parentObj.value()].addChildIndexAndMapToParent(
@@ -1047,6 +1064,7 @@ bool ClauseProcessor::processMap(
 const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t;
 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
+std::string mapperIdName;
 // If the map type is specified, then process it else Tofrom is the
 // default.
 Map::MapType type = mapType.value_or(Map::MapType::Tofrom);
@@ -1090,13 +1108,17 @@ bool ClauseProcessor::processMap(
"Support for iterator modifiers is not implemented yet");
 }
 if (mappers) {
-  TODO(currentLocation,
-   "Support for mapper modifiers is not implemented yet");
+  assert(mappers->size() == 1 && "more than one mapper");
+  mapperIdName = mappers->front().v.id().symbol->name().ToString();
+  if (mapperIdName != "default")
+mapperIdName = converter.mangleName(
+mapperIdName, mappers->front().v.id().symbol->owner());
 }
 
 processMapObjects(stmtCtx, clauseLocation,
   std::get(clause.t), mapTypeBits,
-  parentMemberIndices, result.mapVars, *ptrMapSyms);
+  parentMemberIndices, result.mapVars, *ptrMapSyms,
+  mapperIdName);
   };
 
   bool clauseFound = findRepeatableClause(process);
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index e05f66c7666844f..2b319e890a5adbe 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -175,7 +175,8 @@ class ClauseProcessor {
   llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
   std::map &parentMemberIndices,
   llvm::SmallVectorImpl &mapVars,
-  llvm::SmallVectorImpl &mapSyms) const;
+  llvm::SmallVectorImpl &mapSyms,
+  std::string mapperIdName = "") const;
 
   lower::AbstractConverter &converter;
   semantics::SemanticsContext &semaCtx;
diff --git a/flang/test/Lower/OpenMP/Todo/map-mapper.f90 
b/flang/test/Lower/OpenMP/Todo/map-mapper.f90
deleted file mode 100644
index 9554ffd5fda7bdd..000
--- a/fla

[llvm-branch-commits] [flang] [mlir] [MLIR][OpenMP] Add conversion support from FIR to LLVM Dialect for OMP DeclareMapper (PR #121005)

2025-02-07 Thread Akash Banerjee via llvm-branch-commits

https://github.com/TIFitis updated 
https://github.com/llvm/llvm-project/pull/121005

>From c993ac570b1788867be44690f87cf8ccafb97534 Mon Sep 17 00:00:00 2001
From: Akash Banerjee 
Date: Mon, 23 Dec 2024 21:50:03 +
Subject: [PATCH 1/2] Add OpenMP to LLVM dialect conversion support for
 DeclareMapperOp.

---
 .../Fir/convert-to-llvm-openmp-and-fir.fir| 27 +--
 .../Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp  | 48 +++
 .../OpenMPToLLVM/convert-to-llvmir.mlir   | 13 +
 3 files changed, 74 insertions(+), 14 deletions(-)

diff --git a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir 
b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
index 8e4e1fe824d9f5b..82f2aea3ad983c9 100644
--- a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
+++ b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
@@ -936,9 +936,9 @@ func.func @omp_map_info_descriptor_type_conversion(%arg0 : 
!fir.ref>, i32) 
map_clauses(tofrom) capture(ByRef) -> !fir.llvm_ptr> {name = ""}
   // CHECK: %[[DESC_MAP:.*]] = omp.map.info var_ptr(%[[ARG_0]] : !llvm.ptr, 
!llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>) map_clauses(always, delete) 
capture(ByRef) members(%[[MEMBER_MAP]] : [0] : !llvm.ptr) -> !llvm.ptr {name = 
""}
   %2 = omp.map.info var_ptr(%arg0 : !fir.ref>>, 
!fir.box>) map_clauses(always, delete) capture(ByRef) members(%1 
: [0] : !fir.llvm_ptr>) -> !fir.ref>> 
{name = ""}
-  // CHECK: omp.target_exit_data map_entries(%[[DESC_MAP]] : !llvm.ptr) 
+  // CHECK: omp.target_exit_data map_entries(%[[DESC_MAP]] : !llvm.ptr)
   omp.target_exit_data   map_entries(%2 : !fir.ref>>)
-  return 
+  return
 }
 
 // -
@@ -956,8 +956,8 @@ func.func 
@omp_map_info_derived_type_explicit_member_conversion(%arg0 : !fir.ref
   %3 = fir.field_index real, 
!fir.type<_QFderived_type{real:f32,array:!fir.array<10xi32>,int:i32}>
   %4 = fir.coordinate_of %arg0, %3 : 
(!fir.ref,int:i32}>>,
 !fir.field) -> !fir.ref
   // CHECK: %[[MAP_MEMBER_2:.*]] = omp.map.info var_ptr(%[[GEP_2]] : 
!llvm.ptr, f32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = 
"dtype%real"}
-  %5 = omp.map.info var_ptr(%4 : !fir.ref, f32) map_clauses(tofrom) 
capture(ByRef) -> !fir.ref {name = "dtype%real"}
-  // CHECK: %[[MAP_PARENT:.*]] = omp.map.info var_ptr(%[[ARG_0]] : !llvm.ptr, 
!llvm.struct<"_QFderived_type", (f32, array<10 x i32>, i32)>) 
map_clauses(tofrom) capture(ByRef) members(%[[MAP_MEMBER_1]], %[[MAP_MEMBER_2]] 
: [2], [0] : !llvm.ptr, !llvm.ptr) -> !llvm.ptr {name = "dtype", partial_map = 
true} 
+  %5 = omp.map.info var_ptr(%4 : !fir.ref, f32) map_clauses(tofrom) 
capture(ByRef) -> !fir.ref {name = "dtype%real"}
+  // CHECK: %[[MAP_PARENT:.*]] = omp.map.info var_ptr(%[[ARG_0]] : !llvm.ptr, 
!llvm.struct<"_QFderived_type", (f32, array<10 x i32>, i32)>) 
map_clauses(tofrom) capture(ByRef) members(%[[MAP_MEMBER_1]], %[[MAP_MEMBER_2]] 
: [2], [0] : !llvm.ptr, !llvm.ptr) -> !llvm.ptr {name = "dtype", partial_map = 
true}
   %6 = omp.map.info var_ptr(%arg0 : 
!fir.ref,int:i32}>>,
 !fir.type<_QFderived_type{real:f32,array:!fir.array<10xi32>,int:i32}>) 
map_clauses(tofrom) capture(ByRef) members(%2, %5 : [2], [0] : !fir.ref, 
!fir.ref) -> 
!fir.ref,int:i32}>> 
{name = "dtype", partial_map = true}
   // CHECK: omp.target map_entries(%[[MAP_MEMBER_1]] -> %[[ARG_1:.*]], 
%[[MAP_MEMBER_2]] -> %[[ARG_2:.*]], %[[MAP_PARENT]] -> %[[ARG_3:.*]] : 
!llvm.ptr, !llvm.ptr, !llvm.ptr) {
   omp.target map_entries(%2 -> %arg1, %5 -> %arg2, %6 -> %arg3 : 
!fir.ref, !fir.ref, 
!fir.ref,int:i32}>>)
 {
@@ -1275,3 +1275,22 @@ func.func @map_nested_dtype_alloca_mem2(%arg0 : 
!fir.ref {
+omp.declare_mapper @my_mapper : !fir.type<_QFdeclare_mapperTmy_type{data:i32}> 
{
+// CHECK: ^bb0(%[[VAL_0:.*]]: !llvm.ptr):
+^bb0(%0: !fir.ref>):
+// CHECK:   %[[VAL_1:.*]] = llvm.mlir.constant(0 : i32) : i32
+  %1 = fir.field_index data, !fir.type<_QFdeclare_mapperTmy_type{data:i32}>
+// CHECK:   %[[VAL_2:.*]] = llvm.getelementptr %[[VAL_0]][0, 0] : 
(!llvm.ptr) -> !llvm.ptr, !llvm.struct<"_QFdeclare_mapperTmy_type", (i32)>
+  %2 = fir.coordinate_of %0, %1 : 
(!fir.ref>, !fir.field) -> 
!fir.ref
+// CHECK:   %[[VAL_3:.*]] = omp.map.info var_ptr(%[[VAL_2]] : 
!llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = 
"var%[[VAL_4:.*]]"}
+  %3 = omp.map.info var_ptr(%2 : !fir.ref, i32) map_clauses(tofrom) 
capture(ByRef) -> !fir.ref {name = "var%data"}
+// CHECK:   %[[VAL_5:.*]] = omp.map.info var_ptr(%[[VAL_0]] : 
!llvm.ptr, !llvm.struct<"_QFdeclare_mapperTmy_type", (i32)>) 
map_clauses(tofrom) capture(ByRef) members(%[[VAL_3]] : [0] : !llvm.ptr) -> 
!llvm.ptr {name = "var", partial_map = true}
+  %4 = omp.map.info var_ptr(%0 : 
!fir.ref>, 
!fir.type<_QFdeclare_mapperTmy_type{data:i32}>) map_clauses(tofrom) 
capture(ByRef) members(%3 : [0] : !fir.ref) -> 
!fir.ref> {name = "var", 
partial_map = true}
+// CHECK:   omp.declare_mapper_info map_entries(%[[VAL_5]], %[[VAL_3]] 
: !llvm.ptr, !llvm.ptr)
+  omp.declare_m

[llvm-branch-commits] [clang] [llvm] [mlir] [MLIR][OpenMP] Add LLVM translation support for OpenMP UserDefinedMappers (PR #124746)

2025-02-07 Thread Akash Banerjee via llvm-branch-commits

https://github.com/TIFitis updated 
https://github.com/llvm/llvm-project/pull/124746

>From d80da54e1edee017f97aebf5f2e17895ddbf6413 Mon Sep 17 00:00:00 2001
From: Akash Banerjee 
Date: Tue, 28 Jan 2025 13:38:13 +
Subject: [PATCH 1/4] [MLIR][OpenMP] Add LLVM translation support for OpenMP
 UserDefinedMappers

This patch adds OpenMPToLLVMIRTranslation support for the OpenMP Declare Mapper 
directive.

Since both MLIR and Clang now support custom mappers, I've made the relative 
params required instead of optional as well.

Depends on #121005
---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp |  11 +-
 .../llvm/Frontend/OpenMP/OMPIRBuilder.h   |  31 +--
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp |  70 +++---
 .../Frontend/OpenMPIRBuilderTest.cpp  |  46 ++--
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  | 215 +++---
 mlir/test/Target/LLVMIR/omptarget-llvm.mlir   | 117 ++
 .../fortran/target-custom-mapper.f90  |  46 
 7 files changed, 437 insertions(+), 99 deletions(-)
 create mode 100644 offload/test/offloading/fortran/target-custom-mapper.f90

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index cafaaa364cb7630..b919c1f6ac62760 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8889,8 +8889,8 @@ static void emitOffloadingArraysAndArgs(
 return MFunc;
   };
   OMPBuilder.emitOffloadingArraysAndArgs(
-  AllocaIP, CodeGenIP, Info, Info.RTArgs, CombinedInfo, IsNonContiguous,
-  ForEndCall, DeviceAddrCB, CustomMapperCB);
+  AllocaIP, CodeGenIP, Info, Info.RTArgs, CombinedInfo, CustomMapperCB,
+  IsNonContiguous, ForEndCall, DeviceAddrCB);
 }
 
 /// Check for inner distribute directive.
@@ -9099,9 +9099,10 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const 
OMPDeclareMapperDecl *D,
   CGM.getCXXABI().getMangleContext().mangleCanonicalTypeName(Ty, Out);
   std::string Name = getName({"omp_mapper", TyStr, D->getName()});
 
-  auto *NewFn = OMPBuilder.emitUserDefinedMapper(PrivatizeAndGenMapInfoCB,
- ElemTy, Name, CustomMapperCB);
-  UDMMap.try_emplace(D, NewFn);
+  llvm::Expected NewFn = OMPBuilder.emitUserDefinedMapper(
+  PrivatizeAndGenMapInfoCB, ElemTy, Name, CustomMapperCB);
+  assert(NewFn && "Unexpected error in emitUserDefinedMapper");
+  UDMMap.try_emplace(D, *NewFn);
   if (CGF)
 FunctionUDMMap[CGF->CurFn].push_back(D);
 }
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index d25077cae63e42b..151bd36aadaf0a4 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -2399,6 +2399,7 @@ class OpenMPIRBuilder {
CurInfo.NonContigInfo.Strides.end());
 }
   };
+  using MapInfosOrErrorTy = Expected;
 
   /// Callback function type for functions emitting the host fallback code that
   /// is executed when the kernel launch fails. It takes an insertion point as
@@ -2475,9 +2476,9 @@ class OpenMPIRBuilder {
   /// including base pointers, pointers, sizes, map types, user-defined 
mappers.
   void emitOffloadingArrays(
   InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy 
&CombinedInfo,
-  TargetDataInfo &Info, bool IsNonContiguous = false,
-  function_ref DeviceAddrCB = nullptr,
-  function_ref CustomMapperCB = nullptr);
+  TargetDataInfo &Info, function_ref CustomMapperCB,
+  bool IsNonContiguous = false,
+  function_ref DeviceAddrCB = nullptr);
 
   /// Allocates memory for and populates the arrays required for offloading
   /// (offload_{baseptrs|ptrs|mappers|sizes|maptypes|mapnames}). Then, it
@@ -2488,9 +2489,9 @@ class OpenMPIRBuilder {
   void emitOffloadingArraysAndArgs(
   InsertPointTy AllocaIP, InsertPointTy CodeGenIP, TargetDataInfo &Info,
   TargetDataRTArgs &RTArgs, MapInfosTy &CombinedInfo,
+  function_ref CustomMapperCB,
   bool IsNonContiguous = false, bool ForEndCall = false,
-  function_ref DeviceAddrCB = nullptr,
-  function_ref CustomMapperCB = nullptr);
+  function_ref DeviceAddrCB = nullptr);
 
   /// Creates offloading entry for the provided entry ID \a ID, address \a
   /// Addr, size \a Size, and flags \a Flags.
@@ -2950,12 +2951,12 @@ class OpenMPIRBuilder {
   /// \param FuncName Optional param to specify mapper function name.
   /// \param CustomMapperCB Optional callback to generate code related to
   /// custom mappers.
-  Function *emitUserDefinedMapper(
-  function_ref
+  Expected emitUserDefinedMapper(
+  function_ref
   PrivAndGenMapInfoCB,
   llvm::Type *ElemTy, StringRef FuncName,
-  function_ref CustomMapperCB = nullptr);
+  function_ref CustomMapperCB);
 
   /// Generator for '#omp target data'
   ///
@@ -2969,21 +2970,21 @@ class OpenMPIRBuilder {
   /// \param IfCond Value which corresponds to the i

[llvm-branch-commits] [libc] release/20.x: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193) (PR #126284)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126284
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] 3a3a323 - fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193)

2025-02-07 Thread via llvm-branch-commits

Author: s.vgys
Date: 2025-02-07T18:27:18Z
New Revision: 3a3a3230d171e11842a9940b6da0f72022b1c5b3

URL: 
https://github.com/llvm/llvm-project/commit/3a3a3230d171e11842a9940b6da0f72022b1c5b3
DIFF: 
https://github.com/llvm/llvm-project/commit/3a3a3230d171e11842a9940b6da0f72022b1c5b3.diff

LOG: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace 
(#126193)

Resolves #125831

(cherry picked from commit 51759ffc4408e9eb5c2d40c9489ce3b98de233d5)

Added: 


Modified: 
libc/CMakeLists.txt

Removed: 




diff  --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index c061e2a05ebd8f5..1c4c0cd5aa22ba7 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -51,7 +51,8 @@ set(LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to 
Linux kernel header
 # Defining a global namespace to enclose all libc functions.
 set(default_namespace "__llvm_libc")
 if(LLVM_VERSION_MAJOR)
-  set(default_namespace 
"__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${LLVM_VERSION_SUFFIX}")
+  string(REPLACE "-" "" NS_LLVM_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
+  set(default_namespace 
"__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${NS_LLVM_VERSION_SUFFIX}")
 endif()
 set(LIBC_NAMESPACE ${default_namespace}
   CACHE STRING "The namespace to use to enclose internal implementations. Must 
start with '__llvm_libc'."



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] release/20.x: fix: removes invalid token from LLVM_VERSION_SUFFIX in LIBC namespace (#126193) (PR #126284)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@jhuber6 (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126284
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang] Stop parsing warning suppression mappings in driver (#125722) (PR #126027)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/126027

>From 4cde428de0fe9f16d6c2d8fdbe501aa701c9c6ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?kadir=20=C3=A7etinkaya?= 
Date: Thu, 6 Feb 2025 10:02:42 +0100
Subject: [PATCH] [clang] Stop parsing warning suppression mappings in driver
 (#125722)

This gets rid of some extra IO from driver startup, and possiblity of
emitting warnings twice.

(cherry picked from commit df22bbe2beb57687c76402bc0cfdf7901a31cf29)
---
 .../test/Driver/warning-suppression-mappings-not-parsed.cpp  | 5 +
 clang/tools/driver/driver.cpp| 4 
 2 files changed, 9 insertions(+)
 create mode 100644 
clang/test/Driver/warning-suppression-mappings-not-parsed.cpp

diff --git a/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp 
b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp
new file mode 100644
index 000..8f52fb1c6cc7d6c
--- /dev/null
+++ b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: echo '[unknown-warning]' > %t/foo.txt
+// RUN: %clang -fdriver-only --warning-suppression-mappings=%t/foo.txt %s | 
FileCheck -allow-empty %s
+// CHECK-NOT: unknown warning option 'unknown-warning'
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 74923247b7ee169..00c00cea16f470f 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -318,6 +318,10 @@ int clang_main(int Argc, char **Argv, const 
llvm::ToolContext &ToolContext) {
 
   IntrusiveRefCntPtr DiagOpts =
   CreateAndPopulateDiagOpts(Args);
+  // Driver's diagnostics don't use suppression mappings, so don't bother
+  // parsing them. CC1 still receives full args, so this doesn't impact other
+  // actions.
+  DiagOpts->DiagnosticSuppressionMappingsFile.clear();
 
   TextDiagnosticPrinter *DiagClient
 = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 4cde428 - [clang] Stop parsing warning suppression mappings in driver (#125722)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: kadir çetinkaya
Date: 2025-02-07T12:49:40-08:00
New Revision: 4cde428de0fe9f16d6c2d8fdbe501aa701c9c6ea

URL: 
https://github.com/llvm/llvm-project/commit/4cde428de0fe9f16d6c2d8fdbe501aa701c9c6ea
DIFF: 
https://github.com/llvm/llvm-project/commit/4cde428de0fe9f16d6c2d8fdbe501aa701c9c6ea.diff

LOG: [clang] Stop parsing warning suppression mappings in driver (#125722)

This gets rid of some extra IO from driver startup, and possiblity of
emitting warnings twice.

(cherry picked from commit df22bbe2beb57687c76402bc0cfdf7901a31cf29)

Added: 
clang/test/Driver/warning-suppression-mappings-not-parsed.cpp

Modified: 
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp 
b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp
new file mode 100644
index 000..8f52fb1c6cc7d6c
--- /dev/null
+++ b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: echo '[unknown-warning]' > %t/foo.txt
+// RUN: %clang -fdriver-only --warning-suppression-mappings=%t/foo.txt %s | 
FileCheck -allow-empty %s
+// CHECK-NOT: unknown warning option 'unknown-warning'

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 74923247b7ee169..00c00cea16f470f 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -318,6 +318,10 @@ int clang_main(int Argc, char **Argv, const 
llvm::ToolContext &ToolContext) {
 
   IntrusiveRefCntPtr DiagOpts =
   CreateAndPopulateDiagOpts(Args);
+  // Driver's diagnostics don't use suppression mappings, so don't bother
+  // parsing them. CC1 still receives full args, so this doesn't impact other
+  // actions.
+  DiagOpts->DiagnosticSuppressionMappingsFile.clear();
 
   TextDiagnosticPrinter *DiagClient
 = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang] Stop parsing warning suppression mappings in driver (#125722) (PR #126027)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/126027
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang] Stop parsing warning suppression mappings in driver (#125722) (PR #126027)

2025-02-07 Thread via llvm-branch-commits

github-actions[bot] wrote:

@kadircet (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/126027
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] b2b4154 - [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (#121245)

2025-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Michael Park
Date: 2025-02-07T18:36:03-08:00
New Revision: b2b41544eefa71f97fad492100617aab90d024fb

URL: 
https://github.com/llvm/llvm-project/commit/b2b41544eefa71f97fad492100617aab90d024fb
DIFF: 
https://github.com/llvm/llvm-project/commit/b2b41544eefa71f97fad492100617aab90d024fb.diff

LOG: [C++20][Modules][Serialization] Delay marking pending incomplete decl 
chains until the end of `finishPendingActions`. (#121245)

The call to `hasBody` inside `finishPendingActions` that bumps the 
`PendingIncompleteDeclChains`
size from `0` to `1`, and also sets the `LazyVal->LastGeneration` to `6` which 
matches
the `LazyVal->ExternalSource->getGeneration()` value of `6`. Later, the 
iterations over `redecls()`
(which calls `getNextRedeclaration`) is expected to trigger the reload, but it 
**does not** since
the generation numbers match.

The proposed solution is to perform the marking of incomplete decl chains at 
the end of `finishPendingActions`.
This way, **all** of the incomplete decls are marked incomplete as a 
post-condition of `finishPendingActions`.
It's also safe to delay this operation since any operation being done within 
`finishPendingActions` has
`NumCurrentElementsDeserializing == 1`, which means that any calls to 
`CompleteDeclChain` would simply
add to the `PendingIncompleteDeclChains` without doing anything anyway.

(cherry picked from commit a9e249f64e800fbb20a3b26c0cfb68c1a1aee5e1)

Added: 
clang/test/Modules/pr121245.cpp

Modified: 
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index f524251c48ddd71..24acd6e297e7125 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10186,12 +10186,12 @@ void ASTReader::visitTopLevelModuleMaps(
 }
 
 void ASTReader::finishPendingActions() {
-  while (
-  !PendingIdentifierInfos.empty() || !PendingDeducedFunctionTypes.empty() 
||
-  !PendingDeducedVarTypes.empty() || !PendingIncompleteDeclChains.empty() 
||
-  !PendingDeclChains.empty() || !PendingMacroIDs.empty() ||
-  !PendingDeclContextInfos.empty() || !PendingUpdateRecords.empty() ||
-  !PendingObjCExtensionIvarRedeclarations.empty()) {
+  while (!PendingIdentifierInfos.empty() ||
+ !PendingDeducedFunctionTypes.empty() ||
+ !PendingDeducedVarTypes.empty() || !PendingDeclChains.empty() ||
+ !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
+ !PendingUpdateRecords.empty() ||
+ !PendingObjCExtensionIvarRedeclarations.empty()) {
 // If any identifiers with corresponding top-level declarations have
 // been loaded, load those declarations now.
 using TopLevelDeclsMap =
@@ -10239,13 +10239,6 @@ void ASTReader::finishPendingActions() {
 }
 PendingDeducedVarTypes.clear();
 
-// For each decl chain that we wanted to complete while deserializing, mark
-// it as "still needs to be completed".
-for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
-  markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
-}
-PendingIncompleteDeclChains.clear();
-
 // Load pending declaration chains.
 for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
   loadPendingDeclChain(PendingDeclChains[I].first,
@@ -10483,6 +10476,12 @@ void ASTReader::finishPendingActions() {
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // For each decl chain that we wanted to complete while deserializing, mark
+  // it as "still needs to be completed".
+  for (Decl *D : PendingIncompleteDeclChains)
+markIncompleteDeclChain(D);
+  PendingIncompleteDeclChains.clear();
 }
 
 void ASTReader::diagnoseOdrViolations() {

diff  --git a/clang/test/Modules/pr121245.cpp b/clang/test/Modules/pr121245.cpp
new file mode 100644
index 000..0e276ad0e435d11
--- /dev/null
+++ b/clang/test/Modules/pr121245.cpp
@@ -0,0 +1,93 @@
+// If this test fails, it should be investigated under Debug builds.
+// Before the PR, this test was encountering an `llvm_unreachable()`.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
+// RUN:  -fcxx-exceptions -o %t/hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
+// RUN:  -Wno-exp

[llvm-branch-commits] [llvm] release/20.x: [VPlan] Check VPWidenIntrinsicSC in VPRecipeWithIRFlags::classof. (PR #125363)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/125363

>From e14e4942f057dad830bacef3fe60e9faf2479d0e Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Sat, 1 Feb 2025 21:40:58 +
Subject: [PATCH] [VPlan] Check VPWidenIntrinsicSC in
 VPRecipeWithIRFlags::classof.

When VPWidenIntrinsicRecipe was changed to inhert from VPRecipeWithIRFlags,
VPRecipeWithIRFlags::classof wasn't updated accordingly. Also check for
VPWidenIntrinsicSC in VPRecipeWithIRFlags::classof.

Fixes https://github.com/llvm/llvm-project/issues/125301.

(cherry picked from commit 75b922dccfc35ec25a520b1941e6682a300802b8)
---
 llvm/lib/Transforms/Vectorize/VPlan.h |   1 +
 .../AArch64/drop-poison-generating-flags.ll   | 151 ++
 2 files changed, 152 insertions(+)
 create mode 100644 
llvm/test/Transforms/LoopVectorize/AArch64/drop-poison-generating-flags.ll

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index a1ff684b2b80175..6c95b08a0201461 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1058,6 +1058,7 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
R->getVPDefID() == VPRecipeBase::VPWidenEVLSC ||
R->getVPDefID() == VPRecipeBase::VPWidenGEPSC ||
R->getVPDefID() == VPRecipeBase::VPWidenCastSC ||
+   R->getVPDefID() == VPRecipeBase::VPWidenIntrinsicSC ||
R->getVPDefID() == VPRecipeBase::VPReplicateSC ||
R->getVPDefID() == VPRecipeBase::VPReverseVectorPointerSC ||
R->getVPDefID() == VPRecipeBase::VPVectorPointerSC;
diff --git 
a/llvm/test/Transforms/LoopVectorize/AArch64/drop-poison-generating-flags.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/drop-poison-generating-flags.ll
new file mode 100644
index 000..53bd2d119c1ae40
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/drop-poison-generating-flags.ll
@@ -0,0 +1,151 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --check-globals none --version 5
+; RUN: opt -p loop-vectorize -mcpu=neoverse-v2 -force-vector-width=4 -S %s | 
FileCheck %s
+
+target triple = "aarch64-unknown-linux"
+
+; Test case where we visit a VPWidenIntrinsic (for @llvm.fabs) with nnan flags.
+; For https://github.com/llvm/llvm-project/issues/125301.
+define void @check_widen_intrinsic_with_nnan(ptr noalias %dst.0, ptr noalias 
%dst.1, ptr noalias %src.1, ptr %src.2) {
+; CHECK-LABEL: define void @check_widen_intrinsic_with_nnan(
+; CHECK-SAME: ptr noalias [[DST_0:%.*]], ptr noalias [[DST_1:%.*]], ptr 
noalias [[SRC_1:%.*]], ptr [[SRC_2:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  [[ENTRY:.*]]:
+; CHECK-NEXT:br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
+; CHECK:   [[VECTOR_PH]]:
+; CHECK-NEXT:br label %[[VECTOR_BODY:.*]]
+; CHECK:   [[VECTOR_BODY]]:
+; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], %[[PRED_LOAD_CONTINUE6:.*]] ]
+; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[INDEX]], 0
+; CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds double, ptr [[SRC_1]], 
i64 [[TMP0]]
+; CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds double, ptr [[TMP1]], 
i32 0
+; CHECK-NEXT:[[WIDE_LOAD:%.*]] = load <4 x double>, ptr [[TMP2]], align 8
+; CHECK-NEXT:[[TMP3:%.*]] = call <4 x double> @llvm.fabs.v4f64(<4 x 
double> [[WIDE_LOAD]])
+; CHECK-NEXT:[[TMP4:%.*]] = fcmp olt <4 x double> [[TMP3]], splat (double 
1.00e+00)
+; CHECK-NEXT:[[TMP5:%.*]] = xor <4 x i1> [[TMP4]], splat (i1 true)
+; CHECK-NEXT:[[TMP6:%.*]] = add i64 [[TMP0]], -1
+; CHECK-NEXT:[[TMP7:%.*]] = getelementptr double, ptr [[DST_0]], i64 
[[TMP6]]
+; CHECK-NEXT:[[TMP8:%.*]] = getelementptr double, ptr [[TMP7]], i32 0
+; CHECK-NEXT:call void @llvm.masked.store.v4f64.p0(<4 x double> 
zeroinitializer, ptr [[TMP8]], i32 8, <4 x i1> [[TMP5]])
+; CHECK-NEXT:[[TMP9:%.*]] = extractelement <4 x i1> [[TMP4]], i32 0
+; CHECK-NEXT:br i1 [[TMP9]], label %[[PRED_LOAD_IF:.*]], label 
%[[PRED_LOAD_CONTINUE:.*]]
+; CHECK:   [[PRED_LOAD_IF]]:
+; CHECK-NEXT:[[TMP10:%.*]] = load double, ptr [[SRC_2]], align 8
+; CHECK-NEXT:[[TMP11:%.*]] = insertelement <4 x double> poison, double 
[[TMP10]], i32 0
+; CHECK-NEXT:br label %[[PRED_LOAD_CONTINUE]]
+; CHECK:   [[PRED_LOAD_CONTINUE]]:
+; CHECK-NEXT:[[TMP12:%.*]] = phi <4 x double> [ poison, %[[VECTOR_BODY]] 
], [ [[TMP11]], %[[PRED_LOAD_IF]] ]
+; CHECK-NEXT:[[TMP13:%.*]] = extractelement <4 x i1> [[TMP4]], i32 1
+; CHECK-NEXT:br i1 [[TMP13]], label %[[PRED_LOAD_IF1:.*]], label 
%[[PRED_LOAD_CONTINUE2:.*]]
+; CHECK:   [[PRED_LOAD_IF1]]:
+; CHECK-NEXT:[[TMP14:%.*]] = load double, ptr [[SRC_2]], align 8
+; CHECK-NEXT:[[TMP15:%.*]] = insertelement <4 x double> [[TMP12]], double 
[[TMP14]], i32 1
+; CHECK-NEXT:br label %[[PRED_LOAD_CONTINUE2]]
+; CHECK:   [[PRED_LOAD_CONTINUE2]]:
+; 

[llvm-branch-commits] [clang] release/20.x: [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (#121245) (PR #126289)

2025-02-07 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/126289
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments (PR #126147)

2025-02-07 Thread Austin Kerbow via llvm-branch-commits

https://github.com/kerbowa commented:

This shouldn't be needed after #123547, there are other bugs besides this 
caused by the leftover declarations. 

https://github.com/llvm/llvm-project/pull/126147
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (#121245) (PR #126289)

2025-02-07 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-modules

Author: None (llvmbot)


Changes

Backport a9e249f64e800fbb20a3b26c0cfb68c1a1aee5e1

Requested by: @mpark

---
Full diff: https://github.com/llvm/llvm-project/pull/126289.diff


2 Files Affected:

- (modified) clang/lib/Serialization/ASTReader.cpp (+12-13) 
- (added) clang/test/Modules/pr121245.cpp (+93) 


``diff
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index f524251c48ddd71..24acd6e297e7125 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10186,12 +10186,12 @@ void ASTReader::visitTopLevelModuleMaps(
 }
 
 void ASTReader::finishPendingActions() {
-  while (
-  !PendingIdentifierInfos.empty() || !PendingDeducedFunctionTypes.empty() 
||
-  !PendingDeducedVarTypes.empty() || !PendingIncompleteDeclChains.empty() 
||
-  !PendingDeclChains.empty() || !PendingMacroIDs.empty() ||
-  !PendingDeclContextInfos.empty() || !PendingUpdateRecords.empty() ||
-  !PendingObjCExtensionIvarRedeclarations.empty()) {
+  while (!PendingIdentifierInfos.empty() ||
+ !PendingDeducedFunctionTypes.empty() ||
+ !PendingDeducedVarTypes.empty() || !PendingDeclChains.empty() ||
+ !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
+ !PendingUpdateRecords.empty() ||
+ !PendingObjCExtensionIvarRedeclarations.empty()) {
 // If any identifiers with corresponding top-level declarations have
 // been loaded, load those declarations now.
 using TopLevelDeclsMap =
@@ -10239,13 +10239,6 @@ void ASTReader::finishPendingActions() {
 }
 PendingDeducedVarTypes.clear();
 
-// For each decl chain that we wanted to complete while deserializing, mark
-// it as "still needs to be completed".
-for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
-  markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
-}
-PendingIncompleteDeclChains.clear();
-
 // Load pending declaration chains.
 for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
   loadPendingDeclChain(PendingDeclChains[I].first,
@@ -10483,6 +10476,12 @@ void ASTReader::finishPendingActions() {
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // For each decl chain that we wanted to complete while deserializing, mark
+  // it as "still needs to be completed".
+  for (Decl *D : PendingIncompleteDeclChains)
+markIncompleteDeclChain(D);
+  PendingIncompleteDeclChains.clear();
 }
 
 void ASTReader::diagnoseOdrViolations() {
diff --git a/clang/test/Modules/pr121245.cpp b/clang/test/Modules/pr121245.cpp
new file mode 100644
index 000..0e276ad0e435d11
--- /dev/null
+++ b/clang/test/Modules/pr121245.cpp
@@ -0,0 +1,93 @@
+// If this test fails, it should be investigated under Debug builds.
+// Before the PR, this test was encountering an `llvm_unreachable()`.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
+// RUN:  -fcxx-exceptions -o %t/hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-04.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-05.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-03.pcm -fmodule-file=%t/hu-04.pcm \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-05.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-obj %t/main.cpp \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-02.pcm -fmodule-file=%t/hu-05.pcm \
+// RUN:  -fmodule-file=%t/hu-04.pcm -fmodule-file=%t/hu-03.pcm \
+// RUN:  -fmodule-file=%t/hu-01.pcm
+
+//--- hu-01.h
+template 
+struct A {
+  A() {}
+  ~A() {}
+};
+
+template 
+struct EBO : T {
+  EBO() = default;
+};
+
+template 
+struct HT : EBO> {};
+
+//--- hu-02.h
+import "hu-01.h";
+
+inline void f() {
+  HT();
+}
+
+//--- hu-03.h
+import "hu-01.h";
+
+struct C {
+  C();
+
+  HT _;
+};
+
+//--- hu-04.h
+import "hu-01.h";
+
+void g(HT = {});
+
+//--- hu-05.h
+import "hu-03.h";
+import "hu-04.h";
+import "hu-01.h";
+
+struct B {
+  virtual ~B() = default;
+
+  virtual void f() {
+HT();
+  }
+};
+
+//--- main.cpp
+import "hu-02.h";
+import "hu-05.h";
+import "hu

[llvm-branch-commits] [libclc] release/20.x: [libclc] Allow default path when looking for llvm-spirv (#126071) (PR #126201)

2025-02-07 Thread Fraser Cormack via llvm-branch-commits

https://github.com/frasercrmck approved this pull request.


https://github.com/llvm/llvm-project/pull/126201
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


  1   2   >