[llvm-branch-commits] [llvm] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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


@@ -141,6 +141,43 @@ define <2 x i32> @test_frexp_v2f16_v2i32_only_use_exp(<2 x 
half> %a) {
   ret <2 x i32> %result.1
 }
 
+define { <3 x float>, <3 x i32> } @test_frexp_v3f16_v3i32(<3 x float> %a) {

davemgreen wrote:

f16 -> f32

https://github.com/llvm/llvm-project/pull/146691
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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


@@ -1,5 +1,111 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 2
 ; RUN: llc -mtriple=aarch64-gnu-linux < %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -mtriple=aarch64-windows-pc-msvc < %s | FileCheck 
-check-prefixes=WINDOWS %s
+define { half, i32 } @test_frexp_f16_i32(half %a) {

davemgreen wrote:

Add a newline after the RUN lines.

https://github.com/llvm/llvm-project/pull/146691
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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

https://github.com/davemgreen edited 
https://github.com/llvm/llvm-project/pull/146691
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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

https://github.com/davemgreen commented:

Thanks for adding these.

https://github.com/llvm/llvm-project/pull/146691
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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


@@ -141,6 +141,43 @@ define <2 x i32> @test_frexp_v2f16_v2i32_only_use_exp(<2 x 
half> %a) {
   ret <2 x i32> %result.1
 }
 
+define { <3 x float>, <3 x i32> } @test_frexp_v3f16_v3i32(<3 x float> %a) {
+; CHECK-LABEL: test_frexp_v3f16_v3i32:
+; CHECK:   @ %bb.0:
+; CHECK-NEXT:push.w {r4, r5, r6, r7, r8, lr}
+; CHECK-NEXT:vpush {d8, d9}
+; CHECK-NEXT:sub sp, #8
+; CHECK-NEXT:mov r8, sp
+; CHECK-NEXT:vldr d9, [sp, #48]
+; CHECK-NEXT:mov r4, r0
+; CHECK-NEXT:mov r0, r2
+; CHECK-NEXT:mov r1, r8
+; CHECK-NEXT:mov r5, r3
+; CHECK-NEXT:vmov d8, r2, r3
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:add r6, sp, #4
+; CHECK-NEXT:mov r7, r0
+; CHECK-NEXT:mov r0, r5
+; CHECK-NEXT:mov r1, r6
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:mov r5, r0
+; CHECK-NEXT:vmov r0, s18
+; CHECK-NEXT:vld1.32 {d16[0]}, [r8:32]
+; CHECK-NEXT:add.w r1, r4, #16
+; CHECK-NEXT:vld1.32 {d16[1]}, [r6:32]
+; CHECK-NEXT:vst1.32 {d16}, [r1:64]!
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:vmov s1, r5
+; CHECK-NEXT:vmov s0, r7
+; CHECK-NEXT:vst1.32 {d0}, [r4:64]!
+; CHECK-NEXT:str r0, [r4]
+; CHECK-NEXT:add sp, #8
+; CHECK-NEXT:vpop {d8, d9}
+; CHECK-NEXT:pop.w {r4, r5, r6, r7, r8, pc}
+  %result = call { <3 x float>, <3 x i32> } @llvm.frexp.v3float.v3i32(<3 x 
float> %a)

davemgreen wrote:

v3float -> v3f32

https://github.com/llvm/llvm-project/pull/146691
___
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 definitions for cryptographic instructions (PR #139451)

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


@@ -0,0 +1,98 @@
+//===--- SparcInstrCrypto.td - cryptographic extensions 
---===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains instruction formats, definitions and patterns needed for
+// cryptographic instructions on SPARC.
+//===--===//
+
+
+// Convenience template for 4-operand instructions
+class FourOpImm op3val, bits<4> op5val,
+RegisterClass RC>
+  : F3_4;
+
+let Predicates = [HasCrypto] in {
+def AES_EROUND01 : FourOp<"aes_eround01", 0b011001, 0b, DFPRegs>;
+def AES_EROUND23 : FourOp<"aes_eround23", 0b011001, 0b0001, DFPRegs>;
+def AES_DROUND01 : FourOp<"aes_dround01", 0b011001, 0b0010, DFPRegs>;
+def AES_DROUND23 : FourOp<"aes_dround23", 0b011001, 0b0011, DFPRegs>;
+def AES_EROUND01_LAST : FourOp<"aes_eround01_l", 0b011001, 0b0100, DFPRegs>;
+def AES_EROUND23_LAST : FourOp<"aes_eround23_l", 0b011001, 0b0101, DFPRegs>;
+def AES_DROUND01_LAST : FourOp<"aes_dround01_l", 0b011001, 0b0110, DFPRegs>;
+def AES_DROUND23_LAST : FourOp<"aes_dround23_l", 0b011001, 0b0111, DFPRegs>;
+def AES_KEXPAND0  : F3_3<2, 0b110110, 0b10011,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand0 $rs1, $rs2, $rd", []>;
+def AES_KEXPAND1 : FourOpImm<"aes_kexpand1", 0b011001, 0b1000, DFPRegs>;
+def AES_KEXPAND2  : F3_3<2, 0b110110, 0b100110001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand2 $rs1, $rs2, $rd", []>;
+
+def CAMELLIA_F : FourOp<"camellia_f", 0b011001, 0b1100, DFPRegs>;
+def CAMELLIA_FL  : F3_3<2, 0b110110, 0b10000,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"camellia_fl $rs1, $rs2, $rd", []>;
+def CAMELLIA_FLI : F3_3<2, 0b110110, 0b10001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"camellia_fli $rs1, $rs2, $rd", []>;
+
+def CRC32C : F3_3<2, 0b110110, 0b101000111,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),

s-barannikov wrote:

Ditto

https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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


@@ -0,0 +1,98 @@
+//===--- SparcInstrCrypto.td - cryptographic extensions 
---===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains instruction formats, definitions and patterns needed for
+// cryptographic instructions on SPARC.
+//===--===//
+
+
+// Convenience template for 4-operand instructions
+class FourOpImm op3val, bits<4> op5val,
+RegisterClass RC>
+  : F3_4;
+
+let Predicates = [HasCrypto] in {
+def AES_EROUND01 : FourOp<"aes_eround01", 0b011001, 0b, DFPRegs>;
+def AES_EROUND23 : FourOp<"aes_eround23", 0b011001, 0b0001, DFPRegs>;
+def AES_DROUND01 : FourOp<"aes_dround01", 0b011001, 0b0010, DFPRegs>;
+def AES_DROUND23 : FourOp<"aes_dround23", 0b011001, 0b0011, DFPRegs>;
+def AES_EROUND01_LAST : FourOp<"aes_eround01_l", 0b011001, 0b0100, DFPRegs>;
+def AES_EROUND23_LAST : FourOp<"aes_eround23_l", 0b011001, 0b0101, DFPRegs>;
+def AES_DROUND01_LAST : FourOp<"aes_dround01_l", 0b011001, 0b0110, DFPRegs>;
+def AES_DROUND23_LAST : FourOp<"aes_dround23_l", 0b011001, 0b0111, DFPRegs>;
+def AES_KEXPAND0  : F3_3<2, 0b110110, 0b10011,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand0 $rs1, $rs2, $rd", []>;
+def AES_KEXPAND1 : FourOpImm<"aes_kexpand1", 0b011001, 0b1000, DFPRegs>;
+def AES_KEXPAND2  : F3_3<2, 0b110110, 0b100110001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand2 $rs1, $rs2, $rd", []>;
+
+def CAMELLIA_F : FourOp<"camellia_f", 0b011001, 0b1100, DFPRegs>;
+def CAMELLIA_FL  : F3_3<2, 0b110110, 0b10000,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),

s-barannikov wrote:

Align after '<'

https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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


@@ -0,0 +1,98 @@
+//===--- SparcInstrCrypto.td - cryptographic extensions 
---===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains instruction formats, definitions and patterns needed for
+// cryptographic instructions on SPARC.
+//===--===//
+
+
+// Convenience template for 4-operand instructions
+class FourOpImm op3val, bits<4> op5val,
+RegisterClass RC>
+  : F3_4;

s-barannikov wrote:

```suggestion
class FourOpImm op3val, bits<4> op5val,
RegisterClass RC>
: F3_4;
```

https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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

https://github.com/s-barannikov approved this pull request.

LGTM with formatting nits

https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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


@@ -0,0 +1,98 @@
+//===--- SparcInstrCrypto.td - cryptographic extensions 
---===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains instruction formats, definitions and patterns needed for
+// cryptographic instructions on SPARC.
+//===--===//
+
+
+// Convenience template for 4-operand instructions
+class FourOpImm op3val, bits<4> op5val,
+RegisterClass RC>
+  : F3_4;
+
+let Predicates = [HasCrypto] in {
+def AES_EROUND01 : FourOp<"aes_eround01", 0b011001, 0b, DFPRegs>;
+def AES_EROUND23 : FourOp<"aes_eround23", 0b011001, 0b0001, DFPRegs>;
+def AES_DROUND01 : FourOp<"aes_dround01", 0b011001, 0b0010, DFPRegs>;
+def AES_DROUND23 : FourOp<"aes_dround23", 0b011001, 0b0011, DFPRegs>;
+def AES_EROUND01_LAST : FourOp<"aes_eround01_l", 0b011001, 0b0100, DFPRegs>;
+def AES_EROUND23_LAST : FourOp<"aes_eround23_l", 0b011001, 0b0101, DFPRegs>;
+def AES_DROUND01_LAST : FourOp<"aes_dround01_l", 0b011001, 0b0110, DFPRegs>;
+def AES_DROUND23_LAST : FourOp<"aes_dround23_l", 0b011001, 0b0111, DFPRegs>;
+def AES_KEXPAND0  : F3_3<2, 0b110110, 0b10011,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),

s-barannikov wrote:

Align after '<'

https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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


@@ -0,0 +1,98 @@
+//===--- SparcInstrCrypto.td - cryptographic extensions 
---===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains instruction formats, definitions and patterns needed for
+// cryptographic instructions on SPARC.
+//===--===//
+
+
+// Convenience template for 4-operand instructions
+class FourOpImm op3val, bits<4> op5val,
+RegisterClass RC>
+  : F3_4;
+
+let Predicates = [HasCrypto] in {
+def AES_EROUND01 : FourOp<"aes_eround01", 0b011001, 0b, DFPRegs>;
+def AES_EROUND23 : FourOp<"aes_eround23", 0b011001, 0b0001, DFPRegs>;
+def AES_DROUND01 : FourOp<"aes_dround01", 0b011001, 0b0010, DFPRegs>;
+def AES_DROUND23 : FourOp<"aes_dround23", 0b011001, 0b0011, DFPRegs>;
+def AES_EROUND01_LAST : FourOp<"aes_eround01_l", 0b011001, 0b0100, DFPRegs>;
+def AES_EROUND23_LAST : FourOp<"aes_eround23_l", 0b011001, 0b0101, DFPRegs>;
+def AES_DROUND01_LAST : FourOp<"aes_dround01_l", 0b011001, 0b0110, DFPRegs>;
+def AES_DROUND23_LAST : FourOp<"aes_dround23_l", 0b011001, 0b0111, DFPRegs>;
+def AES_KEXPAND0  : F3_3<2, 0b110110, 0b10011,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand0 $rs1, $rs2, $rd", []>;
+def AES_KEXPAND1 : FourOpImm<"aes_kexpand1", 0b011001, 0b1000, DFPRegs>;
+def AES_KEXPAND2  : F3_3<2, 0b110110, 0b100110001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand2 $rs1, $rs2, $rd", []>;
+
+def CAMELLIA_F : FourOp<"camellia_f", 0b011001, 0b1100, DFPRegs>;
+def CAMELLIA_FL  : F3_3<2, 0b110110, 0b10000,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"camellia_fl $rs1, $rs2, $rd", []>;
+def CAMELLIA_FLI : F3_3<2, 0b110110, 0b10001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),

s-barannikov wrote:

Ditto

https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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


@@ -0,0 +1,98 @@
+//===--- SparcInstrCrypto.td - cryptographic extensions 
---===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains instruction formats, definitions and patterns needed for
+// cryptographic instructions on SPARC.
+//===--===//
+
+
+// Convenience template for 4-operand instructions
+class FourOpImm op3val, bits<4> op5val,
+RegisterClass RC>
+  : F3_4;
+
+let Predicates = [HasCrypto] in {
+def AES_EROUND01 : FourOp<"aes_eround01", 0b011001, 0b, DFPRegs>;
+def AES_EROUND23 : FourOp<"aes_eround23", 0b011001, 0b0001, DFPRegs>;
+def AES_DROUND01 : FourOp<"aes_dround01", 0b011001, 0b0010, DFPRegs>;
+def AES_DROUND23 : FourOp<"aes_dround23", 0b011001, 0b0011, DFPRegs>;
+def AES_EROUND01_LAST : FourOp<"aes_eround01_l", 0b011001, 0b0100, DFPRegs>;
+def AES_EROUND23_LAST : FourOp<"aes_eround23_l", 0b011001, 0b0101, DFPRegs>;
+def AES_DROUND01_LAST : FourOp<"aes_dround01_l", 0b011001, 0b0110, DFPRegs>;
+def AES_DROUND23_LAST : FourOp<"aes_dround23_l", 0b011001, 0b0111, DFPRegs>;
+def AES_KEXPAND0  : F3_3<2, 0b110110, 0b10011,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand0 $rs1, $rs2, $rd", []>;
+def AES_KEXPAND1 : FourOpImm<"aes_kexpand1", 0b011001, 0b1000, DFPRegs>;
+def AES_KEXPAND2  : F3_3<2, 0b110110, 0b100110001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand2 $rs1, $rs2, $rd", []>;
+
+def CAMELLIA_F : FourOp<"camellia_f", 0b011001, 0b1100, DFPRegs>;
+def CAMELLIA_FL  : F3_3<2, 0b110110, 0b10000,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"camellia_fl $rs1, $rs2, $rd", []>;
+def CAMELLIA_FLI : F3_3<2, 0b110110, 0b10001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"camellia_fli $rs1, $rs2, $rd", []>;
+
+def CRC32C : F3_3<2, 0b110110, 0b101000111,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"crc32c $rs1, $rs2, $rd", []>;
+
+def DES_ROUND : FourOp<"des_round", 0b011001, 0b1001, DFPRegs>;
+let rs2 = 0 in {
+def DES_IP  : F3_3<2, 0b110110, 0b100110100,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1),
+"des_ip $rs1, $rd", []>;
+def DES_IIP  : F3_3<2, 0b110110, 0b100110101,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1),
+"des_iip $rs1, $rd", []>;
+}
+def DES_KEXPAND : F3_3<2, 0b110110, 0b100110110,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, simm5Op:$rs2),

s-barannikov wrote:

Ditto

https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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


@@ -0,0 +1,98 @@
+//===--- SparcInstrCrypto.td - cryptographic extensions 
---===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains instruction formats, definitions and patterns needed for
+// cryptographic instructions on SPARC.
+//===--===//
+
+
+// Convenience template for 4-operand instructions
+class FourOpImm op3val, bits<4> op5val,
+RegisterClass RC>
+  : F3_4;
+
+let Predicates = [HasCrypto] in {
+def AES_EROUND01 : FourOp<"aes_eround01", 0b011001, 0b, DFPRegs>;
+def AES_EROUND23 : FourOp<"aes_eround23", 0b011001, 0b0001, DFPRegs>;
+def AES_DROUND01 : FourOp<"aes_dround01", 0b011001, 0b0010, DFPRegs>;
+def AES_DROUND23 : FourOp<"aes_dround23", 0b011001, 0b0011, DFPRegs>;
+def AES_EROUND01_LAST : FourOp<"aes_eround01_l", 0b011001, 0b0100, DFPRegs>;
+def AES_EROUND23_LAST : FourOp<"aes_eround23_l", 0b011001, 0b0101, DFPRegs>;
+def AES_DROUND01_LAST : FourOp<"aes_dround01_l", 0b011001, 0b0110, DFPRegs>;
+def AES_DROUND23_LAST : FourOp<"aes_dround23_l", 0b011001, 0b0111, DFPRegs>;
+def AES_KEXPAND0  : F3_3<2, 0b110110, 0b10011,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand0 $rs1, $rs2, $rd", []>;
+def AES_KEXPAND1 : FourOpImm<"aes_kexpand1", 0b011001, 0b1000, DFPRegs>;
+def AES_KEXPAND2  : F3_3<2, 0b110110, 0b100110001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),

s-barannikov wrote:

Align after '<'

https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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

https://github.com/s-barannikov edited 
https://github.com/llvm/llvm-project/pull/139451
___
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 definitions for cryptographic instructions (PR #139451)

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


@@ -0,0 +1,98 @@
+//===--- SparcInstrCrypto.td - cryptographic extensions 
---===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains instruction formats, definitions and patterns needed for
+// cryptographic instructions on SPARC.
+//===--===//
+
+
+// Convenience template for 4-operand instructions
+class FourOpImm op3val, bits<4> op5val,
+RegisterClass RC>
+  : F3_4;
+
+let Predicates = [HasCrypto] in {
+def AES_EROUND01 : FourOp<"aes_eround01", 0b011001, 0b, DFPRegs>;
+def AES_EROUND23 : FourOp<"aes_eround23", 0b011001, 0b0001, DFPRegs>;
+def AES_DROUND01 : FourOp<"aes_dround01", 0b011001, 0b0010, DFPRegs>;
+def AES_DROUND23 : FourOp<"aes_dround23", 0b011001, 0b0011, DFPRegs>;
+def AES_EROUND01_LAST : FourOp<"aes_eround01_l", 0b011001, 0b0100, DFPRegs>;
+def AES_EROUND23_LAST : FourOp<"aes_eround23_l", 0b011001, 0b0101, DFPRegs>;
+def AES_DROUND01_LAST : FourOp<"aes_dround01_l", 0b011001, 0b0110, DFPRegs>;
+def AES_DROUND23_LAST : FourOp<"aes_dround23_l", 0b011001, 0b0111, DFPRegs>;
+def AES_KEXPAND0  : F3_3<2, 0b110110, 0b10011,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand0 $rs1, $rs2, $rd", []>;
+def AES_KEXPAND1 : FourOpImm<"aes_kexpand1", 0b011001, 0b1000, DFPRegs>;
+def AES_KEXPAND2  : F3_3<2, 0b110110, 0b100110001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"aes_kexpand2 $rs1, $rs2, $rd", []>;
+
+def CAMELLIA_F : FourOp<"camellia_f", 0b011001, 0b1100, DFPRegs>;
+def CAMELLIA_FL  : F3_3<2, 0b110110, 0b10000,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"camellia_fl $rs1, $rs2, $rd", []>;
+def CAMELLIA_FLI : F3_3<2, 0b110110, 0b10001,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"camellia_fli $rs1, $rs2, $rd", []>;
+
+def CRC32C : F3_3<2, 0b110110, 0b101000111,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
+"crc32c $rs1, $rs2, $rd", []>;
+
+def DES_ROUND : FourOp<"des_round", 0b011001, 0b1001, DFPRegs>;
+let rs2 = 0 in {
+def DES_IP  : F3_3<2, 0b110110, 0b100110100,
+(outs DFPRegs:$rd), (ins DFPRegs:$rs1),

s-barannikov wrote:

Ditto

https://github.com/llvm/llvm-project/pull/139451
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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

https://github.com/arsenm created 
https://github.com/llvm/llvm-project/pull/146691

AArch64 was testing a couple of vector cases, and not the base
scalars. Add the one case that isn't in the ARM version there, and
then copy the rest back into AArch64. Also add a windows run line.

>From d7a7f0d1a89ee9b924eac0aa5f33722b25697318 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Wed, 2 Jul 2025 22:16:29 +0900
Subject: [PATCH] AArch64: Fix some missing llvm.frexp test coverage

AArch64 was testing a couple of vector cases, and not the base
scalars. Add the one case that isn't in the ARM version there, and
then copy the rest back into AArch64. Also add a windows run line.
---
 llvm/test/CodeGen/AArch64/llvm.frexp.ll | 1345 +++
 llvm/test/CodeGen/ARM/llvm.frexp.ll |   37 +
 2 files changed, 1382 insertions(+)

diff --git a/llvm/test/CodeGen/AArch64/llvm.frexp.ll 
b/llvm/test/CodeGen/AArch64/llvm.frexp.ll
index e4cb8ed6eaf90..092fe16cbc2f3 100644
--- a/llvm/test/CodeGen/AArch64/llvm.frexp.ll
+++ b/llvm/test/CodeGen/AArch64/llvm.frexp.ll
@@ -1,5 +1,111 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 2
 ; RUN: llc -mtriple=aarch64-gnu-linux < %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -mtriple=aarch64-windows-pc-msvc < %s | FileCheck 
-check-prefixes=WINDOWS %s
+define { half, i32 } @test_frexp_f16_i32(half %a) {
+; CHECK-LABEL: test_frexp_f16_i32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:fcvt s0, h0
+; CHECK-NEXT:add x0, sp, #12
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:ldr w0, [sp, #12]
+; CHECK-NEXT:fcvt h0, s0
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_f16_i32:
+; WINDOWS:   .seh_proc test_frexp_f16_i32
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:fcvt d0, h0
+; WINDOWS-NEXT:add x0, sp, #12
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:ldr w0, [sp, #12]
+; WINDOWS-NEXT:fcvt h0, d0
+; WINDOWS-NEXT:.seh_startepilogue
+; WINDOWS-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endepilogue
+; WINDOWS-NEXT:ret
+; WINDOWS-NEXT:.seh_endfunclet
+; WINDOWS-NEXT:.seh_endproc
+  %result = call { half, i32 } @llvm.frexp.f16.i32(half %a)
+  ret { half, i32 } %result
+}
+
+define half @test_frexp_f16_i32_only_use_fract(half %a) {
+; CHECK-LABEL: test_frexp_f16_i32_only_use_fract:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:fcvt s0, h0
+; CHECK-NEXT:add x0, sp, #12
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:fcvt h0, s0
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_f16_i32_only_use_fract:
+; WINDOWS:   .seh_proc test_frexp_f16_i32_only_use_fract
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:fcvt d0, h0
+; WINDOWS-NEXT:add x0, sp, #12
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:fcvt h0, d0
+; WINDOWS-NEXT:.seh_startepilogue
+; WINDOWS-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endepilogue
+; WINDOWS-NEXT:ret
+; WINDOWS-NEXT:.seh_endfunclet
+; WINDOWS-NEXT:.seh_endproc
+  %result = call { half, i32 } @llvm.frexp.f16.i32(half %a)
+  %result.0 = extractvalue { half, i32 } %result, 0
+  ret half %result.0
+}
+
+define i32 @test_frexp_f16_i32_only_use_exp(half %a) {
+; CHECK-LABEL: test_frexp_f16_i32_only_use_exp:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:fcvt s0, h0
+; CHECK-NEXT:add x0, sp, #12
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:ldr w0, [sp, #12]
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_f16_i32_only_use_exp:
+; WINDOWS:   .seh_proc test_frexp_f16_i32_only_use_exp
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:fcvt d0, h0
+; WINDOWS-NEXT:add x0, sp, #12
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:ldr w0, [sp, #12]
+; WINDOWS-NEXT:.seh_startepilogue
+; WINDOWS-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; WINDO

[llvm-branch-commits] [lld] Backport [LLD][COFF] Disallow importing DllMain from import libraries (#146610) (PR #146699)

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

llvmbot wrote:




@llvm/pr-subscribers-platform-windows

Author: Alexandre Ganea (aganea)


Changes

This is a workaround for
https://github.com/llvm/llvm-project/issues/82050 by skipping the `DllMain` 
symbol if seen in aimport library. If this situation occurs, after this commit 
a warning will also be displayed. The warning can be silenced with 
`/ignore:exporteddllmain`

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


4 Files Affected:

- (modified) lld/COFF/Config.h (+1) 
- (modified) lld/COFF/Driver.cpp (+2) 
- (modified) lld/COFF/InputFiles.cpp (+39-1) 
- (added) lld/test/COFF/exported-dllmain.test (+57) 


``diff
diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h
index 0c7c4e91402f1..424e9578395b3 100644
--- a/lld/COFF/Config.h
+++ b/lld/COFF/Config.h
@@ -313,6 +313,7 @@ struct Configuration {
   bool warnDebugInfoUnusable = true;
   bool warnLongSectionNames = true;
   bool warnStdcallFixup = true;
+  bool warnExportedDllMain = true;
   bool incremental = true;
   bool integrityCheck = false;
   bool killAt = false;
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index a669b7e9296f6..8b2fc9f23178f 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1625,6 +1625,8 @@ void LinkerDriver::linkerMain(ArrayRef 
argsArr) {
 config->warnLocallyDefinedImported = false;
   else if (s == "longsections")
 config->warnLongSectionNames = false;
+  else if (s == "exporteddllmain")
+config->warnExportedDllMain = false;
   // Other warning numbers are ignored.
 }
   }
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index 7b105fb4c17a2..b470b2a8d9080 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -117,6 +117,35 @@ static coff_symbol_generic *cloneSymbol(COFFSymbolRef sym) 
{
   }
 }
 
+// Skip importing DllMain thunks from import libraries.
+static bool fixupDllMain(COFFLinkerContext &ctx, llvm::object::Archive *file,
+ const Archive::Symbol &sym, bool &skipDllMain) {
+  if (skipDllMain)
+return true;
+  const Archive::Child &c =
+  CHECK(sym.getMember(), file->getFileName() +
+ ": could not get the member for symbol " +
+ toCOFFString(ctx, sym));
+  MemoryBufferRef mb =
+  CHECK(c.getMemoryBufferRef(),
+file->getFileName() +
+": could not get the buffer for a child buffer of the 
archive");
+  if (identify_magic(mb.getBuffer()) == file_magic::coff_import_library) {
+if (ctx.config.warnExportedDllMain) {
+  // We won't place DllMain symbols in the symbol table if they are
+  // coming from a import library. This message can be ignored with the 
flag
+  // '/ignore:exporteddllmain'
+  Warn(ctx)
+  << file->getFileName()
+  << ": skipping exported DllMain symbol [exporteddllmain]\nNOTE: this 
"
+ "might be a mistake when the DLL/library was produced.";
+}
+skipDllMain = true;
+return true;
+  }
+  return false;
+}
+
 ArchiveFile::ArchiveFile(COFFLinkerContext &ctx, MemoryBufferRef m)
 : InputFile(ctx.symtab, ArchiveKind, m) {}
 
@@ -140,8 +169,17 @@ void ArchiveFile::parse() {
   }
 
   // Read the symbol table to construct Lazy objects.
-  for (const Archive::Symbol &sym : file->symbols())
+  bool skipDllMain = false;
+  for (const Archive::Symbol &sym : file->symbols()) {
+// If the DllMain symbol was exported by mistake, skip importing it
+// otherwise we might end up with a import thunk in the final binary which
+// is wrong.
+if (sym.getName() == "__imp_DllMain" || sym.getName() == "DllMain") {
+  if (fixupDllMain(ctx, file.get(), sym, skipDllMain))
+continue;
+}
 ctx.symtab.addLazyArchive(this, sym);
+  }
 }
 
 // Returns a buffer pointing to a member file containing a given symbol.
diff --git a/lld/test/COFF/exported-dllmain.test 
b/lld/test/COFF/exported-dllmain.test
new file mode 100644
index 0..fcf6ed1005379
--- /dev/null
+++ b/lld/test/COFF/exported-dllmain.test
@@ -0,0 +1,57 @@
+REQUIRES: x86
+RUN: split-file %s %t.dir && cd %t.dir
+
+RUN: llvm-mc -filetype=obj -triple=x86_64-windows a.s -o a.obj
+
+RUN: llvm-mc -filetype=obj -triple=x86_64-windows b1.s -o b1.obj
+RUN: llvm-mc -filetype=obj -triple=x86_64-windows b2.s -o b2.obj
+
+### This is the line where our problem occurs. Here, we export the DllMain 
symbol which shouldn't happen normally.
+RUN: lld-link b1.obj b2.obj -out:b.dll -dll -implib:b.lib -entry:DllMain 
-export:bar -export:DllMain
+
+RUN: llvm-mc -filetype=obj -triple=x86_64-windows c.s -o c.obj
+RUN: lld-link -lib c.obj -out:c.lib
+
+### Later, if b.lib is provided before other libs/objs that export DllMain 
statically, we previously were using the dllimported DllMain from b.lib, which 
is wrong.
+RUN: lld-link a.obj b.lib c.lib -dll -out:out.dll -entry:DllMain 2>&1 | 
FileCheck -check-prefix=WARN %s
+RUN: lld-link a.obj b.lib 

[llvm-branch-commits] [llvm] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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

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


https://github.com/llvm/llvm-project/pull/146691
___
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] [CIR] Untie Type and Attribute definitions (PR #146663)

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

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


https://github.com/llvm/llvm-project/pull/146663
___
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] [lld] Backport [LLD][COFF] Disallow importing DllMain from import libraries (#146610) (PR #146699)

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

https://github.com/aganea milestoned 
https://github.com/llvm/llvm-project/pull/146699
___
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] [DLCov] Origin-Tracking: Collect stack traces in DebugLoc (PR #143592)

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

SLTozer wrote:

New PR: https://github.com/llvm/llvm-project/pull/146678

https://github.com/llvm/llvm-project/pull/143592
___
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] [DLCov] Origin-Tracking: Add debugify support (PR #143594)

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

https://github.com/SLTozer edited 
https://github.com/llvm/llvm-project/pull/143594
___
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] [lld] Backport [LLD][COFF] Disallow importing DllMain from import libraries (#146610) (PR #146699)

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

https://github.com/aganea created 
https://github.com/llvm/llvm-project/pull/146699

This is a workaround for
https://github.com/llvm/llvm-project/issues/82050 by skipping the `DllMain` 
symbol if seen in aimport library. If this situation occurs, after this commit 
a warning will also be displayed. The warning can be silenced with 
`/ignore:exporteddllmain`

>From cb11f22699cc5cf4761f7ef426721ef0496030f5 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea 
Date: Wed, 2 Jul 2025 08:53:18 -0400
Subject: [PATCH] [LLD][COFF] Disallow importing DllMain from import libraries
 (#146610)

This is a workaround for
https://github.com/llvm/llvm-project/issues/82050 by skipping the `DllMain` 
symbol if seen in aimport library. If this situation occurs, after this commit 
a warning will also be displayed. The warning can be silenced with 
`/ignore:exporteddllmain`
---
 lld/COFF/Config.h   |  1 +
 lld/COFF/Driver.cpp |  2 +
 lld/COFF/InputFiles.cpp | 40 +++-
 lld/test/COFF/exported-dllmain.test | 57 +
 4 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 lld/test/COFF/exported-dllmain.test

diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h
index 0c7c4e91402f1..424e9578395b3 100644
--- a/lld/COFF/Config.h
+++ b/lld/COFF/Config.h
@@ -313,6 +313,7 @@ struct Configuration {
   bool warnDebugInfoUnusable = true;
   bool warnLongSectionNames = true;
   bool warnStdcallFixup = true;
+  bool warnExportedDllMain = true;
   bool incremental = true;
   bool integrityCheck = false;
   bool killAt = false;
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index a669b7e9296f6..8b2fc9f23178f 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1625,6 +1625,8 @@ void LinkerDriver::linkerMain(ArrayRef 
argsArr) {
 config->warnLocallyDefinedImported = false;
   else if (s == "longsections")
 config->warnLongSectionNames = false;
+  else if (s == "exporteddllmain")
+config->warnExportedDllMain = false;
   // Other warning numbers are ignored.
 }
   }
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index 7b105fb4c17a2..b470b2a8d9080 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -117,6 +117,35 @@ static coff_symbol_generic *cloneSymbol(COFFSymbolRef sym) 
{
   }
 }
 
+// Skip importing DllMain thunks from import libraries.
+static bool fixupDllMain(COFFLinkerContext &ctx, llvm::object::Archive *file,
+ const Archive::Symbol &sym, bool &skipDllMain) {
+  if (skipDllMain)
+return true;
+  const Archive::Child &c =
+  CHECK(sym.getMember(), file->getFileName() +
+ ": could not get the member for symbol " +
+ toCOFFString(ctx, sym));
+  MemoryBufferRef mb =
+  CHECK(c.getMemoryBufferRef(),
+file->getFileName() +
+": could not get the buffer for a child buffer of the 
archive");
+  if (identify_magic(mb.getBuffer()) == file_magic::coff_import_library) {
+if (ctx.config.warnExportedDllMain) {
+  // We won't place DllMain symbols in the symbol table if they are
+  // coming from a import library. This message can be ignored with the 
flag
+  // '/ignore:exporteddllmain'
+  Warn(ctx)
+  << file->getFileName()
+  << ": skipping exported DllMain symbol [exporteddllmain]\nNOTE: this 
"
+ "might be a mistake when the DLL/library was produced.";
+}
+skipDllMain = true;
+return true;
+  }
+  return false;
+}
+
 ArchiveFile::ArchiveFile(COFFLinkerContext &ctx, MemoryBufferRef m)
 : InputFile(ctx.symtab, ArchiveKind, m) {}
 
@@ -140,8 +169,17 @@ void ArchiveFile::parse() {
   }
 
   // Read the symbol table to construct Lazy objects.
-  for (const Archive::Symbol &sym : file->symbols())
+  bool skipDllMain = false;
+  for (const Archive::Symbol &sym : file->symbols()) {
+// If the DllMain symbol was exported by mistake, skip importing it
+// otherwise we might end up with a import thunk in the final binary which
+// is wrong.
+if (sym.getName() == "__imp_DllMain" || sym.getName() == "DllMain") {
+  if (fixupDllMain(ctx, file.get(), sym, skipDllMain))
+continue;
+}
 ctx.symtab.addLazyArchive(this, sym);
+  }
 }
 
 // Returns a buffer pointing to a member file containing a given symbol.
diff --git a/lld/test/COFF/exported-dllmain.test 
b/lld/test/COFF/exported-dllmain.test
new file mode 100644
index 0..fcf6ed1005379
--- /dev/null
+++ b/lld/test/COFF/exported-dllmain.test
@@ -0,0 +1,57 @@
+REQUIRES: x86
+RUN: split-file %s %t.dir && cd %t.dir
+
+RUN: llvm-mc -filetype=obj -triple=x86_64-windows a.s -o a.obj
+
+RUN: llvm-mc -filetype=obj -triple=x86_64-windows b1.s -o b1.obj
+RUN: llvm-mc -filetype=obj -triple=x86_64-windows b2.s -o b2.obj
+
+### This is the line where our problem occurs. Here, we export the DllMain 
symbol which sh

[llvm-branch-commits] [lld] release/20.x: Backport [LLD][COFF] Disallow importing DllMain from import libraries (#146610) (PR #146699)

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

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/146699
___
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] [lld] release/20.x: Backport [LLD][COFF] Disallow importing DllMain from import libraries (#146610) (PR #146699)

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

https://github.com/aganea edited 
https://github.com/llvm/llvm-project/pull/146699
___
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] AlwaysInliner: A new inlining algorithm to interleave alloca promotion with inlines. (PR #145613)

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

aemerson wrote:

ping

https://github.com/llvm/llvm-project/pull/145613
___
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] [CIR] Clean up FPAttr (PR #146662)

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

xlauko wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/146662?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#146663** https://app.graphite.dev/github/pr/llvm/llvm-project/146663?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#146662** https://app.graphite.dev/github/pr/llvm/llvm-project/146662?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/146662?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#146661** https://app.graphite.dev/github/pr/llvm/llvm-project/146661?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#146660** https://app.graphite.dev/github/pr/llvm/llvm-project/146660?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


https://github.com/llvm/llvm-project/pull/146662
___
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] [CIR] Clean up IntAttr (PR #146661)

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

https://github.com/xlauko created 
https://github.com/llvm/llvm-project/pull/146661

- Add common CIR_ prefix
- Simplify printing/parsing
- Make it use IntTypeInterface

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1725

>From 7e092b87f30c9081551158186c0afae3b337b66f Mon Sep 17 00:00:00 2001
From: xlauko 
Date: Wed, 2 Jul 2025 09:50:24 +0200
Subject: [PATCH] [CIR] Clean up IntAttr

- Add common CIR_ prefix
- Simplify printing/parsing
- Make it use IntTypeInterface

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1725
---
 .../CIR/Dialect/Builder/CIRBaseBuilder.h  |   2 +-
 .../include/clang/CIR/Dialect/IR/CIRAttrs.td  |  53 --
 clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp  |   6 +-
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp|  15 ++-
 clang/lib/CIR/Dialect/IR/CIRAttrs.cpp | 100 +-
 5 files changed, 101 insertions(+), 75 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h 
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index 3e052c564112e..41ac8c1c875df 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -63,7 +63,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 
   mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ,
 const llvm::APInt &val) {
-return create(loc, getAttr(typ, val));
+return create(loc, cir::IntAttr::get(typ, val));
   }
 
   cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) {
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 9a6560519eec4..a042f5cd0c19e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -117,36 +117,67 @@ def UndefAttr : CIR_TypedAttr<"Undef", "undef"> {
 // IntegerAttr
 
//===--===//
 
-def IntAttr : CIR_Attr<"Int", "int", [TypedAttrInterface]> {
+def CIR_IntAttr : CIR_Attr<"Int", "int", [TypedAttrInterface]> {
   let summary = "An attribute containing an integer value";
   let description = [{
 An integer attribute is a literal attribute that represents an integral
 value of the specified integer type.
   }];
-  let parameters = (ins AttributeSelfTypeParameter<"">:$type,
-APIntParameter<"">:$value);
+
+  let parameters = (ins
+AttributeSelfTypeParameter<"", "cir::IntTypeInterface">:$type,
+APIntParameter<"">:$value
+  );
+
   let builders = [
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "const llvm::APInt &":$value), [{
-  return $_get(type.getContext(), type, value);
+  auto intType = mlir::cast(type);
+  return $_get(type.getContext(), intType, value);
 }]>,
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "int64_t":$value), [{
-  IntType intType = mlir::cast(type);
+  auto intType = mlir::cast(type);
   mlir::APInt apValue(intType.getWidth(), value, intType.isSigned());
   return $_get(intType.getContext(), intType, apValue);
 }]>,
   ];
+
   let extraClassDeclaration = [{
-int64_t getSInt() const { return getValue().getSExtValue(); }
-uint64_t getUInt() const { return getValue().getZExtValue(); }
-bool isNullValue() const { return getValue() == 0; }
-uint64_t getBitWidth() const {
-  return mlir::cast(getType()).getWidth();
+int64_t getSInt() const;
+uint64_t getUInt() const;
+bool isNullValue() const;
+bool isSigned() const;
+bool isUnsigned() const;
+uint64_t getBitWidth() const;
+  }];
+
+ let extraClassDefinition = [{
+int64_t $cppClass::getSInt() const {
+  return getValue().getSExtValue();
+}
+uint64_t $cppClass::getUInt() const {
+  return getValue().getZExtValue();
+}
+bool $cppClass::isNullValue() const {
+  return getValue() == 0;
+}
+bool $cppClass::isSigned() const {
+  return mlir::cast(getType()).isSigned();
+}
+bool $cppClass::isUnsigned() const {
+  return mlir::cast(getType()).isUnsigned();
+}
+uint64_t $cppClass::getBitWidth() const {
+  return mlir::cast(getType()).getWidth();
 }
   }];
+
+  let assemblyFormat = [{
+`<` custom($value, ref($type)) `>`
+  }];
+
   let genVerifyDecl = 1;
-  let hasCustomAssemblyFormat = 1;
 }
 
 
//===--===//
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index e25819cdb11bf..5fc7a92cd00f9 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -684,7 +684,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const 
APValue &value,
 if (mlir::isa(ty))

[llvm-branch-commits] [clang] [CIR] Clean up IntAttr (PR #146661)

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

xlauko wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/146661?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#146663** https://app.graphite.dev/github/pr/llvm/llvm-project/146663?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#146662** https://app.graphite.dev/github/pr/llvm/llvm-project/146662?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#146661** https://app.graphite.dev/github/pr/llvm/llvm-project/146661?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/146661?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#146660** https://app.graphite.dev/github/pr/llvm/llvm-project/146660?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


https://github.com/llvm/llvm-project/pull/146661
___
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] [CIR] Untie Type and Attribute definitions (PR #146663)

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

https://github.com/xlauko created 
https://github.com/llvm/llvm-project/pull/146663

This will allow to use Attributes and Types together in tablegen without 
inducing cyclic dependency.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1727

>From 43374714e80db860b2e51cbb4c33e8ff72d10439 Mon Sep 17 00:00:00 2001
From: xlauko 
Date: Wed, 2 Jul 2025 12:16:53 +0200
Subject: [PATCH] [CIR] Untie Type and Attribute definitions

This will allow to use Attributes and Types together in tablegen without 
inducing cyclic dependency.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1727
---
 clang/include/clang/CIR/Dialect/IR/CIRAttrs.h | 22 ---
 .../include/clang/CIR/Dialect/IR/CIRDialect.h |  1 +
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
index 64556bcb92baa..925a9a87e267f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
@@ -10,16 +10,15 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
-#define LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
-
-#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
-#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#ifndef CLANG_CIR_DIALECT_IR_CIRATTRS_H
+#define CLANG_CIR_DIALECT_IR_CIRATTRS_H
 
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/BuiltinAttributeInterfaces.h"
 
-#include "llvm/ADT/SmallVector.h"
+#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
+
+#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
 
 
//===--===//
 // CIR Dialect Attrs
@@ -27,15 +26,22 @@
 
 namespace clang {
 class FunctionDecl;
-class VarDecl;
 class RecordDecl;
+class VarDecl;
 } // namespace clang
 
 namespace cir {
 class ArrayType;
+class BoolType;
+class ComplexType;
+class IntType;
+class MethodType;
+class PointerType;
+class RecordType;
+class VectorType;
 } // namespace cir
 
 #define GET_ATTRDEF_CLASSES
 #include "clang/CIR/Dialect/IR/CIROpsAttributes.h.inc"
 
-#endif // LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
+#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_H
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h 
b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
index 5de1722cf5bc2..fdd56ac1f218f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
@@ -29,6 +29,7 @@
 #include "clang/CIR/Dialect/IR/CIRAttrs.h"
 #include "clang/CIR/Dialect/IR/CIROpsDialect.h.inc"
 #include "clang/CIR/Dialect/IR/CIROpsEnums.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
 #include "clang/CIR/Interfaces/CIRLoopOpInterface.h"
 #include "clang/CIR/Interfaces/CIROpInterfaces.h"
 #include "clang/CIR/MissingFeatures.h"

___
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] [CIR] Clean up FPAttr (PR #146662)

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

https://github.com/xlauko created 
https://github.com/llvm/llvm-project/pull/146662

- Adds CIR_ prefix to the definition
- Removes redundant builder and cleans up attribute creations

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1726

>From 99f74b960a9416c267e4406de1fa8ff3f9bc5691 Mon Sep 17 00:00:00 2001
From: xlauko 
Date: Wed, 2 Jul 2025 09:56:38 +0200
Subject: [PATCH] [CIR] Clean up FPAttr

- Adds CIR_ prefix to the definition
- Removes redundant builder and cleans up attribute creations

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1726
---
 clang/include/clang/CIR/Dialect/IR/CIRAttrs.td | 14 +++---
 clang/lib/CIR/CodeGen/CIRGenBuilder.cpp|  2 +-
 clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp   |  6 +++---
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp |  3 +--
 4 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index a042f5cd0c19e..569e62ae11612 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -184,34 +184,34 @@ def CIR_IntAttr : CIR_Attr<"Int", "int", 
[TypedAttrInterface]> {
 // FPAttr
 
//===--===//
 
-def FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> {
+def CIR_FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> {
   let summary = "An attribute containing a floating-point value";
   let description = [{
 An fp attribute is a literal attribute that represents a floating-point
 value of the specified floating-point type. Supporting only CIR FP types.
   }];
+
   let parameters = (ins
 AttributeSelfTypeParameter<"", "::cir::FPTypeInterface">:$type,
 APFloatParameter<"">:$value
   );
+
   let builders = [
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "const llvm::APFloat &":$value), [{
   return $_get(type.getContext(), mlir::cast(type), 
value);
-}]>,
-AttrBuilder<(ins "mlir::Type":$type,
- "const llvm::APFloat &":$value), [{
-  return $_get($_ctxt, mlir::cast(type), value);
-}]>,
+}]>
   ];
+
   let extraClassDeclaration = [{
 static FPAttr getZero(mlir::Type type);
   }];
-  let genVerifyDecl = 1;
 
   let assemblyFormat = [{
 `<` custom($value, ref($type)) `>`
   }];
+
+  let genVerifyDecl = 1;
 }
 
 
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
index b94963c71f9c1..4a5a1dd53a05a 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
@@ -63,7 +63,7 @@ cir::ConstantOp
 clang::CIRGen::CIRGenBuilderTy::getConstFP(mlir::Location loc, mlir::Type t,
llvm::APFloat fpVal) {
   assert(mlir::isa(t) && "expected floating point type");
-  return create(loc, getAttr(t, fpVal));
+  return create(loc, cir::FPAttr::get(t, fpVal));
 }
 
 // This can't be defined in Address.h because that file is included by
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index 5fc7a92cd00f9..5b3bf85cefbb0 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -698,7 +698,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const 
APValue &value,
 mlir::Type ty = cgm.convertType(destType);
 assert(mlir::isa(ty) &&
"expected floating-point type");
-return cgm.getBuilder().getAttr(ty, init);
+return cir::FPAttr::get(ty, init);
   }
   case APValue::Array: {
 const ArrayType *arrayTy = cgm.getASTContext().getAsArrayType(destType);
@@ -798,8 +798,8 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const 
APValue &value,
 llvm::APFloat real = value.getComplexFloatReal();
 llvm::APFloat imag = value.getComplexFloatImag();
 return builder.getAttr(
-complexType, builder.getAttr(complexElemTy, real),
-builder.getAttr(complexElemTy, imag));
+complexType, cir::FPAttr::get(complexElemTy, real),
+cir::FPAttr::get(complexElemTy, imag));
   }
   case APValue::FixedPoint:
   case APValue::AddrLabelDiff:
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 06827f84f34d4..6eeecca7e7c8f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -165,8 +165,7 @@ class ScalarExprEmitter : public 
StmtVisitor {
 assert(mlir::isa(type) &&
"expect floating-point type");
 return builder.create(
-cgf.getLoc(e->getExprLoc()),
-builder.getAttr(type, e->getValue()));
+cgf.getLoc(e->getExprLoc()), cir::FPAttr::get(type, e->getValue()));
   }
 
   mlir::Value VisitCharacterLiteral(const CharacterLiteral *e) {


[llvm-branch-commits] [clang] [CIR] Clean up IntAttr (PR #146661)

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

https://github.com/xlauko ready_for_review 
https://github.com/llvm/llvm-project/pull/146661
___
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] [CIR] Clean up IntAttr (PR #146661)

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

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Henrich Lauko (xlauko)


Changes

- Add common CIR_ prefix
- Simplify printing/parsing
- Make it use IntTypeInterface

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1725

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


5 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h (+1-1) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+42-11) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp (+3-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+7-8) 
- (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+48-52) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h 
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index 3e052c564112e..41ac8c1c875df 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -63,7 +63,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 
   mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ,
 const llvm::APInt &val) {
-return create(loc, getAttr(typ, val));
+return create(loc, cir::IntAttr::get(typ, val));
   }
 
   cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) {
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 9a6560519eec4..a042f5cd0c19e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -117,36 +117,67 @@ def UndefAttr : CIR_TypedAttr<"Undef", "undef"> {
 // IntegerAttr
 
//===--===//
 
-def IntAttr : CIR_Attr<"Int", "int", [TypedAttrInterface]> {
+def CIR_IntAttr : CIR_Attr<"Int", "int", [TypedAttrInterface]> {
   let summary = "An attribute containing an integer value";
   let description = [{
 An integer attribute is a literal attribute that represents an integral
 value of the specified integer type.
   }];
-  let parameters = (ins AttributeSelfTypeParameter<"">:$type,
-APIntParameter<"">:$value);
+
+  let parameters = (ins
+AttributeSelfTypeParameter<"", "cir::IntTypeInterface">:$type,
+APIntParameter<"">:$value
+  );
+
   let builders = [
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "const llvm::APInt &":$value), [{
-  return $_get(type.getContext(), type, value);
+  auto intType = mlir::cast(type);
+  return $_get(type.getContext(), intType, value);
 }]>,
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "int64_t":$value), [{
-  IntType intType = mlir::cast(type);
+  auto intType = mlir::cast(type);
   mlir::APInt apValue(intType.getWidth(), value, intType.isSigned());
   return $_get(intType.getContext(), intType, apValue);
 }]>,
   ];
+
   let extraClassDeclaration = [{
-int64_t getSInt() const { return getValue().getSExtValue(); }
-uint64_t getUInt() const { return getValue().getZExtValue(); }
-bool isNullValue() const { return getValue() == 0; }
-uint64_t getBitWidth() const {
-  return mlir::cast(getType()).getWidth();
+int64_t getSInt() const;
+uint64_t getUInt() const;
+bool isNullValue() const;
+bool isSigned() const;
+bool isUnsigned() const;
+uint64_t getBitWidth() const;
+  }];
+
+ let extraClassDefinition = [{
+int64_t $cppClass::getSInt() const {
+  return getValue().getSExtValue();
+}
+uint64_t $cppClass::getUInt() const {
+  return getValue().getZExtValue();
+}
+bool $cppClass::isNullValue() const {
+  return getValue() == 0;
+}
+bool $cppClass::isSigned() const {
+  return mlir::cast(getType()).isSigned();
+}
+bool $cppClass::isUnsigned() const {
+  return mlir::cast(getType()).isUnsigned();
+}
+uint64_t $cppClass::getBitWidth() const {
+  return mlir::cast(getType()).getWidth();
 }
   }];
+
+  let assemblyFormat = [{
+`<` custom($value, ref($type)) `>`
+  }];
+
   let genVerifyDecl = 1;
-  let hasCustomAssemblyFormat = 1;
 }
 
 
//===--===//
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index e25819cdb11bf..5fc7a92cd00f9 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -684,7 +684,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const 
APValue &value,
 if (mlir::isa(ty))
   return builder.getCIRBoolAttr(value.getInt().getZExtValue());
 assert(mlir::isa(ty) && "expected integral type");
-return cgm.getBuilder().getAttr(ty, value.getInt());
+return cir::IntAttr::get(ty, value.getInt());
   }

[llvm-branch-commits] [clang] [CIR] Clean up IntAttr (PR #146661)

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

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Henrich Lauko (xlauko)


Changes

- Add common CIR_ prefix
- Simplify printing/parsing
- Make it use IntTypeInterface

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1725

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


5 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h (+1-1) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+42-11) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp (+3-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+7-8) 
- (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+48-52) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h 
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index 3e052c564112e..41ac8c1c875df 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -63,7 +63,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 
   mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ,
 const llvm::APInt &val) {
-return create(loc, getAttr(typ, val));
+return create(loc, cir::IntAttr::get(typ, val));
   }
 
   cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) {
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 9a6560519eec4..a042f5cd0c19e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -117,36 +117,67 @@ def UndefAttr : CIR_TypedAttr<"Undef", "undef"> {
 // IntegerAttr
 
//===--===//
 
-def IntAttr : CIR_Attr<"Int", "int", [TypedAttrInterface]> {
+def CIR_IntAttr : CIR_Attr<"Int", "int", [TypedAttrInterface]> {
   let summary = "An attribute containing an integer value";
   let description = [{
 An integer attribute is a literal attribute that represents an integral
 value of the specified integer type.
   }];
-  let parameters = (ins AttributeSelfTypeParameter<"">:$type,
-APIntParameter<"">:$value);
+
+  let parameters = (ins
+AttributeSelfTypeParameter<"", "cir::IntTypeInterface">:$type,
+APIntParameter<"">:$value
+  );
+
   let builders = [
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "const llvm::APInt &":$value), [{
-  return $_get(type.getContext(), type, value);
+  auto intType = mlir::cast(type);
+  return $_get(type.getContext(), intType, value);
 }]>,
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "int64_t":$value), [{
-  IntType intType = mlir::cast(type);
+  auto intType = mlir::cast(type);
   mlir::APInt apValue(intType.getWidth(), value, intType.isSigned());
   return $_get(intType.getContext(), intType, apValue);
 }]>,
   ];
+
   let extraClassDeclaration = [{
-int64_t getSInt() const { return getValue().getSExtValue(); }
-uint64_t getUInt() const { return getValue().getZExtValue(); }
-bool isNullValue() const { return getValue() == 0; }
-uint64_t getBitWidth() const {
-  return mlir::cast(getType()).getWidth();
+int64_t getSInt() const;
+uint64_t getUInt() const;
+bool isNullValue() const;
+bool isSigned() const;
+bool isUnsigned() const;
+uint64_t getBitWidth() const;
+  }];
+
+ let extraClassDefinition = [{
+int64_t $cppClass::getSInt() const {
+  return getValue().getSExtValue();
+}
+uint64_t $cppClass::getUInt() const {
+  return getValue().getZExtValue();
+}
+bool $cppClass::isNullValue() const {
+  return getValue() == 0;
+}
+bool $cppClass::isSigned() const {
+  return mlir::cast(getType()).isSigned();
+}
+bool $cppClass::isUnsigned() const {
+  return mlir::cast(getType()).isUnsigned();
+}
+uint64_t $cppClass::getBitWidth() const {
+  return mlir::cast(getType()).getWidth();
 }
   }];
+
+  let assemblyFormat = [{
+`<` custom($value, ref($type)) `>`
+  }];
+
   let genVerifyDecl = 1;
-  let hasCustomAssemblyFormat = 1;
 }
 
 
//===--===//
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index e25819cdb11bf..5fc7a92cd00f9 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -684,7 +684,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const 
APValue &value,
 if (mlir::isa(ty))
   return builder.getCIRBoolAttr(value.getInt().getZExtValue());
 assert(mlir::isa(ty) && "expected integral type");
-return cgm.getBuilder().getAttr(ty, value.getInt());
+return cir::IntAttr::get(ty, value.getInt());
   }
 

[llvm-branch-commits] [clang] [CIR] Clean up FPAttr (PR #146662)

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

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Henrich Lauko (xlauko)


Changes

- Adds CIR_ prefix to the definition
- Removes redundant builder and cleans up attribute creations

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1726

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


4 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+7-7) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.cpp (+1-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp (+3-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+1-2) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index a042f5cd0c19e..569e62ae11612 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -184,34 +184,34 @@ def CIR_IntAttr : CIR_Attr<"Int", "int", 
[TypedAttrInterface]> {
 // FPAttr
 
//===--===//
 
-def FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> {
+def CIR_FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> {
   let summary = "An attribute containing a floating-point value";
   let description = [{
 An fp attribute is a literal attribute that represents a floating-point
 value of the specified floating-point type. Supporting only CIR FP types.
   }];
+
   let parameters = (ins
 AttributeSelfTypeParameter<"", "::cir::FPTypeInterface">:$type,
 APFloatParameter<"">:$value
   );
+
   let builders = [
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "const llvm::APFloat &":$value), [{
   return $_get(type.getContext(), mlir::cast(type), 
value);
-}]>,
-AttrBuilder<(ins "mlir::Type":$type,
- "const llvm::APFloat &":$value), [{
-  return $_get($_ctxt, mlir::cast(type), value);
-}]>,
+}]>
   ];
+
   let extraClassDeclaration = [{
 static FPAttr getZero(mlir::Type type);
   }];
-  let genVerifyDecl = 1;
 
   let assemblyFormat = [{
 `<` custom($value, ref($type)) `>`
   }];
+
+  let genVerifyDecl = 1;
 }
 
 
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
index b94963c71f9c1..4a5a1dd53a05a 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
@@ -63,7 +63,7 @@ cir::ConstantOp
 clang::CIRGen::CIRGenBuilderTy::getConstFP(mlir::Location loc, mlir::Type t,
llvm::APFloat fpVal) {
   assert(mlir::isa(t) && "expected floating point type");
-  return create(loc, getAttr(t, fpVal));
+  return create(loc, cir::FPAttr::get(t, fpVal));
 }
 
 // This can't be defined in Address.h because that file is included by
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index 5fc7a92cd00f9..5b3bf85cefbb0 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -698,7 +698,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const 
APValue &value,
 mlir::Type ty = cgm.convertType(destType);
 assert(mlir::isa(ty) &&
"expected floating-point type");
-return cgm.getBuilder().getAttr(ty, init);
+return cir::FPAttr::get(ty, init);
   }
   case APValue::Array: {
 const ArrayType *arrayTy = cgm.getASTContext().getAsArrayType(destType);
@@ -798,8 +798,8 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const 
APValue &value,
 llvm::APFloat real = value.getComplexFloatReal();
 llvm::APFloat imag = value.getComplexFloatImag();
 return builder.getAttr(
-complexType, builder.getAttr(complexElemTy, real),
-builder.getAttr(complexElemTy, imag));
+complexType, cir::FPAttr::get(complexElemTy, real),
+cir::FPAttr::get(complexElemTy, imag));
   }
   case APValue::FixedPoint:
   case APValue::AddrLabelDiff:
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 06827f84f34d4..6eeecca7e7c8f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -165,8 +165,7 @@ class ScalarExprEmitter : public 
StmtVisitor {
 assert(mlir::isa(type) &&
"expect floating-point type");
 return builder.create(
-cgf.getLoc(e->getExprLoc()),
-builder.getAttr(type, e->getValue()));
+cgf.getLoc(e->getExprLoc()), cir::FPAttr::get(type, e->getValue()));
   }
 
   mlir::Value VisitCharacterLiteral(const CharacterLiteral *e) {

``




https://github.com/llvm/llvm-project/pull/146662
___
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] [CIR] Untie Type and Attribute definitions (PR #146663)

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

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Henrich Lauko (xlauko)


Changes

This will allow to use Attributes and Types together in tablegen without 
inducing cyclic dependency.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1727

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


2 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.h (+14-8) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRDialect.h (+1) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
index 64556bcb92baa..925a9a87e267f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
@@ -10,16 +10,15 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
-#define LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
-
-#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
-#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#ifndef CLANG_CIR_DIALECT_IR_CIRATTRS_H
+#define CLANG_CIR_DIALECT_IR_CIRATTRS_H
 
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/BuiltinAttributeInterfaces.h"
 
-#include "llvm/ADT/SmallVector.h"
+#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
+
+#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
 
 
//===--===//
 // CIR Dialect Attrs
@@ -27,15 +26,22 @@
 
 namespace clang {
 class FunctionDecl;
-class VarDecl;
 class RecordDecl;
+class VarDecl;
 } // namespace clang
 
 namespace cir {
 class ArrayType;
+class BoolType;
+class ComplexType;
+class IntType;
+class MethodType;
+class PointerType;
+class RecordType;
+class VectorType;
 } // namespace cir
 
 #define GET_ATTRDEF_CLASSES
 #include "clang/CIR/Dialect/IR/CIROpsAttributes.h.inc"
 
-#endif // LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
+#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_H
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h 
b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
index 5de1722cf5bc2..fdd56ac1f218f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
@@ -29,6 +29,7 @@
 #include "clang/CIR/Dialect/IR/CIRAttrs.h"
 #include "clang/CIR/Dialect/IR/CIROpsDialect.h.inc"
 #include "clang/CIR/Dialect/IR/CIROpsEnums.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
 #include "clang/CIR/Interfaces/CIRLoopOpInterface.h"
 #include "clang/CIR/Interfaces/CIROpInterfaces.h"
 #include "clang/CIR/MissingFeatures.h"

``




https://github.com/llvm/llvm-project/pull/146663
___
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] [CIR] Untie Type and Attribute definitions (PR #146663)

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

https://github.com/xlauko ready_for_review 
https://github.com/llvm/llvm-project/pull/146663
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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

arsenm wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/146691?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#146691** https://app.graphite.dev/github/pr/llvm/llvm-project/146691?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/146691?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#146690** https://app.graphite.dev/github/pr/llvm/llvm-project/146690?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


https://github.com/llvm/llvm-project/pull/146691
___
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] [DLCov] Origin-Tracking: Add debugify support (PR #143594)

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

https://github.com/djtodoro edited 
https://github.com/llvm/llvm-project/pull/143594
___
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] [DLCov] Origin-Tracking: Add debugify support (PR #143594)

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

https://github.com/djtodoro commented:

@SLTozer thanks for doing this!

Are you planning to extend documentation, e.g. 
https://llvm.org/docs/HowToUpdateDebugInfo.html#how-to-automatically-convert-tests-into-debug-info-tests?


https://github.com/llvm/llvm-project/pull/143594
___
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] [DLCov] Origin-Tracking: Add debugify support (PR #143594)

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


@@ -59,6 +65,52 @@ cl::opt DebugifyLevel(
 
 raw_ostream &dbg() { return Quiet ? nulls() : errs(); }
 
+#if LLVM_ENABLE_DEBUGLOC_TRACKING_ORIGIN
+// These maps refer to addresses in this instance of LLVM, so we can reuse them
+// everywhere - therefore, we store them at file scope.
+static SymbolizedAddressMap SymbolizedAddrs;
+static AddressSet UnsymbolizedAddrs;
+
+std::string symbolizeStackTrace(const Instruction *I) {
+  // We flush the set of unsymbolized addresses at the latest possible moment,
+  // i.e. now.
+  if (!UnsymbolizedAddrs.empty()) {
+sys::symbolizeAddresses(UnsymbolizedAddrs, SymbolizedAddrs);
+UnsymbolizedAddrs.clear();
+  }
+  auto OriginStackTraces = I->getDebugLoc().getOriginStackTraces();
+  std::string Result;
+  raw_string_ostream OS(Result);
+  for (size_t TraceIdx = 0; TraceIdx < OriginStackTraces.size(); ++TraceIdx) {
+if (TraceIdx != 0)
+  OS << "\n";
+auto &[Depth, StackTrace] = OriginStackTraces[TraceIdx];
+unsigned VirtualFrameNo = 0;
+for (int Frame = 0; Frame < Depth; ++Frame) {
+  assert(SymbolizedAddrs.contains(StackTrace[Frame]) &&
+ "Expected each address to have been symbolized.");
+  for (std::string &SymbolizedFrame : SymbolizedAddrs[StackTrace[Frame]]) {
+OS << right_justify(formatv("#{0}", VirtualFrameNo++).str(), 
std::log10(Depth) + 2)

djtodoro wrote:

Please run `clang-format`.

https://github.com/llvm/llvm-project/pull/143594
___
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] [CIR] Untie Type and Attribute definitions (PR #146663)

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

xlauko wrote:

### Merge activity

* **Jul 2, 2:25 PM UTC**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/146663).


https://github.com/llvm/llvm-project/pull/146663
___
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] [CIR] Clean up IntAttr (PR #146661)

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

xlauko wrote:

### Merge activity

* **Jul 2, 2:25 PM UTC**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/146661).


https://github.com/llvm/llvm-project/pull/146661
___
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] [CIR] Clean up FPAttr (PR #146662)

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

xlauko wrote:

### Merge activity

* **Jul 2, 2:25 PM UTC**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/146662).


https://github.com/llvm/llvm-project/pull/146662
___
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] [CIR] Clean up FPAttr (PR #146662)

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

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


https://github.com/llvm/llvm-project/pull/146662
___
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] AlwaysInliner: A new inlining algorithm to interleave alloca promotion with inlines. (PR #145613)

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

https://github.com/nikic commented:

Can you please pre-commit a PhaseOrdering test that demonstrates the problem 
you are trying to solve? It's hard to understand whether this is the correct 
solution to the problem without an actual test case.

https://github.com/llvm/llvm-project/pull/145613
___
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] [flang][fir] Small clean-up in `fir_DoConcurrentLoopOp`'s defintion (PR #146028)

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

https://github.com/ergawy updated 
https://github.com/llvm/llvm-project/pull/146028

>From 15ed831ad72cf5d109278f01a693a8fd4a7e2793 Mon Sep 17 00:00:00 2001
From: ergawy 
Date: Fri, 27 Jun 2025 00:05:42 -0500
Subject: [PATCH] [flang][fir] Small clean-up in `fir_DoConcurrentLoopOp`'s
 defintion

Re-organizes the op definition a little bit and removes a method that
does not add much value to the API.
---
 .../include/flang/Optimizer/Dialect/FIROps.td | 22 +--
 .../OpenMP/DoConcurrentConversion.cpp |  4 ++--
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td 
b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 41363234e5c6b..331cf9b94af7e 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -3884,9 +3884,17 @@ def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
   let hasVerifier = 1;
 
   let extraClassDeclaration = [{
-unsigned getNumInductionVars() { return getLowerBound().size(); }
+unsigned getNumInductionVars() {
+  return getLowerBound().size();
+}
 
-unsigned getNumLocalOperands() { return getLocalVars().size(); }
+unsigned getNumLocalOperands() {
+  return getLocalVars().size();
+}
+
+unsigned getNumReduceOperands() {
+  return getReduceVars().size();
+}
 
 mlir::Block::BlockArgListType getInductionVars() {
   return getBody()->getArguments().slice(0, getNumInductionVars());
@@ -3906,16 +3914,6 @@ def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
 /// Number of operands controlling the loop
 unsigned getNumControlOperands() { return getLowerBound().size() * 3; }
 
-// Get Number of reduction operands
-unsigned getNumReduceOperands() {
-  return getReduceVars().size();
-}
-
-mlir::Operation::operand_range getLocalOperands() {
-  return getOperands()
-  .slice(getNumControlOperands() + getNumReduceOperands(),
- getNumLocalOperands());
-}
   }];
 }
 
diff --git a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp 
b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
index 28f6c8bf02813..709cf1d0938fa 100644
--- a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
+++ b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
@@ -314,9 +314,9 @@ class DoConcurrentConversion
 
 // For `local` (and `local_init`) opernads, emit corresponding `private`
 // clauses and attach these clauses to the workshare loop.
-if (!loop.getLocalOperands().empty())
+if (!loop.getLocalVars().empty())
   for (auto [op, sym, arg] : llvm::zip_equal(
-   loop.getLocalOperands(),
+   loop.getLocalVars(),
loop.getLocalSymsAttr().getAsRange(),
loop.getRegionLocalArgs())) {
 auto localizer = mlir::SymbolTable::lookupNearestSymbolFrom<

___
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] [DLCov] Origin-Tracking: Add debugify support (PR #143594)

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

SLTozer wrote:

> Are you planning to extend documentation

Yes, and it probably is best if the documentation lands in this patch!

https://github.com/llvm/llvm-project/pull/143594
___
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] [flang][OpenMP] Basic mapping of `do concurrent ... reduce` to OpenMP (PR #146033)

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

https://github.com/ergawy updated 
https://github.com/llvm/llvm-project/pull/146033

>From ba0d0c89692622968db915fb89d70443d032cdf3 Mon Sep 17 00:00:00 2001
From: ergawy 
Date: Fri, 27 Jun 2025 00:58:08 -0500
Subject: [PATCH 1/2] [flang][OpenMP] Basic mapping of `do concurrent ...
 reduce` to OpenMP

Now that we have changes introduced by #145837, mapping reductions from
`do concurrent` to OpenMP is almost trivial. This PR adds such mapping.
---
 .../OpenMP/DoConcurrentConversion.cpp | 83 +--
 .../Transforms/DoConcurrent/reduce_add.mlir   | 73 
 .../Transforms/DoConcurrent/reduce_local.mlir | 83 +++
 3 files changed, 212 insertions(+), 27 deletions(-)
 create mode 100644 flang/test/Transforms/DoConcurrent/reduce_add.mlir
 create mode 100644 flang/test/Transforms/DoConcurrent/reduce_local.mlir

diff --git a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp 
b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
index 709cf1d0938fa..31076f6eb328f 100644
--- a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
+++ b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
@@ -312,6 +312,19 @@ class DoConcurrentConversion
   bool isComposite) const {
 mlir::omp::WsloopOperands wsloopClauseOps;
 
+auto cloneFIRRegionToOMP = [&rewriter](mlir::Region &firRegion,
+   mlir::Region &ompRegion) {
+  if (!firRegion.empty()) {
+rewriter.cloneRegionBefore(firRegion, ompRegion, ompRegion.begin());
+auto firYield =
+mlir::cast(ompRegion.back().getTerminator());
+rewriter.setInsertionPoint(firYield);
+rewriter.create(firYield.getLoc(),
+firYield.getOperands());
+rewriter.eraseOp(firYield);
+  }
+};
+
 // For `local` (and `local_init`) opernads, emit corresponding `private`
 // clauses and attach these clauses to the workshare loop.
 if (!loop.getLocalVars().empty())
@@ -326,50 +339,65 @@ class DoConcurrentConversion
   TODO(localizer.getLoc(),
"local_init conversion is not supported yet");
 
-auto oldIP = rewriter.saveInsertionPoint();
+mlir::OpBuilder::InsertionGuard guard(rewriter);
 rewriter.setInsertionPointAfter(localizer);
+
 auto privatizer = rewriter.create(
 localizer.getLoc(), sym.getLeafReference().str() + ".omp",
 localizer.getTypeAttr().getValue(),
 mlir::omp::DataSharingClauseType::Private);
 
-if (!localizer.getInitRegion().empty()) {
-  rewriter.cloneRegionBefore(localizer.getInitRegion(),
- privatizer.getInitRegion(),
- privatizer.getInitRegion().begin());
-  auto firYield = mlir::cast(
-  privatizer.getInitRegion().back().getTerminator());
-  rewriter.setInsertionPoint(firYield);
-  rewriter.create(firYield.getLoc(),
-  firYield.getOperands());
-  rewriter.eraseOp(firYield);
-}
-
-if (!localizer.getDeallocRegion().empty()) {
-  rewriter.cloneRegionBefore(localizer.getDeallocRegion(),
- privatizer.getDeallocRegion(),
- privatizer.getDeallocRegion().begin());
-  auto firYield = mlir::cast(
-  privatizer.getDeallocRegion().back().getTerminator());
-  rewriter.setInsertionPoint(firYield);
-  rewriter.create(firYield.getLoc(),
-  firYield.getOperands());
-  rewriter.eraseOp(firYield);
-}
-
-rewriter.restoreInsertionPoint(oldIP);
+cloneFIRRegionToOMP(localizer.getInitRegion(),
+privatizer.getInitRegion());
+cloneFIRRegionToOMP(localizer.getDeallocRegion(),
+privatizer.getDeallocRegion());
 
 wsloopClauseOps.privateVars.push_back(op);
 wsloopClauseOps.privateSyms.push_back(
 mlir::SymbolRefAttr::get(privatizer));
   }
 
+if (!loop.getReduceVars().empty()) {
+  for (auto [op, byRef, sym, arg] : llvm::zip_equal(
+   loop.getReduceVars(), loop.getReduceByrefAttr().asArrayRef(),
+   loop.getReduceSymsAttr().getAsRange(),
+   loop.getRegionReduceArgs())) {
+auto firReducer =
+
mlir::SymbolTable::lookupNearestSymbolFrom(
+loop, sym);
+
+mlir::OpBuilder::InsertionGuard guard(rewriter);
+rewriter.setInsertionPointAfter(firReducer);
+
+auto ompReducer = rewriter.create(
+firReducer.getLoc(), sym.getLeafReference().str() + ".omp",
+firReducer.getTypeAttr().getValue());
+
+cloneFIRRegionToOMP(firReducer.getAllocRegion(),
+ompReducer.getAllocRegion());
+clo

[llvm-branch-commits] [clang] [CIR] Clean up FPAttr (PR #146662)

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

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


https://github.com/llvm/llvm-project/pull/146662
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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

llvmbot wrote:




@llvm/pr-subscribers-backend-arm

Author: Matt Arsenault (arsenm)


Changes

AArch64 was testing a couple of vector cases, and not the base
scalars. Add the one case that isn't in the ARM version there, and
then copy the rest back into AArch64. Also add a windows run line.

---

Patch is 57.09 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/146691.diff


2 Files Affected:

- (modified) llvm/test/CodeGen/AArch64/llvm.frexp.ll (+1345) 
- (modified) llvm/test/CodeGen/ARM/llvm.frexp.ll (+37) 


``diff
diff --git a/llvm/test/CodeGen/AArch64/llvm.frexp.ll 
b/llvm/test/CodeGen/AArch64/llvm.frexp.ll
index e4cb8ed6eaf90..092fe16cbc2f3 100644
--- a/llvm/test/CodeGen/AArch64/llvm.frexp.ll
+++ b/llvm/test/CodeGen/AArch64/llvm.frexp.ll
@@ -1,5 +1,111 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 2
 ; RUN: llc -mtriple=aarch64-gnu-linux < %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -mtriple=aarch64-windows-pc-msvc < %s | FileCheck 
-check-prefixes=WINDOWS %s
+define { half, i32 } @test_frexp_f16_i32(half %a) {
+; CHECK-LABEL: test_frexp_f16_i32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:fcvt s0, h0
+; CHECK-NEXT:add x0, sp, #12
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:ldr w0, [sp, #12]
+; CHECK-NEXT:fcvt h0, s0
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_f16_i32:
+; WINDOWS:   .seh_proc test_frexp_f16_i32
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:fcvt d0, h0
+; WINDOWS-NEXT:add x0, sp, #12
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:ldr w0, [sp, #12]
+; WINDOWS-NEXT:fcvt h0, d0
+; WINDOWS-NEXT:.seh_startepilogue
+; WINDOWS-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endepilogue
+; WINDOWS-NEXT:ret
+; WINDOWS-NEXT:.seh_endfunclet
+; WINDOWS-NEXT:.seh_endproc
+  %result = call { half, i32 } @llvm.frexp.f16.i32(half %a)
+  ret { half, i32 } %result
+}
+
+define half @test_frexp_f16_i32_only_use_fract(half %a) {
+; CHECK-LABEL: test_frexp_f16_i32_only_use_fract:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:fcvt s0, h0
+; CHECK-NEXT:add x0, sp, #12
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:fcvt h0, s0
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_f16_i32_only_use_fract:
+; WINDOWS:   .seh_proc test_frexp_f16_i32_only_use_fract
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:fcvt d0, h0
+; WINDOWS-NEXT:add x0, sp, #12
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:fcvt h0, d0
+; WINDOWS-NEXT:.seh_startepilogue
+; WINDOWS-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endepilogue
+; WINDOWS-NEXT:ret
+; WINDOWS-NEXT:.seh_endfunclet
+; WINDOWS-NEXT:.seh_endproc
+  %result = call { half, i32 } @llvm.frexp.f16.i32(half %a)
+  %result.0 = extractvalue { half, i32 } %result, 0
+  ret half %result.0
+}
+
+define i32 @test_frexp_f16_i32_only_use_exp(half %a) {
+; CHECK-LABEL: test_frexp_f16_i32_only_use_exp:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:fcvt s0, h0
+; CHECK-NEXT:add x0, sp, #12
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:ldr w0, [sp, #12]
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_f16_i32_only_use_exp:
+; WINDOWS:   .seh_proc test_frexp_f16_i32_only_use_exp
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:fcvt d0, h0
+; WINDOWS-NEXT:add x0, sp, #12
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:ldr w0, [sp, #12]
+; WINDOWS-NEXT:.seh_startepilogue
+; WINDOWS-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endepilogue
+; WINDOWS-NEXT:ret
+; WINDOWS-NEXT:.seh_endfunclet
+; WINDOWS-NEXT:.seh_endproc
+  %result = call { half, i32 } @llvm.frexp.f16.i32(half %a)
+  %result.0 = extractvalue { half, i32 } %

[llvm-branch-commits] [clang] [CIR] Clean up IntAttr (PR #146661)

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

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


https://github.com/llvm/llvm-project/pull/146661
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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

https://github.com/arsenm ready_for_review 
https://github.com/llvm/llvm-project/pull/146691
___
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] [CIR] Untie Type and Attribute definitions (PR #146663)

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

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


https://github.com/llvm/llvm-project/pull/146663
___
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] AArch64: Fix some missing llvm.frexp test coverage (PR #146691)

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


@@ -96,6 +432,1015 @@ define { <3 x float>, <3 x i32> } 
@test_frexp_v3f16_v3i32(<3 x float> %a) {
 ; CHECK-NEXT:mov v0.16b, v2.16b
 ; CHECK-NEXT:add sp, sp, #80
 ; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_v3f16_v3i32:
+; WINDOWS:   .seh_proc test_frexp_v3f16_v3i32
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:sub sp, sp, #80
+; WINDOWS-NEXT:.seh_stackalloc 80
+; WINDOWS-NEXT:stp x19, x20, [sp, #48] // 16-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_regp x19, 48
+; WINDOWS-NEXT:stp x21, x30, [sp, #64] // 16-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_lrpair x21, 64
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:mov s1, v0.s[1]
+; WINDOWS-NEXT:str q0, [sp, #16] // 16-byte Folded Spill
+; WINDOWS-NEXT:add x0, sp, #36
+; WINDOWS-NEXT:add x19, sp, #36
+; WINDOWS-NEXT:fcvt d0, s1
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:fcvt s0, d0
+; WINDOWS-NEXT:add x0, sp, #32
+; WINDOWS-NEXT:str q0, [sp] // 16-byte Folded Spill
+; WINDOWS-NEXT:ldr q0, [sp, #16] // 16-byte Folded Reload
+; WINDOWS-NEXT:fcvt d0, s0
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:fcvt s0, d0
+; WINDOWS-NEXT:ldr q1, [sp] // 16-byte Folded Reload
+; WINDOWS-NEXT:add x0, sp, #40
+; WINDOWS-NEXT:add x20, sp, #40
+; WINDOWS-NEXT:mov v0.s[1], v1.s[0]
+; WINDOWS-NEXT:str q0, [sp] // 16-byte Folded Spill
+; WINDOWS-NEXT:ldr q0, [sp, #16] // 16-byte Folded Reload
+; WINDOWS-NEXT:mov s0, v0.s[2]
+; WINDOWS-NEXT:fcvt d0, s0
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:fcvt s0, d0
+; WINDOWS-NEXT:ldr q1, [sp] // 16-byte Folded Reload
+; WINDOWS-NEXT:add x0, sp, #44
+; WINDOWS-NEXT:add x21, sp, #44
+; WINDOWS-NEXT:mov v1.s[2], v0.s[0]
+; WINDOWS-NEXT:ldr q0, [sp, #16] // 16-byte Folded Reload
+; WINDOWS-NEXT:mov s0, v0.s[3]
+; WINDOWS-NEXT:str q1, [sp] // 16-byte Folded Spill
+; WINDOWS-NEXT:fcvt d0, s0
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:ldr s1, [sp, #32]
+; WINDOWS-NEXT:fcvt s2, d0
+; WINDOWS-NEXT:ldr q0, [sp] // 16-byte Folded Reload
+; WINDOWS-NEXT:ld1 { v1.s }[1], [x19]
+; WINDOWS-NEXT:mov v0.s[3], v2.s[0]
+; WINDOWS-NEXT:ld1 { v1.s }[2], [x20]
+; WINDOWS-NEXT:ld1 { v1.s }[3], [x21]
+; WINDOWS-NEXT:.seh_startepilogue
+; WINDOWS-NEXT:ldp x21, x30, [sp, #64] // 16-byte Folded Reload
+; WINDOWS-NEXT:.seh_save_lrpair x21, 64
+; WINDOWS-NEXT:ldp x19, x20, [sp, #48] // 16-byte Folded Reload
+; WINDOWS-NEXT:.seh_save_regp x19, 48
+; WINDOWS-NEXT:add sp, sp, #80
+; WINDOWS-NEXT:.seh_stackalloc 80
+; WINDOWS-NEXT:.seh_endepilogue
+; WINDOWS-NEXT:ret
+; WINDOWS-NEXT:.seh_endfunclet
+; WINDOWS-NEXT:.seh_endproc
   %result = call { <3 x float>, <3 x i32> } @llvm.frexp.v3float.v3i32(<3 x 
float> %a)
   ret { <3 x float>, <3 x i32> } %result
 }
+
+define { float, i32 } @test_frexp_f32_i32(float %a) {
+; CHECK-LABEL: test_frexp_f32_i32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:add x0, sp, #12
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:ldr w0, [sp, #12]
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_f32_i32:
+; WINDOWS:   .seh_proc test_frexp_f32_i32
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:fcvt d0, s0
+; WINDOWS-NEXT:add x0, sp, #12
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:ldr w0, [sp, #12]
+; WINDOWS-NEXT:fcvt s0, d0
+; WINDOWS-NEXT:.seh_startepilogue
+; WINDOWS-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endepilogue
+; WINDOWS-NEXT:ret
+; WINDOWS-NEXT:.seh_endfunclet
+; WINDOWS-NEXT:.seh_endproc
+  %result = call { float, i32 } @llvm.frexp.f32.i32(float %a)
+  ret { float, i32 } %result
+}
+
+define { float, i32 } @test_frexp_f32_i32_tailcall(float %a) {
+; CHECK-LABEL: test_frexp_f32_i32_tailcall:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:add x0, sp, #12
+; CHECK-NEXT:bl frexpf
+; CHECK-NEXT:ldr w0, [sp, #12]
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+;
+; WINDOWS-LABEL: test_frexp_f32_i32_tailcall:
+; WINDOWS:   .seh_proc test_frexp_f32_i32_tailcall
+; WINDOWS-NEXT:  // %bb.0:
+; WINDOWS-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; WINDOWS-NEXT:.seh_save_reg_x x30, 16
+; WINDOWS-NEXT:.seh_endprologue
+; WINDOWS-NEXT:fcvt d0, s0
+; WINDOWS-NEXT:add x0, sp, #12
+; WINDOWS-NEXT:bl frexp
+; WINDOWS-NEXT:ldr w0,

[llvm-branch-commits] [flang] [NFC][flang] Move `ReductionProcessor` to `Lower/Support`. (PR #146025)

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

https://github.com/ergawy updated 
https://github.com/llvm/llvm-project/pull/146025

>From db537f5fbb7d1f7c6c965262beef9682ccdcabf3 Mon Sep 17 00:00:00 2001
From: ergawy 
Date: Thu, 26 Jun 2025 23:30:04 -0500
Subject: [PATCH 1/2] [NFC][flang] Move `ReductionProcessor` to
 `Lower/Support`.

With #145837, the `ReductionProcessor` component is now used by both
OpenMP and `do concurrent`. Therefore, this PR moves it to a shared
location: `flang/Lower/Support`.
---
 flang/{lib => include/flang}/Lower/OpenMP/Clauses.h   | 0
 .../flang/Lower/Support}/ReductionProcessor.h | 2 +-
 flang/lib/Lower/Bridge.cpp| 2 +-
 flang/lib/Lower/CMakeLists.txt| 2 +-
 flang/lib/Lower/OpenMP/ClauseFinder.h | 2 +-
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp| 4 ++--
 flang/lib/Lower/OpenMP/ClauseProcessor.h  | 2 +-
 flang/lib/Lower/OpenMP/Clauses.cpp| 2 +-
 flang/lib/Lower/OpenMP/DataSharingProcessor.h | 2 +-
 flang/lib/Lower/OpenMP/Decomposer.cpp | 2 +-
 flang/lib/Lower/OpenMP/Decomposer.h   | 2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp | 2 +-
 flang/lib/Lower/OpenMP/Utils.cpp  | 3 +--
 flang/lib/Lower/OpenMP/Utils.h| 2 +-
 flang/lib/Lower/{OpenMP => Support}/ReductionProcessor.cpp| 4 ++--
 15 files changed, 16 insertions(+), 17 deletions(-)
 rename flang/{lib => include/flang}/Lower/OpenMP/Clauses.h (100%)
 rename flang/{lib/Lower/OpenMP => 
include/flang/Lower/Support}/ReductionProcessor.h (99%)
 rename flang/lib/Lower/{OpenMP => Support}/ReductionProcessor.cpp (99%)

diff --git a/flang/lib/Lower/OpenMP/Clauses.h 
b/flang/include/flang/Lower/OpenMP/Clauses.h
similarity index 100%
rename from flang/lib/Lower/OpenMP/Clauses.h
rename to flang/include/flang/Lower/OpenMP/Clauses.h
diff --git a/flang/lib/Lower/OpenMP/ReductionProcessor.h 
b/flang/include/flang/Lower/Support/ReductionProcessor.h
similarity index 99%
rename from flang/lib/Lower/OpenMP/ReductionProcessor.h
rename to flang/include/flang/Lower/Support/ReductionProcessor.h
index 95b4b077bdc46..72d8a0096f511 100644
--- a/flang/lib/Lower/OpenMP/ReductionProcessor.h
+++ b/flang/include/flang/Lower/Support/ReductionProcessor.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_LOWER_REDUCTIONPROCESSOR_H
 #define FORTRAN_LOWER_REDUCTIONPROCESSOR_H
 
-#include "Clauses.h"
+#include "flang/Lower/OpenMP/Clauses.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 8e1c7becdba45..d905d9437c659 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -12,7 +12,6 @@
 
 #include "flang/Lower/Bridge.h"
 
-#include "OpenMP/ReductionProcessor.h"
 #include "flang/Lower/Allocatable.h"
 #include "flang/Lower/CallInterface.h"
 #include "flang/Lower/Coarray.h"
@@ -32,6 +31,7 @@
 #include "flang/Lower/PFTBuilder.h"
 #include "flang/Lower/Runtime.h"
 #include "flang/Lower/StatementContext.h"
+#include "flang/Lower/Support/ReductionProcessor.h"
 #include "flang/Lower/Support/Utils.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/CUFCommon.h"
diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index 8049cdf333173..cd80aaf553869 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -29,11 +29,11 @@ add_flang_library(FortranLower
   OpenMP/DataSharingProcessor.cpp
   OpenMP/Decomposer.cpp
   OpenMP/OpenMP.cpp
-  OpenMP/ReductionProcessor.cpp
   OpenMP/Utils.cpp
   PFTBuilder.cpp
   Runtime.cpp
   Support/PrivateReductionUtils.cpp
+  Support/ReductionProcessor.cpp
   Support/Utils.cpp
   SymbolMap.cpp
   VectorSubscripts.cpp
diff --git a/flang/lib/Lower/OpenMP/ClauseFinder.h 
b/flang/lib/Lower/OpenMP/ClauseFinder.h
index 3b77f2ca1d4cb..af52585452833 100644
--- a/flang/lib/Lower/OpenMP/ClauseFinder.h
+++ b/flang/lib/Lower/OpenMP/ClauseFinder.h
@@ -12,7 +12,7 @@
 #ifndef FORTRAN_LOWER_CLAUSEFINDER_H
 #define FORTRAN_LOWER_CLAUSEFINDER_H
 
-#include "Clauses.h"
+#include "flang/Lower/OpenMP/Clauses.h"
 
 namespace Fortran {
 namespace lower {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 5aebfc901e8ac..74087d42a8e6e 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -11,12 +11,12 @@
 
//===--===//
 
 #include "ClauseProcessor.h"
-#include "Clauses.h"
-#include "ReductionProcessor.h"
 #include "Utils.h"
 
 #include "flang/Lower/ConvertExprToHLFIR.h"
+#include "flang/Lower/OpenMP/Clauses.h"
 #include "flang/Lower/PFTBuilder.h"
+#include "flang/Lowe

[llvm-branch-commits] [llvm] [AArch64][PAC] Combine signing with address materialization (PR #130809)

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

atrosinenko wrote:

Ping.

I have rebased this patch so that it is now on top of the stack of
* #145379 - fix for MachineLICM which is needed for LOADgotAUTH to be 
dead-code-eliminated
* #146488 and #146489 - the patches preventing immediate modifier substitution 
for sign and for auth/resign operations, respectively. Applying them before 
this patch instead of after it removes switching on the opcodes of 
`PAC[DI][AB](Z)?` instructions (which would be dropped later anyway): now the 
key (as per `AArch64PACKey::ID`) is taken from the operand of `AArch64::PAC` 
pseudo and the case of zero discriminator is not special anymore. Furthermore, 
this moves the discussion of `fixupBlendComponents` method to #146488, leaving 
this PR solely for the discussion of merging address materialization with the 
subsequent sign operation.

Unfortunately, this PR was initially opened from my fork of llvm-project, so it 
is impossible to formally add it to the Graphite stack, thus I manually 
re-targeted it from `main` branch to 
`users/atrosinenko/pauth-imm-modifier-auth-resign`.

Compared to #133788 this patch has slightly better coverage (supposedly due to 
cross-BB analysis) and is unified for the two ISel variants. This PR is 
inherently AArch64-specific, but we don't have other users of PtrAuth so far. 
Furthermore, implementing the same fix for GlobalISel in addition to DAGISel 
may require implementing something similar to this patch anyway, I guess.

https://github.com/llvm/llvm-project/pull/130809
___
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] [BOLT][NFC] Update nfc-check-setup.py guidance (PR #146659)

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

https://github.com/paschalis-mpeis created 
https://github.com/llvm/llvm-project/pull/146659

None

>From 8cc8661aa2df5e5a6e04752083335a865b0178fe Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis 
Date: Wed, 2 Jul 2025 10:35:22 +0100
Subject: [PATCH] [BOLT][NFC] Update nfc-check-setup.py guidance

---
 bolt/utils/nfc-check-setup.py | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/bolt/utils/nfc-check-setup.py b/bolt/utils/nfc-check-setup.py
index 6cf1df5c177ae..87a134aea37ca 100755
--- a/bolt/utils/nfc-check-setup.py
+++ b/bolt/utils/nfc-check-setup.py
@@ -47,8 +47,10 @@ def main():
 parser = argparse.ArgumentParser(
 description=textwrap.dedent(
 """
-This script builds two versions of BOLT (with the current and
-previous revision).
+This script builds two versions of BOLT:
+llvm-bolt.new, using the current revision, and llvm-bolt.old using
+the previous revision. These can be used to check whether the
+current revision changes BOLT's functional behavior.
 """
 )
 )
@@ -156,9 +158,8 @@ def main():
 os.replace(bolt_path, f"{bolt_path}.old")
 
 print(
-f"Build directory {args.build_dir} is ready to run BOLT tests, e.g.\n"
-"\tbin/llvm-lit -sv tools/bolt/test\nor\n"
-"\tbin/llvm-lit -sv tools/bolttests"
+f"Build directory {args.build_dir} is ready for NFC-Mode comparison "
+"between the two revisions."
 )
 
 

___
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] [BOLT][NFC] Update nfc-check-setup.py guidance (PR #146659)

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

https://github.com/paschalis-mpeis ready_for_review 
https://github.com/llvm/llvm-project/pull/146659
___
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] [BOLT][NFC] Update nfc-check-setup.py guidance (PR #146659)

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

llvmbot wrote:




@llvm/pr-subscribers-bolt

Author: Paschalis Mpeis (paschalis-mpeis)


Changes



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


1 Files Affected:

- (modified) bolt/utils/nfc-check-setup.py (+6-5) 


``diff
diff --git a/bolt/utils/nfc-check-setup.py b/bolt/utils/nfc-check-setup.py
index 6cf1df5c177ae..87a134aea37ca 100755
--- a/bolt/utils/nfc-check-setup.py
+++ b/bolt/utils/nfc-check-setup.py
@@ -47,8 +47,10 @@ def main():
 parser = argparse.ArgumentParser(
 description=textwrap.dedent(
 """
-This script builds two versions of BOLT (with the current and
-previous revision).
+This script builds two versions of BOLT:
+llvm-bolt.new, using the current revision, and llvm-bolt.old using
+the previous revision. These can be used to check whether the
+current revision changes BOLT's functional behavior.
 """
 )
 )
@@ -156,9 +158,8 @@ def main():
 os.replace(bolt_path, f"{bolt_path}.old")
 
 print(
-f"Build directory {args.build_dir} is ready to run BOLT tests, e.g.\n"
-"\tbin/llvm-lit -sv tools/bolt/test\nor\n"
-"\tbin/llvm-lit -sv tools/bolttests"
+f"Build directory {args.build_dir} is ready for NFC-Mode comparison "
+"between the two revisions."
 )
 
 

``




https://github.com/llvm/llvm-project/pull/146659
___
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] [DLCov] Origin-Tracking: Collect stack traces in DebugLoc (PR #143592)

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

SLTozer wrote:

Clicked the wrong button and accidentally merged the wrong branch (fortunately, 
this just merged into another PR branch, not main) - will reopen imminently, as 
github apparently won't allow me to reopen this PR in-place!

https://github.com/llvm/llvm-project/pull/143592
___
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] [DLCov] Origin-Tracking: Collect stack traces in DebugLoc (PR #143592)

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


@@ -27,6 +27,21 @@ namespace llvm {
   class Function;
 
 #if LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING
+#if LLVM_ENABLE_DEBUGLOC_ORIGIN_TRACKING
+  struct DbgLocOrigin {
+static constexpr unsigned long MaxDepth = 16;
+using StackTracesTy =
+SmallVector>, 0>;

SLTozer wrote:

Most of the time we store 0 stacktraces, but when we do store a stacktrace 
there may be any number of them - the `addTrace` function adds a new stacktrace 
to the vector, and is used whenever the DebugLoc is "transferred", so that we 
can track the motion of a missing debug location through the program.

https://github.com/llvm/llvm-project/pull/143592
___
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] [DLCov] Origin-Tracking: Collect stack traces in DebugLoc (PR #143592)

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


@@ -55,22 +70,29 @@ namespace llvm {
 Temporary
   };
 
-  // Extends TrackingMDNodeRef to also store a DebugLocKind, allowing Debugify
-  // to ignore intentionally-empty DebugLocs.
-  class DILocAndCoverageTracking : public TrackingMDNodeRef {
+  // Extends TrackingMDNodeRef to also store a DebugLocKind and Origin,
+  // allowing Debugify to ignore intentionally-empty DebugLocs and display the
+  // code responsible for generating unintentionally-empty DebugLocs.
+  // Currently we only need to track the Origin of this DILoc when using a
+  // DebugLoc that is not annotated (i.e. has DebugLocKind::Normal) and has a
+  // null DILocation, so only collect the origin stacktrace in those cases.
+  class DILocAndCoverageTracking : public TrackingMDNodeRef,
+   public DbgLocOrigin {

SLTozer wrote:

We could manage without it, but the reason I use inheritance here is that this 
allows `DILocAndCoverageTracking` to automatically have the same public 
functions as `DbgLocOrigin`, meaning we conditionally have the origin-tracking 
functions enabled without having to repeat ourselves here.

https://github.com/llvm/llvm-project/pull/143592
___
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] [compiler-rt] b720ebf - Revert "[TSan] Clarify and enforce shadow end alignment (#144648)"

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

Author: Kunqiu Chen
Date: 2025-07-02T20:08:01+08:00
New Revision: b720ebf8c4dc2e089df2c15a616e9771ed03a4c3

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

LOG: Revert "[TSan] Clarify and enforce shadow end alignment (#144648)"

This reverts commit bc90166a50c4197b7666889c128e70c8f8fad2f3.

Added: 


Modified: 
compiler-rt/lib/tsan/rtl/tsan_interface_java.cpp
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp
compiler-rt/lib/tsan/rtl/tsan_sync.cpp
compiler-rt/test/tsan/java_heap_init2.cpp
compiler-rt/test/tsan/munmap_clear_shadow.c

Removed: 




diff  --git a/compiler-rt/lib/tsan/rtl/tsan_interface_java.cpp 
b/compiler-rt/lib/tsan/rtl/tsan_interface_java.cpp
index cb4d767d903d3..7c15a16388268 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interface_java.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interface_java.cpp
@@ -122,6 +122,7 @@ void __tsan_java_move(jptr src, jptr dst, jptr size) {
   DCHECK_GE(dst, jctx->heap_begin);
   DCHECK_LE(dst + size, jctx->heap_begin + jctx->heap_size);
   DCHECK_NE(dst, src);
+  DCHECK_NE(size, 0);
 
   // Assuming it's not running concurrently with threads that do
   // memory accesses and mutex operations (stop-the-world phase).

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp 
b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index 0d7247a56a4c2..981f37b89e784 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -566,32 +566,17 @@ static bool IsValidMmapRange(uptr addr, uptr size) {
   return false;
 }
 
-void UnmapShadow(ThreadState* thr, uptr addr, uptr size) {
+void UnmapShadow(ThreadState *thr, uptr addr, uptr size) {
   if (size == 0 || !IsValidMmapRange(addr, size))
 return;
-  // unmap shadow is related to semantic of mmap/munmap, so we
-  // should clear the whole shadow range, including the tail shadow
-  // while addr + size % kShadowCell != 0.
-  uptr rounded_size_shadow = RoundUp(addr + size, kShadowCell) - addr;
-  DontNeedShadowFor(addr, rounded_size_shadow);
+  DontNeedShadowFor(addr, size);
   ScopedGlobalProcessor sgp;
   SlotLocker locker(thr, true);
-  uptr rounded_size_meta = RoundUp(addr + size, kMetaShadowCell) - addr;
-  ctx->metamap.ResetRange(thr->proc(), addr, rounded_size_meta, true);
+  ctx->metamap.ResetRange(thr->proc(), addr, size, true);
 }
 #endif
 
 void MapShadow(uptr addr, uptr size) {
-  // Although named MapShadow, this function's semantic is unrelated to
-  // UnmapShadow. This function currently only used for Go's lazy allocation
-  // of shadow, whose targets are program section (e.g., bss, data, etc.).
-  // Therefore, we can guarantee that the addr and size align to kShadowCell
-  // and kMetaShadowCell by the following assertions.
-  DCHECK_EQ(addr % kShadowCell, 0);
-  DCHECK_EQ(size % kShadowCell, 0);
-  DCHECK_EQ(addr % kMetaShadowCell, 0);
-  DCHECK_EQ(size % kMetaShadowCell, 0);
-
   // Ensure thead registry lock held, so as to synchronize
   // with DoReset, which also access the mapped_shadow_* ctxt fields.
   ThreadRegistryLock lock0(&ctx->thread_registry);

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp 
b/compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp
index 487fa490636eb..bd8deefefa1bc 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp
@@ -688,18 +688,16 @@ void MemoryAccessRangeT(ThreadState* thr, uptr pc, uptr 
addr, uptr size) {
 DCHECK(IsShadowMem(shadow_mem));
   }
 
-  uptr rounded_size =
-  (RoundUpTo(addr + size, kShadowCell) - RoundDownTo(addr, kShadowCell));
-  RawShadow* shadow_mem_end =
-  shadow_mem + rounded_size / kShadowCell * kShadowCnt;
-  if (!IsShadowMem(shadow_mem_end - 1)) {
-Printf("Bad shadow end addr: %p (%p)\n", shadow_mem_end - 1,
+  RawShadow* shadow_mem_end = reinterpret_cast(
+  reinterpret_cast(shadow_mem) + size * kShadowMultiplier - 1);
+  if (!IsShadowMem(shadow_mem_end)) {
+Printf("Bad shadow end addr: %p (%p)\n", shadow_mem_end,
(void*)(addr + size - 1));
 Printf(
-"Shadow start addr (ok): %p (%p); size: 0x%zx; rounded_size: 0x%zx; "
-"kShadowMultiplier: %zx\n",
-shadow_mem, (void*)addr, size, rounded_size, kShadowMultiplier);
-DCHECK(IsShadowMem(shadow_mem_end - 1));
+"Shadow start addr (ok): %p (%p); size: 0x%zx; kShadowMultiplier: "
+"%zx\n",
+shadow_mem, (void*)addr, size, kShadowMultiplier);
+DCHECK(IsShadowMem(shadow_mem_end));
   }
 #endif
 

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_sync.cpp 
b/compiler-rt/lib/tsan/rtl/tsan_sync.cpp
index be5829bc823dc..97335bc8ecf71 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_sync.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_sync.cpp
@@ -246,20 +246,6 @@ void MetaMap

[llvm-branch-commits] AlwaysInliner: A new inlining algorithm to interleave alloca promotion with inlines. (PR #145613)

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

https://github.com/aemerson updated 
https://github.com/llvm/llvm-project/pull/145613


___
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] AlwaysInliner: A new inlining algorithm to interleave alloca promotion with inlines. (PR #145613)

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

aemerson wrote:

I managed to reduce down the original SME test to 
`Transforms/PhaseOrdering/always-inline-alloca-promotion.ll`. Compiling that to 
assembly with clang with and without the change shows the differences in 
codegen quality, but the IR shows the kind of scenario this patch is meant to 
handle.

https://github.com/llvm/llvm-project/pull/145613
___
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] AlwaysInliner: A new inlining algorithm to interleave alloca promotion with inlines. (PR #145613)

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

https://github.com/aemerson updated 
https://github.com/llvm/llvm-project/pull/145613


___
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] AlwaysInliner: A new inlining algorithm to interleave alloca promotion with inlines. (PR #145613)

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

github-actions[bot] wrote:




:warning: undef deprecator found issues in your code. :warning:



You can test this locally with the following command:


``bash
git diff -U0 --pickaxe-regex -S 
'([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' 'HEAD~1' HEAD 
llvm/test/Transforms/Inline/always-inline-alloca-promotion-no-leaf.ll 
llvm/test/Transforms/Inline/always-inline-alloca-promotion.ll 
clang/test/CodeGen/PowerPC/builtins-ppc-xl-xst.c 
clang/test/CodeGen/X86/avx512f-builtins.c 
clang/test/CodeGen/X86/avx512vl-builtins.c 
clang/test/CodeGen/X86/avx512vlbw-builtins.c clang/test/CodeGen/arm_acle.c 
clang/test/Headers/amdgcn_openmp_device_math.c 
clang/test/Headers/openmp_device_math_isnan.cpp clang/test/OpenMP/bug57757.cpp 
llvm/lib/Transforms/IPO/AlwaysInliner.cpp 
llvm/test/Transforms/Inline/always-inline-phase-ordering.ll 
llvm/test/Transforms/PhaseOrdering/always-inline-alloca-promotion.ll
``




The following files introduce new uses of undef:
 - llvm/test/Transforms/PhaseOrdering/always-inline-alloca-promotion.ll

[Undef](https://llvm.org/docs/LangRef.html#undefined-values) is now deprecated 
and should only be used in the rare cases where no replacement is possible. For 
example, a load of uninitialized memory yields `undef`. You should use `poison` 
values for placeholders instead.

In tests, avoid using `undef` and having tests that trigger undefined behavior. 
If you need an operand with some unimportant value, you can add a new argument 
to the function and use that instead.

For example, this is considered a bad practice:
```llvm
define void @fn() {
  ...
  br i1 undef, ...
}
```

Please use the following instead:
```llvm
define void @fn(i1 %cond) {
  ...
  br i1 %cond, ...
}
```

Please refer to the [Undefined Behavior 
Manual](https://llvm.org/docs/UndefinedBehavior.html) for more information.



https://github.com/llvm/llvm-project/pull/145613
___
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] [CIR] Untie Type and Attribute definitions (PR #146663)

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

xlauko wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/146663?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#146663** https://app.graphite.dev/github/pr/llvm/llvm-project/146663?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/146663?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#146662** https://app.graphite.dev/github/pr/llvm/llvm-project/146662?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#146661** https://app.graphite.dev/github/pr/llvm/llvm-project/146661?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#146660** https://app.graphite.dev/github/pr/llvm/llvm-project/146660?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


https://github.com/llvm/llvm-project/pull/146663
___
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] [CIR] Untie Type and Attribute definitions (PR #146663)

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

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Henrich Lauko (xlauko)


Changes

This will allow to use Attributes and Types together in tablegen without 
inducing cyclic dependency.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1727

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


2 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.h (+14-8) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRDialect.h (+1) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
index 64556bcb92baa..925a9a87e267f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
@@ -10,16 +10,15 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
-#define LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
-
-#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
-#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#ifndef CLANG_CIR_DIALECT_IR_CIRATTRS_H
+#define CLANG_CIR_DIALECT_IR_CIRATTRS_H
 
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/BuiltinAttributeInterfaces.h"
 
-#include "llvm/ADT/SmallVector.h"
+#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
+
+#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
 
 
//===--===//
 // CIR Dialect Attrs
@@ -27,15 +26,22 @@
 
 namespace clang {
 class FunctionDecl;
-class VarDecl;
 class RecordDecl;
+class VarDecl;
 } // namespace clang
 
 namespace cir {
 class ArrayType;
+class BoolType;
+class ComplexType;
+class IntType;
+class MethodType;
+class PointerType;
+class RecordType;
+class VectorType;
 } // namespace cir
 
 #define GET_ATTRDEF_CLASSES
 #include "clang/CIR/Dialect/IR/CIROpsAttributes.h.inc"
 
-#endif // LLVM_CLANG_CIR_DIALECT_IR_CIRATTRS_H
+#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_H
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h 
b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
index 5de1722cf5bc2..fdd56ac1f218f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
@@ -29,6 +29,7 @@
 #include "clang/CIR/Dialect/IR/CIRAttrs.h"
 #include "clang/CIR/Dialect/IR/CIROpsDialect.h.inc"
 #include "clang/CIR/Dialect/IR/CIROpsEnums.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
 #include "clang/CIR/Interfaces/CIRLoopOpInterface.h"
 #include "clang/CIR/Interfaces/CIROpInterfaces.h"
 #include "clang/CIR/MissingFeatures.h"

``




https://github.com/llvm/llvm-project/pull/146663
___
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] [DLCov] Origin-Tracking: Collect stack traces in DebugLoc (PR #143592)

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

https://github.com/SLTozer closed 
https://github.com/llvm/llvm-project/pull/143592
___
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] [DLCov] Origin-Tracking: Add debugify support (PR #143594)

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

https://github.com/SLTozer edited 
https://github.com/llvm/llvm-project/pull/143594
___
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] [CIR] Clean up FPAttr (PR #146662)

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

https://github.com/xlauko ready_for_review 
https://github.com/llvm/llvm-project/pull/146662
___
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] b1bb298 - Revert "Revert "Fix wcpncpy() return value; add test." (#146752)"

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

Author: enh-google
Date: 2025-07-02T14:13:00-04:00
New Revision: b1bb298246aa96f413625bf2fccdf11d1b329ae7

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

LOG: Revert "Revert "Fix wcpncpy() return value; add test." (#146752)"

This reverts commit 77d95911a3a4dc7445280cd5ee217e2a47a41b47.

Added: 


Modified: 
libc/src/wchar/wcpncpy.cpp
libc/test/src/wchar/wcpncpy_test.cpp

Removed: 




diff  --git a/libc/src/wchar/wcpncpy.cpp b/libc/src/wchar/wcpncpy.cpp
index 9f451b73f07cb..0e729db7abf60 100644
--- a/libc/src/wchar/wcpncpy.cpp
+++ b/libc/src/wchar/wcpncpy.cpp
@@ -28,8 +28,9 @@ LLVM_LIBC_FUNCTION(wchar_t *, wcpncpy,
   for (i = 0; i < n && s2[i] != '\0'; ++i)
 s1[i] = s2[i];
   // When n>strlen(src), n-strlen(src) \0 are appended.
-  for (; i < n; ++i)
-s1[i] = L'\0';
+  for (size_t j = i; j < n; ++j)
+s1[j] = L'\0';
+  // ...but our result points to the first \0 (if any).
   return s1 + i;
 }
 

diff  --git a/libc/test/src/wchar/wcpncpy_test.cpp 
b/libc/test/src/wchar/wcpncpy_test.cpp
index 98738e230e32d..5ce3e8ce7cd93 100644
--- a/libc/test/src/wchar/wcpncpy_test.cpp
+++ b/libc/test/src/wchar/wcpncpy_test.cpp
@@ -75,6 +75,15 @@ TEST(LlvmLibcWCPNCpyTest, CopyTwoWithNull) {
   ASSERT_EQ(dest + 2, res);
 }
 
+TEST(LlvmLibcWCPNCpyTest, CopyAndFill) {
+  wchar_t dest[] = {L'a', L'b', L'c'};
+  wchar_t *res = LIBC_NAMESPACE::wcpncpy(dest, L"x", 3);
+  ASSERT_TRUE(dest[0] == L'x');
+  ASSERT_TRUE(dest[1] == L'\0');
+  ASSERT_TRUE(dest[2] == L'\0');
+  ASSERT_EQ(dest + 1, res);
+}
+
 #if defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER)
 TEST(LlvmLibcWCPNCpyTest, NullptrCrash) {
   // Passing in a nullptr should crash the program.



___
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] [BOLT] Improve file handling in NFC-Mode (PR #146513)

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

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

Thanks for fixing this.

https://github.com/llvm/llvm-project/pull/146513
___
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] [BOLT][NFC] Update nfc-check-setup.py guidance (PR #146659)

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

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


https://github.com/llvm/llvm-project/pull/146659
___
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] [BOLT][NFC] Update nfc-check-setup.py guidance (PR #146659)

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


@@ -156,9 +158,8 @@ def main():
 os.replace(bolt_path, f"{bolt_path}.old")
 
 print(
-f"Build directory {args.build_dir} is ready to run BOLT tests, e.g.\n"
-"\tbin/llvm-lit -sv tools/bolt/test\nor\n"
-"\tbin/llvm-lit -sv tools/bolttests"
+f"Build directory {args.build_dir} is ready for NFC-Mode comparison "
+"between the two revisions."

aaupov wrote:

Keep the example commands? I copy-paste from them often

https://github.com/llvm/llvm-project/pull/146659
___
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] [clang][OpenMP] Use DirectiveNameParser to parse directive names (PR #146779)

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

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krzysztof Parzyszek (kparzysz)


Changes

This simplifies the parsing code in clang quite a bit.

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


1 Files Affected:

- (modified) clang/lib/Parse/ParseOpenMP.cpp (+19-162) 


``diff
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index f694ae1d0d112..c0a17d0e9537d 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -25,6 +25,7 @@
 #include "clang/Sema/SemaOpenMP.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Frontend/OpenMP/DirectiveNameParser.h"
 #include "llvm/Frontend/OpenMP/OMPAssume.h"
 #include "llvm/Frontend/OpenMP/OMPContext.h"
 #include 
@@ -37,48 +38,6 @@ using namespace llvm::omp;
 
//===--===//
 
 namespace {
-enum OpenMPDirectiveKindEx {
-  OMPD_cancellation = llvm::omp::Directive_enumSize + 1,
-  OMPD_data,
-  OMPD_declare,
-  OMPD_end,
-  OMPD_end_declare,
-  OMPD_enter,
-  OMPD_exit,
-  OMPD_point,
-  OMPD_reduction,
-  OMPD_target_enter,
-  OMPD_target_exit,
-  OMPD_update,
-  OMPD_distribute_parallel,
-  OMPD_teams_distribute_parallel,
-  OMPD_target_teams_distribute_parallel,
-  OMPD_mapper,
-  OMPD_variant,
-  OMPD_begin,
-  OMPD_begin_declare,
-};
-
-// Helper to unify the enum class OpenMPDirectiveKind with its extension
-// the OpenMPDirectiveKindEx enum which allows to use them together as if they
-// are unsigned values.
-struct OpenMPDirectiveKindExWrapper {
-  OpenMPDirectiveKindExWrapper(unsigned Value) : Value(Value) {}
-  OpenMPDirectiveKindExWrapper(OpenMPDirectiveKind DK) : Value(unsigned(DK)) {}
-  bool operator==(OpenMPDirectiveKindExWrapper V) const {
-return Value == V.Value;
-  }
-  bool operator!=(OpenMPDirectiveKindExWrapper V) const {
-return Value != V.Value;
-  }
-  bool operator==(OpenMPDirectiveKind V) const { return Value == unsigned(V); }
-  bool operator!=(OpenMPDirectiveKind V) const { return Value != unsigned(V); }
-  bool operator<(OpenMPDirectiveKind V) const { return Value < unsigned(V); }
-  operator unsigned() const { return Value; }
-  operator OpenMPDirectiveKind() const { return OpenMPDirectiveKind(Value); }
-  unsigned Value;
-};
-
 class DeclDirectiveListParserHelper final {
   SmallVector Identifiers;
   Parser *P;
@@ -97,130 +56,32 @@ class DeclDirectiveListParserHelper final {
 };
 } // namespace
 
-// Map token string to extended OMP token kind that are
-// OpenMPDirectiveKind + OpenMPDirectiveKindEx.
-static unsigned getOpenMPDirectiveKindEx(StringRef S) {
-  OpenMPDirectiveKindExWrapper DKind = getOpenMPDirectiveKind(S);
-  if (DKind != OMPD_unknown)
-return DKind;
-
-  return llvm::StringSwitch(S)
-  .Case("cancellation", OMPD_cancellation)
-  .Case("data", OMPD_data)
-  .Case("declare", OMPD_declare)
-  .Case("end", OMPD_end)
-  .Case("enter", OMPD_enter)
-  .Case("exit", OMPD_exit)
-  .Case("point", OMPD_point)
-  .Case("reduction", OMPD_reduction)
-  .Case("update", OMPD_update)
-  .Case("mapper", OMPD_mapper)
-  .Case("variant", OMPD_variant)
-  .Case("begin", OMPD_begin)
-  .Default(OMPD_unknown);
-}
+static OpenMPDirectiveKind parseOpenMPDirectiveKind(Parser &P) {
+  static const DirectiveNameParser DNP;
+
+  const DirectiveNameParser::State *S = DNP.initial();
 
-static OpenMPDirectiveKindExWrapper parseOpenMPDirectiveKind(Parser &P) {
-  // Array of foldings: F[i][0] F[i][1] ===> F[i][2].
-  // E.g.: OMPD_for OMPD_simd ===> OMPD_for_simd
-  // TODO: add other combined directives in topological order.
-  static const OpenMPDirectiveKindExWrapper F[][3] = {
-  {OMPD_begin, OMPD_declare, OMPD_begin_declare},
-  {OMPD_begin, OMPD_assumes, OMPD_begin_assumes},
-  {OMPD_end, OMPD_declare, OMPD_end_declare},
-  {OMPD_end, OMPD_assumes, OMPD_end_assumes},
-  {OMPD_cancellation, OMPD_point, OMPD_cancellation_point},
-  {OMPD_declare, OMPD_reduction, OMPD_declare_reduction},
-  {OMPD_declare, OMPD_mapper, OMPD_declare_mapper},
-  {OMPD_declare, OMPD_simd, OMPD_declare_simd},
-  {OMPD_declare, OMPD_target, OMPD_declare_target},
-  {OMPD_declare, OMPD_variant, OMPD_declare_variant},
-  {OMPD_begin_declare, OMPD_target, OMPD_begin_declare_target},
-  {OMPD_begin_declare, OMPD_variant, OMPD_begin_declare_variant},
-  {OMPD_end_declare, OMPD_variant, OMPD_end_declare_variant},
-  {OMPD_distribute, OMPD_parallel, OMPD_distribute_parallel},
-  {OMPD_distribute_parallel, OMPD_for, OMPD_distribute_parallel_for},
-  {OMPD_distribute_parallel_for, OMPD_simd,
-   OMPD_distribute_parallel_for_simd},
-  {OMPD_distribute, OMPD_simd, OMPD_distribute_simd},
-  {OMPD_end_declare, OMPD_target, OMPD_end_declare_target},
-  {OMPD_target, OMPD_data, OMPD_target_data},
-  {OMPD_target, OMPD_enter, OMPD_target_ent

[llvm-branch-commits] [clang] [clang][OpenMP] Use DirectiveNameParser to parse directive names (PR #146779)

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

https://github.com/kparzysz created 
https://github.com/llvm/llvm-project/pull/146779

This simplifies the parsing code in clang quite a bit.

>From ab3f0cc9d240f12e07be452effa75b5c7d010d9b Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 2 Jul 2025 11:25:00 -0500
Subject: [PATCH] [clang][OpenMP] Use DirectiveNameParser to parse directive
 names

This simplifies the parsing code in clang quite a bit.
---
 clang/lib/Parse/ParseOpenMP.cpp | 181 
 1 file changed, 19 insertions(+), 162 deletions(-)

diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index f694ae1d0d112..c0a17d0e9537d 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -25,6 +25,7 @@
 #include "clang/Sema/SemaOpenMP.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Frontend/OpenMP/DirectiveNameParser.h"
 #include "llvm/Frontend/OpenMP/OMPAssume.h"
 #include "llvm/Frontend/OpenMP/OMPContext.h"
 #include 
@@ -37,48 +38,6 @@ using namespace llvm::omp;
 
//===--===//
 
 namespace {
-enum OpenMPDirectiveKindEx {
-  OMPD_cancellation = llvm::omp::Directive_enumSize + 1,
-  OMPD_data,
-  OMPD_declare,
-  OMPD_end,
-  OMPD_end_declare,
-  OMPD_enter,
-  OMPD_exit,
-  OMPD_point,
-  OMPD_reduction,
-  OMPD_target_enter,
-  OMPD_target_exit,
-  OMPD_update,
-  OMPD_distribute_parallel,
-  OMPD_teams_distribute_parallel,
-  OMPD_target_teams_distribute_parallel,
-  OMPD_mapper,
-  OMPD_variant,
-  OMPD_begin,
-  OMPD_begin_declare,
-};
-
-// Helper to unify the enum class OpenMPDirectiveKind with its extension
-// the OpenMPDirectiveKindEx enum which allows to use them together as if they
-// are unsigned values.
-struct OpenMPDirectiveKindExWrapper {
-  OpenMPDirectiveKindExWrapper(unsigned Value) : Value(Value) {}
-  OpenMPDirectiveKindExWrapper(OpenMPDirectiveKind DK) : Value(unsigned(DK)) {}
-  bool operator==(OpenMPDirectiveKindExWrapper V) const {
-return Value == V.Value;
-  }
-  bool operator!=(OpenMPDirectiveKindExWrapper V) const {
-return Value != V.Value;
-  }
-  bool operator==(OpenMPDirectiveKind V) const { return Value == unsigned(V); }
-  bool operator!=(OpenMPDirectiveKind V) const { return Value != unsigned(V); }
-  bool operator<(OpenMPDirectiveKind V) const { return Value < unsigned(V); }
-  operator unsigned() const { return Value; }
-  operator OpenMPDirectiveKind() const { return OpenMPDirectiveKind(Value); }
-  unsigned Value;
-};
-
 class DeclDirectiveListParserHelper final {
   SmallVector Identifiers;
   Parser *P;
@@ -97,130 +56,32 @@ class DeclDirectiveListParserHelper final {
 };
 } // namespace
 
-// Map token string to extended OMP token kind that are
-// OpenMPDirectiveKind + OpenMPDirectiveKindEx.
-static unsigned getOpenMPDirectiveKindEx(StringRef S) {
-  OpenMPDirectiveKindExWrapper DKind = getOpenMPDirectiveKind(S);
-  if (DKind != OMPD_unknown)
-return DKind;
-
-  return llvm::StringSwitch(S)
-  .Case("cancellation", OMPD_cancellation)
-  .Case("data", OMPD_data)
-  .Case("declare", OMPD_declare)
-  .Case("end", OMPD_end)
-  .Case("enter", OMPD_enter)
-  .Case("exit", OMPD_exit)
-  .Case("point", OMPD_point)
-  .Case("reduction", OMPD_reduction)
-  .Case("update", OMPD_update)
-  .Case("mapper", OMPD_mapper)
-  .Case("variant", OMPD_variant)
-  .Case("begin", OMPD_begin)
-  .Default(OMPD_unknown);
-}
+static OpenMPDirectiveKind parseOpenMPDirectiveKind(Parser &P) {
+  static const DirectiveNameParser DNP;
+
+  const DirectiveNameParser::State *S = DNP.initial();
 
-static OpenMPDirectiveKindExWrapper parseOpenMPDirectiveKind(Parser &P) {
-  // Array of foldings: F[i][0] F[i][1] ===> F[i][2].
-  // E.g.: OMPD_for OMPD_simd ===> OMPD_for_simd
-  // TODO: add other combined directives in topological order.
-  static const OpenMPDirectiveKindExWrapper F[][3] = {
-  {OMPD_begin, OMPD_declare, OMPD_begin_declare},
-  {OMPD_begin, OMPD_assumes, OMPD_begin_assumes},
-  {OMPD_end, OMPD_declare, OMPD_end_declare},
-  {OMPD_end, OMPD_assumes, OMPD_end_assumes},
-  {OMPD_cancellation, OMPD_point, OMPD_cancellation_point},
-  {OMPD_declare, OMPD_reduction, OMPD_declare_reduction},
-  {OMPD_declare, OMPD_mapper, OMPD_declare_mapper},
-  {OMPD_declare, OMPD_simd, OMPD_declare_simd},
-  {OMPD_declare, OMPD_target, OMPD_declare_target},
-  {OMPD_declare, OMPD_variant, OMPD_declare_variant},
-  {OMPD_begin_declare, OMPD_target, OMPD_begin_declare_target},
-  {OMPD_begin_declare, OMPD_variant, OMPD_begin_declare_variant},
-  {OMPD_end_declare, OMPD_variant, OMPD_end_declare_variant},
-  {OMPD_distribute, OMPD_parallel, OMPD_distribute_parallel},
-  {OMPD_distribute_parallel, OMPD_for, OMPD_distribute_parallel_for},
-  {OMPD_distribute_parallel_for, OMPD_simd,
-   OMPD_distribute_parallel_for