[clang] [llvm] [PAC][ELF][AArch64] Encode signed GOT flag in PAuth core info (PR #96159)

2024-07-01 Thread James Henderson via cfe-commits

https://github.com/jh7370 commented:

Thanks, llvm-readobj aspects look good to me (I don't feel like I can review 
the clang side).

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


[clang] 6859e5a - [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ array to vector (#88901)

2024-07-01 Thread via cfe-commits

Author: CarolineConcatto
Date: 2024-07-01T08:23:16+01:00
New Revision: 6859e5a169aa235ac04005aaa86ed5ae11372c4c

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

LOG: [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ array to vector 
(#88901)

According to the specification in
ARM-software/acle#309 this adds the intrinsics

Move and zero multiple ZA single-vector groups to vector registers

// Variants are also available for _za8_u8, _za16_s16, _za16_u16,
// _za16_f16, _za16_bf16, _za32_s32, _za32_u32, _za32_f32,
// _za64_s64, _za64_u64 and _za64_f64
svint8x2_t svreadz_za8_s8_vg1x2(uint32_t slice)
__arm_streaming __arm_inout("za");

// Variants are also available for _za8_u8, _za16_s16, _za16_u16,
// _za16_f16, _za16_bf16, _za32_s32, _za32_u32, _za32_f32,
// _za64_s64, _za64_u64 and _za64_f64
svint8x4_t svreadz_za8_s8_vg1x4(uint32_t slice)
__arm_streaming __arm_inout("za");

Added: 


Modified: 
clang/include/clang/Basic/arm_sme.td
clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
llvm/lib/Target/AArch64/SMEInstrFormats.td
llvm/test/CodeGen/AArch64/sme2p1-intrinsics-movaz.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ce211f97d1c96..ce8908f566f2f 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -805,4 +805,16 @@ defm SVREADZ_ZA16  : ZAReadzSingle<"za16", "sUshb", 
"aarch64_sme_readz", [ImmChe
 defm SVREADZ_ZA32  : ZAReadzSingle<"za32", "iUif", "aarch64_sme_readz", 
[ImmCheck<0, ImmCheck0_3>]>;
 defm SVREADZ_ZA64  : ZAReadzSingle<"za64", "lUld", "aarch64_sme_readz", 
[ImmCheck<0, ImmCheck0_7>]>;
 defm SVREADZ_ZA128 : ZAReadzSingle<"za128", "csilUcUiUsUlbhfd", 
"aarch64_sme_readz_q", [ImmCheck<0, ImmCheck0_15>]>;
+
+multiclass ZAReadzArray{
+  let SMETargetGuard = "sme2p1" in {
+def NAME # _B : SInst<"svreadz_za8_{d}_vg1x" # vg_num, vg_num # "m", 
"cUc", MergeNone, "aarch64_sme_readz_x" # vg_num, [IsStreaming, IsInOutZA]>;
+def NAME # _H : SInst<"svreadz_za16_{d}_vg1x" # vg_num, vg_num # "m", 
"sUsbh", MergeNone, "aarch64_sme_readz_x" # vg_num, [IsStreaming, IsInOutZA]>;
+def NAME # _S : SInst<"svreadz_za32_{d}_vg1x" # vg_num, vg_num # "m", 
"iUif", MergeNone, "aarch64_sme_readz_x" # vg_num, [IsStreaming, IsInOutZA]>;
+def NAME # _D : SInst<"svreadz_za64_{d}_vg1x" # vg_num, vg_num # "m", 
"lUld", MergeNone, "aarch64_sme_readz_x" # vg_num, [IsStreaming, IsInOutZA]>;
+  }
+}
+
+defm SVREADZ_VG2 :  ZAReadzArray<"2">;
+defm SVREADZ_VG4 :  ZAReadzArray<"4">;
 } // let SVETargetGuard = InvalidMode

diff  --git a/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c 
b/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c
index 7c9067a5ceece..466ca13032633 100644
--- a/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c
+++ b/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c
@@ -1823,3 +1823,708 @@ svfloat64_t test_svreadz_hor_za128_f64(uint32_t slice) 
__arm_streaming __arm_ino
 {
return svreadz_hor_za128_f64(15, slice);
 }
+
+// MOVAZ Array to Tile
+//
+// X2
+//
+
+// CHECK-LABEL: define dso_local  @test_svreadz_za8_s8_x2(
+// CHECK-SAME: i32 noundef [[SLICE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { ,  } @llvm.aarch64.sme.readz.x2.nxv16i8(i32 [[SLICE]])
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { ,  } [[TMP0]], 0
+// CHECK-NEXT:[[TMP2:%.*]] = tail call  
@llvm.vector.insert.nxv32i8.nxv16i8( poison,  [[TMP1]], i64 0)
+// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP0]], 1
+// CHECK-NEXT:[[TMP4:%.*]] = tail call  
@llvm.vector.insert.nxv32i8.nxv16i8( [[TMP2]],  [[TMP3]], i64 16)
+// CHECK-NEXT:ret  [[TMP4]]
+//
+// CPP-CHECK-LABEL: define dso_local  
@_Z22test_svreadz_za8_s8_x2j(
+// CPP-CHECK-SAME: i32 noundef [[SLICE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call { ,  } @llvm.aarch64.sme.readz.x2.nxv16i8(i32 [[SLICE]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , 
 } [[TMP0]], 0
+// CPP-CHECK-NEXT:[[TMP2:%.*]] = tail call  
@llvm.vector.insert.nxv32i8.nxv16i8( poison,  [[TMP1]], i64 0)
+// CPP-CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , 
 } [[TMP0]], 1
+// CPP-CHECK-NEXT:[[TMP4:%.*]] = tail call  
@llvm.vector.insert.nxv32i8.nxv16i8( [[TMP2]],  [[TMP3]], i64 16)
+// CPP-CHECK-NEXT:ret  [[TMP4]]
+//
+svint8x2_t test_svreadz_za8_s8_x2(uint32_t slice) __arm_streaming 
__

[clang] [llvm] [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ array to vector (PR #88901)

2024-07-01 Thread via cfe-commits

https://github.com/CarolineConcatto closed 
https://github.com/llvm/llvm-project/pull/88901
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-07-01 Thread James Henderson via cfe-commits

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

LGTM.

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


[clang-tools-extra] [clang-doc][nfc] Avoid constructing SmallString in ToString method (PR #96921)

2024-07-01 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I'd use `std::string_view` as a return value instead of `const char *` as a 
more idiomatic C++ in which case you don't need to rename the method to 
`c_str()`.

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


[clang] [llvm] [AARCH64][SVE] Add intrinsics for SVE LUTI instructions (PR #97058)

2024-07-01 Thread via cfe-commits

https://github.com/Lukacma updated 
https://github.com/llvm/llvm-project/pull/97058

>From 4a6c4033f7deddcd4094ebde81402960de85bd80 Mon Sep 17 00:00:00 2001
From: Marian Lukac 
Date: Fri, 28 Jun 2024 10:13:16 +
Subject: [PATCH] [AARCH64][SVE] Add intrinsics for SVE LUTI instructions

---
 clang/include/clang/Basic/arm_sve.td  |  21 +-
 .../aarch64-sve2-intrinsics/acle_sve2_luti.c  | 336 ++
 .../acle_sve2_imm_lane.cpp|  32 ++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  20 ++
 llvm/lib/Target/AArch64/SVEInstrFormats.td|  37 +-
 .../CodeGen/AArch64/sve2-intrinsics-luti.ll   | 107 ++
 6 files changed, 551 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_luti.c
 create mode 100644 llvm/test/CodeGen/AArch64/sve2-intrinsics-luti.ll

diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 94c093d891156..dc999a5bbb3d8 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1939,6 +1939,25 @@ def SVTBL2_BF16 : SInst<"svtbl2[_{d}]", "d2u",  "b", 
MergeNone, "", [VerifyRunti
 def SVTBX_BF16  : SInst<"svtbx[_{d}]",  "dddu", "b", MergeNone, 
"aarch64_sve_tbx", [VerifyRuntimeMode]>;
 }
 
+
+
+// SVE2 - Lookup table
+let SVETargetGuard = "sve2,lut", SMETargetGuard = "sme2,lut" in {
+  def SVLUTI2_B : SInst<"svluti2_lane[_{d}]", "dd[i", "cUc", MergeNone, 
"aarch64_sve_luti2_lane", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
+  def SVLUTI2_H : SInst<"svluti2_lane[_{d}]", "dd[i", "sUsh", MergeNone, 
"aarch64_sve_luti2_lane", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_7>]>;
+
+  def SVLUTI4_B : SInst<"svluti4_lane[_{d}]", "dd[i", "cUc", MergeNone, 
"aarch64_sve_luti4_lane", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_1>]>;
+  def SVLUTI4_H : SInst<"svluti4_lane[_{d}]", "dd[i", "sUsh", MergeNone, 
"aarch64_sve_luti4_lane", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
+
+  def SVLUTI4_x2 : SInst<"svluti4_lane[_{d}]_x2", "d2.d[i", "sUsh", MergeNone, 
"aarch64_sve_luti4_lane_x2", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
+}
+
+let SVETargetGuard = "sve2,lut,bf16", SMETargetGuard = "sme2,lut,bf16" in {
+  def SVLUTI2_BF16 : SInst<"svluti2_lane[_{d}]", "dd[i", "b", MergeNone, 
"aarch64_sve_luti2_lane", [ VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_7>]>;
+  def SVLUTI4_BF16 : SInst<"svluti4_lane[_{d}]", "dd[i", "b", MergeNone, 
"aarch64_sve_luti4_lane", [ VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
+  def SVLUTI4_BF16_x2 : SInst<"svluti4_lane[_{d}]_x2", "d2.d[i", "b", 
MergeNone, "aarch64_sve_luti4_lane_x2", [ VerifyRuntimeMode], [ImmCheck<2, 
ImmCheck0_3>]>;
+}
+
 

 // SVE2 - Optional
 
@@ -2384,4 +2403,4 @@ let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in 
{
 
   def SVBFMLSLB_LANE : SInst<"svbfmlslb_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslb_lane", [IsOverloadNone, VerifyRuntimeMode], [ImmCheck<3, 
ImmCheck0_7>]>;
   def SVBFMLSLT_LANE : SInst<"svbfmlslt_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslt_lane", [IsOverloadNone, VerifyRuntimeMode], [ImmCheck<3, 
ImmCheck0_7>]>;
-}
+}
\ No newline at end of file
diff --git a/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_luti.c 
b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_luti.c
new file mode 100644
index 0..d19246cba2d37
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_luti.c
@@ -0,0 +1,336 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu \
+// RUN:   -target-feature +sme -target-feature +sme2 -target-feature +lut 
-target-feature +bf16 -O1 -Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve -target-feature +sve2 -target-feature +lut 
-target-feature +bf16 -O1 -Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve -target-feature +sve2 -target-feature +lut 
-target-feature +bf16 -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s 
-check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve -target-feature +sve2 -target-feature +lut 
-target-feature +bf16 -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s 
-check-prefix=CPP-CHECK
+#include 
+
+#if defined __ARM_FEATURE_SME
+#define MODE_ATTR __arm_streaming
+#else
+#define MODE_ATTR
+#endif
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#defin

[clang] [compiler-rt] [llvm] [PAC][AArch64] Support init/fini array signing (PR #96478)

2024-07-01 Thread Daniil Kovalev via cfe-commits

kovdan01 wrote:

Would be glad to see feedback on the changes from those who are interested.

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


[clang] [llvm] Reapply "[analyzer] Accept C library functions from the `std` namespace" again (PR #85791)

2024-07-01 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy ,
=?utf-8?q?Don=C3=A1t?= Nagy ,NagyDonat
 ,NagyDonat 
Message-ID:
In-Reply-To: 


steakhal wrote:

This fixed tickets in our backlog. Thanks for pushing for this.

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


[clang] [llvm] [AArch64][NEON] Add intrinsics for LUTI (PR #96883)

2024-07-01 Thread via cfe-commits


@@ -0,0 +1,433 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+#include 
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon 
-target-feature +lut -target-feature +bf16 -O3 -emit-llvm -o - %s | FileCheck %s

CarolineConcatto wrote:

We tend to add this RUN line to check if all the tests can lower:
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon 
-target-feature +lut -target-feature +bf16 -S -disable-O0-optnone -Werror -Wall 
-o /dev/null %s


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


[clang] [llvm] [AArch64][NEON] Add intrinsics for LUTI (PR #96883)

2024-07-01 Thread via cfe-commits


@@ -545,6 +545,25 @@ let TargetPrefix = "aarch64", IntrProperties = [IntrNoMem] 
in {
   def int_aarch64_neon_vcmla_rot270 : AdvSIMD_3VectorArg_Intrinsic;
 }
 
+let TargetPrefix = "aarch64" in {
+def int_aarch64_neon_vluti2_lane : DefaultAttrsIntrinsic<[llvm_anyvector_ty],

CarolineConcatto wrote:

 I am being picky, but wouldn't be better  to have :
def int_aarch64_neon_vluti2_lane : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 
[llvm_anyvector_ty, llvm_v8i8_ty,   
llvm_i32_ty],  [IntrNoMem, ImmArg>]>;
def int_aarch64_neon_vluti2_laneq : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 
[llvm_anyvector_ty, llvm_v16i8_ty,   
llvm_i32_ty],  [IntrNoMem, ImmArg>]>;
It is just because I believe it is unusual to see the llvm.ir with 3 overloaded 
types. 

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


[clang] [llvm] [AArch64][NEON] Add intrinsics for LUTI (PR #96883)

2024-07-01 Thread via cfe-commits


@@ -0,0 +1,433 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+#include 
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon 
-target-feature +lut -target-feature +bf16 -O3 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2_lane_u8(
+// CHECK-SAME: <8 x i8> noundef [[VN:%.*]], <8 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v8i8.v8i8(<8 x i8> [[VN]], <8 x i8> 
[[VM]], i32 0)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+uint8x16_t test_vluti2_lane_u8(uint8x8_t vn, uint8x8_t vm) {
+  return vluti2_lane_u8(vn, vm, 0);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2_laneq_u8(
+// CHECK-SAME: <8 x i8> noundef [[VN:%.*]], <16 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v8i8.v16i8(<8 x i8> [[VN]], <16 x i8> 
[[VM]], i32 0)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+uint8x16_t test_vluti2_laneq_u8(uint8x8_t vn, uint8x16_t vm) {
+  return vluti2_laneq_u8(vn, vm, 0);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2q_lane_u8(
+// CHECK-SAME: <16 x i8> noundef [[VN:%.*]], <8 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v16i8.v8i8(<16 x i8> [[VN]], <8 x i8> 
[[VM]], i32 3)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+uint8x16_t test_vluti2q_lane_u8(uint8x16_t vn, uint8x8_t vm) {
+  return vluti2q_lane_u8(vn, vm, 3);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2q_laneq_u8(
+// CHECK-SAME: <16 x i8> noundef [[VN:%.*]], <16 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v16i8.v16i8(<16 x i8> [[VN]], <16 x i8> 
[[VM]], i32 7)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+uint8x16_t test_vluti2q_laneq_u8(uint8x16_t vn, uint8x16_t vm) {
+  return vluti2q_laneq_u8(vn, vm, 7);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2_lane_s8(
+// CHECK-SAME: <8 x i8> noundef [[VN:%.*]], <8 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v8i8.v8i8(<8 x i8> [[VN]], <8 x i8> 
[[VM]], i32 0)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+int8x16_t test_vluti2_lane_s8(int8x8_t vn, uint8x8_t vm) {
+  return vluti2_lane_s8(vn, vm, 0);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2_laneq_s8(
+// CHECK-SAME: <8 x i8> noundef [[VN:%.*]], <16 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v8i8.v16i8(<8 x i8> [[VN]], <16 x i8> 
[[VM]], i32 0)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+int8x16_t test_vluti2_laneq_s8(int8x8_t vn, uint8x16_t vm) {
+  return vluti2_laneq_s8(vn, vm, 0);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2q_lane_s8(
+// CHECK-SAME: <16 x i8> noundef [[VN:%.*]], <8 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v16i8.v8i8(<16 x i8> [[VN]], <8 x i8> 
[[VM]], i32 3)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+int8x16_t test_vluti2q_lane_s8(int8x16_t vn, uint8x8_t vm) {
+  return vluti2q_lane_s8(vn, vm, 3);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2q_laneq_s8(
+// CHECK-SAME: <16 x i8> noundef [[VN:%.*]], <16 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v16i8.v16i8(<16 x i8> [[VN]], <16 x i8> 
[[VM]], i32 7)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+int8x16_t test_vluti2q_laneq_s8(int8x16_t vn, uint8x16_t vm) {
+  return vluti2q_laneq_s8(vn, vm, 7);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2_lane_p8(
+// CHECK-SAME: <8 x i8> noundef [[VN:%.*]], <8 x i8> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VLUTI2_LANE:%.*]] = tail call <16 x i8> 
@llvm.aarch64.neon.vluti2.lane.v16i8.v8i8.v8i8(<8 x i8> [[VN]], <8 x i8> 
[[VM]], i32 0)
+// CHECK-NEXT:ret <16 x i8> [[VLUTI2_LANE]]
+//
+poly8x16_t test_vluti2_lane_p8(poly8x8_t vn, uint8x8_t vm) {
+  return vluti2_lane_p8(vn, vm, 0);
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_vluti2_laneq_p8(
+// CHECK-SAME: <8 x i8> n

[clang] [Clang] Extend lifetime bound analysis to support assignments (PR #96475)

2024-07-01 Thread Haojian Wu via cfe-commits

https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/96475

>From 97d1b80680112c3fa271501427a18273aed61dbe Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 24 Jun 2024 10:58:53 +0200
Subject: [PATCH 1/4] [clang] Extend the existing lifetimebound check for
 assignments.

Currently we only detect the builtin pointer type.
---
 clang/include/clang/Basic/DiagnosticGroups.td |  4 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  5 ++
 clang/lib/Sema/CheckExprLifetime.cpp  | 60 ++-
 clang/lib/Sema/CheckExprLifetime.h| 18 +-
 clang/lib/Sema/SemaExpr.cpp   |  4 ++
 clang/lib/Sema/SemaInit.cpp   |  2 +-
 clang/test/Parser/compound_literal.c  |  5 +-
 clang/test/SemaCXX/attr-lifetimebound.cpp |  6 ++
 clang/test/SemaCXX/warn-dangling-local.cpp|  2 +
 9 files changed, 83 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 1c4f305fb5d00..9ae579c2c2a11 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -430,6 +430,7 @@ def LogicalOpParentheses: 
DiagGroup<"logical-op-parentheses">;
 def LogicalNotParentheses: DiagGroup<"logical-not-parentheses">;
 def ShiftOpParentheses: DiagGroup<"shift-op-parentheses">;
 def OverloadedShiftOpParentheses: DiagGroup<"overloaded-shift-op-parentheses">;
+def DanglingAssignment: DiagGroup<"dangling-assignment">;
 def DanglingElse: DiagGroup<"dangling-else">;
 def DanglingField : DiagGroup<"dangling-field">;
 def DanglingInitializerList : DiagGroup<"dangling-initializer-list">;
@@ -437,7 +438,8 @@ def DanglingGsl : DiagGroup<"dangling-gsl">;
 def ReturnStackAddress : DiagGroup<"return-stack-address">;
 // Name of this warning in GCC
 def : DiagGroup<"return-local-addr", [ReturnStackAddress]>;
-def Dangling : DiagGroup<"dangling", [DanglingField,
+def Dangling : DiagGroup<"dangling", [DanglingAssignment,
+  DanglingField,
   DanglingInitializerList,
   DanglingGsl,
   ReturnStackAddress]>;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 33412e14897b6..f613243cb8460 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10120,6 +10120,11 @@ def warn_new_dangling_initializer_list : Warning<
   "the allocated initializer list}0 "
   "will be destroyed at the end of the full-expression">,
   InGroup;
+def warn_dangling_pointer_assignment : Warning<
+   "object backing the pointer %0 "
+   "will be destroyed at the end of the full-expression">,
+   InGroup;
+
 def warn_unsupported_lifetime_extension : Warning<
   "lifetime extension of "
   "%select{temporary|backing array of initializer list}0 created "
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index 54e2f1c22536d..67fbd5e449d4a 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -8,6 +8,8 @@
 
 #include "CheckExprLifetime.h"
 #include "clang/AST/Expr.h"
+#include "clang/Basic/DiagnosticSema.h"
+#include "clang/Sema/Initialization.h"
 #include "clang/Sema/Sema.h"
 #include "llvm/ADT/PointerIntPair.h"
 
@@ -964,11 +966,26 @@ static bool 
pathOnlyInitializesGslPointer(IndirectLocalPath &Path) {
   return false;
 }
 
-void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
+void checkExprLifetime(Sema &SemaRef, const CheckingEntity &CEntity,
Expr *Init) {
-  LifetimeResult LR = getEntityLifetime(&Entity);
-  LifetimeKind LK = LR.getInt();
-  const InitializedEntity *ExtendingEntity = LR.getPointer();
+  LifetimeKind LK = LK_FullExpression;
+
+  const AssignedEntity *AEntity = nullptr;
+  // Local variables for initialized entity.
+  const InitializedEntity *InitEntity = nullptr;
+  const InitializedEntity *ExtendingEntity = nullptr;
+  if (auto IEntityP = std::get_if(&CEntity)) {
+InitEntity = *IEntityP;
+auto LTResult = getEntityLifetime(InitEntity);
+LK = LTResult.getInt();
+ExtendingEntity = LTResult.getPointer();
+  } else if (auto AEntityP = std::get_if(&CEntity)) {
+AEntity = *AEntityP;
+if (AEntity->LHS->getType()->isPointerType()) // builtin pointer type
+  LK = LK_Extended;
+  } else {
+llvm_unreachable("unexpected kind");
+  }
 
   // If this entity doesn't have an interesting lifetime, don't bother looking
   // for temporaries within its initializer.
@@ -1028,6 +1045,7 @@ void checkExprLifetime(Sema &SemaRef, const 
InitializedEntity &Entity,
 
   switch (shouldLifetimeExtendThroughPath(Path)) {
   case PathLifetimeKind::Extend:
+assert(InitEntity && "Expect only on initializing the entity");
 // Update

[clang] [llvm] [PAC][ELF][AArch64] Encode signed GOT flag in PAuth core info (PR #96159)

2024-07-01 Thread Daniil Kovalev via cfe-commits

kovdan01 wrote:

Would be glad to see feedback on the changes from those who are interested.

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


[clang] [Clang] Extend lifetime bound analysis to support assignments (PR #96475)

2024-07-01 Thread Haojian Wu via cfe-commits


@@ -964,17 +966,34 @@ static bool 
pathOnlyInitializesGslPointer(IndirectLocalPath &Path) {
   return false;
 }
 
-void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
+void checkExprLifetime(Sema &SemaRef, const CheckingEntity &CEntity,

hokein wrote:

Thanks for the suggestion. I'm not a fan of `std::variant` either. I've added a 
new overload for `AssignedEntity`.

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


[clang] [llvm] [PAC][ELF][AArch64] Encode signed GOT flag in PAuth core info (PR #96159)

2024-07-01 Thread Daniil Kovalev via cfe-commits

kovdan01 wrote:

@MaskRay Would be glad to see your feedback on the changes

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


[clang] [clang] Disable C++14 sized deallocation by default for MinGW targets (PR #97232)

2024-07-01 Thread Jacek Caban via cfe-commits

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


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


[clang] [llvm] [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ array to vector (PR #88901)

2024-07-01 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `mlir-nvidia-gcc7` running 
on `mlir-nvidia` while building `clang,llvm` at step 5 
"build-check-mlir-build-only".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/116/builds/676

Here is the relevant piece of the build log for the reference:
```
Step 5 (build-check-mlir-build-only) failure: build (failure)
...
621.045 [61/16/4313] Linking CXX static library lib/libMLIRGPUTestPasses.a
621.073 [60/16/4314] Linking CXX static library lib/libMLIRLinalgTestPasses.a
623.548 [59/16/4315] Linking CXX executable bin/mlir-vulkan-runner
623.569 [58/16/4316] Building MyExtension.h.inc...
623.591 [57/16/4317] Building MyExtension.h.inc...
634.049 [56/16/4318] Building CXX object 
tools/mlir/test/lib/Dialect/Test/CMakeFiles/MLIRTestToLLVMIRTranslation.dir/TestToLLVMIRTranslation.cpp.o
634.064 [55/16/4319] Linking CXX static library 
lib/libMLIRTestToLLVMIRTranslation.a
635.996 [54/16/4320] Linking CXX executable bin/mlir-translate
636.053 [53/16/4321] Building CXX object 
tools/mlir/examples/transform/Ch3/lib/CMakeFiles/MyExtensionCh3.dir/MyExtension.cpp.o
636.245 [52/16/4322] Linking CXX static library lib/libMyExtensionCh3.a
command timed out: 1200 seconds without output running [b'ninja', b'-j', b'16', 
b'check-mlir-build-only'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=3056.672296

```

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


[clang] [llvm] Reland "[analyzer][NFC] Reorganize Z3 report refutation" (PR #97265)

2024-07-01 Thread Balazs Benics via cfe-commits

https://github.com/steakhal created 
https://github.com/llvm/llvm-project/pull/97265

This is exactly as originally landed in #95128,
but now the minimal Z3 version was increased to meet this change in #96682.
https://discourse.llvm.org/t/bump-minimal-z3-requirements-from-4-7-1-to-4-8-9/79664/4

---

This change keeps existing behavior, namely that if we hit a Z3 timeout we will 
accept the report as "satisfiable".

This prepares for the commit "Harden safeguards for Z3 query times". 
https://discourse.llvm.org/t/analyzer-rfc-taming-z3-query-times/79520

(cherry picked from commit 89c26f6c7b0a6dfa257ec090fcf5b6e6e0c89aab)

>From 3d5acf85a3e67f76b127e04b47b4dd2335c5acf8 Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Mon, 1 Jul 2024 10:51:11 +0200
Subject: [PATCH] Reland "[analyzer][NFC] Reorganize Z3 report refutation"

This is exactly as originally landed in #95128,
but now the minimal Z3 version was increased to meet this change in #96682.
https://discourse.llvm.org/t/bump-minimal-z3-requirements-from-4-7-1-to-4-8-9/79664/4

---

This change keeps existing behavior, namely that if we hit a Z3 timeout
we will accept the report as "satisfiable".

This prepares for the commit "Harden safeguards for Z3 query times".
https://discourse.llvm.org/t/analyzer-rfc-taming-z3-query-times/79520

(cherry picked from commit 89c26f6c7b0a6dfa257ec090fcf5b6e6e0c89aab)
---
 .../Core/BugReporter/BugReporterVisitors.h|  23 
 .../Core/BugReporter/Z3CrosscheckVisitor.h|  66 ++
 .../Core/PathSensitive/SMTConstraintManager.h |   5 +-
 clang/lib/StaticAnalyzer/Core/BugReporter.cpp |  28 -
 .../Core/BugReporterVisitors.cpp  |  76 ---
 clang/lib/StaticAnalyzer/Core/CMakeLists.txt  |   1 +
 .../Core/Z3CrosscheckVisitor.cpp  | 118 ++
 .../test/Analysis/z3/crosscheck-statistics.c  |  33 +
 clang/unittests/StaticAnalyzer/CMakeLists.txt |   1 +
 .../StaticAnalyzer/Z3CrosscheckOracleTest.cpp |  59 +
 llvm/include/llvm/Support/SMTAPI.h|  19 +++
 llvm/lib/Support/Z3Solver.cpp | 116 ++---
 12 files changed, 419 insertions(+), 126 deletions(-)
 create mode 100644 
clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h
 create mode 100644 clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
 create mode 100644 clang/test/Analysis/z3/crosscheck-statistics.c
 create mode 100644 clang/unittests/StaticAnalyzer/Z3CrosscheckOracleTest.cpp

diff --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index cc3d93aabafda..f97514955a591 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -597,29 +597,6 @@ class SuppressInlineDefensiveChecksVisitor final : public 
BugReporterVisitor {
PathSensitiveBugReport &BR) override;
 };
 
-/// The bug visitor will walk all the nodes in a path and collect all the
-/// constraints. When it reaches the root node, will create a refutation
-/// manager and check if the constraints are satisfiable
-class FalsePositiveRefutationBRVisitor final : public BugReporterVisitor {
-private:
-  /// Holds the constraints in a given path
-  ConstraintMap Constraints;
-
-public:
-  FalsePositiveRefutationBRVisitor();
-
-  void Profile(llvm::FoldingSetNodeID &ID) const override;
-
-  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
-   BugReporterContext &BRC,
-   PathSensitiveBugReport &BR) override;
-
-  void finalizeVisitor(BugReporterContext &BRC, const ExplodedNode 
*EndPathNode,
-   PathSensitiveBugReport &BR) override;
-  void addConstraints(const ExplodedNode *N,
-  bool OverwriteConstraintsOnExistingSyms);
-};
-
 /// The visitor detects NoteTags and displays the event notes they contain.
 class TagVisitor : public BugReporterVisitor {
 public:
diff --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h
new file mode 100644
index 0..9413fd739f607
--- /dev/null
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h
@@ -0,0 +1,66 @@
+//===- Z3CrosscheckVisitor.h - Crosscheck reports with Z3 ---*- C++ 
-*-===//
+//
+// 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 defines the visitor and utilities around it for Z3 report
+//  refutation.
+//
+//===--===//

[clang] [llvm] Reland "[analyzer][NFC] Reorganize Z3 report refutation" (PR #97265)

2024-07-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balazs Benics (steakhal)


Changes

This is exactly as originally landed in #95128,
but now the minimal Z3 version was increased to meet this change in #96682.
https://discourse.llvm.org/t/bump-minimal-z3-requirements-from-4-7-1-to-4-8-9/79664/4

---

This change keeps existing behavior, namely that if we hit a Z3 timeout we will 
accept the report as "satisfiable".

This prepares for the commit "Harden safeguards for Z3 query times". 
https://discourse.llvm.org/t/analyzer-rfc-taming-z3-query-times/79520

(cherry picked from commit 89c26f6c7b0a6dfa257ec090fcf5b6e6e0c89aab)

---

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


12 Files Affected:

- (modified) 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h (-23) 
- (added) 
clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h (+66) 
- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
(+4-1) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporter.cpp (+22-6) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (-76) 
- (modified) clang/lib/StaticAnalyzer/Core/CMakeLists.txt (+1) 
- (added) clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp (+118) 
- (added) clang/test/Analysis/z3/crosscheck-statistics.c (+33) 
- (modified) clang/unittests/StaticAnalyzer/CMakeLists.txt (+1) 
- (added) clang/unittests/StaticAnalyzer/Z3CrosscheckOracleTest.cpp (+59) 
- (modified) llvm/include/llvm/Support/SMTAPI.h (+19) 
- (modified) llvm/lib/Support/Z3Solver.cpp (+96-20) 


``diff
diff --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index cc3d93aabafda..f97514955a591 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -597,29 +597,6 @@ class SuppressInlineDefensiveChecksVisitor final : public 
BugReporterVisitor {
PathSensitiveBugReport &BR) override;
 };
 
-/// The bug visitor will walk all the nodes in a path and collect all the
-/// constraints. When it reaches the root node, will create a refutation
-/// manager and check if the constraints are satisfiable
-class FalsePositiveRefutationBRVisitor final : public BugReporterVisitor {
-private:
-  /// Holds the constraints in a given path
-  ConstraintMap Constraints;
-
-public:
-  FalsePositiveRefutationBRVisitor();
-
-  void Profile(llvm::FoldingSetNodeID &ID) const override;
-
-  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
-   BugReporterContext &BRC,
-   PathSensitiveBugReport &BR) override;
-
-  void finalizeVisitor(BugReporterContext &BRC, const ExplodedNode 
*EndPathNode,
-   PathSensitiveBugReport &BR) override;
-  void addConstraints(const ExplodedNode *N,
-  bool OverwriteConstraintsOnExistingSyms);
-};
-
 /// The visitor detects NoteTags and displays the event notes they contain.
 class TagVisitor : public BugReporterVisitor {
 public:
diff --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h
new file mode 100644
index 0..9413fd739f607
--- /dev/null
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h
@@ -0,0 +1,66 @@
+//===- Z3CrosscheckVisitor.h - Crosscheck reports with Z3 ---*- C++ 
-*-===//
+//
+// 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 defines the visitor and utilities around it for Z3 report
+//  refutation.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_Z3CROSSCHECKVISITOR_H
+#define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_Z3CROSSCHECKVISITOR_H
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
+
+namespace clang::ento {
+
+/// The bug visitor will walk all the nodes in a path and collect all the
+/// constraints. When it reaches the root node, will create a refutation
+/// manager and check if the constraints are satisfiable.
+class Z3CrosscheckVisitor final : public BugReporterVisitor {
+public:
+  struct Z3Result {
+std::optional IsSAT = std::nullopt;
+  };
+  explicit Z3CrosscheckVisitor(Z3CrosscheckVisitor::Z3Result &Result);
+
+  void Profile(llvm::FoldingSetNodeID &ID) const override;
+
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *

[clang] [llvm] Reland "[analyzer][NFC] Reorganize Z3 report refutation" (PR #97265)

2024-07-01 Thread Balazs Benics via cfe-commits

steakhal wrote:

This was already reviewed and approved in the past. The content is identical to 
that one.

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


[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat requested changes to this pull request.

Unfortunately this PR is not a full solution, because e.g. the following test 
code still triggers the crash (if it is appended to the test file `stream.c`):
```c
struct zerosized {
int foo[0];
};

void fread_zerosized(struct zerosized *buffer) {
  FILE *f = fopen("/tmp/foo.txt", "r");
  fread(buffer, 1, 1, f);
  fclose(f);
}
```

(I know that zero-sized arrays are not standard-compliant, but they are a 
widespread extension: e.g. both clang and gcc accept this `struct zerosized` 
with the default settings.)

Overall, I'd say that it's futile to try to recognize zero-sized types with a 
"canonical type equal to" check, so you should just check whether 
`ElemSizeInChars` is zero and do something based on that. (Either an early 
return, or you can say `ElemSizeInChars = 1` at that point if you think that 
that's the logically correct solution.)

``This way you could also avoid the immediately invoked lambda in 
`getPointeeType` which is really ugly in my opinion.``

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


[clang] [llvm] [AArch64][NEON] Add intrinsics for LUTI (PR #96883)

2024-07-01 Thread via cfe-commits


@@ -545,6 +545,25 @@ let TargetPrefix = "aarch64", IntrProperties = [IntrNoMem] 
in {
   def int_aarch64_neon_vcmla_rot270 : AdvSIMD_3VectorArg_Intrinsic;
 }
 
+let TargetPrefix = "aarch64" in {
+def int_aarch64_neon_vluti2_lane : DefaultAttrsIntrinsic<[llvm_anyvector_ty],

Lukacma wrote:

I don't have strong opinion either way. I do not see advantage to either 
approach, but maybe I am missing smth

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


[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)

2024-07-01 Thread Tomas Matheson via cfe-commits

https://github.com/tmatheson-arm approved this pull request.


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


[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)

2024-07-01 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea updated 
https://github.com/llvm/llvm-project/pull/96628

>From ff4635208e9cd83c6735c95ebf12125ca737029a Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Tue, 25 Jun 2024 00:27:45 +0100
Subject: [PATCH 1/3] [clang][FMV] Do not omit explicit default target_version
 attribute.

Fixes a crash and cleans up some dead code.

namespace Foo {
int bar();
__attribute((target_version("default"))) int bar() { return 0; }
__attribute((target_version("mops"))) int bar() { return 1; }
}

$ clang++ --target=aarch64-linux-gnu --rtlib=compiler-rt fmv.cpp

None multiversion type isn't valid here
UNREACHABLE executed at clang/lib/CodeGen/CodeGenModule.cpp:1840!
...
getMangledNameImpl
clang::CodeGen::CodeGenModule::getMangledName
clang::CodeGen::CodeGenModule::EmitGlobal
---
 clang/include/clang/Sema/Sema.h  |  3 +-
 clang/lib/Sema/SemaDecl.cpp  | 45 +---
 clang/lib/Sema/SemaDeclAttr.cpp  | 16 ++---
 clang/test/CodeGen/attr-target-version.c | 88 
 clang/test/CodeGenCXX/fmv-namespace.cpp  | 60 
 clang/test/Sema/attr-target-version.c|  5 +-
 6 files changed, 118 insertions(+), 99 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2e7af0f691cbb..31bb81705a742 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3786,8 +3786,7 @@ class Sema final : public SemaBase {
 StringRef Name);
 
   bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
-  bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
-  StringRef &Str, bool &isDefault);
+  bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
   bool checkTargetClonesAttrString(
   SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
   Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 029ccf944c513..572c46eed1aaa 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11465,6 +11465,10 @@ static bool CheckMultiVersionFirstFunction(Sema &S, 
FunctionDecl *FD) {
   // otherwise it is treated as a normal function.
   if (TA && !TA->isDefaultVersion())
 return false;
+  // The target_version attribute only causes Multiversioning if this
+  // declaration is NOT the default version.
+  if (TVA && TVA->isDefaultVersion())
+return false;
 
   if ((TA || TVA) && CheckMultiVersionValue(S, FD)) {
 FD->setInvalidDecl();
@@ -11498,11 +11502,9 @@ static void patchDefaultTargetVersion(FunctionDecl 
*From, FunctionDecl *To) {
 
   if (MVKindTo == MultiVersionKind::None &&
   (MVKindFrom == MultiVersionKind::TargetVersion ||
-   MVKindFrom == MultiVersionKind::TargetClones)) {
-To->setIsMultiVersion();
+   MVKindFrom == MultiVersionKind::TargetClones))
 To->addAttr(TargetVersionAttr::CreateImplicit(
 To->getASTContext(), "default", To->getSourceRange()));
-  }
 }
 
 static bool CheckTargetCausesMultiVersioning(Sema &S, FunctionDecl *OldFD,
@@ -11523,10 +11525,16 @@ static bool CheckTargetCausesMultiVersioning(Sema &S, 
FunctionDecl *OldFD,
   const auto *OldTVA = OldFD->getAttr();
   // If the old decl is NOT MultiVersioned yet, and we don't cause that
   // to change, this is a simple redeclaration.
-  if ((NewTA && !NewTA->isDefaultVersion() &&
-   (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) ||
-  (NewTVA && !NewTVA->isDefaultVersion() &&
-   (!OldTVA || OldTVA->getName() == NewTVA->getName(
+  if (NewTA && !NewTA->isDefaultVersion() &&
+  (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
+return false;
+
+  // The target_version attribute only causes Multiversioning if this
+  // declaration is NOT the default version. Moreover, the old declaration
+  // must be the default version (either explicitly via the attribute,
+  // or implicitly without it).
+  if (NewTVA &&
+  (NewTVA->isDefaultVersion() || (OldTVA && !OldTVA->isDefaultVersion(
 return false;
 
   // Otherwise, this decl causes MultiVersioning.
@@ -11543,8 +11551,7 @@ static bool CheckTargetCausesMultiVersioning(Sema &S, 
FunctionDecl *OldFD,
   }
 
   // If this is 'default', permit the forward declaration.
-  if ((NewTA && NewTA->isDefaultVersion() && !OldTA) ||
-  (NewTVA && NewTVA->isDefaultVersion() && !OldTVA)) {
+  if (NewTA && NewTA->isDefaultVersion() && !OldTA) {
 Redeclaration = true;
 OldDecl = OldFD;
 OldFD->setIsMultiVersion();
@@ -11947,24 +11954,8 @@ static bool CheckMultiVersionFunction(Sema &S, 
FunctionDecl *NewFD,
 
   FunctionDecl *OldFD = OldDecl->getAsFunction();
 
-  if (!OldFD->isMultiVersion() && MVKind == MultiVersionKind::None) {
-if (NewTVA || !OldFD->getAttr())
-  return false;
-if (!NewFD->getType()->getAs()) {
-  // Multiversion

[clang] [clang][analyzer][doc] Migrate user-related docs from HTML to RST (PR #97034)

2024-07-01 Thread Endre Fülöp via cfe-commits

https://github.com/gamesh411 edited 
https://github.com/llvm/llvm-project/pull/97034
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer][doc] Migrate checkers-related docs from HTML to RST (PR #97032)

2024-07-01 Thread Endre Fülöp via cfe-commits

gamesh411 wrote:

I have tried to ensure no information is lost with this change.
I have cross-checked the history of the checker's HTML files with commits that 
introduce checkers and have found that we tend to add checkers only to the RST 
files and sometimes miss the fact that there is another description in the HTML 
format.

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


[clang] [llvm] [AArch64][NEON] Add intrinsics for LUTI (PR #96883)

2024-07-01 Thread Momchil Velikov via cfe-commits


@@ -545,6 +545,25 @@ let TargetPrefix = "aarch64", IntrProperties = [IntrNoMem] 
in {
   def int_aarch64_neon_vcmla_rot270 : AdvSIMD_3VectorArg_Intrinsic;
 }
 
+let TargetPrefix = "aarch64" in {
+def int_aarch64_neon_vluti2_lane : DefaultAttrsIntrinsic<[llvm_anyvector_ty],

momchil-velikov wrote:

Only the return type and the table type are polymorphic, isn't it? The indices 
and the immediate are always integers.

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


[clang] [llvm] [AArch64][NEON] Add intrinsics for LUTI (PR #96883)

2024-07-01 Thread Momchil Velikov via cfe-commits

https://github.com/momchil-velikov edited 
https://github.com/llvm/llvm-project/pull/96883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AArch64][NEON] Add intrinsics for LUTI (PR #96883)

2024-07-01 Thread via cfe-commits


@@ -545,6 +545,25 @@ let TargetPrefix = "aarch64", IntrProperties = [IntrNoMem] 
in {
   def int_aarch64_neon_vcmla_rot270 : AdvSIMD_3VectorArg_Intrinsic;
 }
 
+let TargetPrefix = "aarch64" in {
+def int_aarch64_neon_vluti2_lane : DefaultAttrsIntrinsic<[llvm_anyvector_ty],

Lukacma wrote:

In a sense. The indices are integral type, but they are polymorphic in vector 
size.

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


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits

DeinAlptraum wrote:

\*Ping*

@boomanaiden154 @linux4life798 a review/feedback would be appreciated!

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


[clang] [AMDGPU][OpenMP] Do not attach -fcuda-is-device flag for AMDGPU OpenMP (PR #96909)

2024-07-01 Thread Dominik Adamski via cfe-commits

https://github.com/DominikAdamski closed 
https://github.com/llvm/llvm-project/pull/96909
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8bb00cb - [AMDGPU][OpenMP] Do not attach -fcuda-is-device flag for AMDGPU OpenMP (#96909)

2024-07-01 Thread via cfe-commits

Author: Dominik Adamski
Date: 2024-07-01T11:36:49+02:00
New Revision: 8bb00cb160830ec8f6029c2aae79d3e46b04b99c

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

LOG: [AMDGPU][OpenMP] Do not attach -fcuda-is-device flag for AMDGPU OpenMP 
(#96909)

`-fcuda-is-device` flag is not used for OpenMP offloading for AMD GPUs
and it does not need to be added as clang cc1 option for OpenMP code.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 1c0fb4babe3a5..b75d400e6ce91 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -47,8 +47,6 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
   assert(DeviceOffloadingKind == Action::OFK_OpenMP &&
  "Only OpenMP offloading kinds are supported.");
 
-  CC1Args.push_back("-fcuda-is-device");
-
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 

diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain.c 
b/clang/test/Driver/amdgpu-openmp-toolchain.c
index 49af04acc4639..a153c4afb0ce8 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -7,7 +7,7 @@
 
 // verify the tools invocations
 // CHECK: "-cc1" "-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-emit-llvm-bc"{{.*}}"-x" "c"
-// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-fcuda-is-device"{{.*}}"-target-cpu" "gfx906"
+// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" 
"x86_64-unknown-linux-gnu"{{.*}}"-target-cpu" "gfx906"
 // CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-obj"
 // CHECK: clang-linker-wrapper{{.*}} "-o" "a.out"
 



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


[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

2024-07-01 Thread Mariya Podchishchaeva via cfe-commits

Fznamznon wrote:

Ping.

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


[clang] 7f1d672 - [clang][Interp] Diagnose static declarations in constexpr functions

2024-07-01 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-07-01T11:58:56+02:00
New Revision: 7f1d672d70eabe010567fcd8c365d27549736c6d

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

LOG: [clang][Interp] Diagnose static declarations in constexpr functions

Added: 


Modified: 
clang/lib/AST/Interp/Compiler.cpp
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/Opcodes.td
clang/test/AST/Interp/cxx23.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 424f4f84a0167..ff755d503f871 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -3520,6 +3520,11 @@ VarCreationState Compiler::visitVarDecl(const 
VarDecl *VD) {
   const Expr *Init = VD->getInit();
   std::optional VarT = classify(VD->getType());
 
+  auto checkDecl = [&]() -> bool {
+bool NeedsOp = VD->isLocalVarDecl() && VD->isStaticLocal();
+return !NeedsOp || this->emitCheckDecl(VD, VD);
+  };
+
   if (Context::shouldBeGloballyIndexed(VD)) {
 auto initGlobal = [&](unsigned GlobalIndex) -> bool {
   assert(Init);
@@ -3527,20 +3532,22 @@ VarCreationState Compiler::visitVarDecl(const 
VarDecl *VD) {
 
   if (VarT) {
 if (!this->visit(Init))
-  return false;
-return this->emitInitGlobal(*VarT, GlobalIndex, VD);
+  return checkDecl() && false;
+
+return checkDecl() && this->emitInitGlobal(*VarT, GlobalIndex, VD);
   }
-  return this->visitGlobalInitializer(Init, GlobalIndex);
+
+  return checkDecl() && this->visitGlobalInitializer(Init, GlobalIndex);
 };
 
 // We've already seen and initialized this global.
 if (std::optional GlobalIndex = P.getGlobal(VD)) {
   if (P.getPtrGlobal(*GlobalIndex).isInitialized())
-return true;
+return checkDecl();
 
   // The previous attempt at initialization might've been unsuccessful,
   // so let's try this one.
-  return Init && initGlobal(*GlobalIndex);
+  return Init && checkDecl() && initGlobal(*GlobalIndex);
 }
 
 std::optional GlobalIndex = P.createGlobal(VD, Init);
@@ -3548,9 +3555,10 @@ VarCreationState Compiler::visitVarDecl(const 
VarDecl *VD) {
 if (!GlobalIndex)
   return false;
 
-return !Init || initGlobal(*GlobalIndex);
+return !Init || (checkDecl() && initGlobal(*GlobalIndex));
   } else {
 VariableScope LocalScope(this, VD);
+
 if (VarT) {
   unsigned Offset = this->allocateLocalPrimitive(
   VD, *VarT, VD->getType().isConstQualified());

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 866593b9af094..ff6d50ab9b6f8 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -2689,6 +2689,25 @@ inline bool DecayPtr(InterpState &S, CodePtr OpPC) {
   return true;
 }
 
+inline bool CheckDecl(InterpState &S, CodePtr OpPC, const VarDecl *VD) {
+  // An expression E is a core constant expression unless the evaluation of E
+  // would evaluate one of the following: [C++23] - a control flow that passes
+  // through a declaration of a variable with static or thread storage duration
+  // unless that variable is usable in constant expressions.
+  assert(VD->isLocalVarDecl() &&
+ VD->isStaticLocal()); // Checked before emitting this.
+
+  if (VD == S.EvaluatingDecl)
+return true;
+
+  if (!VD->isUsableInConstantExpressions(S.getCtx())) {
+S.CCEDiag(VD->getLocation(), diag::note_constexpr_static_local)
+<< (VD->getTSCSpec() == TSCS_unspecified ? 0 : 1) << VD;
+return false;
+  }
+  return true;
+}
+
 
//===--===//
 // Read opcode arguments
 
//===--===//

diff  --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td
index ddd955fc4cfa4..81e7b812da237 100644
--- a/clang/lib/AST/Interp/Opcodes.td
+++ b/clang/lib/AST/Interp/Opcodes.td
@@ -63,6 +63,7 @@ def ArgDeclRef : ArgType { let Name = "const DeclRefExpr *"; }
 def ArgDesc : ArgType { let Name = "const Descriptor *"; }
 def ArgCCI : ArgType { let Name = "const ComparisonCategoryInfo *"; }
 def ArgDecl : ArgType { let Name = "const Decl*"; }
+def ArgVarDecl : ArgType { let Name = "const VarDecl*"; }
 
 
//===--===//
 // Classes of types instructions operate on.
@@ -382,6 +383,10 @@ def GetLocal : AccessOpcode { let HasCustomEval = 1; }
 // [] -> [Pointer]
 def SetLocal : AccessOpcode { let HasCustomEval = 1; }
 
+def CheckDecl : Opcode {
+  let Args = [ArgVarDecl];
+}
+
 // [] -> [Value]
 def GetGlobal : AccessOpcode;
 def GetGlobalUnchecked : AccessOpcode;

diff  --git a/clang/test/AST/Interp/cxx23.cp

[clang] 42fc93d - [clang][Interp][NFC] Make a local pointer const

2024-07-01 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-07-01T11:59:56+02:00
New Revision: 42fc93d3ffb35ec1ff5c6584e1b15d5118db7311

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

LOG: [clang][Interp][NFC] Make a local pointer const

Added: 


Modified: 
clang/lib/AST/Interp/Compiler.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index ff755d503f871..5ae36dae6557d 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -4039,7 +4039,7 @@ bool Compiler::visitCompoundStmt(const 
CompoundStmt *S) {
 
 template 
 bool Compiler::visitDeclStmt(const DeclStmt *DS) {
-  for (auto *D : DS->decls()) {
+  for (const auto *D : DS->decls()) {
 if (isa(D))
   continue;



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


[clang] [clang] Inject tokens containing #embed back into token stream (PR #97274)

2024-07-01 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon created 
https://github.com/llvm/llvm-project/pull/97274

Instead of playing "whack a mole" with places where #embed should be expanded 
as comma-separated list, just inject each byte as a token back into the stream, 
separated by commas.

>From 4d5008fcf3ac37fa213c8f2cf42c3cce6369c83d Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Thu, 20 Jun 2024 06:04:07 -0700
Subject: [PATCH] [clang] Inject tokens containing #embed back into token
 stream

Instead of playing "whack a mole" with places where #embed should be
expanded as comma-separated list, just inject each byte as a token back
into the stream, separated by commas.
---
 clang/include/clang/Basic/TokenKinds.def|  3 ++
 clang/include/clang/Basic/TokenKinds.h  |  2 +-
 clang/include/clang/Lex/Preprocessor.h  |  5 +-
 clang/include/clang/Parse/Parser.h  |  3 +-
 clang/lib/Parse/ParseExpr.cpp   | 53 ++---
 clang/lib/Parse/ParseTemplate.cpp   | 41 +---
 clang/lib/Sema/SemaExpr.cpp |  6 ++-
 clang/test/Preprocessor/embed_codegen.cpp   |  3 +-
 clang/test/Preprocessor/embed_constexpr.cpp |  3 +-
 clang/test/Preprocessor/embed_weird.cpp | 21 
 10 files changed, 63 insertions(+), 77 deletions(-)

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 37d570ca5e75b..1bc9c59576f33 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -165,6 +165,9 @@ TOK(raw_identifier)  // Used only in raw lexing mode.
 // C99 6.4.4.2: Floating Constants
 TOK(numeric_constant)// 0x123
 
+// Directly holds numerical value. Used to process C23 #embed.
+TOK(binary_data)
+
 // C99 6.4.4: Character Constants
 TOK(char_constant)   // 'a'
 TOK(wide_char_constant)  // L'b'
diff --git a/clang/include/clang/Basic/TokenKinds.h 
b/clang/include/clang/Basic/TokenKinds.h
index e5183a27d2bc5..1b133dde89587 100644
--- a/clang/include/clang/Basic/TokenKinds.h
+++ b/clang/include/clang/Basic/TokenKinds.h
@@ -98,7 +98,7 @@ inline bool isLiteral(TokenKind K) {
   return K == tok::numeric_constant || K == tok::char_constant ||
  K == tok::wide_char_constant || K == tok::utf8_char_constant ||
  K == tok::utf16_char_constant || K == tok::utf32_char_constant ||
- isStringLiteral(K) || K == tok::header_name;
+ isStringLiteral(K) || K == tok::header_name || K == tok::binary_data;
 }
 
 /// Return true if this is any of tok::annot_* kinds.
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index be3334b980746..8e30756da2a01 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2123,8 +2123,9 @@ class Preprocessor {
   char
   getSpellingOfSingleCharacterNumericConstant(const Token &Tok,
   bool *Invalid = nullptr) const {
-assert(Tok.is(tok::numeric_constant) &&
-   Tok.getLength() == 1 && "Called on unsupported token");
+assert((Tok.is(tok::numeric_constant) || Tok.is(tok::binary_data)) &&
+Tok.getLength() == 1 &&
+"Called on unsupported token");
 assert(!Tok.needsCleaning() && "Token can't need cleaning with length 1");
 
 // If the token is carrying a literal data pointer, just use it.
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 6880fa4bb0b03..7bc2280764c5b 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2123,7 +2123,7 @@ class Parser : public CodeCompletionHandler {
   };
   ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
   ExprResult createEmbedExpr();
-  void ExpandEmbedDirective(SmallVectorImpl &Exprs);
+  void injectEmbedTokens();
 
   
//======//
   // clang Expressions
@@ -3830,7 +3830,6 @@ class Parser : public CodeCompletionHandler {
   AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
 ImplicitTypenameContext AllowImplicitTypename,
 bool IsClassName = false);
-  void ExpandEmbedIntoTemplateArgList(TemplateArgList &TemplateArgs);
   bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
  TemplateTy Template, SourceLocation OpenLoc);
   ParsedTemplateArgument ParseTemplateTemplateArgument();
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 9fc3cd73f73a0..a3b800a35b55e 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1018,6 +1018,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
 
 // primary-expression
   case tok::numeric_constant:
+  case tok::binary_data:
 // constant: integer-consta

[clang] [clang] Inject tokens containing #embed back into token stream (PR #97274)

2024-07-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mariya Podchishchaeva (Fznamznon)


Changes

Instead of playing "whack a mole" with places where #embed should be expanded 
as comma-separated list, just inject each byte as a token back into the stream, 
separated by commas.

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


10 Files Affected:

- (modified) clang/include/clang/Basic/TokenKinds.def (+3) 
- (modified) clang/include/clang/Basic/TokenKinds.h (+1-1) 
- (modified) clang/include/clang/Lex/Preprocessor.h (+3-2) 
- (modified) clang/include/clang/Parse/Parser.h (+1-2) 
- (modified) clang/lib/Parse/ParseExpr.cpp (+25-28) 
- (modified) clang/lib/Parse/ParseTemplate.cpp (+12-29) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+4-2) 
- (modified) clang/test/Preprocessor/embed_codegen.cpp (+2-1) 
- (modified) clang/test/Preprocessor/embed_constexpr.cpp (+2-1) 
- (modified) clang/test/Preprocessor/embed_weird.cpp (+10-11) 


``diff
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 37d570ca5e75b..1bc9c59576f33 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -165,6 +165,9 @@ TOK(raw_identifier)  // Used only in raw lexing mode.
 // C99 6.4.4.2: Floating Constants
 TOK(numeric_constant)// 0x123
 
+// Directly holds numerical value. Used to process C23 #embed.
+TOK(binary_data)
+
 // C99 6.4.4: Character Constants
 TOK(char_constant)   // 'a'
 TOK(wide_char_constant)  // L'b'
diff --git a/clang/include/clang/Basic/TokenKinds.h 
b/clang/include/clang/Basic/TokenKinds.h
index e5183a27d2bc5..1b133dde89587 100644
--- a/clang/include/clang/Basic/TokenKinds.h
+++ b/clang/include/clang/Basic/TokenKinds.h
@@ -98,7 +98,7 @@ inline bool isLiteral(TokenKind K) {
   return K == tok::numeric_constant || K == tok::char_constant ||
  K == tok::wide_char_constant || K == tok::utf8_char_constant ||
  K == tok::utf16_char_constant || K == tok::utf32_char_constant ||
- isStringLiteral(K) || K == tok::header_name;
+ isStringLiteral(K) || K == tok::header_name || K == tok::binary_data;
 }
 
 /// Return true if this is any of tok::annot_* kinds.
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index be3334b980746..8e30756da2a01 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2123,8 +2123,9 @@ class Preprocessor {
   char
   getSpellingOfSingleCharacterNumericConstant(const Token &Tok,
   bool *Invalid = nullptr) const {
-assert(Tok.is(tok::numeric_constant) &&
-   Tok.getLength() == 1 && "Called on unsupported token");
+assert((Tok.is(tok::numeric_constant) || Tok.is(tok::binary_data)) &&
+Tok.getLength() == 1 &&
+"Called on unsupported token");
 assert(!Tok.needsCleaning() && "Token can't need cleaning with length 1");
 
 // If the token is carrying a literal data pointer, just use it.
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 6880fa4bb0b03..7bc2280764c5b 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2123,7 +2123,7 @@ class Parser : public CodeCompletionHandler {
   };
   ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
   ExprResult createEmbedExpr();
-  void ExpandEmbedDirective(SmallVectorImpl &Exprs);
+  void injectEmbedTokens();
 
   
//======//
   // clang Expressions
@@ -3830,7 +3830,6 @@ class Parser : public CodeCompletionHandler {
   AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
 ImplicitTypenameContext AllowImplicitTypename,
 bool IsClassName = false);
-  void ExpandEmbedIntoTemplateArgList(TemplateArgList &TemplateArgs);
   bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
  TemplateTy Template, SourceLocation OpenLoc);
   ParsedTemplateArgument ParseTemplateTemplateArgument();
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 9fc3cd73f73a0..a3b800a35b55e 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1018,6 +1018,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
 
 // primary-expression
   case tok::numeric_constant:
+  case tok::binary_data:
 // constant: integer-constant
 // constant: floating-constant
 
@@ -1067,18 +1068,9 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   }
 
   case tok::annot_embed: {
-// We've met #embed in a context where a single value is expected. Take 
last
-// element from #embed data as if it were a comma expression.
-EmbedA

[clang] [clang] Inject tokens containing #embed back into token stream (PR #97274)

2024-07-01 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 8bb00cb160830ec8f6029c2aae79d3e46b04b99c 
4d5008fcf3ac37fa213c8f2cf42c3cce6369c83d -- 
clang/include/clang/Basic/TokenKinds.h clang/include/clang/Lex/Preprocessor.h 
clang/include/clang/Parse/Parser.h clang/lib/Parse/ParseExpr.cpp 
clang/lib/Parse/ParseTemplate.cpp clang/lib/Sema/SemaExpr.cpp 
clang/test/Preprocessor/embed_codegen.cpp 
clang/test/Preprocessor/embed_constexpr.cpp 
clang/test/Preprocessor/embed_weird.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 8e30756da2..591c1fccf9 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2124,8 +2124,7 @@ public:
   getSpellingOfSingleCharacterNumericConstant(const Token &Tok,
   bool *Invalid = nullptr) const {
 assert((Tok.is(tok::numeric_constant) || Tok.is(tok::binary_data)) &&
-Tok.getLength() == 1 &&
-"Called on unsupported token");
+   Tok.getLength() == 1 && "Called on unsupported token");
 assert(!Tok.needsCleaning() && "Token can't need cleaning with length 1");
 
 // If the token is carrying a literal data pointer, just use it.
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index a3b800a35b..88169037f0 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3573,9 +3573,9 @@ ExprResult Parser::ParseFoldExpression(ExprResult LHS,
 void Parser::injectEmbedTokens() {
   EmbedAnnotationData *Data =
   reinterpret_cast(Tok.getAnnotationValue());
-  MutableArrayRef Toks(
-  PP.getPreprocessorAllocator().Allocate(Data->BinaryData.size() * 
2 - 1),
-  Data->BinaryData.size() * 2 - 1);
+  MutableArrayRef Toks(PP.getPreprocessorAllocator().Allocate(
+  Data->BinaryData.size() * 2 - 1),
+  Data->BinaryData.size() * 2 - 1);
   unsigned I = 0;
   for (auto &Byte : Data->BinaryData) {
 Toks[I].startToken();

``




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


[clang] [Clang] fix cast failures by adjusting the resolution of record declaration contexts to handle semantic and lexical distinctions (PR #96228)

2024-07-01 Thread Oleksandr T. via cfe-commits

a-tarasyuk wrote:

ping 

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


[clang] [WIP][CLANG][AArch64] Add the modal 8 bit floating-point scalar type (PR #97277)

2024-07-01 Thread via cfe-commits

https://github.com/CarolineConcatto created 
https://github.com/llvm/llvm-project/pull/97277

ARM ACLE PR#323[1] adds new modal types for 8-bit floating point intrinsic.

>From the PR#323:
```
ACLE defines the `__fpm8` type, which can be used for the E5M2 and E4M3
8-bit floating-point formats. It is a storage and interchange only type
with no arithmetic operations other than intrinsic calls.


The type should be an opaque type and its format in undefined in Clang. Only 
defined in the backend by a status/format register, for AArch64 the FPMR.

This patch is an attempt to the add the fpm8_t scalar type. It has a parser and 
codegen for the new scalar type.

The patch it is lowering to and 8bit unsigned as it has no format. But maybe we 
should add another opaque type.

[1]  https://github.com/ARM-software/acle/pull/323

>From fbeca5c357b1a5589757bbb2cac8208f8c9027ab Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Mon, 24 Jun 2024 09:59:24 +
Subject: [PATCH] [WIP][CLANG][AArch64] Add the  modal 8 bit floating-point
 scalar type

ARM ACLE PR#323[1] adds new modal types for 8-bit floating point intrinsic.

>From the PR#323:
```
ACLE defines the `__fpm8` type, which can be used for the E5M2 and E4M3
8-bit floating-point formats. It is a storage and interchange only type
with no arithmetic operations other than intrinsic calls.


The type should be an opaque type and its format in undefined in Clang.
Only defined in the backend by a status/format register, for AArch64 the FPMR.

This patch is an attempt to the add the fpm8_t scalar type.
It has a parser and codegen for the new scalar type.

The patch it is lowering to and 8bit unsigned as it has no format.
But maybe we should add another opaque type.

[1]  https://github.com/ARM-software/acle/pull/323
---
 clang/include/clang/AST/ASTContext.h  |  1 +
 clang/include/clang/AST/BuiltinTypes.def  |  4 +
 clang/include/clang/AST/Type.h|  5 +
 clang/include/clang/Basic/Specifiers.h|  1 +
 clang/include/clang/Basic/TokenKinds.def  |  1 +
 clang/include/clang/Sema/DeclSpec.h   |  1 +
 .../include/clang/Serialization/ASTBitCodes.h |  4 +-
 clang/lib/AST/ASTContext.cpp  |  7 ++
 clang/lib/AST/ItaniumMangle.cpp   |  1 +
 clang/lib/AST/Type.cpp|  2 +
 clang/lib/AST/TypeLoc.cpp |  1 +
 clang/lib/CodeGen/CodeGenTypes.cpp|  4 +-
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  1 +
 clang/lib/Index/USRGeneration.cpp |  1 +
 clang/lib/Lex/Lexer.cpp   |  1 +
 clang/lib/Parse/ParseDecl.cpp |  7 ++
 clang/lib/Parse/ParseExpr.cpp |  1 +
 clang/lib/Parse/ParseExprCXX.cpp  |  3 +
 clang/lib/Parse/ParseTentative.cpp|  2 +
 clang/lib/Sema/DeclSpec.cpp   |  3 +
 clang/lib/Sema/SemaTemplateVariadic.cpp   |  1 +
 clang/lib/Sema/SemaType.cpp   |  3 +
 clang/lib/Serialization/ASTCommon.cpp |  3 +
 clang/test/AST/fpm8_opaque.cpp| 91 +++
 clang/test/CodeGen/fpm8_opaque.c  | 24 +
 25 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/AST/fpm8_opaque.cpp
 create mode 100644 clang/test/CodeGen/fpm8_opaque.c

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 53ece996769a8..532ec05ab90a6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1115,6 +1115,7 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  CanQualType Fpm8Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index 444be4311a743..0c1cccf4f73b8 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -221,6 +221,10 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+
+// '__fpm8'
+UNSIGNED_TYPE(Fpm8, Fpm8Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index fab233b62d8d1..9f835b8459847 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2492,6 +2492,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isDoubleType() const;
   bool isBFloat16Type() const;
   bool isFloat128Type() const;
+  bool isFpm8Type() const;
   bool isIbm128Type() const;
   bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
   bool isArithmeticType() const;   //

[clang] [WIP][CLANG][AArch64] Add the modal 8 bit floating-point scalar type (PR #97277)

2024-07-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: None (CarolineConcatto)


Changes

ARM ACLE PR#323[1] adds new modal types for 8-bit floating point 
intrinsic.

>From the PR#323:
```
ACLE defines the `__fpm8` type, which can be used for the E5M2 and E4M3
8-bit floating-point formats. It is a storage and interchange only type
with no arithmetic operations other than intrinsic calls.


The type should be an opaque type and its format in undefined in Clang. Only 
defined in the backend by a status/format register, for AArch64 the FPMR.

This patch is an attempt to the add the fpm8_t scalar type. It has a parser and 
codegen for the new scalar type.

The patch it is lowering to and 8bit unsigned as it has no format. But maybe we 
should add another opaque type.

[1]  https://github.com/ARM-software/acle/pull/323

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


25 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+1) 
- (modified) clang/include/clang/AST/BuiltinTypes.def (+4) 
- (modified) clang/include/clang/AST/Type.h (+5) 
- (modified) clang/include/clang/Basic/Specifiers.h (+1) 
- (modified) clang/include/clang/Basic/TokenKinds.def (+1) 
- (modified) clang/include/clang/Sema/DeclSpec.h (+1) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+3-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+7) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1) 
- (modified) clang/lib/AST/Type.cpp (+2) 
- (modified) clang/lib/AST/TypeLoc.cpp (+1) 
- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+3-1) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1) 
- (modified) clang/lib/Index/USRGeneration.cpp (+1) 
- (modified) clang/lib/Lex/Lexer.cpp (+1) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+7) 
- (modified) clang/lib/Parse/ParseExpr.cpp (+1) 
- (modified) clang/lib/Parse/ParseExprCXX.cpp (+3) 
- (modified) clang/lib/Parse/ParseTentative.cpp (+2) 
- (modified) clang/lib/Sema/DeclSpec.cpp (+3) 
- (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+1) 
- (modified) clang/lib/Sema/SemaType.cpp (+3) 
- (modified) clang/lib/Serialization/ASTCommon.cpp (+3) 
- (added) clang/test/AST/fpm8_opaque.cpp (+91) 
- (added) clang/test/CodeGen/fpm8_opaque.c (+24) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 53ece996769a8..532ec05ab90a6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1115,6 +1115,7 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  CanQualType Fpm8Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index 444be4311a743..0c1cccf4f73b8 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -221,6 +221,10 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+
+// '__fpm8'
+UNSIGNED_TYPE(Fpm8, Fpm8Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index fab233b62d8d1..9f835b8459847 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2492,6 +2492,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isDoubleType() const;
   bool isBFloat16Type() const;
   bool isFloat128Type() const;
+  bool isFpm8Type() const;
   bool isIbm128Type() const;
   bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
   bool isArithmeticType() const;   // C99 6.2.5p18 (integer + floating)
@@ -7944,6 +7945,10 @@ inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
+inline bool Type::isFpm8Type() const {
+  return isSpecificBuiltinType(BuiltinType::Fpm8);
+}
+
 inline bool Type::isFloat128Type() const {
   return isSpecificBuiltinType(BuiltinType::Float128);
 }
diff --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index fb11e8212f8b6..b4db94d273949 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -68,6 +68,7 @@ namespace clang {
 TST_Accum,   // ISO/IEC JTC1 SC22 WG14 N1169 Extension
 TST_Fract,
 TST_BFloat16,
+TST_Fpm8,
 TST_float,
 TST_double,
 TST_float128,
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 9c4b17465e18a..c08cf760962f3 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -655,6 +655,7 @@ KEYWORD(__bool

[clang] [WIP][CLANG][AArch64] Add the modal 8 bit floating-point scalar type (PR #97277)

2024-07-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (CarolineConcatto)


Changes

ARM ACLE PR#323[1] adds new modal types for 8-bit floating point 
intrinsic.

>From the PR#323:
```
ACLE defines the `__fpm8` type, which can be used for the E5M2 and E4M3
8-bit floating-point formats. It is a storage and interchange only type
with no arithmetic operations other than intrinsic calls.


The type should be an opaque type and its format in undefined in Clang. Only 
defined in the backend by a status/format register, for AArch64 the FPMR.

This patch is an attempt to the add the fpm8_t scalar type. It has a parser and 
codegen for the new scalar type.

The patch it is lowering to and 8bit unsigned as it has no format. But maybe we 
should add another opaque type.

[1]  https://github.com/ARM-software/acle/pull/323

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


25 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+1) 
- (modified) clang/include/clang/AST/BuiltinTypes.def (+4) 
- (modified) clang/include/clang/AST/Type.h (+5) 
- (modified) clang/include/clang/Basic/Specifiers.h (+1) 
- (modified) clang/include/clang/Basic/TokenKinds.def (+1) 
- (modified) clang/include/clang/Sema/DeclSpec.h (+1) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+3-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+7) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1) 
- (modified) clang/lib/AST/Type.cpp (+2) 
- (modified) clang/lib/AST/TypeLoc.cpp (+1) 
- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+3-1) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1) 
- (modified) clang/lib/Index/USRGeneration.cpp (+1) 
- (modified) clang/lib/Lex/Lexer.cpp (+1) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+7) 
- (modified) clang/lib/Parse/ParseExpr.cpp (+1) 
- (modified) clang/lib/Parse/ParseExprCXX.cpp (+3) 
- (modified) clang/lib/Parse/ParseTentative.cpp (+2) 
- (modified) clang/lib/Sema/DeclSpec.cpp (+3) 
- (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+1) 
- (modified) clang/lib/Sema/SemaType.cpp (+3) 
- (modified) clang/lib/Serialization/ASTCommon.cpp (+3) 
- (added) clang/test/AST/fpm8_opaque.cpp (+91) 
- (added) clang/test/CodeGen/fpm8_opaque.c (+24) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 53ece996769a8..532ec05ab90a6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1115,6 +1115,7 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  CanQualType Fpm8Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index 444be4311a743..0c1cccf4f73b8 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -221,6 +221,10 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+
+// '__fpm8'
+UNSIGNED_TYPE(Fpm8, Fpm8Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index fab233b62d8d1..9f835b8459847 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2492,6 +2492,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isDoubleType() const;
   bool isBFloat16Type() const;
   bool isFloat128Type() const;
+  bool isFpm8Type() const;
   bool isIbm128Type() const;
   bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
   bool isArithmeticType() const;   // C99 6.2.5p18 (integer + floating)
@@ -7944,6 +7945,10 @@ inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
+inline bool Type::isFpm8Type() const {
+  return isSpecificBuiltinType(BuiltinType::Fpm8);
+}
+
 inline bool Type::isFloat128Type() const {
   return isSpecificBuiltinType(BuiltinType::Float128);
 }
diff --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index fb11e8212f8b6..b4db94d273949 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -68,6 +68,7 @@ namespace clang {
 TST_Accum,   // ISO/IEC JTC1 SC22 WG14 N1169 Extension
 TST_Fract,
 TST_BFloat16,
+TST_Fpm8,
 TST_float,
 TST_double,
 TST_float128,
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 9c4b17465e18a..c08cf760962f3 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -655,6 +655,7 @@ KEYWORD(__bool  , KEYA

[clang] [WIP][CLANG][AArch64] Add the modal 8 bit floating-point scalar type (PR #97277)

2024-07-01 Thread via cfe-commits

CarolineConcatto wrote:

Just in I don't believe this patch is ready, but I would like to share so I 
could get some pointers of what is missing.
I  also have  question about implementation:
Should we convert to a)unsigned 8 bits correspondent in CodeGenTypes.cpp or 
b)should we create another opaque  in LLVM  or c) something else?
In the implementation should we use  UNSIGNED_TYPE(Fpm8, Fpm8Ty) in 
BuiltinTypes.def or needs to adds OPAQUE?

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


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Vlad Serebrennikov via cfe-commits


@@ -10,26 +10,6 @@
 
 
 class TestTokenKind(unittest.TestCase):
-def test_constructor(self):

Endilll wrote:

Can't we keep those tests?

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


[clang] [flang] [Flang-new][OpenMP] Add offload related flags for AMDGPU (PR #96742)

2024-07-01 Thread Dominik Adamski via cfe-commits

https://github.com/DominikAdamski updated 
https://github.com/llvm/llvm-project/pull/96742

>From 5b487aac3c8414b6f37f6888f361ca7488094048 Mon Sep 17 00:00:00 2001
From: Dominik Adamski 
Date: Fri, 21 Jun 2024 18:03:53 +0200
Subject: [PATCH 1/2] [Flang-new][OpenMP] Add offload related flags for AMDGPU

Flang-new needs to add mlink-builtin-bitcode objects
to properly support offload code generation for AMD GPU.

fcuda-is-device flag is not used by Flang currently.
In the future it will be needed for Flang equivalent function:
AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace.
---
 clang/include/clang/Driver/Options.td |  4 +-
 clang/lib/Driver/ToolChains/Flang.cpp |  3 ++
 flang/test/Driver/omp-driver-offload.f90  | 58 +--
 flang/test/Driver/target-cpu-features.f90 |  4 +-
 flang/test/Driver/target-gpu-features.f90 |  2 +-
 5 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index dd55838dcf384..612d5793232ce 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8016,7 +8016,7 @@ def source_date_epoch : Separate<["-"], 
"source-date-epoch">,
 // CUDA Options
 
//===--===//
 
-let Visibility = [CC1Option] in {
+let Visibility = [CC1Option, FC1Option] in {
 
 def fcuda_is_device : Flag<["-"], "fcuda-is-device">,
   HelpText<"Generate code for CUDA device">,
@@ -8031,7 +8031,7 @@ def fno_cuda_host_device_constexpr : Flag<["-"], 
"fno-cuda-host-device-constexpr
   HelpText<"Don't treat unattributed constexpr functions as __host__ 
__device__.">,
   MarshallingInfoNegativeFlag>;
 
-} // let Visibility = [CC1Option]
+} // let Visibility = [CC1Option, FC1Option]
 
 
//===--===//
 // OpenMP Options
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 42b45dba2bd31..2679f284c5016 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -333,6 +333,9 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args,
 StringRef Val = A->getValue();
 CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val));
   }
+
+  const ToolChain &TC = getToolChain();
+  TC.addClangTargetOptions(Args, CmdArgs, Action::OffloadKind::OFK_OpenMP);
 }
 
 void Flang::addTargetOptions(const ArgList &Args,
diff --git a/flang/test/Driver/omp-driver-offload.f90 
b/flang/test/Driver/omp-driver-offload.f90
index 6fb4f4ca1..da81a6ee3ba8f 100644
--- a/flang/test/Driver/omp-driver-offload.f90
+++ b/flang/test/Driver/omp-driver-offload.f90
@@ -14,12 +14,12 @@
 ! Test regular -fopenmp with offload, and invocation filtering options
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 \
-! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: --target=aarch64-unknown-linux-gnu -nogpulib\
 ! RUN:   | FileCheck %s --check-prefix=OFFLOAD-HOST-AND-DEVICE
 
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 
--offload-host-device \
-! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: --target=aarch64-unknown-linux-gnu -nogpulib\
 ! RUN:   | FileCheck %s --check-prefix=OFFLOAD-HOST-AND-DEVICE
 
 ! OFFLOAD-HOST-AND-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
@@ -29,7 +29,7 @@
 
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 --offload-host-only 
\
-! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: --target=aarch64-unknown-linux-gnu -nogpulib\
 ! RUN:   | FileCheck %s --check-prefix=OFFLOAD-HOST
 
 ! OFFLOAD-HOST: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
@@ -39,7 +39,7 @@
 
 ! RUN: %flang -S -### %s 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 
--offload-device-only \
-! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: --target=aarch64-unknown-linux-gnu -nogpulib\
 ! RUN:   | FileCheck %s --check-prefix=OFFLOAD-DEVICE
 
 ! OFFLOAD-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
@@ -48,13 +48,13 @@
 ! OFFLOAD-DEVICE-NOT: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
 
 ! Test regular -fopenmp with offload for basic fopenmp-is-target-device flag 
addition and correct fopenmp 
-! RUN: %flang -### -fopenmp --offload-arch=gfx90a 
-fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck 
--check-prefixes=CHECK-OPENMP-IS-TARGET-DEVICE %s
+! RUN: %flang -### -fopenmp --offload-arch=gfx90a 
-fopenmp-targets=amdgcn-amd-amdhsa -nogpulib %s 2>&1 | FileCheck 
--check-prefixes=CHECK-OPENMP-IS-TARGET-DEVICE %s
 ! CHECK-OPENMP-IS-TARGET-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" 
{{.*}} "-fopenmp-is-target-device" {{.*}}.f90"
 
 ! Testing appropriate flags are gnerated and appropriately assigned by the 
dr

[clang] [libc] [llvm] AMDGPU: Add a subtarget feature for fine-grained remote memory support (PR #96442)

2024-07-01 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/96442
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libc] [llvm] AMDGPU: Add a subtarget feature for fine-grained remote memory support (PR #96442)

2024-07-01 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

ping 

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


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits


@@ -39,6 +39,7 @@ ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, 
llvm::Reloc::PIC_) ///<
 ENUM_CODEGENOPT(DebugInfo,  llvm::codegenoptions::DebugInfoKind, 4,  
llvm::codegenoptions::NoDebugInfo) ///< Level of debug info to generate
 ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
 ENUM_CODEGENOPT(FramePointer, llvm::FramePointerKind, 2, 
llvm::FramePointerKind::None) ///< Enable the usage of frame pointers
+ENUM_CODEGENOPT(CodeModel, llvm::CodeModel::Model, 5, 
llvm::CodeModel::Model::Small)

Leporacanthicus wrote:

Rightly or wrongly, I've changed it to copy the way that Clang does it, and 
store the string in CodeGenOptions, then parse it (twice, but sharing the code 
to do so, rather than implementing the same-ish code twice in Clang). 

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


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits


@@ -39,6 +39,7 @@ ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, 
llvm::Reloc::PIC_) ///<
 ENUM_CODEGENOPT(DebugInfo,  llvm::codegenoptions::DebugInfoKind, 4,  
llvm::codegenoptions::NoDebugInfo) ///< Level of debug info to generate
 ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
 ENUM_CODEGENOPT(FramePointer, llvm::FramePointerKind, 2, 
llvm::FramePointerKind::None) ///< Enable the usage of frame pointers
+ENUM_CODEGENOPT(CodeModel, llvm::CodeModel::Model, 5, 
llvm::CodeModel::Model::Small)

Leporacanthicus wrote:

This code is no longer present. 

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


[clang] [clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (PR #97071)

2024-07-01 Thread David Spickett via cfe-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

Also remove the comment that links to 
https://github.com/llvm/llvm-project/issues/94994 and add `Fixes #94994` to the 
commit message.

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


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits


@@ -10,26 +10,6 @@
 
 
 class TestTokenKind(unittest.TestCase):
-def test_constructor(self):

DeinAlptraum wrote:

thNot really:
- `test_constructor`: this tests the ability to add enum variants "on the fly", 
which is not possible with the Python stdlib's `Enum` class
- `test_bad_register`: the `Enum` class tests for this on initialization, so if 
you define a duplicate `Enum` variant, you will get a failure on import 
already. This makes the test both a) effectively covered by that and b) you 
couldn't import the module to run such a test anyway in a case where there's a 
duplicate
- `test_unknown_value`: this is covered in `test_from_id` in `test_enums.py` 
since I added the `TokenKind` class to the test there 

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


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits

https://github.com/DeinAlptraum edited 
https://github.com/llvm/llvm-project/pull/95608
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits

https://github.com/DeinAlptraum edited 
https://github.com/llvm/llvm-project/pull/95608
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-07-01 Thread Kristóf Umann via cfe-commits

https://github.com/Szelethus updated 
https://github.com/llvm/llvm-project/pull/95408

From 90cedd519da8b76c686db9c3f824b6d044e16eb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Krist=C3=B3f=20Umann?= 
Date: Thu, 25 Apr 2024 17:31:24 +0200
Subject: [PATCH 1/6] [analyzer] Check the correct first and last elements in
 cstring.UninitializedRead

I intend to fix this checker up so that we can move it out of alpha. I
made a bunch of analyses, and found many similar false positives:

```c++
int t[] = {1,2,3};
memcpy(dst, t, sizeof(t) / sizeof(t[0])); // warn
```

The problem here is the way CStringChecker checks whether the
destination and source buffers are initialized: heuristically, it only
checks the first and last element. This is fine, however, it retrieves
these elements as characters, even if the underlaying object is not a
character array. Reading the last byte of an integer is undefined, so
the checker emits a bug here.

A quick search tells you the rationale: "Both objects are reinterpreted
as arrays of unsigned char.". But the static analyzer right now can't
check byte-by-byte if a memory region is _initialized_, it can only
check if its a well-defined character or not.

In this patch, I pry the original array out of the arguments to memcpy
(and similar functions), and retrieve the actual first and last elements
according to the array's actual element type.

Currently, my improvements reduced the number of reports to 29 on these
projects: memcached,tmux,curl,twin,vim,openssl,sqlite,ffmpeg,postgres

https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?detection-status=New&detection-status=Reopened&detection-status=Unresolved&is-unique=on&run=%2acstring_uninit_upper_bound_patched&newcheck=%2acstring_uninit_upper_bounds_patched&diff-type=New&checker-name=alpha.unix.cstring.UninitializedRead&items-per-page=100

Before my patch, there were 87.

https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?detection-status=New&detection-status=Reopened&detection-status=Unresolved&is-unique=on&run=%2acstring_uninit_baseline&newcheck=%2acstring_uninit_upper_bounds_patched&diff-type=New&checker-name=alpha.unix.cstring.UninitializedRead&items-per-page=100

Change-Id: I0ef16beed735201af857abb6ed02de764af2e78a
---
 .../Core/PathSensitive/MemRegion.h|  14 ++
 .../Checkers/CStringChecker.cpp   | 226 +++---
 clang/test/Analysis/bstring_UninitRead.c  |  66 -
 3 files changed, 258 insertions(+), 48 deletions(-)

diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
index c0d3fbd0eb961a..9e9f2f4fc1a0e5 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -34,6 +34,7 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
 #include 
 #include 
 #include 
@@ -99,6 +100,8 @@ class MemRegion : public llvm::FoldingSetNode {
 #define REGION(Id, Parent) Id ## Kind,
 #define REGION_RANGE(Id, First, Last) BEGIN_##Id = First, END_##Id = Last,
 #include "clang/StaticAnalyzer/Core/PathSensitive/Regions.def"
+#undef REGION
+#undef REGION_RANGE
   };
 
 private:
@@ -171,6 +174,17 @@ class MemRegion : public llvm::FoldingSetNode {
 
   Kind getKind() const { return kind; }
 
+  StringRef getKindStr() const {
+switch (getKind()) {
+#define REGION(Id, Parent) 
\
+  case Id##Kind:   
\
+return #Id;
+#include "clang/StaticAnalyzer/Core/PathSensitive/Regions.def"
+#undef REGION
+}
+llvm_unreachable("Unkown kind!");
+  }
+
   template const RegionTy* getAs() const;
   template 
   LLVM_ATTRIBUTE_RETURNS_NONNULL const RegionTy *castAs() const;
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 238e87a712a43a..fdea2e01215b44 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "InterCheckerAPI.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
@@ -22,10 +23,13 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "llvm/ADT/APSInt.h"

[clang] [Clang] Bring initFeatureMap back to AArch64TargetInfo. (PR #96832)

2024-07-01 Thread Tomas Matheson via cfe-commits

tmatheson-arm wrote:

Thank you for the example, I understand what is happening how.

- Before #94279, we used to add CPU features in `AArch64::initFeatureMap`.
- In #94279, we decided that actually you should do that in the Driver, which 
should put all `-target-features` it wants on the -cc1 command line. The Driver 
is responsible for expanding the CPU (and architecture) feature dependencies 
and their interaction with any modifiers on the command line.
- This means that when `initFeatureMap` runs in `clang`, `FeaturesAsWritten` is 
populated with the CPU features and is used to initialise the `FeatureMap`.
- In contrast, you are not using the `Driver`, and do not populate 
`FeaturesAsWritten` with the CPU features.
- Instead, you expect `initFeatureMap` to add CPU features. This is not 
unreasonable, given that the CPU is passed the function and several other 
backends add CPU features at this stage.

[This bit of 
code](https://github.com/llvm/llvm-project/pull/94279/files#diff-2ccae12096c75c4b8422ea0d2fdf6b195896d2554d62cce604e8fcb56a78ef62L1057-L1067)
 used to crudely add the CPU features to the end of the feature list. However 
there are some problems with that approach, which we attempted to rectify in 
#94279:
- CPU features that were explicitly disabled on the command line could actually 
end up enabled in the backend
- The architecture features (i.e. implied by `-march`) were not treated the 
same way as the CPU features (`-mcpu`)

For example, if you wrote: `clang -mcpu=cortex-a75+norcpc -###`, you would see 
all the Cortex-A75 features expanded on the `-cc1` command line, but with RCPC 
disabled: `-target-feature -rcpc`. But in this case, `AArch64::initFeatureMap` 
would have re-added `+rcpc`, overriding the command line. (This is technically 
not the case after [this 
line](https://github.com/llvm/llvm-project/pull/94279/files#diff-2ccae12096c75c4b8422ea0d2fdf6b195896d2554d62cce604e8fcb56a78ef62L1092)
 was added, but the general point is that `initFeatureMap` broke feature 
dependency resolution in ways that are difficult to reason about).

There doesn't seem to be a way to specify an architecture in `TargetOptions`, 
which looks odd to me. That means there is no way to select e.g. `armv9.4-a` in 
your example, except by manually adding the features in 
`TargetOptions::Features` or `TargetOptions::FeaturesAsWritten`.

So the way that we set up the AArch64 backend in #94279 is to require you to 
calculate your feature set up front, which are then trivially passed through by 
the default `TargetInfo::initFeatureMap`.

I'm not sure there is a clear answer on this one. I can't see a way to easily 
let `AArch64:: initFeatureMap` add CPU features again without breaking the 
dependency resolution. I am open to suggestions though.

If you wanted to go the route of building the feature list before calling 
`initFeatureMap`, the functions `tools::getTargetFeatures` and 
`aarch64::getAArch64TargetFeatures` can do that for you. Currently they require 
a `const Driver &D`, but fundamentally I think they just need a 
`DiagnosticsEngine&` so that could be changed.

I'm open to other suggestions too.


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


[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-07-01 Thread via cfe-commits
=?utf-8?q?Kristóf?= Umann ,
=?utf-8?q?Kristóf?= Umann ,
=?utf-8?q?Kristóf?= Umann ,
=?utf-8?q?Kristóf?= Umann ,
=?utf-8?q?Kristóf?= Umann 
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff d78211912391b724a064ef017dbf239eff10380a 
d37f0cb4ceb0f99947be4ee65564b257dc095e6e -- 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
clang/lib/StaticAnalyzer/Core/MemRegion.cpp 
clang/test/Analysis/bstring_UninitRead.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 9fe53a0bcb..8dd08f14b2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -359,12 +359,12 @@ REGISTER_MAP_WITH_PROGRAMSTATE(CStringLength, const 
MemRegion *, SVal)
 // Individual checks and utility methods.
 
//===--===//
 
-std::pair
+std::pair
 CStringChecker::assumeZero(CheckerContext &C, ProgramStateRef State, SVal V,
QualType Ty) {
   std::optional val = V.getAs();
   if (!val)
-return std::pair(State, State);
+return std::pair(State, State);
 
   SValBuilder &svalBuilder = C.getSValBuilder();
   DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);

``




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


[clang] [Clang][Sema] Diagnose variable template explicit specializations with storage-class-specifiers (PR #93873)

2024-07-01 Thread via cfe-commits

alexfh wrote:

It looks like the presence of `static` on template variable specializations 
makes difference in the namespace context: https://gcc.godbolt.org/z/b5ns1zhx6

Specifically, the specializations not marked `static` result in an exported 
variable. Thus, we have seemingly valid code that generates this diagnostic:
```
namespace A {
template = 1 && N <= 64>>
static constexpr uint64_t kMaxUnsignedInt = 2 * kMaxUnsignedInt + 1;

template <>
static constexpr uint64_t kMaxUnsignedInt<1> = 1;
}
```

However, if we remove the `static` from the specialization, we're getting a 
potential ODR violation (considering this code can be in a header included into 
multiple translation units).

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


[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-07-01 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

> Even protobuf contains this type of code: 
> https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=protobuf_v3.13.0_pointersub1&is-unique=on&diff-type=New&checker-name=alpha.core.PointerSub&report-id=5545776&report-hash=1bcd310fbaeccbcc13645b9b277239a2&report-filepath=%2adescriptor.pb.cc

I still think that this
 (1) is undeniably undefined behavior
 (2) isn't common, so won't cause "spam"  problems and
 (3( can be replaced by standard-compliant code (`offsetof`)
so there is no need to introduce a special case for it.

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


[clang] [Clang][Sema] Diagnose variable template explicit specializations with storage-class-specifiers (PR #93873)

2024-07-01 Thread via cfe-commits

alexfh wrote:

There's more (https://gcc.godbolt.org/z/YKKah8M1n):
```
class D {
template 
static constexpr int kMaxUnsignedInt = 2 * kMaxUnsignedInt + 1;

template <>
constexpr auto kMaxUnsignedInt<1> = 1;
};
```
fails to compile with 
```
:14:11: error: 'auto' not allowed in non-static class member
   14 | constexpr auto kMaxUnsignedInt<1> = 1;
  |   ^~~~
```

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


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Vlad Serebrennikov via cfe-commits


@@ -10,26 +10,6 @@
 
 
 class TestTokenKind(unittest.TestCase):
-def test_constructor(self):

Endilll wrote:

> test_constructor: this tests the ability to add enum variants "on the fly", 
> which is not possible with the Python stdlib's Enum class

Do we have a test that this is not possible anymore?

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


[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-07-01 Thread via cfe-commits

https://github.com/zmodem commented:

I've read half the patch so far, but wanted to ask before continuing: would it 
be possible (and simpler) to extend the /winsysroot support somehow to also 
handle --sysroot?

(It would also be easier to review if the unrelated formatting changes were 
removed or split to a separate PR.)

+ @aganea and @mstorsjo in case you have comments too.

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


[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-07-01 Thread via cfe-commits


@@ -1290,6 +1296,9 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
   case ToolChain::CST_Libstdcxx:
 CmdArgs.push_back("-lstdc++");
 break;
+
+  default:

zmodem wrote:

Let's spell out the CST_Stl case explicitly and avoid a default case. That way 
-Wswitch-enum will fire in the future if a new enum gets added.

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


[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-07-01 Thread via cfe-commits

https://github.com/zmodem edited https://github.com/llvm/llvm-project/pull/96417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-07-01 Thread via cfe-commits


@@ -95,43 +95,52 @@ void visualstudio::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   // the environment variable is set however, assume the user knows what
   // they're doing. If the user passes /vctoolsdir or /winsdkdir, trust that
   // over env vars.
-  if (const Arg *A = Args.getLastArg(options::OPT__SLASH_diasdkdir,
- options::OPT__SLASH_winsysroot)) {
-// cl.exe doesn't find the DIA SDK automatically, so this too requires
-// explicit flags and doesn't automatically look in "DIA SDK" relative
-// to the path we found for VCToolChainPath.
-llvm::SmallString<128> DIAPath(A->getValue());
-if (A->getOption().getID() == options::OPT__SLASH_winsysroot)
-  llvm::sys::path::append(DIAPath, "DIA SDK");
-
-// The DIA SDK always uses the legacy vc arch, even in new MSVC versions.
-llvm::sys::path::append(DIAPath, "lib",
-llvm::archToLegacyVCArch(TC.getArch()));
-CmdArgs.push_back(Args.MakeArgString(Twine("-libpath:") + DIAPath));
-  }
-  if (!llvm::sys::Process::GetEnv("LIB") ||
-  Args.getLastArg(options::OPT__SLASH_vctoolsdir,
-  options::OPT__SLASH_winsysroot)) {
-CmdArgs.push_back(Args.MakeArgString(
-Twine("-libpath:") +
-TC.getSubDirectoryPath(llvm::SubDirectoryType::Lib)));
-CmdArgs.push_back(Args.MakeArgString(
-Twine("-libpath:") +
-TC.getSubDirectoryPath(llvm::SubDirectoryType::Lib, "atlmfc")));
-  }
-  if (!llvm::sys::Process::GetEnv("LIB") ||
-  Args.getLastArg(options::OPT__SLASH_winsdkdir,
-  options::OPT__SLASH_winsysroot)) {
-if (TC.useUniversalCRT()) {
-  std::string UniversalCRTLibPath;
-  if (TC.getUniversalCRTLibraryPath(Args, UniversalCRTLibPath))
+  auto SysRoot = TC.getDriver().SysRoot;
+  if (SysRoot.empty()) {
+if (const Arg *A = Args.getLastArg(options::OPT__SLASH_diasdkdir,
+   options::OPT__SLASH_winsysroot)) {
+  // cl.exe doesn't find the DIA SDK automatically, so this too requires
+  // explicit flags and doesn't automatically look in "DIA SDK" relative
+  // to the path we found for VCToolChainPath.
+  llvm::SmallString<128> DIAPath(A->getValue());
+  if (A->getOption().getID() == options::OPT__SLASH_winsysroot)
+llvm::sys::path::append(DIAPath, "DIA SDK");
+
+  // The DIA SDK always uses the legacy vc arch, even in new MSVC versions.
+  llvm::sys::path::append(DIAPath, "lib",
+  llvm::archToLegacyVCArch(TC.getArch()));
+  CmdArgs.push_back(Args.MakeArgString(Twine("-libpath:") + DIAPath));
+}
+if (!llvm::sys::Process::GetEnv("LIB") ||
+Args.getLastArg(options::OPT__SLASH_vctoolsdir,
+options::OPT__SLASH_winsysroot)) {
+  CmdArgs.push_back(Args.MakeArgString(
+  Twine("-libpath:") +
+  TC.getSubDirectoryPath(llvm::SubDirectoryType::Lib)));
+  CmdArgs.push_back(Args.MakeArgString(
+  Twine("-libpath:") +
+  TC.getSubDirectoryPath(llvm::SubDirectoryType::Lib, "atlmfc")));
+}
+if (!llvm::sys::Process::GetEnv("LIB") ||
+Args.getLastArg(options::OPT__SLASH_winsdkdir,
+options::OPT__SLASH_winsysroot)) {
+  if (TC.useUniversalCRT()) {
+std::string UniversalCRTLibPath;
+if (TC.getUniversalCRTLibraryPath(Args, UniversalCRTLibPath))
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("-libpath:") + UniversalCRTLibPath));
+  }
+  std::string WindowsSdkLibPath;
+  if (TC.getWindowsSDKLibraryPath(Args, WindowsSdkLibPath))
 CmdArgs.push_back(
-Args.MakeArgString(Twine("-libpath:") + UniversalCRTLibPath));
+Args.MakeArgString(std::string("-libpath:") + WindowsSdkLibPath));

zmodem wrote:

Might as well use Twine while we're here.

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


[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-07-01 Thread via cfe-commits


@@ -763,19 +789,36 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const 
ArgList &DriverArgs,
   // As a fallback, select default install paths.
   // FIXME: Don't guess drives and paths like this on Windows.
   const StringRef Paths[] = {
-"C:/Program Files/Microsoft Visual Studio 10.0/VC/include",
-"C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
-"C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
-"C:/Program Files/Microsoft Visual Studio 8/VC/include",
-"C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"
-  };
+  "C:/Program Files/Microsoft Visual Studio 10.0/VC/include",
+  "C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
+  "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
+  "C:/Program Files/Microsoft Visual Studio 8/VC/include",
+  "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"};
   addSystemIncludes(DriverArgs, CC1Args, Paths);
 #endif
 }
 
 void MSVCToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
  ArgStringList &CC1Args) const 
{
   // FIXME: There should probably be logic here to find libc++ on Windows.
+  if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
+options::OPT_nostdincxx))
+return;
+  if (getDriver().SysRoot.empty())
+return;
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Stl:
+addStlIncludePaths(DriverArgs, CC1Args);
+break;
+  case ToolChain::CST_Libstdcxx:
+addLibStdCXXIncludePaths(DriverArgs, CC1Args);
+break;
+  case ToolChain::CST_Libcxx:
+addLibCxxIncludePaths(DriverArgs, CC1Args);
+break;
+  default:

zmodem wrote:

Again no need for default if all enumerators are covered (-Wswitch-enum will 
ensure this)

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


[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-07-01 Thread via cfe-commits


@@ -95,18 +95,21 @@ class ToolChain {
 
   enum CXXStdlibType {
 CST_Libcxx,
-CST_Libstdcxx
+CST_Libstdcxx,
+CST_Stl,

zmodem wrote:

Could this be Msvcstl or something? Just Stl seems a pretty generic name.

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


[clang] [flang] [Flang-new][OpenMP] Add offload related flags for AMDGPU (PR #96742)

2024-07-01 Thread Dominik Adamski via cfe-commits

DominikAdamski wrote:

Updated PR after: https://github.com/llvm/llvm-project/pull/96909/ .
Scope of changes:
`-fcuda-is-device` is not attached by OpenMP AMD GPU toolchain any more, so we 
do not need to accept this flag by Flang-new. This flag remains HIP/CUDA 
specific.
- OpenMP AMD GPU toolchain only searches and attaches required bitcode files to 
`flang -fc1` invocation.

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


[clang] [flang] [Flang-new][OpenMP] Add offload related flags for AMDGPU (PR #96742)

2024-07-01 Thread Dominik Adamski via cfe-commits

https://github.com/DominikAdamski edited 
https://github.com/llvm/llvm-project/pull/96742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus updated 
https://github.com/llvm/llvm-project/pull/95411

>From 0ef4b61d0429517b92f7b6de7fa52c516f3a1468 Mon Sep 17 00:00:00 2001
From: David Truby 
Date: Thu, 13 Jun 2024 14:01:36 +
Subject: [PATCH 1/4] [flang] Implement -mcmodel flag

This patch implements the -mcmodel flag from clang, allowing the Code Model to
be changed for the LLVM module. The same set of mcmodel flags are accepted as
in clang and the same Code Model attributes are added to the LLVM module for
those flags.
---
 clang/include/clang/Driver/Options.td |  2 +-
 clang/lib/Driver/ToolChains/Clang.cpp | 76 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp| 81 +++
 clang/lib/Driver/ToolChains/CommonArgs.h  |  4 +
 clang/lib/Driver/ToolChains/Flang.cpp |  5 ++
 .../include/flang/Frontend/CodeGenOptions.def |  1 +
 flang/lib/Frontend/CompilerInvocation.cpp | 21 +
 flang/lib/Frontend/FrontendActions.cpp|  3 +
 flang/test/Driver/mcmodel.f90 | 44 ++
 flang/test/Lower/mcmodel.f90  | 16 
 10 files changed, 177 insertions(+), 76 deletions(-)
 create mode 100644 flang/test/Driver/mcmodel.f90
 create mode 100644 flang/test/Lower/mcmodel.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f7904dd94b94..4087d3b95cc39 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4600,7 +4600,7 @@ def inline_asm_EQ : Joined<["-"], "inline-asm=">, 
Group,
   NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["IAD_ATT", 
"IAD_Intel"]>,
   MarshallingInfoEnum, "IAD_ATT">;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   MarshallingInfoString, [{"default"}]>;
 def mlarge_data_threshold_EQ : Joined<["-"], "mlarge-data-threshold=">, 
Group,
   Flags<[TargetSpecific]>, Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1f8591537b6c8..0447581128cd1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5908,81 +5908,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
 
-  if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
-StringRef CM = A->getValue();
-bool Ok = false;
-if (Triple.isOSAIX() && CM == "medium")
-  CM = "large";
-if (Triple.isAArch64(64)) {
-  Ok = CM == "tiny" || CM == "small" || CM == "large";
-  if (CM == "large" && !Triple.isOSBinFormatMachO() &&
-  RelocationModel != llvm::Reloc::Static)
-D.Diag(diag::err_drv_argument_only_allowed_with)
-<< A->getAsString(Args) << "-fno-pic";
-} else if (Triple.isLoongArch()) {
-  if (CM == "extreme" &&
-  Args.hasFlagNoClaim(options::OPT_fplt, options::OPT_fno_plt, false))
-D.Diag(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "-fplt";
-  Ok = CM == "normal" || CM == "medium" || CM == "extreme";
-  // Convert to LLVM recognizable names.
-  if (Ok)
-CM = llvm::StringSwitch(CM)
- .Case("normal", "small")
- .Case("extreme", "large")
- .Default(CM);
-} else if (Triple.isPPC64() || Triple.isOSAIX()) {
-  Ok = CM == "small" || CM == "medium" || CM == "large";
-} else if (Triple.isRISCV()) {
-  if (CM == "medlow")
-CM = "small";
-  else if (CM == "medany")
-CM = "medium";
-  Ok = CM == "small" || CM == "medium";
-} else if (Triple.getArch() == llvm::Triple::x86_64) {
-  Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"},
-  CM);
-} else if (Triple.isNVPTX() || Triple.isAMDGPU() || Triple.isSPIRV()) {
-  // NVPTX/AMDGPU/SPIRV does not care about the code model and will accept
-  // whatever works for the host.
-  Ok = true;
-} else if (Triple.isSPARC64()) {
-  if (CM == "medlow")
-CM = "small";
-  else if (CM == "medmid")
-CM = "medium";
-  else if (CM == "medany")
-CM = "large";
-  Ok = CM == "small" || CM == "medium" || CM == "large";
-}
-if (Ok) {
-  CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));
-} else {
-  D.Diag(diag::err_drv_unsupported_option_argument_for_target)
-  << A->getSpelling() << CM << TripleStr;
-}
-  }
-
-  if (Triple.getArch() == llvm::Triple::x86_64) {
-bool IsMediumCM = false;
-bool IsLargeCM = false;
-if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
-  IsMediumCM = StringRef(A->getValue()) == "medium";
-  IsLargeCM = StringRef(A->getValue()) == "large";
-}
-if (Arg *A = Args.getLastArg(options::OPT_ml

[clang] [flang] [Flang-new][OpenMP] Add bitcode files for AMD GPU OpenMP (PR #96742)

2024-07-01 Thread Dominik Adamski via cfe-commits

https://github.com/DominikAdamski edited 
https://github.com/llvm/llvm-project/pull/96742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 1d4523505e54415a270d7b13b6e203fc25585c5b 
eaad187a5e1372cc34f79f36ca5d28016a94b221 -- 
clang/lib/Driver/ToolChains/Clang.cpp 
clang/lib/Driver/ToolChains/CommonArgs.cpp 
clang/lib/Driver/ToolChains/CommonArgs.h clang/lib/Driver/ToolChains/Flang.cpp 
flang/include/flang/Frontend/CodeGenOptions.h 
flang/lib/Frontend/CodeGenOptions.cpp flang/lib/Frontend/CompilerInstance.cpp 
flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp
``





View the diff from clang-format here.


``diff
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 2fd2ac3244..eddfa5029d 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -395,15 +395,16 @@ static void 
parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
   << a->getAsString(args) << modelName;
   }
 
-  if (const llvm::opt::Arg *arg = 
args.getLastArg(clang::driver::options::OPT_mlarge_data_threshold_EQ)) {
+  if (const llvm::opt::Arg *arg = args.getLastArg(
+  clang::driver::options::OPT_mlarge_data_threshold_EQ)) {
 uint64_t LDT;
 if (llvm::StringRef(arg->getValue()).getAsInteger(/*Radix=*/10, LDT)) {
   diags.Report(clang::diag::err_drv_invalid_value)
   << arg->getSpelling() << arg->getValue();
-}  
+}
 opts.LargeDataThreshold = LDT;
   }
-  
+
   // This option is compatible with -f[no-]underscoring in gfortran.
   if (args.hasFlag(clang::driver::options::OPT_fno_underscoring,
clang::driver::options::OPT_funderscoring, false)) {

``




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


[clang] [C23] Add INFINITY and NAN macros to (PR #96659)

2024-07-01 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> We already have `-Wnan-infinity-disabled`, which I think is sufficient on the 
> warning side? Haven't checked carefully to see what cases it covers.

Not this one. :-D https://godbolt.org/z/hq8jvse9o But yeah, that may be a good 
diagnostic to consider putting this under, but I think that diagnostic should 
be enabled by default when passing -Wfinite-math-only or other flags that 
disable infinity or nan support.

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


[clang] 9f04d75 - [Clang][Comments] Attach comments to decl even if preproc directives are in between (#88367)

2024-07-01 Thread via cfe-commits

Author: hdoc
Date: 2024-07-01T08:47:26-04:00
New Revision: 9f04d75b2bd8ba83863db74ebe1a5c08cfc5815c

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

LOG: [Clang][Comments] Attach comments to decl even if preproc directives are 
in between (#88367)

### Background

It's surprisingly common for C++ code in the wild to conditionally
show/hide declarations to Doxygen through the use of preprocessor
directives. One especially common version of this pattern is
demonstrated below:

```cpp
/// @brief Test comment
#ifdef DOXYGEN_BUILD_ENABLED
template
#else
template 
typename std::enable_if::value>::type
#endif
void f() {}
```

There are more examples I've collected below to demonstrate usage of
this pattern:
- Example 1:
[Magnum](https://github.com/mosra/magnum/blob/8538610fa27e1db37070eaabe34f1e4e41648bab/src/Magnum/Resource.h#L117-L127)
- Example 2:
[libcds](https://github.com/khizmax/libcds/blob/9985d2a87feaa3e92532e28f4ab762a82855a49c/cds/container/michael_list_nogc.h#L36-L54)
- Example 3:
[rocPRIM](https://github.com/ROCm/rocPRIM/blob/609ae19565ff6a3499168b76a0be5652762e24f6/rocprim/include/rocprim/block/detail/block_reduce_raking_reduce.hpp#L60-L65)
 
>From my research, it seems like the most common rationale for this
functionality is hiding difficult-to-parse code from Doxygen, especially
where template metaprogramming is concerned.

Currently, Clang does not support attaching comments to decls if there
are preprocessor comments between the comment and the decl. This is
enforced here:
https://github.com/llvm/llvm-project/blob/b6ebea7972cd05a8e4dcf0d5a54f2c79395a/clang/lib/AST/ASTContext.cpp#L284-L287

Alongside preprocessor directives, any instance of `;{}#@` between a
comment and decl will cause the comment to not be attached to the decl.

 Rationale

It would be nice for Clang-based documentation tools, such as
[hdoc](https://hdoc.io), to support code using this pattern. Users
expect to see comments attached to the relevant decl — even if there is
an `#ifdef` in the way — which Clang does not currently do.

 History

Originally, commas were also in the list of "banned" characters, but
were removed in `b534d3a0ef69`
([link](https://github.com/llvm/llvm-project/commit/b534d3a0ef6970f5e42f10ba5cfcb562d8b184e1))
because availability macros often have commas in them. From my reading
of the code, it appears that the original intent of the code was to
exclude macros and decorators between comments and decls, possibly in an
attempt to properly attribute comments to macros (discussed further in
"Complications", below). There's some more discussion here:
https://reviews.llvm.org/D125061.

### Change

This modifies Clang comment parsing so that comments are attached to
subsequent declarations even if there are preprocessor directives
between the end of the comment and the start of the decl. Furthermore,
this change:

- Adds tests to verify that comments are attached to their associated
decls even if there are preprocessor directives in between
- Adds tests to verify that current behavior has not changed (i.e. use
of the other characters between comment and decl will result in the
comment not being attached to the decl)
- Updates existing `lit` tests which would otherwise break.

 Complications

Clang [does not yet
support](https://github.com/llvm/llvm-project/issues/38206) attaching
doc comments to macros. Consequently, the change proposed in this RFC
affects cases where a doc comment attached to a macro is followed
immediately by a normal declaration. In these cases, the macro's doc
comments will be attached to the subsequent decl. Previously they would
be ignored because any preprocessor directives between a comment and a
decl would result in the comment not being attached to the decl. An
example of this is shown below.

```cpp
/// Doc comment for a function-like macro
/// @param n
///A macro argument
#define custom_sqrt(n) __internal_sqrt(n)

int __internal_sqrt(int n) { return __builtin_sqrt(n); }

// NB: the doc comment for the custom_sqrt macro will actually be attached to 
__internal_sqrt!
```

There is a real instance of this problem in the Clang codebase, namely
here:
https://github.com/llvm/llvm-project/blob/be10070f91b86a6f126d2451852242bfcb2cd366/clang/lib/Headers/amxcomplexintrin.h#L65-L114

As part of this RFC, I've added a semicolon to break up the Clang
comment parsing so that the `-Wdocumentation` errors go away, but this
is a hack. The real solution is to fix Clang comment parsing so that doc
comments are properly attached to macros, however this would be a large
change that is outside of the scope of this RFC.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ASTContext.cpp
clang/lib/Headers/amxcomplexintrin.h
clang/lib/Headers/ia32intrin.h
clang/test/Index/annotate-comments.cpp
clang/unittests/AS

[clang] [Clang][Comments] Attach comments to decl even if preproc directives are in between (PR #88367)

2024-07-01 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman closed 
https://github.com/llvm/llvm-project/pull/88367
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Comments] Attach comments to decl even if preproc directives are in between (PR #88367)

2024-07-01 Thread via cfe-commits

github-actions[bot] wrote:



@hdoc Congratulations on having your first Pull Request (PR) merged into the 
LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested
by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with 
a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself.
This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[clang] [C23] Add INFINITY and NAN macros to (PR #96659)

2024-07-01 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff de68294b4dd31370773cb7a976b2d59e0e8b9bcc 
1ba1735702376bfb46b96d819ab141f1c841263a -- clang/lib/Headers/float.h 
clang/test/Headers/float.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h
index a0cfeb1286..bbcc61d872 100644
--- a/clang/lib/Headers/float.h
+++ b/clang/lib/Headers/float.h
@@ -47,8 +47,8 @@
 (defined(__cplusplus) && __cplusplus >= 201103L) ||
\
 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #undef DECIMAL_DIG
-#undef INFINITY
-#undef NAN
+#undef INFINITY
+#undef NAN
 #  endif
 #  undef FLT_DIG
 #  undef DBL_DIG
@@ -159,9 +159,9 @@
 
 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) ||  
\
 !defined(__STRICT_ANSI__)
-   /* C23 5.2.5.3.3p29-30 */
-#  define INFINITY (__builtin_inf())
-#  define NAN (__builtin_nan(""))
+/* C23 5.2.5.3.3p29-30 */
+#define INFINITY (__builtin_inf())
+#define NAN (__builtin_nan(""))
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__

``




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


[clang] [Serialization] Clear moved-from deque to ensure valid state post-move (PR #97221)

2024-07-01 Thread via cfe-commits

smanna12 wrote:

Thank you @ChuanqiXu9 for reviews!

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


[clang] 035e76f - [Serialization] Clear moved-from deque to ensure valid state post-move (#97221)

2024-07-01 Thread via cfe-commits

Author: smanna12
Date: 2024-07-01T07:50:57-05:00
New Revision: 035e76ff3706ee3e677fbae67cf47a343cf6eceb

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

LOG: [Serialization] Clear moved-from deque to ensure valid state post-move 
(#97221)

This patch addresses a use-after-move issue, reported by static analyzer
tool, by clearing the `PotentiallyInterestingDecls` deque after it has
been moved to `MaybeInterestingDecls`.

The fix ensures that the subsequent assert statement correctly checks
for an empty state, preventing any undefined behavior in
ASTReader::PassInterestingDeclsToConsumer().

Added: 


Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 6afb18f932e72..cf3737c5a501d 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4215,6 +4215,7 @@ void ASTReader::PassInterestingDeclsToConsumer() {
   };
   std::deque MaybeInterestingDecls =
   std::move(PotentiallyInterestingDecls);
+  PotentiallyInterestingDecls.clear();
   assert(PotentiallyInterestingDecls.empty());
   while (!MaybeInterestingDecls.empty()) {
 Decl *D = MaybeInterestingDecls.front();



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


[clang] [Serialization] Clear moved-from deque to ensure valid state post-move (PR #97221)

2024-07-01 Thread via cfe-commits

https://github.com/smanna12 closed 
https://github.com/llvm/llvm-project/pull/97221
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [LLVM] Fix incorrect alignment on AMDGPU variadics (PR #96370)

2024-07-01 Thread Jon Chesterfield via cfe-commits

JonChesterfield wrote:

This PR is invalid.

First, the alignment on the eight byte pointer is supposed to be four. 
Increasing it to 8 makes things worse.

Second, I can't see any support for the claim that the code is incrementing by 
the alignment of the value, as opposed to the size.

The frame is setup as a struct instance with explicit padding by Int8Tys and 
the calculation there is correct.

The va_arg increment is done in CodeGen:emitVoidPtrVAArg, where DirectSize is 
ValueInfo.Width, aligned to the 4 byte slot size, then stored. It does not 
increment the iterator by the alignment of the type.

The lowering pass is doing exactly what was intended.


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


[clang] a662750 - [Clang] [NFC] Use range-based for loops (#96831)

2024-07-01 Thread via cfe-commits

Author: MagentaTreehouse
Date: 2024-07-01T14:55:23+02:00
New Revision: a66275090e140b9e800d694ce79b7781636dc849

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

LOG: [Clang] [NFC] Use range-based for loops (#96831)

Use range-based for loops. In addition, extracted a loop from
`CXXRecordDecl::completeDefinition` to eliminate the `Done` flag, and
only construct `MyFinalOverriders` when `FinalOverriders` is null.

Added: 


Modified: 
clang/lib/AST/DeclCXX.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 7f2c786547b9b..d5c140fd34389 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1521,11 +1521,11 @@ void CXXRecordDecl::setCaptures(ASTContext &Context,
   auto *ToCapture = (LambdaCapture *)Context.Allocate(sizeof(LambdaCapture) *
   Captures.size());
   Data.AddCaptureList(Context, ToCapture);
-  for (unsigned I = 0, N = Captures.size(); I != N; ++I) {
-if (Captures[I].isExplicit())
+  for (const LambdaCapture &C : Captures) {
+if (C.isExplicit())
   ++Data.NumExplicitCaptures;
 
-new (ToCapture) LambdaCapture(Captures[I]);
+new (ToCapture) LambdaCapture(C);
 ToCapture++;
   }
 
@@ -2056,40 +2056,39 @@ void CXXRecordDecl::completeDefinition() {
   completeDefinition(nullptr);
 }
 
+static bool hasPureVirtualFinalOverrider(
+const CXXRecordDecl &RD, const CXXFinalOverriderMap *FinalOverriders) {
+  if (!FinalOverriders) {
+CXXFinalOverriderMap MyFinalOverriders;
+RD.getFinalOverriders(MyFinalOverriders);
+return hasPureVirtualFinalOverrider(RD, &MyFinalOverriders);
+  }
+
+  for (const CXXFinalOverriderMap::value_type &
+OverridingMethodsEntry : *FinalOverriders) {
+for (const auto &[_, SubobjOverrides] : OverridingMethodsEntry.second) {
+  assert(SubobjOverrides.size() > 0 &&
+"All virtual functions have overriding virtual functions");
+
+  if (SubobjOverrides.front().Method->isPureVirtual())
+return true;
+}
+  }
+  return false;
+}
+
 void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
   RecordDecl::completeDefinition();
 
   // If the class may be abstract (but hasn't been marked as such), check for
   // any pure final overriders.
-  if (mayBeAbstract()) {
-CXXFinalOverriderMap MyFinalOverriders;
-if (!FinalOverriders) {
-  getFinalOverriders(MyFinalOverriders);
-  FinalOverriders = &MyFinalOverriders;
-}
-
-bool Done = false;
-for (CXXFinalOverriderMap::iterator M = FinalOverriders->begin(),
- MEnd = FinalOverriders->end();
- M != MEnd && !Done; ++M) {
-  for (OverridingMethods::iterator SO = M->second.begin(),
-SOEnd = M->second.end();
-   SO != SOEnd && !Done; ++SO) {
-assert(SO->second.size() > 0 &&
-   "All virtual functions have overriding virtual functions");
-
-// C++ [class.abstract]p4:
-//   A class is abstract if it contains or inherits at least one
-//   pure virtual function for which the final overrider is pure
-//   virtual.
-if (SO->second.front().Method->isPureVirtual()) {
-  data().Abstract = true;
-  Done = true;
-  break;
-}
-  }
-}
-  }
+  //
+  // C++ [class.abstract]p4:
+  //   A class is abstract if it contains or inherits at least one
+  //   pure virtual function for which the final overrider is pure
+  //   virtual.
+  if (mayBeAbstract() && hasPureVirtualFinalOverrider(*this, FinalOverriders))
+markAbstract();
 
   // Set access bits correctly on the directly-declared conversions.
   for (conversion_iterator I = conversion_begin(), E = conversion_end();



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


[clang] [clang][NFC] Use range-based for loops (PR #96831)

2024-07-01 Thread via cfe-commits

https://github.com/Sirraide closed 
https://github.com/llvm/llvm-project/pull/96831
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

_I only noticed that this PR was already merged after posting the review. There 
is no need to revert the commit -- it's better than nothing -- but I'd be happy 
if you created a followup change that also handles the testcase that I 
mentioned._

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


[clang] [libc] [llvm] [libc] Implement (v|f)printf on the GPU (PR #96369)

2024-07-01 Thread Jon Chesterfield via cfe-commits


@@ -0,0 +1,77 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -emit-llvm -o - %s | FileCheck 
%s
+
+extern void varargs_simple(int, ...);
+
+// CHECK-LABEL: define dso_local void @foo(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[C:%.*]] = alloca i8, align 1
+// CHECK-NEXT:[[S:%.*]] = alloca i16, align 2
+// CHECK-NEXT:[[I:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[L:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[F:%.*]] = alloca float, align 4
+// CHECK-NEXT:[[D:%.*]] = alloca double, align 8
+// CHECK-NEXT:[[A:%.*]] = alloca [[STRUCT_ANON:%.*]], align 4
+// CHECK-NEXT:[[V:%.*]] = alloca <4 x i32>, align 16
+// CHECK-NEXT:store i8 1, ptr [[C]], align 1
+// CHECK-NEXT:store i16 1, ptr [[S]], align 2
+// CHECK-NEXT:store i32 1, ptr [[I]], align 4
+// CHECK-NEXT:store i64 1, ptr [[L]], align 8
+// CHECK-NEXT:store float 1.00e+00, ptr [[F]], align 4
+// CHECK-NEXT:store double 1.00e+00, ptr [[D]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i8, ptr [[C]], align 1
+// CHECK-NEXT:[[CONV:%.*]] = sext i8 [[TMP0]] to i32

JonChesterfield wrote:

C promotes them to i32. C has a lot of rules around vararg type promotion that 
have not aged brilliantly.

If you want a i8 or i16, put it in a struct. C doesn't say anything about 
promoting that and amdgpu will pass it inlined into the struct, i.e. with no 
overhead. I believe nvptx will do likewise.

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


[clang] [C23] Add INFINITY and NAN macros to (PR #96659)

2024-07-01 Thread Aaron Ballman via cfe-commits


@@ -47,6 +47,8 @@
 (defined(__cplusplus) && __cplusplus >= 201103L) ||
\
 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #undef DECIMAL_DIG
+#undef INFINITY

AaronBallman wrote:

Good catch, I've corrected this.

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


[clang] Improve error message for invalid lambda captures (PR #94865)

2024-07-01 Thread via cfe-commits

https://github.com/Sirraide edited 
https://github.com/llvm/llvm-project/pull/94865
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Improve error message for invalid lambda captures (PR #94865)

2024-07-01 Thread via cfe-commits


@@ -623,6 +623,8 @@ Improvements to Clang's diagnostics
 - Clang no longer emits a "declared here" note for a builtin function that has 
no declaration in source.
   Fixes #GH93369.
 
+- Clang now has an improved error message when trying to capture a class 
member variable for lambda function expressions.

Sirraide wrote:

```suggestion
- Clang now has an improved error message for captures that refer to a class 
member.
  Fixes #GH94764.
```

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


[clang] Improve error message for invalid lambda captures (PR #94865)

2024-07-01 Thread via cfe-commits

https://github.com/Sirraide commented:

Release note could still be a bit less wordy and should also include the issue 
this fixes.

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


[clang] [libc] [llvm] [libc] Implement (v|f)printf on the GPU (PR #96369)

2024-07-01 Thread Jon Chesterfield via cfe-commits


@@ -942,6 +942,36 @@ struct Amdgpu final : public VariadicABIInfo {
   }
 };
 
+struct NVPTX final : public VariadicABIInfo {
+
+  bool enableForTarget() override { return true; }
+
+  bool vaListPassedInSSARegister() override { return true; }
+
+  Type *vaListType(LLVMContext &Ctx) override {
+return PointerType::getUnqual(Ctx);
+  }
+
+  Type *vaListParameterType(Module &M) override {
+return PointerType::getUnqual(M.getContext());
+  }
+
+  Value *initializeVaList(Module &M, LLVMContext &Ctx, IRBuilder<> &Builder,
+  AllocaInst *, Value *Buffer) override {
+return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
+  }
+
+  VAArgSlotInfo slotInfo(const DataLayout &DL, Type *Parameter) override {
+// NVPTX expects natural alignment in all cases. The variadic call ABI will
+// handle promoting types to their appropriate size and alignment.
+const unsigned MinAlign = 1;
+Align A = DL.getABITypeAlign(Parameter);

JonChesterfield wrote:

can getABITypeAlign return 0?

Does nvptx actually expect natural alignment? That would be inconsistent with 
the slot size of four which strongly suggests everything is passed with at 
least four byte alignment

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


[clang] Improve error message for invalid lambda captures (PR #94865)

2024-07-01 Thread via cfe-commits

Sirraide wrote:

(Also, just so you know, don’t worry too much about merge conflicts in the 
release notes; usually, whoever merges the pr can handle those if they’re not 
too complicated)

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


[clang] [flang] [Flang-new][OpenMP] Add bitcode files for AMD GPU OpenMP (PR #96742)

2024-07-01 Thread Dominik Adamski via cfe-commits

https://github.com/DominikAdamski updated 
https://github.com/llvm/llvm-project/pull/96742

>From 5b487aac3c8414b6f37f6888f361ca7488094048 Mon Sep 17 00:00:00 2001
From: Dominik Adamski 
Date: Fri, 21 Jun 2024 18:03:53 +0200
Subject: [PATCH 1/3] [Flang-new][OpenMP] Add offload related flags for AMDGPU

Flang-new needs to add mlink-builtin-bitcode objects
to properly support offload code generation for AMD GPU.

fcuda-is-device flag is not used by Flang currently.
In the future it will be needed for Flang equivalent function:
AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace.
---
 clang/include/clang/Driver/Options.td |  4 +-
 clang/lib/Driver/ToolChains/Flang.cpp |  3 ++
 flang/test/Driver/omp-driver-offload.f90  | 58 +--
 flang/test/Driver/target-cpu-features.f90 |  4 +-
 flang/test/Driver/target-gpu-features.f90 |  2 +-
 5 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index dd55838dcf384..612d5793232ce 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8016,7 +8016,7 @@ def source_date_epoch : Separate<["-"], 
"source-date-epoch">,
 // CUDA Options
 
//===--===//
 
-let Visibility = [CC1Option] in {
+let Visibility = [CC1Option, FC1Option] in {
 
 def fcuda_is_device : Flag<["-"], "fcuda-is-device">,
   HelpText<"Generate code for CUDA device">,
@@ -8031,7 +8031,7 @@ def fno_cuda_host_device_constexpr : Flag<["-"], 
"fno-cuda-host-device-constexpr
   HelpText<"Don't treat unattributed constexpr functions as __host__ 
__device__.">,
   MarshallingInfoNegativeFlag>;
 
-} // let Visibility = [CC1Option]
+} // let Visibility = [CC1Option, FC1Option]
 
 
//===--===//
 // OpenMP Options
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 42b45dba2bd31..2679f284c5016 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -333,6 +333,9 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args,
 StringRef Val = A->getValue();
 CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val));
   }
+
+  const ToolChain &TC = getToolChain();
+  TC.addClangTargetOptions(Args, CmdArgs, Action::OffloadKind::OFK_OpenMP);
 }
 
 void Flang::addTargetOptions(const ArgList &Args,
diff --git a/flang/test/Driver/omp-driver-offload.f90 
b/flang/test/Driver/omp-driver-offload.f90
index 6fb4f4ca1..da81a6ee3ba8f 100644
--- a/flang/test/Driver/omp-driver-offload.f90
+++ b/flang/test/Driver/omp-driver-offload.f90
@@ -14,12 +14,12 @@
 ! Test regular -fopenmp with offload, and invocation filtering options
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 \
-! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: --target=aarch64-unknown-linux-gnu -nogpulib\
 ! RUN:   | FileCheck %s --check-prefix=OFFLOAD-HOST-AND-DEVICE
 
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 
--offload-host-device \
-! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: --target=aarch64-unknown-linux-gnu -nogpulib\
 ! RUN:   | FileCheck %s --check-prefix=OFFLOAD-HOST-AND-DEVICE
 
 ! OFFLOAD-HOST-AND-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
@@ -29,7 +29,7 @@
 
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 --offload-host-only 
\
-! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: --target=aarch64-unknown-linux-gnu -nogpulib\
 ! RUN:   | FileCheck %s --check-prefix=OFFLOAD-HOST
 
 ! OFFLOAD-HOST: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
@@ -39,7 +39,7 @@
 
 ! RUN: %flang -S -### %s 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a --offload-arch=sm_70 
--offload-device-only \
-! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: --target=aarch64-unknown-linux-gnu -nogpulib\
 ! RUN:   | FileCheck %s --check-prefix=OFFLOAD-DEVICE
 
 ! OFFLOAD-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
@@ -48,13 +48,13 @@
 ! OFFLOAD-DEVICE-NOT: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
 
 ! Test regular -fopenmp with offload for basic fopenmp-is-target-device flag 
addition and correct fopenmp 
-! RUN: %flang -### -fopenmp --offload-arch=gfx90a 
-fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck 
--check-prefixes=CHECK-OPENMP-IS-TARGET-DEVICE %s
+! RUN: %flang -### -fopenmp --offload-arch=gfx90a 
-fopenmp-targets=amdgcn-amd-amdhsa -nogpulib %s 2>&1 | FileCheck 
--check-prefixes=CHECK-OPENMP-IS-TARGET-DEVICE %s
 ! CHECK-OPENMP-IS-TARGET-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" 
{{.*}} "-fopenmp-is-target-device" {{.*}}.f90"
 
 ! Testing appropriate flags are gnerated and appropriately assigned by the 
dr

[clang] [libc] [llvm] [libc] Implement (v|f)printf on the GPU (PR #96369)

2024-07-01 Thread Matt Arsenault via cfe-commits


@@ -942,6 +942,36 @@ struct Amdgpu final : public VariadicABIInfo {
   }
 };
 
+struct NVPTX final : public VariadicABIInfo {
+
+  bool enableForTarget() override { return true; }
+
+  bool vaListPassedInSSARegister() override { return true; }
+
+  Type *vaListType(LLVMContext &Ctx) override {
+return PointerType::getUnqual(Ctx);
+  }
+
+  Type *vaListParameterType(Module &M) override {
+return PointerType::getUnqual(M.getContext());
+  }
+
+  Value *initializeVaList(Module &M, LLVMContext &Ctx, IRBuilder<> &Builder,
+  AllocaInst *, Value *Buffer) override {
+return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
+  }
+
+  VAArgSlotInfo slotInfo(const DataLayout &DL, Type *Parameter) override {
+// NVPTX expects natural alignment in all cases. The variadic call ABI will
+// handle promoting types to their appropriate size and alignment.
+const unsigned MinAlign = 1;
+Align A = DL.getABITypeAlign(Parameter);

arsenm wrote:

This should use Align instead of unsigned for alignment values 

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


[clang] [libc] [llvm] [libc] Implement (v|f)printf on the GPU (PR #96369)

2024-07-01 Thread Jon Chesterfield via cfe-commits

https://github.com/JonChesterfield requested changes to this pull request.

The amdgpu patch is incorrect, see 
https://github.com/llvm/llvm-project/pull/96370/

The nvptx lowering looks dubious - values smaller than slot size should be 
passed with the same alignment as the slot and presently aren't. A struct 
containing i8, i16 or half should be miscompiled on nvptx as written.

No comment on the libc part.

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


[clang] [libc] [llvm] [libc] Implement (v|f)printf on the GPU (PR #96369)

2024-07-01 Thread Joseph Huber via cfe-commits


@@ -942,6 +942,36 @@ struct Amdgpu final : public VariadicABIInfo {
   }
 };
 
+struct NVPTX final : public VariadicABIInfo {
+
+  bool enableForTarget() override { return true; }
+
+  bool vaListPassedInSSARegister() override { return true; }
+
+  Type *vaListType(LLVMContext &Ctx) override {
+return PointerType::getUnqual(Ctx);
+  }
+
+  Type *vaListParameterType(Module &M) override {
+return PointerType::getUnqual(M.getContext());
+  }
+
+  Value *initializeVaList(Module &M, LLVMContext &Ctx, IRBuilder<> &Builder,
+  AllocaInst *, Value *Buffer) override {
+return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
+  }
+
+  VAArgSlotInfo slotInfo(const DataLayout &DL, Type *Parameter) override {
+// NVPTX expects natural alignment in all cases. The variadic call ABI will
+// handle promoting types to their appropriate size and alignment.
+const unsigned MinAlign = 1;
+Align A = DL.getABITypeAlign(Parameter);

jhuber6 wrote:

I don't think so, NVPTX uses structs with normal padding, see 
https://godbolt.org/z/1v54YY6d3.

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


[clang] [llvm] [LLVM] Fix incorrect alignment on AMDGPU variadics (PR #96370)

2024-07-01 Thread Jon Chesterfield via cfe-commits

https://github.com/JonChesterfield requested changes to this pull request.

Patch should not land. Need to know what bug this was trying to address to 
guess at what the right fix would be.

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


[clang] [libc] [llvm] [libc] Implement (v|f)printf on the GPU (PR #96369)

2024-07-01 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> The nvptx lowering looks dubious - values smaller than slot size should be 
> passed with the same alignment as the slot and presently aren't. A struct 
> containing i8, i16 or half should be miscompiled on nvptx as written.

I mentioned this in the original patch, it's correct as far as I know. NVPTX 
does not require nested structs to have slot alignment, which means that the 
minimum alignment is exactly the type. The C ABI helps us here by making 
arguments passed directly all get type promoted to `i32`. You could 
theoretically break this if you didn't go through the C ABI and ignored type 
promotion, but I'm not concerned with that kind of misuse since it's against 
the ABI in the first place.

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


[clang] [Clang][ExprConstant] fix constant expression did not evaluate to integer (PR #97146)

2024-07-01 Thread via cfe-commits

Sirraide wrote:

> I'm concerned that we're calling EvaluateKnownConstInt on an lvalue; that 
> might indicate there's something wrong with the AST. Usually there should be 
> an lvalue-to-rvalue cast somewhere.

Yeah, I also remember finding that strange, but after looking into it I figured 
it made sense, but I don’t remmeber why exactly...

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


[clang] [Clang][ExprConstant] fix constant expression did not evaluate to integer (PR #97146)

2024-07-01 Thread via cfe-commits

Sirraide wrote:

Actually, where are we calling `EvaluateKnownConstInt` here; am I missing 
something obvious?

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


[clang] [libc] [llvm] [libc] Implement (v|f)printf on the GPU (PR #96369)

2024-07-01 Thread Matt Arsenault via cfe-commits

arsenm wrote:

> You could theoretically break this if you didn't go through the C ABI and 
> ignored type promotion, but I'm not concerned with that kind of misuse since 
> it's against the ABI in the first place.

The IR has its own ABI that may or may not match whatever the platform "C ABI' 
is. Especially given the lack of a formal platform ABI specification, I would 
not characterize not using the C ABI as misuse or against the ABI 


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


[clang] [llvm] [LLVM] Fix incorrect alignment on AMDGPU variadics (PR #96370)

2024-07-01 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> Patch should not land. Need to know what bug this was trying to address to 
> guess at what the right fix would be.

My understanding was that the variadics did lowering to a struct with a minimum 
alignment of four. This currently *doesn't* do that, hence my confusion. The 
current lowering provides no padding, which I now see is a deliberate choice to 
save on stack presumably. The issue I had was that I laid out my `printf` code 
with the assumption that the buffer was a struct, so now it won't work when 
copied to another target via RPC because it's not the correct alignment.

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


  1   2   3   4   5   >