[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -1219,6 +1219,9 @@ static int getInstructionID(struct InternalInstruction 
*insn,
 attrMask |= ATTR_EVEXKZ;
   if (bFromEVEX4of4(insn->vectorExtensionPrefix[3]))
 attrMask |= ATTR_EVEXB;
+  if (x2FromEVEX3of4(insn->vectorExtensionPrefix[2]) &&
+  (insn->opcodeType != MAP4))

phoebewang wrote:

Thanks for the reminder. It's fully matched with AVX10.2 SPEC now.

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-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 03e1eb29e7169ddb0804b1d0b9d71d6d2aaf531d 
114a5721e593a9b57ef31ed9856d0bce4a62da94 --extensions cpp -- 
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 9a540a5061..80acdc3366 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,7 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-  
+
   for (auto  : USRToBitcode) {
 std::vector  = Entry.second;
 std::sort(Bitcode.begin(), Bitcode.end(),

``




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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/2] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/2] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto  : USRToBitcode) {
+std::vector  = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef , const llvm::StringRef ) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

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


[clang] [llvm] [LV] Support generating masks for switch terminators. (PR #99808)

2024-08-01 Thread via cfe-commits


@@ -6,9 +6,43 @@ define void @switch_default_to_latch_common_dest(ptr %start, 
ptr %end) {
 ; IC1-LABEL: define void @switch_default_to_latch_common_dest(
 ; IC1-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0:[0-9]+]] {
 ; IC1-NEXT:  [[ENTRY:.*]]:
+; IC1-NEXT:[[START2:%.*]] = ptrtoint ptr [[START]] to i64
+; IC1-NEXT:[[END1:%.*]] = ptrtoint ptr [[END]] to i64
+; IC1-NEXT:[[TMP0:%.*]] = add i64 [[END1]], -8
+; IC1-NEXT:[[TMP1:%.*]] = sub i64 [[TMP0]], [[START2]]
+; IC1-NEXT:[[TMP2:%.*]] = lshr i64 [[TMP1]], 3
+; IC1-NEXT:[[TMP3:%.*]] = add nuw nsw i64 [[TMP2]], 1
+; IC1-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP3]], 4
+; IC1-NEXT:br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label 
%[[VECTOR_PH:.*]]
+; IC1:   [[VECTOR_PH]]:
+; IC1-NEXT:[[N_MOD_VF:%.*]] = urem i64 [[TMP3]], 4
+; IC1-NEXT:[[N_VEC:%.*]] = sub i64 [[TMP3]], [[N_MOD_VF]]
+; IC1-NEXT:[[TMP4:%.*]] = mul i64 [[N_VEC]], 8
+; IC1-NEXT:[[IND_END:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP4]]
+; IC1-NEXT:br label %[[VECTOR_BODY:.*]]
+; IC1:   [[VECTOR_BODY]]:
+; IC1-NEXT:[[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
+; IC1-NEXT:[[OFFSET_IDX:%.*]] = mul i64 [[INDEX]], 8
+; IC1-NEXT:[[TMP5:%.*]] = add i64 [[OFFSET_IDX]], 0
+; IC1-NEXT:[[NEXT_GEP:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP5]]
+; IC1-NEXT:[[TMP6:%.*]] = getelementptr i64, ptr [[NEXT_GEP]], i32 0
+; IC1-NEXT:[[WIDE_LOAD:%.*]] = load <4 x i64>, ptr [[TMP6]], align 1
+; IC1-NEXT:[[TMP7:%.*]] = icmp eq <4 x i64> [[WIDE_LOAD]], 
+; IC1-NEXT:[[TMP8:%.*]] = icmp eq <4 x i64> [[WIDE_LOAD]], 
+; IC1-NEXT:[[TMP9:%.*]] = or <4 x i1> [[TMP7]], [[TMP8]]
+; IC1-NEXT:[[TMP10:%.*]] = or <4 x i1> [[TMP9]], [[TMP9]]

ayalz wrote:

Good catch!

This stems from having parallel {pred, succ} edges in the CFG for multiple 
switch cases that share a common succ destination, coupled with caching a 
single edge mask per {pred, succ} pair of VPBB's.

The in mask of a VPBB is created by ORing the edge masks from its predecessors 
- suffice to visit each predecessor once.

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


[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

2024-08-01 Thread Max Winkler via cfe-commits

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


[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

2024-08-01 Thread Max Winkler via cfe-commits

https://github.com/MaxEW707 updated 
https://github.com/llvm/llvm-project/pull/99833

>From c66fee7969fc4bd8b5ce79085f0fc09cbc4147da Mon Sep 17 00:00:00 2001
From: MaxEW707 
Date: Fri, 21 Jun 2024 20:37:40 -0700
Subject: [PATCH 01/12] Support MSVC lvalue to temporary reference binding

---
 clang/docs/ReleaseNotes.rst |   4 +
 clang/include/clang/Basic/LangOptions.def   |   1 +
 clang/include/clang/Driver/Options.td   |  12 +++
 clang/include/clang/Sema/Sema.h |   2 +
 clang/lib/Driver/ToolChains/Clang.cpp   |   5 +
 clang/lib/Driver/ToolChains/MSVC.cpp|   1 +
 clang/lib/Sema/SemaInit.cpp |  22 +++--
 clang/lib/Sema/SemaOverload.cpp |  16 ++-
 clang/test/Driver/cl-permissive.c   |   7 ++
 clang/test/Driver/cl-zc.cpp |   2 +
 clang/test/SemaCXX/ms-reference-binding.cpp | 102 
 11 files changed, 165 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/SemaCXX/ms-reference-binding.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..becf12fa62ec0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -104,6 +104,10 @@ C23 Feature Support
 New Compiler Flags
 --
 
+- ``-fms-reference-binding`` and its clang-cl counterpart 
``/Zc:referenceBinding``.
+  Implements the MSVC extension where expressions that bind a user-defined 
type temporary
+  to a non-const lvalue reference are allowed.
+
 Deprecated Compiler Flags
 -
 
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 0035092ce0d86..ff350410d598a 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -307,6 +307,7 @@ LANGOPT(HIPStdParInterposeAlloc, 1, 0, "Replace allocations 
/ deallocations with
 LANGOPT(OpenACC   , 1, 0, "OpenACC Enabled")
 
 LANGOPT(MSVCEnableStdcMacro , 1, 0, "Define __STDC__ with 
'-fms-compatibility'")
+LANGOPT(MSVCReferenceBinding , 1, 0, "Accept expressions that bind a non-const 
lvalue reference to a temporary")
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28..53a356d120e3a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3034,6 +3034,12 @@ def fms_extensions : Flag<["-"], "fms-extensions">, 
Group,
   Visibility<[ClangOption, CC1Option, CLOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft 
compiler">,
   MarshallingInfoFlag>, 
ImpliedByAnyOf<[fms_compatibility.KeyPath]>;
+def fms_reference_binding : Flag<["-"], "fms-reference-binding">, 
Group,
+  Visibility<[ClangOption, CC1Option, CLOption]>,
+  HelpText<"Accept expressions that bind a non-const lvalue reference to a 
user-defined type temporary as supported by the Microsoft Compiler">,
+  MarshallingInfoFlag>;
+def fno_ms_reference_binding : Flag<["-"], "fno-ms-reference-binding">, 
Group,
+  Visibility<[ClangOption, CLOption]>;
 defm asm_blocks : BoolFOption<"asm-blocks",
   LangOpts<"AsmBlocks">, Default,
   PosFlag,
@@ -8492,6 +8498,12 @@ def _SLASH_Zc_wchar_t : CLFlag<"Zc:wchar_t">,
   HelpText<"Enable C++ builtin type wchar_t (default)">;
 def _SLASH_Zc_wchar_t_ : CLFlag<"Zc:wchar_t-">,
   HelpText<"Disable C++ builtin type wchar_t">;
+def _SLASH_Zc_referenceBinding : CLFlag<"Zc:referenceBinding">,
+  HelpText<"Do not accept expressions that bind a non-const lvalue reference 
to a user-defined type temporary">,
+  Alias;
+def _SLASH_Zc_referenceBinding_ : CLFlag<"Zc:referenceBinding-">,
+  HelpText<"Accept expressions that bind a non-const lvalue reference to a 
user-defined type temporary">,
+  Alias;
 def _SLASH_Z7 : CLFlag<"Z7">, Alias,
   HelpText<"Enable CodeView debug information in object files">;
 def _SLASH_ZH_MD5 : CLFlag<"ZH:MD5">,
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2ec6367eccea0..6bd575d105675 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10161,6 +10161,8 @@ class Sema final : public SemaBase {
   CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2,
ReferenceConversions *Conv = nullptr);
 
+  bool AllowMSLValueReferenceBinding(Qualifiers Quals, QualType QT);
+
   /// AddOverloadCandidate - Adds the given function to the set of
   /// candidate functions, using the given function call arguments.  If
   /// @p SuppressUserConversions, then don't allow user-defined
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 843d68c85bc59..13867181b21c0 100644
--- 

[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -1219,6 +1219,9 @@ static int getInstructionID(struct InternalInstruction 
*insn,
 attrMask |= ATTR_EVEXKZ;
   if (bFromEVEX4of4(insn->vectorExtensionPrefix[3]))
 attrMask |= ATTR_EVEXB;
+  if (x2FromEVEX3of4(insn->vectorExtensionPrefix[2]) &&

phoebewang wrote:

Done.

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


[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)

2024-08-01 Thread via cfe-commits

yingopq wrote:

> I have a try of your patch
> 
> ```
> $ ./bin/clang --target=mips-linux-gnu -mfp64 -Wa,-mmsa nn.c
> error: unknown argument: '-mmsa'
> ```
> 
> Oh, `-no-integrated-as` works with your patch.
> 
> ```
>  mipsel-linux-gnu-gcc-14 -mfp64 -Wa,-mmsa nn.c
> ```
> 
> has no such problem.

I added Visibility option 'CC1Option' and tested OK.

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


[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)

2024-08-01 Thread via cfe-commits

https://github.com/yingopq updated 
https://github.com/llvm/llvm-project/pull/99615

>From 881ada57bfeb0d0433aa84bb93689f7c06338a19 Mon Sep 17 00:00:00 2001
From: Ying Huang 
Date: Fri, 19 Jul 2024 04:19:09 -0400
Subject: [PATCH] [clang] Support -Wa, options -mmsa and -mno-msa

---
 clang/include/clang/Basic/CodeGenOptions.def | 1 +
 clang/include/clang/Driver/Options.td| 4 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 7 +++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index f671b780bcbeb..4a834ea78eeb4 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -178,6 +178,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical 
constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
+CODEGENOPT(Msa   , 1, 0) ///< Set when -Wa,-mmsa is enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
 CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 12b20fe04675b..b66ef557ac3e9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5337,7 +5337,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, 
Group,
 def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
   HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group,
-  HelpText<"Enable MSA ASE (MIPS only)">;
+  Visibility<[ClangOption, CC1Option, CC1AsOption]>,
+  HelpText<"Enable MSA ASE (MIPS only)">,
+  MarshallingInfoFlag>;
 def mno_msa : Flag<["-"], "mno-msa">, Group,
   HelpText<"Disable MSA ASE (MIPS only)">;
 def mmt : Flag<["-"], "mmt">, Group,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1fd6fba210042..560f3bd4a67ae 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2507,6 +2507,7 @@ static void CollectArgsForIntegratedAssembler(Compilation 
,
   bool Crel = false, ExperimentalCrel = false;
   bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
   bool UseNoExecStack = false;
+  bool Msa = false;
   const char *MipsTargetFeature = nullptr;
   StringRef ImplicitIt;
   for (const Arg *A :
@@ -2630,6 +2631,10 @@ static void 
CollectArgsForIntegratedAssembler(Compilation ,
 CmdArgs.push_back("-massembler-no-warn");
   } else if (Value == "--noexecstack") {
 UseNoExecStack = true;
+  } else if (Value == "-mmsa") {
+Msa = true;
+  } else if (Value == "-mno-msa") {
+Msa = false;
   } else if (Value.starts_with("-compress-debug-sections") ||
  Value.starts_with("--compress-debug-sections") ||
  Value == "-nocompress-debug-sections" ||
@@ -2716,6 +2721,8 @@ static void CollectArgsForIntegratedAssembler(Compilation 
,
   << "-Wa,--crel" << D.getTargetTriple();
 }
   }
+  if (Msa)
+CmdArgs.push_back("-mmsa");
   if (!UseRelaxRelocations)
 CmdArgs.push_back("-mrelax-relocations=no");
   if (UseNoExecStack)

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -1219,6 +1219,9 @@ static int getInstructionID(struct InternalInstruction 
*insn,
 attrMask |= ATTR_EVEXKZ;
   if (bFromEVEX4of4(insn->vectorExtensionPrefix[3]))
 attrMask |= ATTR_EVEXB;
+  if (x2FromEVEX3of4(insn->vectorExtensionPrefix[2]) &&

KanRobert wrote:

Rename this to `uFromEVEX3of4`?

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -575,6 +575,31 @@ static inline bool inheritsFrom(InstructionContext child,
   case IC_EVEX_W_NF:
   case IC_EVEX_W_B_NF:
 return false;
+  case IC_EVEX_B_U:
+  case IC_EVEX_XS_B_U:
+  case IC_EVEX_XD_B_U:
+  case IC_EVEX_OPSIZE_B_U:
+  case IC_EVEX_W_B_U:
+  case IC_EVEX_W_XS_B_U:
+  case IC_EVEX_W_XD_B_U:
+  case IC_EVEX_W_OPSIZE_B_U:
+  case IC_EVEX_K_B_U:
+  case IC_EVEX_XS_K_B_U:
+  case IC_EVEX_XD_K_B_U:
+  case IC_EVEX_OPSIZE_K_B_U:
+  case IC_EVEX_W_K_B_U:
+  case IC_EVEX_W_XS_K_B_U:
+  case IC_EVEX_W_XD_K_B_U:
+  case IC_EVEX_W_OPSIZE_K_B_U:
+  case IC_EVEX_KZ_B_U:
+  case IC_EVEX_XS_KZ_B_U:
+  case IC_EVEX_XD_KZ_B_U:
+  case IC_EVEX_OPSIZE_KZ_B_U:
+  case IC_EVEX_W_KZ_B_U:
+  case IC_EVEX_W_XS_KZ_B_U:
+  case IC_EVEX_W_XD_KZ_B_U:
+  case IC_EVEX_W_OPSIZE_KZ_B_U:

KanRobert wrote:

Got it, thanks.

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


[clang] [C++20] [Modules] Always emit the inline builtins (PR #101278)

2024-08-01 Thread Chuanqi Xu via cfe-commits

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


[clang] e167f75 - [C++20] [Modules] Always emit the inline builtins (#101278)

2024-08-01 Thread via cfe-commits

Author: Chuanqi Xu
Date: 2024-08-01T14:45:21+08:00
New Revision: e167f753bd4679329ebcf0232f72be9c63d9b671

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

LOG: [C++20] [Modules] Always emit the inline builtins (#101278)

See the attached test for the motivation example. If we're too greedy to
not emit the definition for inline builtins, we may meet a middle end
crash. And it should be good to emit inline builtins always.

Added: 
clang/test/Modules/inline-builtins.cppm

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 760185d4d51ff..31f6632df9f27 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4022,6 +4022,11 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
 return true;
 
   const auto *F = cast(GD.getDecl());
+  // Inline builtins declaration must be emitted. They often are fortified
+  // functions.
+  if (F->isInlineBuiltinDeclaration())
+return true;
+
   if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr())
 return false;
 
@@ -4067,11 +4072,6 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
 }
   }
 
-  // Inline builtins declaration must be emitted. They often are fortified
-  // functions.
-  if (F->isInlineBuiltinDeclaration())
-return true;
-
   // PR9614. Avoid cases where the source code is lying to us. An available
   // externally function should have an equivalent function somewhere else,
   // but a function that calls itself through asm label/`__builtin_` trickery 
is

diff  --git a/clang/test/Modules/inline-builtins.cppm 
b/clang/test/Modules/inline-builtins.cppm
new file mode 100644
index 0..8a0fffbfc25bc
--- /dev/null
+++ b/clang/test/Modules/inline-builtins.cppm
@@ -0,0 +1,36 @@
+// REQUIRES: !system-windows
+//
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 -O3 %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 -O3 %t/test.cc -fmodule-file=a=%t/a.pcm \
+// RUN:   -emit-llvm -o - | FileCheck %t/test.cc
+
+//--- memmove.h
+typedef long unsigned int size_t;
+extern "C" void *memmove (void *__dest, const void *__src, size_t __n)
+ throw () __attribute__ ((__nonnull__ (1, 2)));
+extern "C" __inline __attribute__ ((__always_inline__)) __attribute__ 
((__gnu_inline__)) void *
+ memmove (void *__dest, const void *__src, size_t __len) throw ()
+{
+  return __builtin_memmove(__dest, __src, __len);
+}
+
+//--- a.cppm
+module;
+#include "memmove.h"
+export module a;
+export using ::memmove;
+
+//--- test.cc
+import a;
+
+void test() {
+  int a, b;
+  unsigned c = 0;
+  memmove(, , c);
+}
+
+// CHECK-NOT: memmove



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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -1219,6 +1219,9 @@ static int getInstructionID(struct InternalInstruction 
*insn,
 attrMask |= ATTR_EVEXKZ;
   if (bFromEVEX4of4(insn->vectorExtensionPrefix[3]))
 attrMask |= ATTR_EVEXB;
+  if (x2FromEVEX3of4(insn->vectorExtensionPrefix[2]) &&
+  (insn->opcodeType != MAP4))

KanRobert wrote:

I think you also need to check more things for this, e.g. `EVEX.b`. Since the 
APX SPEC says

> When any of the bits in EVEX.{R4,X4,B4} is not used by a promoted VEX 
> instruction, it is ignored, 

@FreddyLeaf is working on adding tests for the ignore semantic while it's not 
ready yet.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -111,9 +111,9 @@ class X86OpcodePrefixHelper {
   //  0b11: F2
 
   // EVEX (4 bytes)
-  // +-+ +---+ ++ 
++
-  // | 62h | | RXBR' | B'mmm | | W |  | X' | pp | | z | L'L | b | v' | aaa 
|
-  // +-+ +---+ ++ 
++
+  // +-+ +---+ +---+ ++
+  // | 62h | | RXBR' | B'mmm | | W |  | U | pp | | z | L'L | b | v' | aaa |

KanRobert wrote:

> Besides, I assume the SDM will only use `U` for this bit.

Fine. I believe you will add X' back if it's added into SDM?

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -111,9 +111,9 @@ class X86OpcodePrefixHelper {
   //  0b11: F2
 
   // EVEX (4 bytes)
-  // +-+ +---+ ++ 
++
-  // | 62h | | RXBR' | B'mmm | | W |  | X' | pp | | z | L'L | b | v' | aaa 
|
-  // +-+ +---+ ++ 
++
+  // +-+ +---+ +---+ ++
+  // | 62h | | RXBR' | B'mmm | | W |  | U | pp | | z | L'L | b | v' | aaa |

KanRobert wrote:

Out of 80 columns is not an issue. We can use sth like
```
// clang-format off
// clang-format on
```
for the comment.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -575,6 +575,31 @@ static inline bool inheritsFrom(InstructionContext child,
   case IC_EVEX_W_NF:
   case IC_EVEX_W_B_NF:
 return false;
+  case IC_EVEX_B_U:
+  case IC_EVEX_XS_B_U:
+  case IC_EVEX_XD_B_U:
+  case IC_EVEX_OPSIZE_B_U:
+  case IC_EVEX_W_B_U:
+  case IC_EVEX_W_XS_B_U:
+  case IC_EVEX_W_XD_B_U:
+  case IC_EVEX_W_OPSIZE_B_U:
+  case IC_EVEX_K_B_U:
+  case IC_EVEX_XS_K_B_U:
+  case IC_EVEX_XD_K_B_U:
+  case IC_EVEX_OPSIZE_K_B_U:
+  case IC_EVEX_W_K_B_U:
+  case IC_EVEX_W_XS_K_B_U:
+  case IC_EVEX_W_XD_K_B_U:
+  case IC_EVEX_W_OPSIZE_K_B_U:
+  case IC_EVEX_KZ_B_U:
+  case IC_EVEX_XS_KZ_B_U:
+  case IC_EVEX_XD_KZ_B_U:
+  case IC_EVEX_OPSIZE_KZ_B_U:
+  case IC_EVEX_W_KZ_B_U:
+  case IC_EVEX_W_XS_KZ_B_U:
+  case IC_EVEX_W_XD_KZ_B_U:
+  case IC_EVEX_W_OPSIZE_KZ_B_U:

phoebewang wrote:

All YMM rounding instructions use either W0 or W1. And they don't inherit other 
classes, because the `U` bit is for YMM rounding only.

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


[clang] [Driver] Include crt0.o in the baremetal link (PR #101258)

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


@@ -105,6 +109,10 @@
 // CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-USR-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a"
 
+// RUN: %clangxx --target=arm-none-eabi -nostartfiles -v 2>&1 \

petrhosek wrote:

Done.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -926,7 +951,9 @@ void DisassemblerTables::emitContextTable(raw_ostream , 
unsigned ) const {
   else
 o << "IC_VEX";
 
-  if ((index & ATTR_EVEX) && (index & ATTR_EVEXL2))
+  if ((index & ATTR_EVEXB) && (index & ATTR_EVEXU))
+; // Ignore ATTR_VEXL and ATTR_EVEXL2 under YMM rounding.

phoebewang wrote:

`L` and `L2` are repurposed as rouding bits, they have been test with {sae-*} 
tests.

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


[clang] [Driver] Include crt0.o in the baremetal link (PR #101258)

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

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/101258

>From 245a552033793bab479c9be805aacf33cfe64493 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Tue, 30 Jul 2024 15:17:13 -0700
Subject: [PATCH 1/2] [Driver] Include crt0.o in the baremetal link

The common baremetal libc implementations already provide crt0.o and
GCC automatically links it so this improves parity.
---
 clang/lib/Driver/ToolChains/BareMetal.cpp | 5 +
 clang/test/Driver/Inputs/baremetal_arm/lib/crt0.o | 0
 .../lib/armv6m-unknown-none-eabi/crt0.o   | 0
 clang/test/Driver/baremetal.cpp   | 8 
 4 files changed, 13 insertions(+)
 create mode 100644 clang/test/Driver/Inputs/baremetal_arm/lib/crt0.o
 create mode 100644 
clang/test/Driver/Inputs/basic_baremetal_tree/lib/armv6m-unknown-none-eabi/crt0.o

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 852e0442f50a2..102d12700229e 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -487,6 +487,11 @@ void baremetal::Linker::ConstructJob(Compilation , const 
JobAction ,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  }
+
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_s, options::OPT_t, options::OPT_r});
 
diff --git a/clang/test/Driver/Inputs/baremetal_arm/lib/crt0.o 
b/clang/test/Driver/Inputs/baremetal_arm/lib/crt0.o
new file mode 100644
index 0..e69de29bb2d1d
diff --git 
a/clang/test/Driver/Inputs/basic_baremetal_tree/lib/armv6m-unknown-none-eabi/crt0.o
 
b/clang/test/Driver/Inputs/basic_baremetal_tree/lib/armv6m-unknown-none-eabi/crt0.o
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index de4e93434e203..9814bf7b0a395 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -16,6 +16,7 @@
 // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
+// CHECK-V6M-C-SAME: "[[SYSROOT:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}crt0.o"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a" 
"--target2=rel" "-o" "{{.*}}.tmp.out"
@@ -37,6 +38,7 @@
 // CHECK-V6M-TREE-SAME: "-internal-isystem" 
"[[INSTALLED_DIR]]{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}armv6m-unknown-none-eabi"
 // CHECK-V6M-TREE-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-TREE-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
+// CHECK-V6M-TREE-SAME: 
"[[INSTALLED_DIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}armv6m-unknown-none-eabi{{[/\\]+}}crt0.o"
 // CHECK-V6M-TREE-SAME: 
"-L[[INSTALLED_DIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}armv6m-unknown-none-eabi"
 // CHECK-V6M-TREE-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a" 
"--target2=rel" "-o" "{{.*}}.tmp.out"
 
@@ -48,6 +50,7 @@
 // CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-ARMV7M-PER-TARGET: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
+// CHECK-ARMV7M-PER_TARGET: "[[SYSROOT:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}crt0.o"
 // CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-ARMV7M-PER-TARGET: 
"-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
 // CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a"
@@ -56,6 +59,7 @@
 // RUN: --sysroot=%S/Inputs/baremetal_arm | FileCheck 
--check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-DEFAULTCXX: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
+// CHECK-V6M-DEFAULTCXX-SAME: "[[SYSROOT:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}crt0.o"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a" 
"--target2=rel" "-o" "a.out"
@@ -105,6 +109,10 @@
 // CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-USR-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a"
 
+// RUN: %clangxx --target=arm-none-eabi -nostartfiles -v 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOSTARTFILES
+// CHECK-NOSTARTFILES-NOT: "crt0.o"
+
 // RUN: %clangxx --target=arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
 // 

[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -131,7 +131,7 @@ class X86OpcodePrefixHelper {
   // | RM (VR)  | EVEX_X  | EVEX_B | modrm.r/m | VR  | Dest or Src  |
   // | RM (GPR) | EVEX_B' | EVEX_B | modrm.r/m | GPR | Dest or Src  |
   // | BASE | EVEX_B' | EVEX_B | modrm.r/m | GPR | MA   |
-  // | INDEX| EVEX_X' | EVEX_X | sib.index | GPR | MA   |
+  // | INDEX| EVEX_U  | EVEX_X | sib.index | GPR | MA   |

phoebewang wrote:

We need to change it if we only list U in the table.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -575,6 +575,31 @@ static inline bool inheritsFrom(InstructionContext child,
   case IC_EVEX_W_NF:
   case IC_EVEX_W_B_NF:
 return false;
+  case IC_EVEX_B_U:
+  case IC_EVEX_XS_B_U:
+  case IC_EVEX_XD_B_U:
+  case IC_EVEX_OPSIZE_B_U:
+  case IC_EVEX_W_B_U:
+  case IC_EVEX_W_XS_B_U:
+  case IC_EVEX_W_XD_B_U:
+  case IC_EVEX_W_OPSIZE_B_U:
+  case IC_EVEX_K_B_U:
+  case IC_EVEX_XS_K_B_U:
+  case IC_EVEX_XD_K_B_U:
+  case IC_EVEX_OPSIZE_K_B_U:
+  case IC_EVEX_W_K_B_U:
+  case IC_EVEX_W_XS_K_B_U:
+  case IC_EVEX_W_XD_K_B_U:
+  case IC_EVEX_W_OPSIZE_K_B_U:
+  case IC_EVEX_KZ_B_U:
+  case IC_EVEX_XS_KZ_B_U:
+  case IC_EVEX_XD_KZ_B_U:
+  case IC_EVEX_OPSIZE_KZ_B_U:
+  case IC_EVEX_W_KZ_B_U:
+  case IC_EVEX_W_XS_KZ_B_U:
+  case IC_EVEX_W_XD_KZ_B_U:
+  case IC_EVEX_W_OPSIZE_KZ_B_U:

KanRobert wrote:

Probably we need sth like `WIG && inheritsFrom` for the new added context.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -111,9 +111,9 @@ class X86OpcodePrefixHelper {
   //  0b11: F2
 
   // EVEX (4 bytes)
-  // +-+ +---+ ++ 
++
-  // | 62h | | RXBR' | B'mmm | | W |  | X' | pp | | z | L'L | b | v' | aaa 
|
-  // +-+ +---+ ++ 
++
+  // +-+ +---+ +---+ ++
+  // | 62h | | RXBR' | B'mmm | | W |  | U | pp | | z | L'L | b | v' | aaa |

phoebewang wrote:

Besides, I assume the SDM will only use `U` for this bit.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -111,9 +111,9 @@ class X86OpcodePrefixHelper {
   //  0b11: F2
 
   // EVEX (4 bytes)
-  // +-+ +---+ ++ 
++
-  // | 62h | | RXBR' | B'mmm | | W |  | X' | pp | | z | L'L | b | v' | aaa 
|
-  // +-+ +---+ ++ 
++
+  // +-+ +---+ +---+ ++
+  // | 62h | | RXBR' | B'mmm | | W |  | U | pp | | z | L'L | b | v' | aaa |

phoebewang wrote:

That will result in out of 80 columns.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -926,7 +951,9 @@ void DisassemblerTables::emitContextTable(raw_ostream , 
unsigned ) const {
   else
 o << "IC_VEX";
 
-  if ((index & ATTR_EVEX) && (index & ATTR_EVEXL2))
+  if ((index & ATTR_EVEXB) && (index & ATTR_EVEXU))
+; // Ignore ATTR_VEXL and ATTR_EVEXL2 under YMM rounding.

KanRobert wrote:

Do you mean `L`, `L2` bits are ignored if EVEX.U and EVEX.b are set?  If so, 
should we add decoding test for it?

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -257,6 +257,8 @@ X86_FEATURE_COMPAT(USERMSR, "usermsr",  
  0)
 X86_FEATURE_COMPAT(AVX10_1, "avx10.1-256",   36)
 X86_FEATURE_COMPAT(AVX10_1_512, "avx10.1-512",   37)
 X86_FEATURE   (ZU,  "zu")
+X86_FEATURE_COMPAT(AVX10_2, "avx10.2-256",0)

phoebewang wrote:

Done.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-256 -emit-llvm -o - | 
FileCheck %s
+

phoebewang wrote:

Done.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-512 -emit-llvm -o - | 
FileCheck %s
+

phoebewang wrote:

Added i386 test. `-flax-vector-conversions=none` is required. It is used to 
check no implicit vector type conversion.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -162,6 +162,9 @@ bool SemaX86::CheckBuiltinRoundingOrSAE(unsigned BuiltinID, 
CallExpr *TheCall) {
   case X86::BI__builtin_ia32_mulps512:
   case X86::BI__builtin_ia32_subpd512:
   case X86::BI__builtin_ia32_subps512:
+  case X86::BI__builtin_ia32_vaddpd256_round:

phoebewang wrote:

I don't think it's necessary. For one thing, it's verbose given we have 149 new 
rounding instructions. For another, we didn't add test for 
BI__builtin_ia32_addpd512 either.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-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 1c5f6cfc352c3bd2a4faa0e3aebb4028b557a5e7 
787a1bca8c855e5ee00760e58381979206c83f70 --extensions c,inc,cpp,h -- 
clang/lib/Headers/avx10_2_512niintrin.h clang/lib/Headers/avx10_2niintrin.h 
clang/test/CodeGen/X86/avx10_2_512ni-builtins.c 
clang/test/CodeGen/X86/avx10_2ni-builtins.c clang/lib/Basic/Targets/X86.cpp 
clang/lib/Basic/Targets/X86.h clang/lib/Driver/ToolChains/Arch/X86.cpp 
clang/lib/Headers/immintrin.h clang/lib/Sema/SemaX86.cpp 
clang/test/CodeGen/attr-target-x86.c 
clang/test/CodeGen/target-builtin-noerror.c 
clang/test/Driver/x86-target-features.c 
clang/test/Preprocessor/x86_target_features.c 
compiler-rt/lib/builtins/cpu_model/x86.c 
llvm/include/llvm/Support/X86DisassemblerDecoderCommon.h 
llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp 
llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp 
llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86ISelLowering.h 
llvm/lib/Target/X86/X86IntrinsicsInfo.h llvm/lib/TargetParser/Host.cpp 
llvm/lib/TargetParser/X86TargetParser.cpp 
llvm/test/TableGen/x86-fold-tables.inc 
llvm/utils/TableGen/X86DisassemblerTables.cpp 
llvm/utils/TableGen/X86RecognizableInstr.cpp 
llvm/utils/TableGen/X86RecognizableInstr.h
``





View the diff from clang-format here.


``diff
diff --git a/compiler-rt/lib/builtins/cpu_model/x86.c 
b/compiler-rt/lib/builtins/cpu_model/x86.c
index 78fe49f3af..e3a8c0af67 100644
--- a/compiler-rt/lib/builtins/cpu_model/x86.c
+++ b/compiler-rt/lib/builtins/cpu_model/x86.c
@@ -981,7 +981,8 @@ static void getAvailableFeatures(unsigned ECX, unsigned 
EDX, unsigned MaxLeaf,
   if (HasLeaf7Subleaf1 && ((EDX >> 19) & 1) && HasLeaf24) {
 bool Has512Len = (EBX >> 18) & 1;
 switch (EBX & 0xff) {
-default: llvm_unreachable("Unknown version!");
+default:
+  llvm_unreachable("Unknown version!");
 case 2:
   setFeature(FEATURE_AVX10_2_256);
   if (Has512Len)

``




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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,83 @@
+/*=== avx10_2niintrin.h - AVX10.2 new instruction intrinsics ---===
+ *
+ * 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
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifdef __SSE2__
+
+#ifndef __AVX10_2INTRIN_H

phoebewang wrote:

Done.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -1819,7 +1819,7 @@ const StringMap sys::getHostCPUFeatures() {
   Features["avxvnniint16"] = HasLeaf7Subleaf1 && ((EDX >> 10) & 1) && 
HasAVXSave;
   Features["prefetchi"]  = HasLeaf7Subleaf1 && ((EDX >> 14) & 1);
   Features["usermsr"]  = HasLeaf7Subleaf1 && ((EDX >> 15) & 1);
-  Features["avx10.1-256"] = HasLeaf7Subleaf1 && ((EDX >> 19) & 1);
+  bool HasAVX10 = HasLeaf7Subleaf1 && ((EDX >> 19) & 1);

phoebewang wrote:

Done.

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -131,7 +131,7 @@ class X86OpcodePrefixHelper {
   // | RM (VR)  | EVEX_X  | EVEX_B | modrm.r/m | VR  | Dest or Src  |
   // | RM (GPR) | EVEX_B' | EVEX_B | modrm.r/m | GPR | Dest or Src  |
   // | BASE | EVEX_B' | EVEX_B | modrm.r/m | GPR | MA   |
-  // | INDEX| EVEX_X' | EVEX_X | sib.index | GPR | MA   |
+  // | INDEX| EVEX_U  | EVEX_X | sib.index | GPR | MA   |

KanRobert wrote:

Keep unchanged?

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Shengchen Kan via cfe-commits


@@ -111,9 +111,9 @@ class X86OpcodePrefixHelper {
   //  0b11: F2
 
   // EVEX (4 bytes)
-  // +-+ +---+ ++ 
++
-  // | 62h | | RXBR' | B'mmm | | W |  | X' | pp | | z | L'L | b | v' | aaa 
|
-  // +-+ +---+ ++ 
++
+  // +-+ +---+ +---+ ++
+  // | 62h | | RXBR' | B'mmm | | W |  | U | pp | | z | L'L | b | v' | aaa |

KanRobert wrote:

Can we use `X'/U` here as we have interface `setXX2`

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


[clang] [PPC] Disable vsx and altivec when -msoft-float is used (PR #100450)

2024-07-31 Thread Chen Zheng via cfe-commits


@@ -690,6 +698,19 @@ bool PPCTargetInfo::initFeatureMap(
 return false;
   }
 
+  if (llvm::is_contained(FeaturesVec, "-hard-float")) {

chenzheng1030 wrote:

After another look, I still think this should be done in 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Targets/PPC.cpp#L783-L789,
 with changes like:
```diff
@@ -802,11 +803,15 @@ void 
PPCTargetInfo::setFeatureEnabled(llvm::StringMap ,
   Features["efpu2"] = false;
 // If we're disabling altivec or vsx go ahead and disable all of the vsx
 // features.
-if ((Name == "altivec") || (Name == "vsx"))
+if ((Name == "altivec") || (Name == "vsx") || (Name == "hard-float")) {
+  if (Name != "vsx")
+Features["altivec"] = Features["crypto"] = false;
```

What do you think?

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


[clang] [PPC] Disable vsx and altivec when -msoft-float is used (PR #100450)

2024-07-31 Thread Chen Zheng via cfe-commits

https://github.com/chenzheng1030 commented:

We still miss many implications in `PPCTargetInfo::setFeatureEnabled()`. This 
patch fixes the implications for `-msoft-float`. But implications like 
`-mno-power8-altivec` for `-crypto` is still not handled.

Let's leave them for now and make this patch focus on `-msoft-float`. There 
will be a refactor for PPC target for the target features based on 
`PPCTargetParser.cpp`. I think that time is a better time to handle all other 
feature implications.

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


[clang] [PPC] Disable vsx and altivec when -msoft-float is used (PR #100450)

2024-07-31 Thread Chen Zheng via cfe-commits

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-512 -emit-llvm -o - | 
FileCheck %s
+

FreddyLeaf wrote:

is `-flax-vector-conversions=none` required?

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Freddy Ye via cfe-commits


@@ -257,6 +257,8 @@ X86_FEATURE_COMPAT(USERMSR, "usermsr",  
  0)
 X86_FEATURE_COMPAT(AVX10_1, "avx10.1-256",   36)
 X86_FEATURE_COMPAT(AVX10_1_512, "avx10.1-512",   37)
 X86_FEATURE   (ZU,  "zu")
+X86_FEATURE_COMPAT(AVX10_2, "avx10.2-256",0)

FreddyLeaf wrote:

and pls update clang/test/CodeGen/target-builtin-noerror.c

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Freddy Ye via cfe-commits


@@ -257,6 +257,8 @@ X86_FEATURE_COMPAT(USERMSR, "usermsr",  
  0)
 X86_FEATURE_COMPAT(AVX10_1, "avx10.1-256",   36)
 X86_FEATURE_COMPAT(AVX10_1_512, "avx10.1-512",   37)
 X86_FEATURE   (ZU,  "zu")
+X86_FEATURE_COMPAT(AVX10_2, "avx10.2-256",0)

FreddyLeaf wrote:

should be before "zu"

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-256 -emit-llvm -o - | 
FileCheck %s
+

FreddyLeaf wrote:

ditto

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-512 -emit-llvm -o - | 
FileCheck %s
+

FreddyLeaf wrote:

pls add i386 test.

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Freddy Ye via cfe-commits


@@ -162,6 +162,9 @@ bool SemaX86::CheckBuiltinRoundingOrSAE(unsigned BuiltinID, 
CallExpr *TheCall) {
   case X86::BI__builtin_ia32_mulps512:
   case X86::BI__builtin_ia32_subpd512:
   case X86::BI__builtin_ia32_subps512:
+  case X86::BI__builtin_ia32_vaddpd256_round:

FreddyLeaf wrote:

missing error check test?

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,83 @@
+/*=== avx10_2niintrin.h - AVX10.2 new instruction intrinsics ---===
+ *
+ * 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
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifdef __SSE2__
+
+#ifndef __AVX10_2INTRIN_H

FreddyLeaf wrote:

should this be `__AVX10_2NIINTRIN_H`?

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Freddy Ye via cfe-commits


@@ -1819,7 +1819,7 @@ const StringMap sys::getHostCPUFeatures() {
   Features["avxvnniint16"] = HasLeaf7Subleaf1 && ((EDX >> 10) & 1) && 
HasAVXSave;
   Features["prefetchi"]  = HasLeaf7Subleaf1 && ((EDX >> 14) & 1);
   Features["usermsr"]  = HasLeaf7Subleaf1 && ((EDX >> 15) & 1);
-  Features["avx10.1-256"] = HasLeaf7Subleaf1 && ((EDX >> 19) & 1);
+  bool HasAVX10 = HasLeaf7Subleaf1 && ((EDX >> 19) & 1);

FreddyLeaf wrote:

pls update compiler-rt/lib/builtins/cpu_model/x86.c as well.

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


[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)

2024-07-31 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

I think that you may need to detect that whether  integrated-as is used.
If so, pass `-target-feature` option.

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


[clang] [X86_32][C++] fix 0 sized struct case in vaarg. (PR #86388)

2024-07-31 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

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


[clang] [clang][CUDA] Add 'noconvergent' function and statement attribute (PR #100637)

2024-07-31 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

A revert isn't necessary just for the missing release note; a followup PR is 
fine.

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


[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)

2024-07-31 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

I have a try of your patch
```
$ ./bin/clang --target=mips-linux-gnu -mfp64 -Wa,-mmsa nn.c
error: unknown argument: '-mmsa'
```

```
 mipsel-linux-gnu-gcc-14 -mfp64 -Wa,-mmsa nn.c
```
has no such problem.

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


[clang] [Clang][SemaCXX] Fix bug where unexpanded lambda captures where assumed to have size 1 (PR #101385)

2024-07-31 Thread Younan Zhang via cfe-commits

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

Thanks!

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


[clang] [Clang][SemaCXX] Fix bug where unexpanded lambda captures where assumed to have size 1 (PR #101385)

2024-07-31 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

Sorry I was wrong. I mixed up my patch along with this fix so I reapplied it to 
a clean branch locally, and this could also *fix* the above case. With this 
patch, we don't need to bother to handling PackExpansionExpr in the transform 
pass of PackIndexingExpr, which is great!

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


[clang] [clang] fix classification of a string literal expression used as initializer (PR #101447)

2024-07-31 Thread Eli Friedman via cfe-commits


@@ -119,8 +119,6 @@ static Cl::Kinds ClassifyInternal(ASTContext , const 
Expr *E) {
 
 // First come the expressions that are always lvalues, unconditionally.
   case Expr::ObjCIsaExprClass:
-// C++ [expr.prim.general]p1: A string literal is an lvalue.
-  case Expr::StringLiteralClass:
 // @encode is equivalent to its string
   case Expr::ObjCEncodeExprClass:

efriedma-quic wrote:

Also PredefinedExprClass in isTransparent mode (with -fms-extensions).

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


[clang] [llvm] [Clang] C++20 Coroutines: Introduce Frontend Attribute [[clang::coro_await_elidable]] (PR #99282)

2024-07-31 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 updated 
https://github.com/llvm/llvm-project/pull/99282

>From 55e27fdace4dabc0748c20ae5271b735dcc22e3e Mon Sep 17 00:00:00 2001
From: Yuxuan Chen 
Date: Tue, 4 Jun 2024 23:22:00 -0700
Subject: [PATCH] [Clang] Introduce [[clang::coro_await_elidable]]

---
 clang/include/clang/AST/Expr.h|  3 +
 clang/include/clang/AST/Stmt.h|  5 +-
 clang/include/clang/Basic/Attr.td |  8 ++
 clang/include/clang/Basic/AttrDocs.td | 30 ++-
 clang/lib/AST/Expr.cpp|  2 +
 clang/lib/CodeGen/CGBlocks.cpp|  5 +-
 clang/lib/CodeGen/CGCUDARuntime.cpp   |  5 +-
 clang/lib/CodeGen/CGCUDARuntime.h |  8 +-
 clang/lib/CodeGen/CGCXXABI.h  | 10 +--
 clang/lib/CodeGen/CGClass.cpp | 16 ++--
 clang/lib/CodeGen/CGExpr.cpp  | 55 
 clang/lib/CodeGen/CGExprCXX.cpp   | 60 +++--
 clang/lib/CodeGen/CodeGenFunction.h   | 64 --
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 16 ++--
 clang/lib/CodeGen/MicrosoftCXXABI.cpp | 18 ++--
 clang/lib/Sema/SemaCoroutine.cpp  | 30 ++-
 clang/test/CodeGenCoroutines/Inputs/utility.h | 13 +++
 .../CodeGenCoroutines/coro-await-elidable.cpp | 87 +++
 ...a-attribute-supported-attributes-list.test |  1 +
 llvm/include/llvm/Bitcode/LLVMBitCodes.h  |  1 +
 llvm/include/llvm/IR/Attributes.td|  3 +
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  2 +
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp |  2 +
 llvm/lib/Transforms/Utils/CodeExtractor.cpp   |  1 +
 24 files changed, 335 insertions(+), 110 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-await-elidable.cpp

diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 5b813bfc2faf9..83985499e6eba 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2991,6 +2991,9 @@ class CallExpr : public Expr {
 
   bool hasStoredFPFeatures() const { return CallExprBits.HasFPFeatures; }
 
+  bool isCoroMustElide() const { return CallExprBits.IsCoroMustElide; }
+  void setCoroMustElide(bool V = true) { CallExprBits.IsCoroMustElide = V; }
+
   Decl *getCalleeDecl() { return getCallee()->getReferencedDeclOfCallee(); }
   const Decl *getCalleeDecl() const {
 return getCallee()->getReferencedDeclOfCallee();
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index bbd7634bcc3bf..acdb9070ded0f 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -561,8 +561,11 @@ class alignas(void *) Stmt {
 LLVM_PREFERRED_TYPE(bool)
 unsigned HasFPFeatures : 1;
 
+/// True if the call expression is a must-elide call to a coroutine.
+unsigned IsCoroMustElide : 1;
+
 /// Padding used to align OffsetToTrailingObjects to a byte multiple.
-unsigned : 24 - 3 - NumExprBits;
+unsigned : 24 - 4 - NumExprBits;
 
 /// The offset in bytes from the this pointer to the start of the
 /// trailing objects belonging to CallExpr. Intentionally byte sized
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 46d0a66d59c37..d2781ba23ce0e 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1220,6 +1220,14 @@ def CoroDisableLifetimeBound : InheritableAttr {
   let SimpleHandler = 1;
 }
 
+def CoroAwaitElidable : InheritableAttr {
+  let Spellings = [Clang<"coro_await_elidable">];
+  let Subjects = SubjectList<[CXXRecord]>;
+  let LangOpts = [CPlusPlus];
+  let Documentation = [CoroAwaitElidableDoc];
+  let SimpleHandler = 1;
+}
+
 // OSObject-based attributes.
 def OSConsumed : InheritableParamAttr {
   let Spellings = [Clang<"os_consumed">];
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 4b8d520d73893..42dcbcd403d9d 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -8119,6 +8119,35 @@ but do not pass them to the underlying coroutine or pass 
them by value.
 }];
 }
 
+def CoroAwaitElidableDoc : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+The ``[[clang::coro_await_elidable]]`` is a class attribute which can be 
applied
+to a coroutine return type.
+
+When a coroutine function that returns such a type calls another coroutine 
function,
+the compiler performs heap allocation elision when the call to the coroutine 
function
+is immediately co_awaited as a prvalue.
+
+Example:
+
+.. code-block:: c++
+
+  class [[clang::coro_await_elidable]] Task { ... };
+
+  Task foo();
+  Task bar() {
+co_await foo(); // foo()'s coroutine frame on this line is elidable
+auto t = foo(); // foo()'s coroutine frame on this line is NOT elidable
+co_await t;
+  }
+
+The behavior is undefined if the caller 

[clang] [Clang][OpenMP] fix issue: Implicit conversion with `pragma omp taskloop` #100536 (PR #101307)

2024-07-31 Thread via cfe-commits

HenryZ16 wrote:

@jdoerfert @alexey-bataev 

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


[clang] [clang] fix classification of a string literal expression used as initializer (PR #101447)

2024-07-31 Thread Eli Friedman via cfe-commits


@@ -150,6 +148,12 @@ static Cl::Kinds ClassifyInternal(ASTContext , const 
Expr *E) {
   case Expr::OMPIteratorExprClass:
 return Cl::CL_LValue;
 
+// C++ [expr.prim.general]p1: A string literal is an lvalue.
+// Except we special case them as prvalues when they are used for
+// initialization.

efriedma-quic wrote:

Maybe say more specifically "to initialize a char array".

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


[clang] [clang] fix classification of a string literal expression used as initializer (PR #101447)

2024-07-31 Thread Eli Friedman via cfe-commits


@@ -119,8 +119,6 @@ static Cl::Kinds ClassifyInternal(ASTContext , const 
Expr *E) {
 
 // First come the expressions that are always lvalues, unconditionally.
   case Expr::ObjCIsaExprClass:
-// C++ [expr.prim.general]p1: A string literal is an lvalue.
-  case Expr::StringLiteralClass:
 // @encode is equivalent to its string
   case Expr::ObjCEncodeExprClass:

efriedma-quic wrote:

I think we also need to handle ObjCEncodeExprClass the same way.

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


[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

2024-07-31 Thread Max Winkler via cfe-commits


@@ -4446,6 +4446,24 @@ CompareStandardConversionSequences(Sema , 
SourceLocation Loc,
 T1 = S.Context.getQualifiedType(UnqualT1, T1Quals);
   if (isa(T2) && T2Quals)
 T2 = S.Context.getQualifiedType(UnqualT2, T2Quals);
+
+  if (S.getLangOpts().MSVCReferenceBinding &&
+  S.Context.hasSameType(SCS1.getFromType(), SCS2.getFromType()) &&
+  !SCS1.getFromType().hasQualifiers() && SCS1.BindsToRvalue &&
+  SCS2.BindsToRvalue) {
+
+// When binding a user-defined type temporary to an lvalue MSVC will
+// pick `const T&` over `T&` when binding an unqualified `T&&`.
+// Therefore we want to pick the more qualified const overload in this
+// specific case.

MaxEW707 wrote:

https://godbolt.org/z/xaPE6rMc1 for reference on this overload resolution case.

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


[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

2024-07-31 Thread Max Winkler via cfe-commits

https://github.com/MaxEW707 updated 
https://github.com/llvm/llvm-project/pull/99833

>From c66fee7969fc4bd8b5ce79085f0fc09cbc4147da Mon Sep 17 00:00:00 2001
From: MaxEW707 
Date: Fri, 21 Jun 2024 20:37:40 -0700
Subject: [PATCH 01/11] Support MSVC lvalue to temporary reference binding

---
 clang/docs/ReleaseNotes.rst |   4 +
 clang/include/clang/Basic/LangOptions.def   |   1 +
 clang/include/clang/Driver/Options.td   |  12 +++
 clang/include/clang/Sema/Sema.h |   2 +
 clang/lib/Driver/ToolChains/Clang.cpp   |   5 +
 clang/lib/Driver/ToolChains/MSVC.cpp|   1 +
 clang/lib/Sema/SemaInit.cpp |  22 +++--
 clang/lib/Sema/SemaOverload.cpp |  16 ++-
 clang/test/Driver/cl-permissive.c   |   7 ++
 clang/test/Driver/cl-zc.cpp |   2 +
 clang/test/SemaCXX/ms-reference-binding.cpp | 102 
 11 files changed, 165 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/SemaCXX/ms-reference-binding.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72d..becf12fa62ec00 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -104,6 +104,10 @@ C23 Feature Support
 New Compiler Flags
 --
 
+- ``-fms-reference-binding`` and its clang-cl counterpart 
``/Zc:referenceBinding``.
+  Implements the MSVC extension where expressions that bind a user-defined 
type temporary
+  to a non-const lvalue reference are allowed.
+
 Deprecated Compiler Flags
 -
 
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 0035092ce0d863..ff350410d598a0 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -307,6 +307,7 @@ LANGOPT(HIPStdParInterposeAlloc, 1, 0, "Replace allocations 
/ deallocations with
 LANGOPT(OpenACC   , 1, 0, "OpenACC Enabled")
 
 LANGOPT(MSVCEnableStdcMacro , 1, 0, "Define __STDC__ with 
'-fms-compatibility'")
+LANGOPT(MSVCReferenceBinding , 1, 0, "Accept expressions that bind a non-const 
lvalue reference to a temporary")
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28a..53a356d120e3a6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3034,6 +3034,12 @@ def fms_extensions : Flag<["-"], "fms-extensions">, 
Group,
   Visibility<[ClangOption, CC1Option, CLOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft 
compiler">,
   MarshallingInfoFlag>, 
ImpliedByAnyOf<[fms_compatibility.KeyPath]>;
+def fms_reference_binding : Flag<["-"], "fms-reference-binding">, 
Group,
+  Visibility<[ClangOption, CC1Option, CLOption]>,
+  HelpText<"Accept expressions that bind a non-const lvalue reference to a 
user-defined type temporary as supported by the Microsoft Compiler">,
+  MarshallingInfoFlag>;
+def fno_ms_reference_binding : Flag<["-"], "fno-ms-reference-binding">, 
Group,
+  Visibility<[ClangOption, CLOption]>;
 defm asm_blocks : BoolFOption<"asm-blocks",
   LangOpts<"AsmBlocks">, Default,
   PosFlag,
@@ -8492,6 +8498,12 @@ def _SLASH_Zc_wchar_t : CLFlag<"Zc:wchar_t">,
   HelpText<"Enable C++ builtin type wchar_t (default)">;
 def _SLASH_Zc_wchar_t_ : CLFlag<"Zc:wchar_t-">,
   HelpText<"Disable C++ builtin type wchar_t">;
+def _SLASH_Zc_referenceBinding : CLFlag<"Zc:referenceBinding">,
+  HelpText<"Do not accept expressions that bind a non-const lvalue reference 
to a user-defined type temporary">,
+  Alias;
+def _SLASH_Zc_referenceBinding_ : CLFlag<"Zc:referenceBinding-">,
+  HelpText<"Accept expressions that bind a non-const lvalue reference to a 
user-defined type temporary">,
+  Alias;
 def _SLASH_Z7 : CLFlag<"Z7">, Alias,
   HelpText<"Enable CodeView debug information in object files">;
 def _SLASH_ZH_MD5 : CLFlag<"ZH:MD5">,
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2ec6367eccea01..6bd575d105675b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10161,6 +10161,8 @@ class Sema final : public SemaBase {
   CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2,
ReferenceConversions *Conv = nullptr);
 
+  bool AllowMSLValueReferenceBinding(Qualifiers Quals, QualType QT);
+
   /// AddOverloadCandidate - Adds the given function to the set of
   /// candidate functions, using the given function call arguments.  If
   /// @p SuppressUserConversions, then don't allow user-defined
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 843d68c85bc592..13867181b21c07 100644
--- 

[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

2024-07-31 Thread Max Winkler via cfe-commits

https://github.com/MaxEW707 updated 
https://github.com/llvm/llvm-project/pull/99833

>From c66fee7969fc4bd8b5ce79085f0fc09cbc4147da Mon Sep 17 00:00:00 2001
From: MaxEW707 
Date: Fri, 21 Jun 2024 20:37:40 -0700
Subject: [PATCH 01/10] Support MSVC lvalue to temporary reference binding

---
 clang/docs/ReleaseNotes.rst |   4 +
 clang/include/clang/Basic/LangOptions.def   |   1 +
 clang/include/clang/Driver/Options.td   |  12 +++
 clang/include/clang/Sema/Sema.h |   2 +
 clang/lib/Driver/ToolChains/Clang.cpp   |   5 +
 clang/lib/Driver/ToolChains/MSVC.cpp|   1 +
 clang/lib/Sema/SemaInit.cpp |  22 +++--
 clang/lib/Sema/SemaOverload.cpp |  16 ++-
 clang/test/Driver/cl-permissive.c   |   7 ++
 clang/test/Driver/cl-zc.cpp |   2 +
 clang/test/SemaCXX/ms-reference-binding.cpp | 102 
 11 files changed, 165 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/SemaCXX/ms-reference-binding.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72d..becf12fa62ec00 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -104,6 +104,10 @@ C23 Feature Support
 New Compiler Flags
 --
 
+- ``-fms-reference-binding`` and its clang-cl counterpart 
``/Zc:referenceBinding``.
+  Implements the MSVC extension where expressions that bind a user-defined 
type temporary
+  to a non-const lvalue reference are allowed.
+
 Deprecated Compiler Flags
 -
 
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 0035092ce0d863..ff350410d598a0 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -307,6 +307,7 @@ LANGOPT(HIPStdParInterposeAlloc, 1, 0, "Replace allocations 
/ deallocations with
 LANGOPT(OpenACC   , 1, 0, "OpenACC Enabled")
 
 LANGOPT(MSVCEnableStdcMacro , 1, 0, "Define __STDC__ with 
'-fms-compatibility'")
+LANGOPT(MSVCReferenceBinding , 1, 0, "Accept expressions that bind a non-const 
lvalue reference to a temporary")
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28a..53a356d120e3a6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3034,6 +3034,12 @@ def fms_extensions : Flag<["-"], "fms-extensions">, 
Group,
   Visibility<[ClangOption, CC1Option, CLOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft 
compiler">,
   MarshallingInfoFlag>, 
ImpliedByAnyOf<[fms_compatibility.KeyPath]>;
+def fms_reference_binding : Flag<["-"], "fms-reference-binding">, 
Group,
+  Visibility<[ClangOption, CC1Option, CLOption]>,
+  HelpText<"Accept expressions that bind a non-const lvalue reference to a 
user-defined type temporary as supported by the Microsoft Compiler">,
+  MarshallingInfoFlag>;
+def fno_ms_reference_binding : Flag<["-"], "fno-ms-reference-binding">, 
Group,
+  Visibility<[ClangOption, CLOption]>;
 defm asm_blocks : BoolFOption<"asm-blocks",
   LangOpts<"AsmBlocks">, Default,
   PosFlag,
@@ -8492,6 +8498,12 @@ def _SLASH_Zc_wchar_t : CLFlag<"Zc:wchar_t">,
   HelpText<"Enable C++ builtin type wchar_t (default)">;
 def _SLASH_Zc_wchar_t_ : CLFlag<"Zc:wchar_t-">,
   HelpText<"Disable C++ builtin type wchar_t">;
+def _SLASH_Zc_referenceBinding : CLFlag<"Zc:referenceBinding">,
+  HelpText<"Do not accept expressions that bind a non-const lvalue reference 
to a user-defined type temporary">,
+  Alias;
+def _SLASH_Zc_referenceBinding_ : CLFlag<"Zc:referenceBinding-">,
+  HelpText<"Accept expressions that bind a non-const lvalue reference to a 
user-defined type temporary">,
+  Alias;
 def _SLASH_Z7 : CLFlag<"Z7">, Alias,
   HelpText<"Enable CodeView debug information in object files">;
 def _SLASH_ZH_MD5 : CLFlag<"ZH:MD5">,
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2ec6367eccea01..6bd575d105675b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10161,6 +10161,8 @@ class Sema final : public SemaBase {
   CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2,
ReferenceConversions *Conv = nullptr);
 
+  bool AllowMSLValueReferenceBinding(Qualifiers Quals, QualType QT);
+
   /// AddOverloadCandidate - Adds the given function to the set of
   /// candidate functions, using the given function call arguments.  If
   /// @p SuppressUserConversions, then don't allow user-defined
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 843d68c85bc592..13867181b21c07 100644
--- 

[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Phoebe Wang (phoebewang)


Changes

…nstructions

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965

---

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


46 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/BuiltinsX86.def (+8) 
- (modified) clang/include/clang/Driver/Options.td (+6) 
- (modified) clang/lib/Basic/Targets/X86.cpp (+12) 
- (modified) clang/lib/Basic/Targets/X86.h (+2) 
- (modified) clang/lib/Driver/ToolChains/Arch/X86.cpp (+1-1) 
- (modified) clang/lib/Headers/CMakeLists.txt (+2) 
- (added) clang/lib/Headers/avx10_2_512niintrin.h (+35) 
- (added) clang/lib/Headers/avx10_2niintrin.h (+83) 
- (modified) clang/lib/Headers/immintrin.h (+8) 
- (modified) clang/lib/Sema/SemaX86.cpp (+3) 
- (added) clang/test/CodeGen/X86/avx10_2_512ni-builtins.c (+24) 
- (added) clang/test/CodeGen/X86/avx10_2ni-builtins.c (+105) 
- (modified) clang/test/CodeGen/attr-target-x86.c (+4-4) 
- (modified) clang/test/Driver/x86-target-features.c (+7) 
- (modified) clang/test/Preprocessor/x86_target_features.c (+9) 
- (modified) llvm/docs/ReleaseNotes.rst (+2) 
- (modified) llvm/include/llvm/IR/IntrinsicsX86.td (+29-1) 
- (modified) llvm/include/llvm/Support/X86DisassemblerDecoderCommon.h (+43-2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (+2) 
- (modified) llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp (+3) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (+4-1) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp (+6-4) 
- (modified) llvm/lib/Target/X86/X86.td (+6) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.h (+2) 
- (added) llvm/lib/Target/X86/X86InstrAVX10.td (+33) 
- (modified) llvm/lib/Target/X86/X86InstrFormats.td (+2) 
- (modified) llvm/lib/Target/X86/X86InstrFragmentsSIMD.td (+7-5) 
- (modified) llvm/lib/Target/X86/X86InstrInfo.td (+1) 
- (modified) llvm/lib/Target/X86/X86InstrPredicates.td (+3) 
- (modified) llvm/lib/Target/X86/X86InstrSSE.td (+11-11) 
- (modified) llvm/lib/Target/X86/X86IntrinsicsInfo.h (+10) 
- (modified) llvm/lib/TargetParser/Host.cpp (+8-3) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (+3) 
- (added) llvm/test/CodeGen/X86/avx10_2_512ni-intrinsics.ll (+41) 
- (added) llvm/test/CodeGen/X86/avx10_2ni-intrinsics.ll (+216) 
- (added) llvm/test/MC/Disassembler/X86/avx10_2ni-32.txt (+150) 
- (added) llvm/test/MC/Disassembler/X86/avx10_2ni-64.txt (+150) 
- (added) llvm/test/MC/X86/avx10_2ni-32-intel.s (+149) 
- (added) llvm/test/MC/X86/avx10_2ni-64-att.s (+149) 
- (modified) llvm/test/TableGen/x86-fold-tables.inc (+9) 
- (modified) llvm/utils/TableGen/X86DisassemblerTables.cpp (+31-1) 
- (modified) llvm/utils/TableGen/X86ManualInstrMapping.def (+4) 
- (modified) llvm/utils/TableGen/X86RecognizableInstr.cpp (+25-1) 
- (modified) llvm/utils/TableGen/X86RecognizableInstr.h (+2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..956c6e88da1bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,6 +211,8 @@ X86 Support
   functions defined by the ``*mmintrin.h`` headers. A mapping can be
   found in the file ``clang/www/builtins.py``.
 
+- Support ISA of ``AVX10.2``.
+
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
index 06ca30d65f5bd..f028711a807c0 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -1959,6 +1959,14 @@ TARGET_HEADER_BUILTIN(__readgsword,  "UsUNi", "nh", 
INTRIN_H, ALL_MS_LANGUAGES,
 TARGET_HEADER_BUILTIN(__readgsdword, "UNiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__readgsqword, "ULLiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 
+// AVX10.2 VMPSADBW
+TARGET_BUILTIN(__builtin_ia32_mpsadbw512, "V32sV64cV64cIc", "ncV:512:", 
"avx10.2-512")
+
+// AVX10.2 YMM Rounding
+TARGET_BUILTIN(__builtin_ia32_vaddpd256_round, "V4dV4dV4dIi", "nV:256:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vaddph256_round, "V16xV16xV16xIi", "nV:256:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vaddps256_round, "V8fV8fV8fIi", "nV:256:", 
"avx10.2-256")
+
 // AVX-VNNI-INT16
 TARGET_BUILTIN(__builtin_ia32_vpdpwsud128, "V4iV4iV4iV4i", "nV:128:", 
"avxvnniint16")
 TARGET_BUILTIN(__builtin_ia32_vpdpwsud256, "V8iV8iV8iV8i", "nV:256:", 
"avxvnniint16")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28..d19c2a30c5f3f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6205,6 +6205,12 @@ def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group, 
Group;
 def mavx10_1 : Flag<["-"], "mavx10.1">, Alias;
 def mno_avx10_1 : 

[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Phoebe Wang via cfe-commits

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-ir

Author: Phoebe Wang (phoebewang)


Changes

…nstructions

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965

---

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


46 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/BuiltinsX86.def (+8) 
- (modified) clang/include/clang/Driver/Options.td (+6) 
- (modified) clang/lib/Basic/Targets/X86.cpp (+12) 
- (modified) clang/lib/Basic/Targets/X86.h (+2) 
- (modified) clang/lib/Driver/ToolChains/Arch/X86.cpp (+1-1) 
- (modified) clang/lib/Headers/CMakeLists.txt (+2) 
- (added) clang/lib/Headers/avx10_2_512niintrin.h (+35) 
- (added) clang/lib/Headers/avx10_2niintrin.h (+83) 
- (modified) clang/lib/Headers/immintrin.h (+8) 
- (modified) clang/lib/Sema/SemaX86.cpp (+3) 
- (added) clang/test/CodeGen/X86/avx10_2_512ni-builtins.c (+24) 
- (added) clang/test/CodeGen/X86/avx10_2ni-builtins.c (+105) 
- (modified) clang/test/CodeGen/attr-target-x86.c (+4-4) 
- (modified) clang/test/Driver/x86-target-features.c (+7) 
- (modified) clang/test/Preprocessor/x86_target_features.c (+9) 
- (modified) llvm/docs/ReleaseNotes.rst (+2) 
- (modified) llvm/include/llvm/IR/IntrinsicsX86.td (+29-1) 
- (modified) llvm/include/llvm/Support/X86DisassemblerDecoderCommon.h (+43-2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (+2) 
- (modified) llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp (+3) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (+4-1) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp (+6-4) 
- (modified) llvm/lib/Target/X86/X86.td (+6) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.h (+2) 
- (added) llvm/lib/Target/X86/X86InstrAVX10.td (+33) 
- (modified) llvm/lib/Target/X86/X86InstrFormats.td (+2) 
- (modified) llvm/lib/Target/X86/X86InstrFragmentsSIMD.td (+7-5) 
- (modified) llvm/lib/Target/X86/X86InstrInfo.td (+1) 
- (modified) llvm/lib/Target/X86/X86InstrPredicates.td (+3) 
- (modified) llvm/lib/Target/X86/X86InstrSSE.td (+11-11) 
- (modified) llvm/lib/Target/X86/X86IntrinsicsInfo.h (+10) 
- (modified) llvm/lib/TargetParser/Host.cpp (+8-3) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (+3) 
- (added) llvm/test/CodeGen/X86/avx10_2_512ni-intrinsics.ll (+41) 
- (added) llvm/test/CodeGen/X86/avx10_2ni-intrinsics.ll (+216) 
- (added) llvm/test/MC/Disassembler/X86/avx10_2ni-32.txt (+150) 
- (added) llvm/test/MC/Disassembler/X86/avx10_2ni-64.txt (+150) 
- (added) llvm/test/MC/X86/avx10_2ni-32-intel.s (+149) 
- (added) llvm/test/MC/X86/avx10_2ni-64-att.s (+149) 
- (modified) llvm/test/TableGen/x86-fold-tables.inc (+9) 
- (modified) llvm/utils/TableGen/X86DisassemblerTables.cpp (+31-1) 
- (modified) llvm/utils/TableGen/X86ManualInstrMapping.def (+4) 
- (modified) llvm/utils/TableGen/X86RecognizableInstr.cpp (+25-1) 
- (modified) llvm/utils/TableGen/X86RecognizableInstr.h (+2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..956c6e88da1bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,6 +211,8 @@ X86 Support
   functions defined by the ``*mmintrin.h`` headers. A mapping can be
   found in the file ``clang/www/builtins.py``.
 
+- Support ISA of ``AVX10.2``.
+
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
index 06ca30d65f5bd..f028711a807c0 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -1959,6 +1959,14 @@ TARGET_HEADER_BUILTIN(__readgsword,  "UsUNi", "nh", 
INTRIN_H, ALL_MS_LANGUAGES,
 TARGET_HEADER_BUILTIN(__readgsdword, "UNiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__readgsqword, "ULLiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 
+// AVX10.2 VMPSADBW
+TARGET_BUILTIN(__builtin_ia32_mpsadbw512, "V32sV64cV64cIc", "ncV:512:", 
"avx10.2-512")
+
+// AVX10.2 YMM Rounding
+TARGET_BUILTIN(__builtin_ia32_vaddpd256_round, "V4dV4dV4dIi", "nV:256:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vaddph256_round, "V16xV16xV16xIi", "nV:256:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vaddps256_round, "V8fV8fV8fIi", "nV:256:", 
"avx10.2-256")
+
 // AVX-VNNI-INT16
 TARGET_BUILTIN(__builtin_ia32_vpdpwsud128, "V4iV4iV4iV4i", "nV:128:", 
"avxvnniint16")
 TARGET_BUILTIN(__builtin_ia32_vpdpwsud256, "V8iV8iV8iV8i", "nV:256:", 
"avxvnniint16")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28..d19c2a30c5f3f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6205,6 +6205,12 @@ def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group, 
Group;
 def mavx10_1 : Flag<["-"], "mavx10.1">, Alias;
 def mno_avx10_1 : 

[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-mc

@llvm/pr-subscribers-clang-driver

Author: Phoebe Wang (phoebewang)


Changes

…nstructions

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965

---

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


46 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/BuiltinsX86.def (+8) 
- (modified) clang/include/clang/Driver/Options.td (+6) 
- (modified) clang/lib/Basic/Targets/X86.cpp (+12) 
- (modified) clang/lib/Basic/Targets/X86.h (+2) 
- (modified) clang/lib/Driver/ToolChains/Arch/X86.cpp (+1-1) 
- (modified) clang/lib/Headers/CMakeLists.txt (+2) 
- (added) clang/lib/Headers/avx10_2_512niintrin.h (+35) 
- (added) clang/lib/Headers/avx10_2niintrin.h (+83) 
- (modified) clang/lib/Headers/immintrin.h (+8) 
- (modified) clang/lib/Sema/SemaX86.cpp (+3) 
- (added) clang/test/CodeGen/X86/avx10_2_512ni-builtins.c (+24) 
- (added) clang/test/CodeGen/X86/avx10_2ni-builtins.c (+105) 
- (modified) clang/test/CodeGen/attr-target-x86.c (+4-4) 
- (modified) clang/test/Driver/x86-target-features.c (+7) 
- (modified) clang/test/Preprocessor/x86_target_features.c (+9) 
- (modified) llvm/docs/ReleaseNotes.rst (+2) 
- (modified) llvm/include/llvm/IR/IntrinsicsX86.td (+29-1) 
- (modified) llvm/include/llvm/Support/X86DisassemblerDecoderCommon.h (+43-2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (+2) 
- (modified) llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp (+3) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (+4-1) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp (+6-4) 
- (modified) llvm/lib/Target/X86/X86.td (+6) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.h (+2) 
- (added) llvm/lib/Target/X86/X86InstrAVX10.td (+33) 
- (modified) llvm/lib/Target/X86/X86InstrFormats.td (+2) 
- (modified) llvm/lib/Target/X86/X86InstrFragmentsSIMD.td (+7-5) 
- (modified) llvm/lib/Target/X86/X86InstrInfo.td (+1) 
- (modified) llvm/lib/Target/X86/X86InstrPredicates.td (+3) 
- (modified) llvm/lib/Target/X86/X86InstrSSE.td (+11-11) 
- (modified) llvm/lib/Target/X86/X86IntrinsicsInfo.h (+10) 
- (modified) llvm/lib/TargetParser/Host.cpp (+8-3) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (+3) 
- (added) llvm/test/CodeGen/X86/avx10_2_512ni-intrinsics.ll (+41) 
- (added) llvm/test/CodeGen/X86/avx10_2ni-intrinsics.ll (+216) 
- (added) llvm/test/MC/Disassembler/X86/avx10_2ni-32.txt (+150) 
- (added) llvm/test/MC/Disassembler/X86/avx10_2ni-64.txt (+150) 
- (added) llvm/test/MC/X86/avx10_2ni-32-intel.s (+149) 
- (added) llvm/test/MC/X86/avx10_2ni-64-att.s (+149) 
- (modified) llvm/test/TableGen/x86-fold-tables.inc (+9) 
- (modified) llvm/utils/TableGen/X86DisassemblerTables.cpp (+31-1) 
- (modified) llvm/utils/TableGen/X86ManualInstrMapping.def (+4) 
- (modified) llvm/utils/TableGen/X86RecognizableInstr.cpp (+25-1) 
- (modified) llvm/utils/TableGen/X86RecognizableInstr.h (+2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..956c6e88da1bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,6 +211,8 @@ X86 Support
   functions defined by the ``*mmintrin.h`` headers. A mapping can be
   found in the file ``clang/www/builtins.py``.
 
+- Support ISA of ``AVX10.2``.
+
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
index 06ca30d65f5bd..f028711a807c0 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -1959,6 +1959,14 @@ TARGET_HEADER_BUILTIN(__readgsword,  "UsUNi", "nh", 
INTRIN_H, ALL_MS_LANGUAGES,
 TARGET_HEADER_BUILTIN(__readgsdword, "UNiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__readgsqword, "ULLiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 
+// AVX10.2 VMPSADBW
+TARGET_BUILTIN(__builtin_ia32_mpsadbw512, "V32sV64cV64cIc", "ncV:512:", 
"avx10.2-512")
+
+// AVX10.2 YMM Rounding
+TARGET_BUILTIN(__builtin_ia32_vaddpd256_round, "V4dV4dV4dIi", "nV:256:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vaddph256_round, "V16xV16xV16xIi", "nV:256:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vaddps256_round, "V8fV8fV8fIi", "nV:256:", 
"avx10.2-256")
+
 // AVX-VNNI-INT16
 TARGET_BUILTIN(__builtin_ia32_vpdpwsud128, "V4iV4iV4iV4i", "nV:128:", 
"avxvnniint16")
 TARGET_BUILTIN(__builtin_ia32_vpdpwsud256, "V8iV8iV8iV8i", "nV:256:", 
"avxvnniint16")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28..d19c2a30c5f3f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6205,6 +6205,12 @@ def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group, 
Group;
 def mavx10_1 : Flag<["-"], "mavx10.1">, 

[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-support

Author: Phoebe Wang (phoebewang)


Changes

…nstructions

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965

---

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


46 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/BuiltinsX86.def (+8) 
- (modified) clang/include/clang/Driver/Options.td (+6) 
- (modified) clang/lib/Basic/Targets/X86.cpp (+12) 
- (modified) clang/lib/Basic/Targets/X86.h (+2) 
- (modified) clang/lib/Driver/ToolChains/Arch/X86.cpp (+1-1) 
- (modified) clang/lib/Headers/CMakeLists.txt (+2) 
- (added) clang/lib/Headers/avx10_2_512niintrin.h (+35) 
- (added) clang/lib/Headers/avx10_2niintrin.h (+83) 
- (modified) clang/lib/Headers/immintrin.h (+8) 
- (modified) clang/lib/Sema/SemaX86.cpp (+3) 
- (added) clang/test/CodeGen/X86/avx10_2_512ni-builtins.c (+24) 
- (added) clang/test/CodeGen/X86/avx10_2ni-builtins.c (+105) 
- (modified) clang/test/CodeGen/attr-target-x86.c (+4-4) 
- (modified) clang/test/Driver/x86-target-features.c (+7) 
- (modified) clang/test/Preprocessor/x86_target_features.c (+9) 
- (modified) llvm/docs/ReleaseNotes.rst (+2) 
- (modified) llvm/include/llvm/IR/IntrinsicsX86.td (+29-1) 
- (modified) llvm/include/llvm/Support/X86DisassemblerDecoderCommon.h (+43-2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (+2) 
- (modified) llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp (+3) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (+4-1) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp (+6-4) 
- (modified) llvm/lib/Target/X86/X86.td (+6) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.h (+2) 
- (added) llvm/lib/Target/X86/X86InstrAVX10.td (+33) 
- (modified) llvm/lib/Target/X86/X86InstrFormats.td (+2) 
- (modified) llvm/lib/Target/X86/X86InstrFragmentsSIMD.td (+7-5) 
- (modified) llvm/lib/Target/X86/X86InstrInfo.td (+1) 
- (modified) llvm/lib/Target/X86/X86InstrPredicates.td (+3) 
- (modified) llvm/lib/Target/X86/X86InstrSSE.td (+11-11) 
- (modified) llvm/lib/Target/X86/X86IntrinsicsInfo.h (+10) 
- (modified) llvm/lib/TargetParser/Host.cpp (+8-3) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (+3) 
- (added) llvm/test/CodeGen/X86/avx10_2_512ni-intrinsics.ll (+41) 
- (added) llvm/test/CodeGen/X86/avx10_2ni-intrinsics.ll (+216) 
- (added) llvm/test/MC/Disassembler/X86/avx10_2ni-32.txt (+150) 
- (added) llvm/test/MC/Disassembler/X86/avx10_2ni-64.txt (+150) 
- (added) llvm/test/MC/X86/avx10_2ni-32-intel.s (+149) 
- (added) llvm/test/MC/X86/avx10_2ni-64-att.s (+149) 
- (modified) llvm/test/TableGen/x86-fold-tables.inc (+9) 
- (modified) llvm/utils/TableGen/X86DisassemblerTables.cpp (+31-1) 
- (modified) llvm/utils/TableGen/X86ManualInstrMapping.def (+4) 
- (modified) llvm/utils/TableGen/X86RecognizableInstr.cpp (+25-1) 
- (modified) llvm/utils/TableGen/X86RecognizableInstr.h (+2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..956c6e88da1bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,6 +211,8 @@ X86 Support
   functions defined by the ``*mmintrin.h`` headers. A mapping can be
   found in the file ``clang/www/builtins.py``.
 
+- Support ISA of ``AVX10.2``.
+
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
index 06ca30d65f5bd..f028711a807c0 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -1959,6 +1959,14 @@ TARGET_HEADER_BUILTIN(__readgsword,  "UsUNi", "nh", 
INTRIN_H, ALL_MS_LANGUAGES,
 TARGET_HEADER_BUILTIN(__readgsdword, "UNiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__readgsqword, "ULLiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 
+// AVX10.2 VMPSADBW
+TARGET_BUILTIN(__builtin_ia32_mpsadbw512, "V32sV64cV64cIc", "ncV:512:", 
"avx10.2-512")
+
+// AVX10.2 YMM Rounding
+TARGET_BUILTIN(__builtin_ia32_vaddpd256_round, "V4dV4dV4dIi", "nV:256:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vaddph256_round, "V16xV16xV16xIi", "nV:256:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vaddps256_round, "V8fV8fV8fIi", "nV:256:", 
"avx10.2-256")
+
 // AVX-VNNI-INT16
 TARGET_BUILTIN(__builtin_ia32_vpdpwsud128, "V4iV4iV4iV4i", "nV:128:", 
"avxvnniint16")
 TARGET_BUILTIN(__builtin_ia32_vpdpwsud256, "V8iV8iV8iV8i", "nV:256:", 
"avxvnniint16")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28..d19c2a30c5f3f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6205,6 +6205,12 @@ def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group, 
Group;
 def mavx10_1 : Flag<["-"], "mavx10.1">, Alias;
 def mno_avx10_1 : 

[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-07-31 Thread Phoebe Wang via cfe-commits

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new i… (PR #101452)

2024-07-31 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/101452

…nstructions

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965

>From 56b26bfaaa071dde226077531aaa46f4b671a815 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Sat, 27 Jul 2024 22:21:32 +0800
Subject: [PATCH] [X86][AVX10.2] Support AVX10.2 option and
 VMPSADBW/VADDP[D,H,S] new instructions

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965
---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/include/clang/Basic/BuiltinsX86.def |   8 +
 clang/include/clang/Driver/Options.td |   6 +
 clang/lib/Basic/Targets/X86.cpp   |  12 +
 clang/lib/Basic/Targets/X86.h |   2 +
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |   2 +-
 clang/lib/Headers/CMakeLists.txt  |   2 +
 clang/lib/Headers/avx10_2_512niintrin.h   |  35 +++
 clang/lib/Headers/avx10_2niintrin.h   |  83 +++
 clang/lib/Headers/immintrin.h |   8 +
 clang/lib/Sema/SemaX86.cpp|   3 +
 .../test/CodeGen/X86/avx10_2_512ni-builtins.c |  24 ++
 clang/test/CodeGen/X86/avx10_2ni-builtins.c   | 105 +
 clang/test/CodeGen/attr-target-x86.c  |   8 +-
 clang/test/Driver/x86-target-features.c   |   7 +
 clang/test/Preprocessor/x86_target_features.c |   9 +
 llvm/docs/ReleaseNotes.rst|   2 +
 llvm/include/llvm/IR/IntrinsicsX86.td |  30 ++-
 .../Support/X86DisassemblerDecoderCommon.h|  45 +++-
 .../llvm/TargetParser/X86TargetParser.def |   2 +
 .../X86/Disassembler/X86Disassembler.cpp  |   3 +
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |   5 +-
 .../X86/MCTargetDesc/X86MCCodeEmitter.cpp |  10 +-
 llvm/lib/Target/X86/X86.td|   6 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |   1 +
 llvm/lib/Target/X86/X86ISelLowering.h |   2 +
 llvm/lib/Target/X86/X86InstrAVX10.td  |  33 +++
 llvm/lib/Target/X86/X86InstrFormats.td|   2 +
 llvm/lib/Target/X86/X86InstrFragmentsSIMD.td  |  12 +-
 llvm/lib/Target/X86/X86InstrInfo.td   |   1 +
 llvm/lib/Target/X86/X86InstrPredicates.td |   3 +
 llvm/lib/Target/X86/X86InstrSSE.td|  22 +-
 llvm/lib/Target/X86/X86IntrinsicsInfo.h   |  10 +
 llvm/lib/TargetParser/Host.cpp|  11 +-
 llvm/lib/TargetParser/X86TargetParser.cpp |   3 +
 .../CodeGen/X86/avx10_2_512ni-intrinsics.ll   |  41 
 llvm/test/CodeGen/X86/avx10_2ni-intrinsics.ll | 216 ++
 .../test/MC/Disassembler/X86/avx10_2ni-32.txt | 150 
 .../test/MC/Disassembler/X86/avx10_2ni-64.txt | 150 
 llvm/test/MC/X86/avx10_2ni-32-intel.s | 149 
 llvm/test/MC/X86/avx10_2ni-64-att.s   | 149 
 llvm/test/TableGen/x86-fold-tables.inc|   9 +
 llvm/utils/TableGen/X86DisassemblerTables.cpp |  32 ++-
 llvm/utils/TableGen/X86ManualInstrMapping.def |   4 +
 llvm/utils/TableGen/X86RecognizableInstr.cpp  |  26 ++-
 llvm/utils/TableGen/X86RecognizableInstr.h|   2 +
 46 files changed, 1413 insertions(+), 34 deletions(-)
 create mode 100644 clang/lib/Headers/avx10_2_512niintrin.h
 create mode 100644 clang/lib/Headers/avx10_2niintrin.h
 create mode 100644 clang/test/CodeGen/X86/avx10_2_512ni-builtins.c
 create mode 100644 clang/test/CodeGen/X86/avx10_2ni-builtins.c
 create mode 100644 llvm/lib/Target/X86/X86InstrAVX10.td
 create mode 100644 llvm/test/CodeGen/X86/avx10_2_512ni-intrinsics.ll
 create mode 100644 llvm/test/CodeGen/X86/avx10_2ni-intrinsics.ll
 create mode 100644 llvm/test/MC/Disassembler/X86/avx10_2ni-32.txt
 create mode 100644 llvm/test/MC/Disassembler/X86/avx10_2ni-64.txt
 create mode 100644 llvm/test/MC/X86/avx10_2ni-32-intel.s
 create mode 100644 llvm/test/MC/X86/avx10_2ni-64-att.s

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..956c6e88da1bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,6 +211,8 @@ X86 Support
   functions defined by the ``*mmintrin.h`` headers. A mapping can be
   found in the file ``clang/www/builtins.py``.
 
+- Support ISA of ``AVX10.2``.
+
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
index 06ca30d65f5bd..f028711a807c0 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -1959,6 +1959,14 @@ TARGET_HEADER_BUILTIN(__readgsword,  "UsUNi", "nh", 
INTRIN_H, ALL_MS_LANGUAGES,
 TARGET_HEADER_BUILTIN(__readgsdword, "UNiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__readgsqword, "ULLiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 
+// AVX10.2 VMPSADBW
+TARGET_BUILTIN(__builtin_ia32_mpsadbw512, "V32sV64cV64cIc", "ncV:512:", 
"avx10.2-512")
+
+// AVX10.2 YMM Rounding
+TARGET_BUILTIN(__builtin_ia32_vaddpd256_round, "V4dV4dV4dIi", "nV:256:", 
"avx10.2-256")

[clang] [llvm] [RISCV] Add Syntacore SCR4 RV32/64 processors definition (PR #101321)

2024-07-31 Thread Pengcheng Wang via cfe-commits


@@ -106,6 +106,7 @@ Changes to the RISC-V Backend
 * `.balign N, 0`, `.p2align N, 0`, `.align N, 0` in code sections will now fill
   the required alignment space with a sequence of `0x0` bytes (the requested
   fill value) rather than NOPs.
+* Added Syntacore SCR4 CPUs: ``-mcpu=syntacore-scr4-rv32/64``

wangpc-pp wrote:

This should be in `clang/docs/ReleaseNotes.rst` not llvm?

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


[clang] [clang-tools-extra] [clang-tidy] Add support for bsl::optional (PR #101450)

2024-07-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Chris Cotter (ccotter)


Changes



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


5 Files Affected:

- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+5) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bdlb_nullablevalue.h
 (+38) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bsl_optional.h
 (+75) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
 (+91) 
- (modified) 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp 
(+49-13) 


``diff
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 642ad39cc0c1c..cc999b142561f 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -104,6 +104,11 @@ New check aliases
 Changes in existing checks
 ^^
 
+- Improved :doc:`bugprone-unchecked-optional-access
+  ` to support
+  `bsl::optional` and `bdlb::NullableValue` from
+  _.
+
 Removed checks
 ^^
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bdlb_nullablevalue.h
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bdlb_nullablevalue.h
new file mode 100644
index 0..53efebba1bb9f
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bdlb_nullablevalue.h
@@ -0,0 +1,38 @@
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_
+#define 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_
+
+#include "bsl_optional.h"
+
+/// Mock of `bdbl::NullableValue`.
+namespace BloombergLP::bdlb {
+
+template 
+class NullableValue : public bsl::optional {
+public:
+  constexpr NullableValue() noexcept;
+
+  constexpr NullableValue(bsl::nullopt_t) noexcept;
+
+  NullableValue(const NullableValue &) = default;
+
+  NullableValue(NullableValue &&) = default;
+
+  const T () const &;
+  T () &;
+
+  // 'operator bool' is inherited from bsl::optional
+
+  constexpr bool isNull() const noexcept;
+
+  template 
+  constexpr T valueOr(U &) const &;
+
+  // 'reset' is inherited from bsl::optional
+
+  template  NullableValue =(const U );
+};
+
+
+} // namespace BloombergLP::bdlb
+
+#endif // 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bsl_optional.h
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bsl_optional.h
new file mode 100644
index 0..7e1a129e04a55
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bsl_optional.h
@@ -0,0 +1,75 @@
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
+#define 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
+
+/// Mock of `bsl::optional`.
+namespace bsl {
+
+// clang-format off
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference { using type = T; };
+// clang-format on
+
+template 
+using remove_reference_t = typename remove_reference::type;
+
+template 
+constexpr T &(remove_reference_t ) noexcept;
+
+template 
+constexpr T &(remove_reference_t &) noexcept;
+
+template 
+constexpr remove_reference_t &(T &);
+
+struct nullopt_t {
+  constexpr explicit nullopt_t() {}
+};
+
+constexpr nullopt_t nullopt;
+
+template 
+class optional {
+public:
+  constexpr optional() noexcept;
+
+  constexpr optional(nullopt_t) noexcept;
+
+  optional(const optional &) = default;
+
+  optional(optional &&) = default;
+
+  const T *() const &;
+  T *() &;
+  const T &*() const &&;
+  T &*() &&;
+
+  const T *operator->() const;
+  T *operator->();
+
+  const T () const &;
+  T () &;
+  const T &() const &&;
+  T &() &&;
+
+  constexpr explicit operator bool() const noexcept;
+  constexpr bool has_value() const noexcept;
+
+  template 
+  constexpr T value_or(U &) const &;
+  template 
+  T value_or(U &) &&;
+
+  template 
+  T (Args &&...args);
+
+  void reset() noexcept;
+
+  void swap(optional ) noexcept;
+
+  template  optional =(const U );
+};
+
+} // namespace bsl
+
+#endif // 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
index 13a3ff52f3ebc..3167b85f0e024 100644
--- 

[clang] [clang-tools-extra] [clang-tidy] Add support for bsl::optional (PR #101450)

2024-07-31 Thread Chris Cotter via cfe-commits

https://github.com/ccotter created 
https://github.com/llvm/llvm-project/pull/101450

None

>From f7e7681db6ad83878fd00cf250047c98b1b4f051 Mon Sep 17 00:00:00 2001
From: Chris Cotter 
Date: Tue, 23 Jul 2024 10:30:54 -0400
Subject: [PATCH] [clang-tidy] Add support for bsl::optional

---
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 +
 .../bde/types/bdlb_nullablevalue.h| 38 
 .../bde/types/bsl_optional.h  | 75 +++
 .../bugprone/unchecked-optional-access.cpp| 91 +++
 .../Models/UncheckedOptionalAccessModel.cpp   | 62 ++---
 5 files changed, 258 insertions(+), 13 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bdlb_nullablevalue.h
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bsl_optional.h

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 642ad39cc0c1c..cc999b142561f 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -104,6 +104,11 @@ New check aliases
 Changes in existing checks
 ^^
 
+- Improved :doc:`bugprone-unchecked-optional-access
+  ` to support
+  `bsl::optional` and `bdlb::NullableValue` from
+  _.
+
 Removed checks
 ^^
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bdlb_nullablevalue.h
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bdlb_nullablevalue.h
new file mode 100644
index 0..53efebba1bb9f
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bdlb_nullablevalue.h
@@ -0,0 +1,38 @@
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_
+#define 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_
+
+#include "bsl_optional.h"
+
+/// Mock of `bdbl::NullableValue`.
+namespace BloombergLP::bdlb {
+
+template 
+class NullableValue : public bsl::optional {
+public:
+  constexpr NullableValue() noexcept;
+
+  constexpr NullableValue(bsl::nullopt_t) noexcept;
+
+  NullableValue(const NullableValue &) = default;
+
+  NullableValue(NullableValue &&) = default;
+
+  const T () const &;
+  T () &;
+
+  // 'operator bool' is inherited from bsl::optional
+
+  constexpr bool isNull() const noexcept;
+
+  template 
+  constexpr T valueOr(U &) const &;
+
+  // 'reset' is inherited from bsl::optional
+
+  template  NullableValue =(const U );
+};
+
+
+} // namespace BloombergLP::bdlb
+
+#endif // 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bsl_optional.h
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bsl_optional.h
new file mode 100644
index 0..7e1a129e04a55
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/bde/types/bsl_optional.h
@@ -0,0 +1,75 @@
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
+#define 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
+
+/// Mock of `bsl::optional`.
+namespace bsl {
+
+// clang-format off
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference { using type = T; };
+// clang-format on
+
+template 
+using remove_reference_t = typename remove_reference::type;
+
+template 
+constexpr T &(remove_reference_t ) noexcept;
+
+template 
+constexpr T &(remove_reference_t &) noexcept;
+
+template 
+constexpr remove_reference_t &(T &);
+
+struct nullopt_t {
+  constexpr explicit nullopt_t() {}
+};
+
+constexpr nullopt_t nullopt;
+
+template 
+class optional {
+public:
+  constexpr optional() noexcept;
+
+  constexpr optional(nullopt_t) noexcept;
+
+  optional(const optional &) = default;
+
+  optional(optional &&) = default;
+
+  const T *() const &;
+  T *() &;
+  const T &*() const &&;
+  T &*() &&;
+
+  const T *operator->() const;
+  T *operator->();
+
+  const T () const &;
+  T () &;
+  const T &() const &&;
+  T &() &&;
+
+  constexpr explicit operator bool() const noexcept;
+  constexpr bool has_value() const noexcept;
+
+  template 
+  constexpr T value_or(U &) const &;
+  template 
+  T value_or(U &) &&;
+
+  template 
+  T (Args &&...args);
+
+  void reset() noexcept;
+
+  void swap(optional ) noexcept;
+
+  template  optional =(const U );
+};
+
+} // namespace bsl
+
+#endif // 
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
diff --git 

[clang] [Clang] Implement C++26’s P2893R3 ‘Variadic friends’ (PR #101448)

2024-07-31 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/101448

>From 1fd8db659961fd1702c0c786feb71ad6c5998aa8 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Wed, 31 Jul 2024 21:44:02 +0200
Subject: [PATCH 1/6] [Parser] Parse variadic friends

---
 clang/include/clang/AST/DeclFriend.h  | 15 +++-
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Sema/Sema.h   |  6 +-
 clang/lib/AST/ASTImporter.cpp |  7 +-
 clang/lib/AST/DeclFriend.cpp  | 14 +--
 clang/lib/AST/DeclPrinter.cpp |  3 +
 clang/lib/AST/ODRHash.cpp |  1 +
 clang/lib/AST/TextNodeDumper.cpp  |  2 +
 clang/lib/Parse/ParseDeclCXX.cpp  | 89 +++
 clang/lib/Sema/SemaDecl.cpp   |  8 +-
 clang/lib/Sema/SemaDeclCXX.cpp| 26 --
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  3 +
 clang/lib/Serialization/ASTReaderDecl.cpp |  1 +
 clang/lib/Serialization/ASTWriterDecl.cpp |  1 +
 .../Parser/cxx2c-variadic-friends-errors.cpp  | 63 +
 clang/test/Parser/cxx2c-variadic-friends.cpp  | 60 +
 16 files changed, 278 insertions(+), 23 deletions(-)
 create mode 100644 clang/test/Parser/cxx2c-variadic-friends-errors.cpp
 create mode 100644 clang/test/Parser/cxx2c-variadic-friends.cpp

diff --git a/clang/include/clang/AST/DeclFriend.h 
b/clang/include/clang/AST/DeclFriend.h
index 9789282f351a5..1c2c86d3ef384 100644
--- a/clang/include/clang/AST/DeclFriend.h
+++ b/clang/include/clang/AST/DeclFriend.h
@@ -70,6 +70,9 @@ class FriendDecl final
   // Location of the 'friend' specifier.
   SourceLocation FriendLoc;
 
+  // Location of the '...', if present.
+  SourceLocation EllipsisLoc;
+
   /// True if this 'friend' declaration is unsupported.  Eventually we
   /// will support every possible friend declaration, but for now we
   /// silently ignore some and set this flag to authorize all access.
@@ -82,10 +85,11 @@ class FriendDecl final
   unsigned NumTPLists : 31;
 
   FriendDecl(DeclContext *DC, SourceLocation L, FriendUnion Friend,
- SourceLocation FriendL,
+ SourceLocation FriendL, SourceLocation EllipsisLoc,
  ArrayRef FriendTypeTPLists)
   : Decl(Decl::Friend, DC, L), Friend(Friend), FriendLoc(FriendL),
-UnsupportedFriend(false), NumTPLists(FriendTypeTPLists.size()) {
+EllipsisLoc(EllipsisLoc), UnsupportedFriend(false),
+NumTPLists(FriendTypeTPLists.size()) {
 for (unsigned i = 0; i < NumTPLists; ++i)
   getTrailingObjects()[i] = FriendTypeTPLists[i];
   }
@@ -110,7 +114,7 @@ class FriendDecl final
 
   static FriendDecl *
   Create(ASTContext , DeclContext *DC, SourceLocation L, FriendUnion Friend_,
- SourceLocation FriendL,
+ SourceLocation FriendL, SourceLocation EllipsisLoc = {},
  ArrayRef FriendTypeTPLists = std::nullopt);
   static FriendDecl *CreateDeserialized(ASTContext , GlobalDeclID ID,
 unsigned FriendTypeNumTPLists);
@@ -143,6 +147,9 @@ class FriendDecl final
 return FriendLoc;
   }
 
+  /// Retrieves the location of the '...', if present.
+  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
+
   /// Retrieves the source range for the friend declaration.
   SourceRange getSourceRange() const override LLVM_READONLY {
 if (NamedDecl *ND = getFriendDecl()) {
@@ -177,6 +184,8 @@ class FriendDecl final
 UnsupportedFriend = Unsupported;
   }
 
+  bool isVariadic() const { return EllipsisLoc.isValid(); }
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == Decl::Friend; }
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 581434d33c5c9..8daa2386ef64f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1738,6 +1738,8 @@ def ext_friend_tag_redecl_outside_namespace : ExtWarn<
   "enclosing namespace is a Microsoft extension; add a nested name specifier">,
   InGroup;
 def err_pure_friend : Error<"friend declaration cannot have a pure-specifier">;
+def err_friend_template_decl_multiple_specifiers: Error<
+  "a friend declaration that befriends a template must contain exactly one 
type-specifier">;
 
 def err_invalid_base_in_interface : Error<
   "interface type cannot inherit from "
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2ec6367eccea0..07c8c2cef9cc3 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3800,7 +3800,8 @@ class Sema final : public SemaBase {
const ParsedAttributesView ,
MultiTemplateParamsArg TemplateParams,
bool 

[clang] [Clang] Implement C++26’s P2893R3 ‘Variadic friends’ (PR #101448)

2024-07-31 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 eb03279ddcc4bb655021101f0038ece2cec3158a 
da65e3b79893f64848caca47823ff2ed894ac97d --extensions cpp,h -- 
clang/test/AST/cxx2c-variadic-friends.cpp 
clang/test/Parser/cxx2c-variadic-friends.cpp 
clang/test/SemaCXX/cxx2c-variadic-friends.cpp 
clang/include/clang/AST/DeclFriend.h 
clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Sema/Sema.h 
clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/ASTImporter.cpp 
clang/lib/AST/DeclBase.cpp clang/lib/AST/DeclFriend.cpp 
clang/lib/AST/DeclPrinter.cpp clang/lib/AST/ODRHash.cpp 
clang/lib/AST/TextNodeDumper.cpp clang/lib/CodeGen/CGDecl.cpp 
clang/lib/Frontend/InitPreprocessor.cpp clang/lib/Parse/ParseDeclCXX.cpp 
clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
clang/lib/Serialization/ASTCommon.cpp clang/lib/Serialization/ASTReaderDecl.cpp 
clang/lib/Serialization/ASTWriterDecl.cpp clang/tools/libclang/CIndex.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index d17e213ea4..bb5822e36c 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -769,7 +769,6 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions ,
   // C++26 features supported in earlier language modes.
   Builder.defineMacro("__cpp_deleted_function", "202403L");
 
-
   if (LangOpts.Char8)
 Builder.defineMacro("__cpp_char8_t", "202207L");
   Builder.defineMacro("__cpp_impl_destroying_delete", "201806L");

``




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


[clang] [Clang] Implement C++26’s P2893R3 ‘Variadic friends’ (PR #101448)

2024-07-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: None (Sirraide)


Changes

Implement P2893R3 ‘Variadic friends’ for C++26.

The implementation proper is mostly done, from what I can tell, but I have a 
few questions, so I thought I’d be best to list them all here (some are for me 
to investigate, some I’d appreciate it if anyone would happen to know the 
answer to them):
- [ ] I don’t know much about the `ASTImporter`, so I’m not entirely sure if I 
did everything right in there.
- [ ] Still need to add tests for [CWG 
2917](https://cplusplus.github.io/CWG/issues/2917.html), which I filed while 
working on this, to the DR test suite proper. (@Endilll Sorry for 
asking this *again*, but do I need to run the script that updates the DR tests 
as part of this, or should that be done in a separate pr before this?)
- [ ] Do we want to expose this in earlier language modes? The syntax wasn’t 
valid before, so I *believe* there shouldn’t be an issue with that, but I’m not 
sure.
- [ ] There are some edge cases that mostly involve what we treat as 
unsupported friend declarations that I still need to either reject or also 
convert to unsupported friend declarations.
- [ ] Is there ever a situation that would cause us to have to instantiate a 
`FriendPackDecl` in the `TemplateDeclInstantiator`? We do that for 
`UsingPackDecl`s, but those are sufficiently different enough from the former 
that I’m not sure about it. I at least haven’t been able to come up w/ any 
cases that would cause us to try and instantiate one.
- [ ] The diagnostics for some invalid declarations (e.g. CWG 2917) could still 
be better imo.
- [ ] I had to add a hack to the decl printer to get e.g. `friend int, long;` 
to be printed like that instead of as separate declarations (which they 
currently are in the AST). Is that fine or is that too much of a hack?
- [ ] Whether an ellipsis is present after a friend-type-specifier is currently 
handled via a separate parameter in some of the Sema functions. It would be 
possible to instead store that information in the `DeclSpec`, but I haven’t 
written too much parser code in Clang before, and wasn’t sure how strict we are 
wrt putting things in that class because I don’t think the `...` is part of the 
specifier according to the grammar.

Thanks also to @zyn0217, who was working on this before me; I’ve taken 
over working on this since they didn’t have time for it anymore. I’ve 
incorporated parts of their WIP patch, so I’ll credit them as a co-author 
whenever this gets merged.

This closes #98587.


---

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


27 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/AST/DeclFriend.h (+71-12) 
- (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+2) 
- (modified) clang/include/clang/Basic/DeclNodes.td (+1) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2) 
- (modified) clang/include/clang/Sema/Sema.h (+4-2) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+3) 
- (modified) clang/lib/AST/ASTImporter.cpp (+31-2) 
- (modified) clang/lib/AST/DeclBase.cpp (+1) 
- (modified) clang/lib/AST/DeclFriend.cpp (+27-7) 
- (modified) clang/lib/AST/DeclPrinter.cpp (+35-5) 
- (modified) clang/lib/AST/ODRHash.cpp (+1) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+2) 
- (modified) clang/lib/CodeGen/CGDecl.cpp (+1) 
- (modified) clang/lib/Frontend/InitPreprocessor.cpp (+5) 
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+89) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+6-2) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+20-7) 
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+49-2) 
- (modified) clang/lib/Serialization/ASTCommon.cpp (+1) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+12) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+10) 
- (added) clang/test/AST/cxx2c-variadic-friends.cpp (+74) 
- (added) clang/test/Parser/cxx2c-variadic-friends.cpp (+60) 
- (added) clang/test/SemaCXX/cxx2c-variadic-friends.cpp (+136) 
- (modified) clang/tools/libclang/CIndex.cpp (+1) 
- (modified) clang/www/cxx_status.html (+1-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..aa8bb903d3646 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@ C++2c Feature Support
 - Add ``__builtin_is_virtual_base_of`` intrinsic, which supports
   `P2985R0 A type trait for detecting virtual base classes 
`_
 
+- Implemented `P2893R3 Variadic Friends `_
+
 Resolutions to C++ Defect Reports
 ^
 
diff --git a/clang/include/clang/AST/DeclFriend.h 
b/clang/include/clang/AST/DeclFriend.h
index 9789282f351a5..19dd531e89ccf 100644
--- a/clang/include/clang/AST/DeclFriend.h
+++ b/clang/include/clang/AST/DeclFriend.h
@@ -70,6 +70,9 

[clang] [Clang] Implement C++26’s P2893R3 ‘Variadic friends’ (PR #101448)

2024-07-31 Thread via cfe-commits

https://github.com/Sirraide created 
https://github.com/llvm/llvm-project/pull/101448

Implement P2893R3 ‘Variadic friends’ for C++26.

The implementation proper is mostly done, from what I can tell, but I have a 
few questions, so I thought I’d be best to list them all here (some are for me 
to investigate, some I’d appreciate it if anyone would happen to know the 
answer to them):
- [ ] I don’t know much about the `ASTImporter`, so I’m not entirely sure if I 
did everything right in there.
- [ ] Still need to add tests for [CWG 
2917](https://cplusplus.github.io/CWG/issues/2917.html), which I filed while 
working on this, to the DR test suite proper. (@Endilll Sorry for asking this 
*again*, but do I need to run the script that updates the DR tests as part of 
this, or should that be done in a separate pr before this?)
- [ ] Do we want to expose this in earlier language modes? The syntax wasn’t 
valid before, so I *believe* there shouldn’t be an issue with that, but I’m not 
sure.
- [ ] There are some edge cases that mostly involve what we treat as 
unsupported friend declarations that I still need to either reject or also 
convert to unsupported friend declarations.
- [ ] Is there ever a situation that would cause us to have to instantiate a 
`FriendPackDecl` in the `TemplateDeclInstantiator`? We do that for 
`UsingPackDecl`s, but those are sufficiently different enough from the former 
that I’m not sure about it. I at least haven’t been able to come up w/ any 
cases that would cause us to try and instantiate one.
- [ ] The diagnostics for some invalid declarations (e.g. CWG 2917) could still 
be better imo.
- [ ] I had to add a hack to the decl printer to get e.g. `friend int, long;` 
to be printed like that instead of as separate declarations (which they 
currently are in the AST). Is that fine or is that too much of a hack?
- [ ] Whether an ellipsis is present after a friend-type-specifier is currently 
handled via a separate parameter in some of the Sema functions. It would be 
possible to instead store that information in the `DeclSpec`, but I haven’t 
written too much parser code in Clang before, and wasn’t sure how strict we are 
wrt putting things in that class because I don’t think the `...` is part of the 
specifier according to the grammar.

Thanks also to @zyn0217, who was working on this before me; I’ve taken over 
working on this since they didn’t have time for it anymore. I’ve incorporated 
parts of their WIP patch, so I’ll credit them as a co-author whenever this gets 
merged.

This closes #98587.


>From 1fd8db659961fd1702c0c786feb71ad6c5998aa8 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Wed, 31 Jul 2024 21:44:02 +0200
Subject: [PATCH 1/5] [Parser] Parse variadic friends

---
 clang/include/clang/AST/DeclFriend.h  | 15 +++-
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Sema/Sema.h   |  6 +-
 clang/lib/AST/ASTImporter.cpp |  7 +-
 clang/lib/AST/DeclFriend.cpp  | 14 +--
 clang/lib/AST/DeclPrinter.cpp |  3 +
 clang/lib/AST/ODRHash.cpp |  1 +
 clang/lib/AST/TextNodeDumper.cpp  |  2 +
 clang/lib/Parse/ParseDeclCXX.cpp  | 89 +++
 clang/lib/Sema/SemaDecl.cpp   |  8 +-
 clang/lib/Sema/SemaDeclCXX.cpp| 26 --
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  3 +
 clang/lib/Serialization/ASTReaderDecl.cpp |  1 +
 clang/lib/Serialization/ASTWriterDecl.cpp |  1 +
 .../Parser/cxx2c-variadic-friends-errors.cpp  | 63 +
 clang/test/Parser/cxx2c-variadic-friends.cpp  | 60 +
 16 files changed, 278 insertions(+), 23 deletions(-)
 create mode 100644 clang/test/Parser/cxx2c-variadic-friends-errors.cpp
 create mode 100644 clang/test/Parser/cxx2c-variadic-friends.cpp

diff --git a/clang/include/clang/AST/DeclFriend.h 
b/clang/include/clang/AST/DeclFriend.h
index 9789282f351a5..1c2c86d3ef384 100644
--- a/clang/include/clang/AST/DeclFriend.h
+++ b/clang/include/clang/AST/DeclFriend.h
@@ -70,6 +70,9 @@ class FriendDecl final
   // Location of the 'friend' specifier.
   SourceLocation FriendLoc;
 
+  // Location of the '...', if present.
+  SourceLocation EllipsisLoc;
+
   /// True if this 'friend' declaration is unsupported.  Eventually we
   /// will support every possible friend declaration, but for now we
   /// silently ignore some and set this flag to authorize all access.
@@ -82,10 +85,11 @@ class FriendDecl final
   unsigned NumTPLists : 31;
 
   FriendDecl(DeclContext *DC, SourceLocation L, FriendUnion Friend,
- SourceLocation FriendL,
+ SourceLocation FriendL, SourceLocation EllipsisLoc,
  ArrayRef FriendTypeTPLists)
   : Decl(Decl::Friend, DC, L), Friend(Friend), FriendLoc(FriendL),
-UnsupportedFriend(false), NumTPLists(FriendTypeTPLists.size()) {
+EllipsisLoc(EllipsisLoc), UnsupportedFriend(false),
+

[clang] [clang][CUDA] Add 'noconvergent' function and statement attribute (PR #100637)

2024-07-31 Thread Sameer Sahasrabuddhe via cfe-commits

ssahasra wrote:

> > Please also update the documentation for the attribute and the release 
> > notes.
> 
> It looks like you may have overlooked the request to add release notes for 
> this new feature.

@darkbuck, please revert and address the documentation!

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


[clang] [clang] fix classification of a string literal expression used as initializer (PR #101447)

2024-07-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

Since 3bf72d7d64b8465acd4f4af1a469d68d9dc86058 we have made a simplification 
where we transform a string literal into a prvalue, where normally they would 
always be lvalues.

This patch fixes expression classification to account for this case.

Fixes #82167

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3-1) 
- (modified) clang/lib/AST/ExprClassification.cpp (+6-2) 
- (added) clang/test/SemaCXX/GH82167.cpp (+15) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..c4dca7252e87a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -130,7 +130,7 @@ Improvements to Clang's diagnostics
 - Some template related diagnostics have been improved.
 
   .. code-block:: c++
-
+
  void foo() { template  int i; } // error: templates can only be 
declared in namespace or class scope
 
  struct S {
@@ -170,6 +170,8 @@ Bug Fixes to C++ Support
 - Fixed a failed assertion when checking invalid delete operator declaration. 
(#GH96191)
 - Fix a crash when checking destructor reference with an invalid initializer. 
(#GH97230)
 - Clang now correctly parses potentially declarative nested-name-specifiers in 
pointer-to-member declarators.
+- Fix a crash when checking the initialzier of an object that was initialized
+  with a string literal. (#GH82167)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/ExprClassification.cpp 
b/clang/lib/AST/ExprClassification.cpp
index 6482cb6d39acc..3b3c0af826079 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -119,8 +119,6 @@ static Cl::Kinds ClassifyInternal(ASTContext , const 
Expr *E) {
 
 // First come the expressions that are always lvalues, unconditionally.
   case Expr::ObjCIsaExprClass:
-// C++ [expr.prim.general]p1: A string literal is an lvalue.
-  case Expr::StringLiteralClass:
 // @encode is equivalent to its string
   case Expr::ObjCEncodeExprClass:
 // __func__ and friends are too.
@@ -150,6 +148,12 @@ static Cl::Kinds ClassifyInternal(ASTContext , const 
Expr *E) {
   case Expr::OMPIteratorExprClass:
 return Cl::CL_LValue;
 
+// C++ [expr.prim.general]p1: A string literal is an lvalue.
+// Except we special case them as prvalues when they are used for
+// initialization.
+  case Expr::StringLiteralClass:
+return E->isLValue() ? Cl::CL_LValue : Cl::CL_PRValue;
+
 // C99 6.5.2.5p5 says that compound literals are lvalues.
 // In C++, they're prvalue temporaries, except for file-scope arrays.
   case Expr::CompoundLiteralExprClass:
diff --git a/clang/test/SemaCXX/GH82167.cpp b/clang/test/SemaCXX/GH82167.cpp
new file mode 100644
index 0..0e13a5a3e1b6d
--- /dev/null
+++ b/clang/test/SemaCXX/GH82167.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++23 -fsyntax-only 
-verify %s
+// expected-no-diagnostics
+
+namespace t1 {
+  struct array {
+char elems[2];
+  };
+
+  template  struct Literal {
+array arr;
+constexpr Literal() : arr("") {}
+  };
+
+  template struct Literal<0>;
+} // namespace t1

``




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


[clang] [clang] fix classification of a string literal expression used as initializer (PR #101447)

2024-07-31 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/101447

Since 3bf72d7d64b8465acd4f4af1a469d68d9dc86058 we have made a simplification 
where we transform a string literal into a prvalue, where normally they would 
always be lvalues.

This patch fixes expression classification to account for this case.

Fixes #82167

>From 345d5d15f7d8992ce1ecd575f83ea85088bb27c1 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 1 Aug 2024 00:01:19 -0300
Subject: [PATCH] [clang] fix classification of a string literal expression
 used as initialzier

Since 3bf72d7d64b8465acd4f4af1a469d68d9dc86058 we have made a
simplification where we transform a string literal into a prvalue,
where normally they would always be lvalues.

This patch fixes expression classification to account for this
case.

Fixes #82167
---
 clang/docs/ReleaseNotes.rst  |  4 +++-
 clang/lib/AST/ExprClassification.cpp |  8 ++--
 clang/test/SemaCXX/GH82167.cpp   | 15 +++
 3 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/SemaCXX/GH82167.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..c4dca7252e87a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -130,7 +130,7 @@ Improvements to Clang's diagnostics
 - Some template related diagnostics have been improved.
 
   .. code-block:: c++
-
+
  void foo() { template  int i; } // error: templates can only be 
declared in namespace or class scope
 
  struct S {
@@ -170,6 +170,8 @@ Bug Fixes to C++ Support
 - Fixed a failed assertion when checking invalid delete operator declaration. 
(#GH96191)
 - Fix a crash when checking destructor reference with an invalid initializer. 
(#GH97230)
 - Clang now correctly parses potentially declarative nested-name-specifiers in 
pointer-to-member declarators.
+- Fix a crash when checking the initialzier of an object that was initialized
+  with a string literal. (#GH82167)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/ExprClassification.cpp 
b/clang/lib/AST/ExprClassification.cpp
index 6482cb6d39acc..3b3c0af826079 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -119,8 +119,6 @@ static Cl::Kinds ClassifyInternal(ASTContext , const 
Expr *E) {
 
 // First come the expressions that are always lvalues, unconditionally.
   case Expr::ObjCIsaExprClass:
-// C++ [expr.prim.general]p1: A string literal is an lvalue.
-  case Expr::StringLiteralClass:
 // @encode is equivalent to its string
   case Expr::ObjCEncodeExprClass:
 // __func__ and friends are too.
@@ -150,6 +148,12 @@ static Cl::Kinds ClassifyInternal(ASTContext , const 
Expr *E) {
   case Expr::OMPIteratorExprClass:
 return Cl::CL_LValue;
 
+// C++ [expr.prim.general]p1: A string literal is an lvalue.
+// Except we special case them as prvalues when they are used for
+// initialization.
+  case Expr::StringLiteralClass:
+return E->isLValue() ? Cl::CL_LValue : Cl::CL_PRValue;
+
 // C99 6.5.2.5p5 says that compound literals are lvalues.
 // In C++, they're prvalue temporaries, except for file-scope arrays.
   case Expr::CompoundLiteralExprClass:
diff --git a/clang/test/SemaCXX/GH82167.cpp b/clang/test/SemaCXX/GH82167.cpp
new file mode 100644
index 0..0e13a5a3e1b6d
--- /dev/null
+++ b/clang/test/SemaCXX/GH82167.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++23 -fsyntax-only 
-verify %s
+// expected-no-diagnostics
+
+namespace t1 {
+  struct array {
+char elems[2];
+  };
+
+  template  struct Literal {
+array arr;
+constexpr Literal() : arr("") {}
+  };
+
+  template struct Literal<0>;
+} // namespace t1

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


[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

2024-07-31 Thread Joshua Batista via cfe-commits

https://github.com/bob80905 updated 
https://github.com/llvm/llvm-project/pull/101433

>From b17ddcc6f2081135125d6178b22d033bcf7c0998 Mon Sep 17 00:00:00 2001
From: Joshua Batista 
Date: Wed, 31 Jul 2024 17:01:56 -0700
Subject: [PATCH 1/3] add attrs to handle in record decl, add ast dump test to
 verify

---
 clang/lib/CodeGen/CGHLSLRuntime.cpp   | 24 +---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 28 ---
 .../hlsl_resource_handle_attrs.hlsl   | 14 ++
 3 files changed, 40 insertions(+), 26 deletions(-)
 create mode 100644 clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 6a6aff594fb0f..a475d46966969 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -280,18 +280,22 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl 
*D, GlobalVariable *GV) {
   const auto *RD = Ty->getAsCXXRecordDecl();
   if (!RD)
 return;
-  const auto *HLSLResAttr = RD->getAttr();
-  const auto *HLSLResClassAttr = RD->getAttr();
-  if (!HLSLResAttr || !HLSLResClassAttr)
-return;
+  // the resource related attributes are on the handle member 
+  // inside the record decl
+  for (auto *FD : RD->fields()) {
+const auto *HLSLResAttr = FD->getAttr();
+const auto *HLSLResClassAttr = FD->getAttr();
+if (!HLSLResAttr || !HLSLResClassAttr)
+  continue;
 
-  llvm::hlsl::ResourceClass RC = HLSLResClassAttr->getResourceClass();
-  llvm::hlsl::ResourceKind RK = HLSLResAttr->getResourceKind();
-  bool IsROV = HLSLResAttr->getIsROV();
-  llvm::hlsl::ElementType ET = calculateElementType(CGM.getContext(), Ty);
+llvm::hlsl::ResourceClass RC = HLSLResClassAttr->getResourceClass();
+llvm::hlsl::ResourceKind RK = HLSLResAttr->getResourceKind();
+bool IsROV = HLSLResAttr->getIsROV();
+llvm::hlsl::ElementType ET = calculateElementType(CGM.getContext(), Ty);
 
-  BufferResBinding Binding(D->getAttr());
-  addBufferResourceAnnotation(GV, RC, RK, IsROV, ET, Binding);
+BufferResBinding Binding(D->getAttr());
+addBufferResourceAnnotation(GV, RC, RK, IsROV, ET, Binding);
+   }
 }
 
 CGHLSLRuntime::BufferResBinding::BufferResBinding(
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index ca88d138aef5d..e651f9cd967f5 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -101,8 +101,9 @@ struct BuiltinTypeDeclBuilder {
 return *this;
   }
 
-  BuiltinTypeDeclBuilder &
-  addHandleMember(AccessSpecifier Access = AccessSpecifier::AS_private) {
+  BuiltinTypeDeclBuilder (
+  ResourceClass RC, ResourceKind RK,
+  bool IsROV, AccessSpecifier Access = AccessSpecifier::AS_private) {
 if (Record->isCompleteDefinition())
   return *this;
 QualType Ty = Record->getASTContext().VoidPtrTy;
@@ -112,17 +113,13 @@ struct BuiltinTypeDeclBuilder {
 Ty = Record->getASTContext().getPointerType(
 QualType(TTD->getTypeForDecl(), 0));
 }
-return addMemberVariable("h", Ty, Access);
-  }
-
-  BuiltinTypeDeclBuilder (ResourceClass RC,
-   ResourceKind RK, bool IsROV) {
-if (Record->isCompleteDefinition())
-  return *this;
-Record->addAttr(
-HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC));
-Record->addAttr(
-HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV));
+// add handle member
+addMemberVariable("h", Ty, Access);
+// add resource attributes to handle
+auto *FD = Fields["h"];
+FD->addAttr(HLSLResourceClassAttr::CreateImplicit(FD->getASTContext(), 
RC));
+FD->addAttr(
+HLSLResourceAttr::CreateImplicit(FD->getASTContext(), RK, IsROV));
 return *this;
   }
 
@@ -489,9 +486,8 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl 
*Decl, Sema ,
   ResourceClass RC, ResourceKind 
RK,
   bool IsROV) {
   return BuiltinTypeDeclBuilder(Decl)
-  .addHandleMember()
-  .addDefaultHandleConstructor(S, RC)
-  .annotateHLSLResource(RC, RK, IsROV);
+  .addHandleMember(RC, RK, IsROV)
+  .addDefaultHandleConstructor(S, RC);
 }
 
 void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
diff --git a/clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl 
b/clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl
new file mode 100644
index 0..6b7bcbc35b8f8
--- /dev/null
+++ b/clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o 
- %s | FileCheck %s
+
+// CHECK: -ClassTemplateDecl 0x{{[0-9a-f]+}} <>  
implicit RWBuffer
+// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} <>  
implicit class RWBuffer definition
+// CHECK: -FieldDecl 

[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

2024-07-31 Thread via cfe-commits

antangelo wrote:

Friendly ping

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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-07-31 Thread Shafik Yaghmour via cfe-commits

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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-07-31 Thread Shafik Yaghmour via cfe-commits


@@ -9267,14 +9267,14 @@ bool Sema::RequireLiteralType(SourceLocation Loc, 
QualType T,
   if (!RT)
 return true;
 
-  const CXXRecordDecl *RD = cast(RT->getDecl());
-
   // A partially-defined class type can't be a literal type, because a literal
   // class type must have a trivial destructor (which can't be checked until
   // the class definition is complete).
   if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
 return true;
 
+  const CXXRecordDecl *RD = cast(RT->getDecl());

shafik wrote:

I am surprised we have not run into this before this code was added in 2012.

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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-07-31 Thread Shafik Yaghmour via cfe-commits

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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-07-31 Thread Shafik Yaghmour via cfe-commits

https://github.com/shafik commented:

This looks good but you need to add a bit more details to your summary, more 
specifically what case caused the bug to emerge.

I am also curious why this does not show up in C++, we obtain a similar 
diagnostic but no crash. 

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


[clang] [Clang][SemaCXX] Fix bug where unexpanded lambda captures where assumed to have size 1 (PR #101385)

2024-07-31 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

I remembered @LYP951018 shared me with a case involving PackIndexingExprs that 
was incorrectly rejected due to the mishandling of PackExpansionExprs:

```cpp

namespace init_capture_pack {

void init_capture() {
  auto L = [](auto... x) {
return [x...](auto... y) {
  return [... w = y]() {
return w...[3];
  };
};
  };
  static_assert(L()(0, 1, 2, 3)() == 3);
}

```

I have prepared for a fix on my branch 
https://github.com/zyn0217/llvm-project/commit/72fc2fcf472066a78c1496119aabf23a93c06ca0,
 which somehow relies on this "the unexpanded pack should have size 1" feature. 
I applied this PR locally only to find we ran into a crash with the case 
afterward.

```
bool clang::Sema::DiagnoseUnexpandedParameterPack(Expr *, 
UnexpandedParameterPackContext): Assertion `!Unexpanded.empty() && "Unable to 
find unexpanded parameter packs"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: ../llvm-project-Build/BuildDebug/bin/clang 
-fsyntax-only -fno-crash-diagnostics -std=c++20 /clangd-test/pack-indexing.cpp 
-DCRASH
1.  /clangd-test/pack-indexing.cpp:11:19: current parser token ')'
2.  /clangd-test/pack-indexing.cpp:1:1: parsing namespace 
'init_capture_pack'
3.  /clangd-test/pack-indexing.cpp:3:21: parsing function body 
'init_capture_pack::init_capture'
4.  /clangd-test/pack-indexing.cpp:3:21: in compound statement ('{}')
5.  /clangd-test/pack-indexing.cpp:4:12: instantiating function definition 
'init_capture_pack::init_capture()::(anonymous class)::operator()<>'

#11 0x7f68109c9dad 
clang::Sema::DiagnoseUnexpandedParameterPack(clang::Expr*, 
clang::Sema::UnexpandedParameterPackContext) 
/repo/llvm-project/clang/lib/Sema/SemaTemplateVariadic.cpp:427:43
#12 0x7f681049bdd1 clang::Sema::BuildReturnStmt(clang::SourceLocation, 
clang::Expr*, bool) /repo/llvm-project/clang/lib/Sema/SemaStmt.cpp:3782:7
#13 0x7f681091c6a3 clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::RebuildReturnStmt(clang::SourceLocation, 
clang::Expr*) /repo/llvm-project/clang/lib/Sema/TreeTransform.h:1501:22
#14 0x7f68109045d7 clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformReturnStmt(clang::ReturnStmt*) 
/repo/llvm-project/clang/lib/Sema/TreeTransform.h:8288:23
#15 0x7f68108be03e clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::StmtDiscardKind) 
/repo/llvm-project-Build/BuildDebug/tools/clang/include/clang/AST/StmtNodes.inc:926:1
#16 0x7f68108dabbb clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, 
bool) /repo/llvm-project/clang/lib/Sema/TreeTransform.h:7859:38
```

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


[clang] [llvm] [PPC] Implement BCD assist builtins (PR #101390)

2024-07-31 Thread Qiu Chaofan via cfe-commits


@@ -515,6 +515,16 @@ TARGET_BUILTIN(__builtin_altivec_vctzh, "V8UsV8Us", "", 
"power9-vector")
 TARGET_BUILTIN(__builtin_altivec_vctzw, "V4UiV4Ui", "", "power9-vector")
 TARGET_BUILTIN(__builtin_altivec_vctzd, "V2ULLiV2ULLi", "", "power9-vector")
 
+// P7 BCD builtins.
+TARGET_BUILTIN(__builtin_cdtbcd, "UiUi", "", "isa-v206-instructions")
+TARGET_BUILTIN(__builtin_cbcdtd, "UiUi", "", "isa-v206-instructions")
+TARGET_BUILTIN(__builtin_addg6s, "UiUiUi", "", "isa-v206-instructions")

ecnelises wrote:

It's surprising that `__builtin_xxx` and `__builtin_ppc_xxx` has difference in 
signature. Does XL have these?

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


[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)

2024-07-31 Thread Sergei Barannikov via cfe-commits


@@ -6077,6 +6077,10 @@ def mvis3 : Flag<["-"], "mvis3">, 
Group;
 def mno_vis3 : Flag<["-"], "mno-vis3">, Group;
 def mhard_quad_float : Flag<["-"], "mhard-quad-float">, 
Group;
 def msoft_quad_float : Flag<["-"], "msoft-quad-float">, 
Group;
+def mv8plus : Flag<["-"], "mv8plus">, Group,
+  HelpText<"Enable V8+ mode, allowing use of 64-bit V9 instructions in 32-bit 
code">;

s-barannikov wrote:

Never mind.

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


[clang] [Clang] Improve generation of GEP and RecordDecl loop (PR #101434)

2024-07-31 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Bill Wendling (bwendling)


Changes

As with other loops, we need only look at a RecordDecl's FieldDecls. Convert to 
using them. In the meantime, we can improve the generation of the 'counted_by' 
FieldDecl's GEP: create one GEP instead of a series of GEPs.

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


4 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+20-21) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+3-3) 
- (modified) clang/test/CodeGen/attr-counted-by.c (+4-4) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 0c2ee446aa303..b2cab812985af 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -996,7 +996,7 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, 
unsigned Type,
 
   // Build a load of the counted_by field.
   bool IsSigned = CountedByFD->getType()->isSignedIntegerType();
-  Value *CountedByInst = EmitCountedByFieldExpr(Base, FAMDecl, CountedByFD);
+  Value *CountedByInst = EmitLoadOfCountedByField(Base, FAMDecl, CountedByFD);
   if (!CountedByInst)
 return getDefaultBuiltinObjectSizeResult(Type, ResType);
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 5f58a64d8386c..cf22ff43c35f7 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1067,8 +1067,7 @@ class StructAccessBase
 
 } // end anonymous namespace
 
-using RecIndicesTy =
-SmallVector, 8>;
+using RecIndicesTy = SmallVector;
 
 static bool getGEPIndicesToField(CodeGenFunction , const RecordDecl *RD,
  const FieldDecl *Field,
@@ -1083,7 +1082,7 @@ static bool getGEPIndicesToField(CodeGenFunction , 
const RecordDecl *RD,
 
 FieldNo = Layout.getLLVMFieldNo(FD);
 if (FD == Field) {
-  Indices.emplace_back(std::make_pair(RD, CGF.Builder.getInt32(FieldNo)));
+  Indices.emplace_back(CGF.Builder.getInt32(FieldNo));
   return true;
 }
 
@@ -1092,7 +1091,7 @@ static bool getGEPIndicesToField(CodeGenFunction , 
const RecordDecl *RD,
   if (getGEPIndicesToField(CGF, Ty->getAsRecordDecl(), Field, Indices)) {
 if (RD->isUnion())
   FieldNo = 0;
-Indices.emplace_back(std::make_pair(RD, 
CGF.Builder.getInt32(FieldNo)));
+Indices.emplace_back(CGF.Builder.getInt32(FieldNo));
 return true;
   }
 }
@@ -1109,7 +1108,7 @@ static bool getGEPIndicesToField(CodeGenFunction , 
const RecordDecl *RD,
 /// - \p FAMDecl: the \p Decl for the flexible array member. It may not be
 ///   within the top-level struct.
 /// - \p CountDecl: must be within the same non-anonymous struct as \p FAMDecl.
-llvm::Value *CodeGenFunction::EmitCountedByFieldExpr(
+llvm::Value *CodeGenFunction::EmitLoadOfCountedByField(
 const Expr *Base, const FieldDecl *FAMDecl, const FieldDecl *CountDecl) {
   const RecordDecl *RD = 
CountDecl->getParent()->getOuterLexicalRecordContext();
 
@@ -1136,15 +1135,15 @@ llvm::Value *CodeGenFunction::EmitCountedByFieldExpr(
 return nullptr;
   }
 
-  llvm::Value *Zero = Builder.getInt32(0);
   RecIndicesTy Indices;
-
   getGEPIndicesToField(*this, RD, CountDecl, Indices);
+  if (Indices.empty())
+return nullptr;
 
-  for (auto I = Indices.rbegin(), E = Indices.rend(); I != E; ++I)
-Res = Builder.CreateInBoundsGEP(
-ConvertType(QualType(I->first->getTypeForDecl(), 0)), Res,
-{Zero, I->second}, "..counted_by.gep");
+  Indices.emplace_back(Builder.getInt32(0));
+  Res = Builder.CreateInBoundsGEP(
+  ConvertType(QualType(RD->getTypeForDecl(), 0)), Res,
+  RecIndicesTy(llvm::reverse(Indices)), "..counted_by.gep");
 
   return Builder.CreateAlignedLoad(ConvertType(CountDecl->getType()), Res,
getIntAlign(), "..counted_by.load");
@@ -4108,25 +4107,25 @@ static Address emitArraySubscriptGEP(CodeGenFunction 
, Address addr,
 
 /// The offset of a field from the beginning of the record.
 static bool getFieldOffsetInBits(CodeGenFunction , const RecordDecl *RD,
- const FieldDecl *FD, int64_t ) {
+ const FieldDecl *Field, int64_t ) {
   ASTContext  = CGF.getContext();
   const ASTRecordLayout  = Ctx.getASTRecordLayout(RD);
   unsigned FieldNo = 0;
 
-  for (const Decl *D : RD->decls()) {
-if (const auto *Record = dyn_cast(D))
-  if (getFieldOffsetInBits(CGF, Record, FD, Offset)) {
-Offset += Layout.getFieldOffset(FieldNo);
-return true;
-  }
+  for (const FieldDecl *FD : RD->fields()) {
+if (FD == Field) {
+  Offset += Layout.getFieldOffset(FieldNo);
+  return true;
+}
 
-if (const auto *Field = dyn_cast(D))
-  if (FD == Field) {
+QualType Ty = FD->getType();
+if (Ty->isRecordType())
+  if 

[clang] [Clang] Improve generation of GEP and RecordDecl loop (PR #101434)

2024-07-31 Thread Bill Wendling via cfe-commits

https://github.com/bwendling created 
https://github.com/llvm/llvm-project/pull/101434

As with other loops, we need only look at a RecordDecl's FieldDecls. Convert to 
using them. In the meantime, we can improve the generation of the 'counted_by' 
FieldDecl's GEP: create one GEP instead of a series of GEPs.

>From 580fb57202daa5fcfba3e0fdcc50bb3786dc9798 Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Wed, 31 Jul 2024 16:53:21 -0700
Subject: [PATCH] [Clang] Improve generation of GEP and RecordDecl loop

As with other loops, we need only look at a RecordDecl's FieldDecls.
Convert to using them. In the meantime, we can improve the generation of
the 'counted_by' FieldDecl's GEP: create one GEP instead of a series of
GEPs.
---
 clang/lib/CodeGen/CGBuiltin.cpp  |  2 +-
 clang/lib/CodeGen/CGExpr.cpp | 41 ++--
 clang/lib/CodeGen/CodeGenFunction.h  |  6 ++--
 clang/test/CodeGen/attr-counted-by.c |  8 +++---
 4 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 0c2ee446aa303..b2cab812985af 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -996,7 +996,7 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, 
unsigned Type,
 
   // Build a load of the counted_by field.
   bool IsSigned = CountedByFD->getType()->isSignedIntegerType();
-  Value *CountedByInst = EmitCountedByFieldExpr(Base, FAMDecl, CountedByFD);
+  Value *CountedByInst = EmitLoadOfCountedByField(Base, FAMDecl, CountedByFD);
   if (!CountedByInst)
 return getDefaultBuiltinObjectSizeResult(Type, ResType);
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 5f58a64d8386c..cf22ff43c35f7 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1067,8 +1067,7 @@ class StructAccessBase
 
 } // end anonymous namespace
 
-using RecIndicesTy =
-SmallVector, 8>;
+using RecIndicesTy = SmallVector;
 
 static bool getGEPIndicesToField(CodeGenFunction , const RecordDecl *RD,
  const FieldDecl *Field,
@@ -1083,7 +1082,7 @@ static bool getGEPIndicesToField(CodeGenFunction , 
const RecordDecl *RD,
 
 FieldNo = Layout.getLLVMFieldNo(FD);
 if (FD == Field) {
-  Indices.emplace_back(std::make_pair(RD, CGF.Builder.getInt32(FieldNo)));
+  Indices.emplace_back(CGF.Builder.getInt32(FieldNo));
   return true;
 }
 
@@ -1092,7 +1091,7 @@ static bool getGEPIndicesToField(CodeGenFunction , 
const RecordDecl *RD,
   if (getGEPIndicesToField(CGF, Ty->getAsRecordDecl(), Field, Indices)) {
 if (RD->isUnion())
   FieldNo = 0;
-Indices.emplace_back(std::make_pair(RD, 
CGF.Builder.getInt32(FieldNo)));
+Indices.emplace_back(CGF.Builder.getInt32(FieldNo));
 return true;
   }
 }
@@ -1109,7 +1108,7 @@ static bool getGEPIndicesToField(CodeGenFunction , 
const RecordDecl *RD,
 /// - \p FAMDecl: the \p Decl for the flexible array member. It may not be
 ///   within the top-level struct.
 /// - \p CountDecl: must be within the same non-anonymous struct as \p FAMDecl.
-llvm::Value *CodeGenFunction::EmitCountedByFieldExpr(
+llvm::Value *CodeGenFunction::EmitLoadOfCountedByField(
 const Expr *Base, const FieldDecl *FAMDecl, const FieldDecl *CountDecl) {
   const RecordDecl *RD = 
CountDecl->getParent()->getOuterLexicalRecordContext();
 
@@ -1136,15 +1135,15 @@ llvm::Value *CodeGenFunction::EmitCountedByFieldExpr(
 return nullptr;
   }
 
-  llvm::Value *Zero = Builder.getInt32(0);
   RecIndicesTy Indices;
-
   getGEPIndicesToField(*this, RD, CountDecl, Indices);
+  if (Indices.empty())
+return nullptr;
 
-  for (auto I = Indices.rbegin(), E = Indices.rend(); I != E; ++I)
-Res = Builder.CreateInBoundsGEP(
-ConvertType(QualType(I->first->getTypeForDecl(), 0)), Res,
-{Zero, I->second}, "..counted_by.gep");
+  Indices.emplace_back(Builder.getInt32(0));
+  Res = Builder.CreateInBoundsGEP(
+  ConvertType(QualType(RD->getTypeForDecl(), 0)), Res,
+  RecIndicesTy(llvm::reverse(Indices)), "..counted_by.gep");
 
   return Builder.CreateAlignedLoad(ConvertType(CountDecl->getType()), Res,
getIntAlign(), "..counted_by.load");
@@ -4108,25 +4107,25 @@ static Address emitArraySubscriptGEP(CodeGenFunction 
, Address addr,
 
 /// The offset of a field from the beginning of the record.
 static bool getFieldOffsetInBits(CodeGenFunction , const RecordDecl *RD,
- const FieldDecl *FD, int64_t ) {
+ const FieldDecl *Field, int64_t ) {
   ASTContext  = CGF.getContext();
   const ASTRecordLayout  = Ctx.getASTRecordLayout(RD);
   unsigned FieldNo = 0;
 
-  for (const Decl *D : RD->decls()) {
-if (const auto *Record = dyn_cast(D))
-  if (getFieldOffsetInBits(CGF, Record, FD, Offset)) {
-Offset += Layout.getFieldOffset(FieldNo);
-

[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

2024-07-31 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 7583c484c81218ab4c8c2fba2774cb518d8bbd43 
b17ddcc6f2081135125d6178b22d033bcf7c0998 --extensions cpp -- 
clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/Sema/HLSLExternalSemaSource.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index a475d46966..defc79683e 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -280,7 +280,7 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, 
GlobalVariable *GV) {
   const auto *RD = Ty->getAsCXXRecordDecl();
   if (!RD)
 return;
-  // the resource related attributes are on the handle member 
+  // the resource related attributes are on the handle member
   // inside the record decl
   for (auto *FD : RD->fields()) {
 const auto *HLSLResAttr = FD->getAttr();
@@ -295,7 +295,7 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, 
GlobalVariable *GV) {
 
 BufferResBinding Binding(D->getAttr());
 addBufferResourceAnnotation(GV, RC, RK, IsROV, ET, Binding);
-   }
+  }
 }
 
 CGHLSLRuntime::BufferResBinding::BufferResBinding(
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index e651f9cd96..2f3aaa0bb2 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -101,9 +101,9 @@ struct BuiltinTypeDeclBuilder {
 return *this;
   }
 
-  BuiltinTypeDeclBuilder (
-  ResourceClass RC, ResourceKind RK,
-  bool IsROV, AccessSpecifier Access = AccessSpecifier::AS_private) {
+  BuiltinTypeDeclBuilder &
+  addHandleMember(ResourceClass RC, ResourceKind RK, bool IsROV,
+  AccessSpecifier Access = AccessSpecifier::AS_private) {
 if (Record->isCompleteDefinition())
   return *this;
 QualType Ty = Record->getASTContext().VoidPtrTy;

``




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


[clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-31 Thread Helena Kotas via cfe-commits

hekota wrote:

> > I also don't see anywhere that actually successfully uses 
> > `__builtin_hlsl_resource_t`. Am I missing it, or should I not expect to see 
> > it?
> 
> You are correct - the type cannot be directly declared in user code, so the 
> tests only check for errors and that the type shows up properly in AST. It is 
> possible to use this type internally in Clang or in implicit headers though, 
> which are two ways how we could define `RWBuffer` and other builtin types 
> that will internally use `__builtin_hlsl_resource_t` handle. That will come 
> alive in (#84824).

The PR has been updated to allow instantiation of `__hlsl_resource_t` in struct 
fields.


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


[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

2024-07-31 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-hlsl

Author: Joshua Batista (bob80905)


Changes

This PR attaches the resource attributes, `HLSLResourceAttr` and 
`HLSLResourceClassAttr`, to the handle contained within such resource classes 
like `RWBuffer`. CodeGen will now search for fields within HLSL resource decls, 
and emit previous data based on attributes on the handle member. An AST-dump 
test was added to verify that the resource attribute is attached to the handle 
within the resource record decl.
Fixes #98556

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


3 Files Affected:

- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+14-10) 
- (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+12-16) 
- (added) clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl (+14) 


``diff
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 6a6aff594fb0f..a475d46966969 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -280,18 +280,22 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl 
*D, GlobalVariable *GV) {
   const auto *RD = Ty->getAsCXXRecordDecl();
   if (!RD)
 return;
-  const auto *HLSLResAttr = RD->getAttr();
-  const auto *HLSLResClassAttr = RD->getAttr();
-  if (!HLSLResAttr || !HLSLResClassAttr)
-return;
+  // the resource related attributes are on the handle member 
+  // inside the record decl
+  for (auto *FD : RD->fields()) {
+const auto *HLSLResAttr = FD->getAttr();
+const auto *HLSLResClassAttr = FD->getAttr();
+if (!HLSLResAttr || !HLSLResClassAttr)
+  continue;
 
-  llvm::hlsl::ResourceClass RC = HLSLResClassAttr->getResourceClass();
-  llvm::hlsl::ResourceKind RK = HLSLResAttr->getResourceKind();
-  bool IsROV = HLSLResAttr->getIsROV();
-  llvm::hlsl::ElementType ET = calculateElementType(CGM.getContext(), Ty);
+llvm::hlsl::ResourceClass RC = HLSLResClassAttr->getResourceClass();
+llvm::hlsl::ResourceKind RK = HLSLResAttr->getResourceKind();
+bool IsROV = HLSLResAttr->getIsROV();
+llvm::hlsl::ElementType ET = calculateElementType(CGM.getContext(), Ty);
 
-  BufferResBinding Binding(D->getAttr());
-  addBufferResourceAnnotation(GV, RC, RK, IsROV, ET, Binding);
+BufferResBinding Binding(D->getAttr());
+addBufferResourceAnnotation(GV, RC, RK, IsROV, ET, Binding);
+   }
 }
 
 CGHLSLRuntime::BufferResBinding::BufferResBinding(
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index ca88d138aef5d..e651f9cd967f5 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -101,8 +101,9 @@ struct BuiltinTypeDeclBuilder {
 return *this;
   }
 
-  BuiltinTypeDeclBuilder &
-  addHandleMember(AccessSpecifier Access = AccessSpecifier::AS_private) {
+  BuiltinTypeDeclBuilder (
+  ResourceClass RC, ResourceKind RK,
+  bool IsROV, AccessSpecifier Access = AccessSpecifier::AS_private) {
 if (Record->isCompleteDefinition())
   return *this;
 QualType Ty = Record->getASTContext().VoidPtrTy;
@@ -112,17 +113,13 @@ struct BuiltinTypeDeclBuilder {
 Ty = Record->getASTContext().getPointerType(
 QualType(TTD->getTypeForDecl(), 0));
 }
-return addMemberVariable("h", Ty, Access);
-  }
-
-  BuiltinTypeDeclBuilder (ResourceClass RC,
-   ResourceKind RK, bool IsROV) {
-if (Record->isCompleteDefinition())
-  return *this;
-Record->addAttr(
-HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC));
-Record->addAttr(
-HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV));
+// add handle member
+addMemberVariable("h", Ty, Access);
+// add resource attributes to handle
+auto *FD = Fields["h"];
+FD->addAttr(HLSLResourceClassAttr::CreateImplicit(FD->getASTContext(), 
RC));
+FD->addAttr(
+HLSLResourceAttr::CreateImplicit(FD->getASTContext(), RK, IsROV));
 return *this;
   }
 
@@ -489,9 +486,8 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl 
*Decl, Sema ,
   ResourceClass RC, ResourceKind 
RK,
   bool IsROV) {
   return BuiltinTypeDeclBuilder(Decl)
-  .addHandleMember()
-  .addDefaultHandleConstructor(S, RC)
-  .annotateHLSLResource(RC, RK, IsROV);
+  .addHandleMember(RC, RK, IsROV)
+  .addDefaultHandleConstructor(S, RC);
 }
 
 void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
diff --git a/clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl 
b/clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl
new file mode 100644
index 0..6b7bcbc35b8f8
--- /dev/null
+++ b/clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x 

[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

2024-07-31 Thread Joshua Batista via cfe-commits

https://github.com/bob80905 created 
https://github.com/llvm/llvm-project/pull/101433

This PR attaches the resource attributes, `HLSLResourceAttr` and 
`HLSLResourceClassAttr`, to the handle contained within such resource classes 
like `RWBuffer`. CodeGen will now search for fields within HLSL resource decls, 
and emit previous data based on attributes on the handle member. An AST-dump 
test was added to verify that the resource attribute is attached to the handle 
within the resource record decl.
Fixes #98556

>From b17ddcc6f2081135125d6178b22d033bcf7c0998 Mon Sep 17 00:00:00 2001
From: Joshua Batista 
Date: Wed, 31 Jul 2024 17:01:56 -0700
Subject: [PATCH] add attrs to handle in record decl, add ast dump test to
 verify

---
 clang/lib/CodeGen/CGHLSLRuntime.cpp   | 24 +---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 28 ---
 .../hlsl_resource_handle_attrs.hlsl   | 14 ++
 3 files changed, 40 insertions(+), 26 deletions(-)
 create mode 100644 clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 6a6aff594fb0f..a475d46966969 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -280,18 +280,22 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl 
*D, GlobalVariable *GV) {
   const auto *RD = Ty->getAsCXXRecordDecl();
   if (!RD)
 return;
-  const auto *HLSLResAttr = RD->getAttr();
-  const auto *HLSLResClassAttr = RD->getAttr();
-  if (!HLSLResAttr || !HLSLResClassAttr)
-return;
+  // the resource related attributes are on the handle member 
+  // inside the record decl
+  for (auto *FD : RD->fields()) {
+const auto *HLSLResAttr = FD->getAttr();
+const auto *HLSLResClassAttr = FD->getAttr();
+if (!HLSLResAttr || !HLSLResClassAttr)
+  continue;
 
-  llvm::hlsl::ResourceClass RC = HLSLResClassAttr->getResourceClass();
-  llvm::hlsl::ResourceKind RK = HLSLResAttr->getResourceKind();
-  bool IsROV = HLSLResAttr->getIsROV();
-  llvm::hlsl::ElementType ET = calculateElementType(CGM.getContext(), Ty);
+llvm::hlsl::ResourceClass RC = HLSLResClassAttr->getResourceClass();
+llvm::hlsl::ResourceKind RK = HLSLResAttr->getResourceKind();
+bool IsROV = HLSLResAttr->getIsROV();
+llvm::hlsl::ElementType ET = calculateElementType(CGM.getContext(), Ty);
 
-  BufferResBinding Binding(D->getAttr());
-  addBufferResourceAnnotation(GV, RC, RK, IsROV, ET, Binding);
+BufferResBinding Binding(D->getAttr());
+addBufferResourceAnnotation(GV, RC, RK, IsROV, ET, Binding);
+   }
 }
 
 CGHLSLRuntime::BufferResBinding::BufferResBinding(
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index ca88d138aef5d..e651f9cd967f5 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -101,8 +101,9 @@ struct BuiltinTypeDeclBuilder {
 return *this;
   }
 
-  BuiltinTypeDeclBuilder &
-  addHandleMember(AccessSpecifier Access = AccessSpecifier::AS_private) {
+  BuiltinTypeDeclBuilder (
+  ResourceClass RC, ResourceKind RK,
+  bool IsROV, AccessSpecifier Access = AccessSpecifier::AS_private) {
 if (Record->isCompleteDefinition())
   return *this;
 QualType Ty = Record->getASTContext().VoidPtrTy;
@@ -112,17 +113,13 @@ struct BuiltinTypeDeclBuilder {
 Ty = Record->getASTContext().getPointerType(
 QualType(TTD->getTypeForDecl(), 0));
 }
-return addMemberVariable("h", Ty, Access);
-  }
-
-  BuiltinTypeDeclBuilder (ResourceClass RC,
-   ResourceKind RK, bool IsROV) {
-if (Record->isCompleteDefinition())
-  return *this;
-Record->addAttr(
-HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC));
-Record->addAttr(
-HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV));
+// add handle member
+addMemberVariable("h", Ty, Access);
+// add resource attributes to handle
+auto *FD = Fields["h"];
+FD->addAttr(HLSLResourceClassAttr::CreateImplicit(FD->getASTContext(), 
RC));
+FD->addAttr(
+HLSLResourceAttr::CreateImplicit(FD->getASTContext(), RK, IsROV));
 return *this;
   }
 
@@ -489,9 +486,8 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl 
*Decl, Sema ,
   ResourceClass RC, ResourceKind 
RK,
   bool IsROV) {
   return BuiltinTypeDeclBuilder(Decl)
-  .addHandleMember()
-  .addDefaultHandleConstructor(S, RC)
-  .annotateHLSLResource(RC, RK, IsROV);
+  .addHandleMember(RC, RK, IsROV)
+  .addDefaultHandleConstructor(S, RC);
 }
 
 void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
diff --git a/clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl 

[clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)

2024-07-31 Thread Jonas Devlieghere via cfe-commits

JDevlieghere wrote:

> Thanks @JDevlieghere! Could you add this special case?

I'm happy to help but I wouldn't feel comfortable making such a change without 
being able to reproduce and test it. 
 
> The authoritatively established and supported way to link with `ncurses` on 
> most Linux platforms would be to use `pkg-config --libs ncurses` to the 
> `LDFLAGS` for `ncurses` for the given compile target.

I'm confused, I thought the problem was that we are linking `ncurses` and 
that's not sufficient because it doesn't export all the symbols. Wouldn't the 
fix consist of linking `terminfo`, in addition to `ncurses` on the platform 
you're observing this on? I presume this isn't an issue on all Linux systems as 
we have bots running Ubuntu that do not have this issue. 

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


[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-31 Thread Christopher Di Bella via cfe-commits


@@ -3058,6 +3058,133 @@ void Sema::NoteAllFoundTemplates(TemplateName Name) {
   }
 }
 
+static QualType commonTypeImpl(Sema , TemplateName BaseTemplate,
+   SourceLocation TemplateLoc,
+   ArrayRef Ts) {
+  auto lookUpCommonType = [&](TemplateArgument T1,
+  TemplateArgument T2) -> QualType {
+// Don't bother looking for other specializations if both types are
+// builtins - users aren't allowed to specialize for them

cjdb wrote:

It is only precedent due to it not having been previously recognised as an 
issue. It has now been identified and should be addressed, instead of 
increasing the problem's surface area.

We should do things right, not wrong because "they were done that way 
previously".

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


[clang] [NFC][Clang] Clean up VisitUnaryPlus by removing unused FP feature check (PR #101412)

2024-07-31 Thread via cfe-commits

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


[clang] d5d1cf0 - [NFC][Clang] Clean up VisitUnaryPlus by removing unused FP feature check (#101412)

2024-07-31 Thread via cfe-commits

Author: smanna12
Date: 2024-07-31T18:25:52-05:00
New Revision: d5d1cf05499ba9a0adc192c723f622fc13ef9c0b

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

LOG: [NFC][Clang] Clean up VisitUnaryPlus by removing unused FP feature check 
(#101412)

This commit removes an unnecessary call to `E->hasStoredFPFeatures()`
within the `VisitUnaryPlus` function. The method's return value was not
being used, leading to a redundant operation. The removal of this line
streamlines the function and eliminates an unneeded check for stored
floating-point features.

Added: 


Modified: 
clang/lib/CodeGen/CGExprComplex.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index 4d45f6d64c1cd..828a09856099a 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -649,7 +649,6 @@ ComplexPairTy ComplexExprEmitter::EmitCast(CastKind CK, 
Expr *Op,
 
 ComplexPairTy ComplexExprEmitter::VisitUnaryPlus(const UnaryOperator *E,
  QualType PromotionType) {
-  E->hasStoredFPFeatures();
   QualType promotionTy =
   PromotionType.isNull()
   ? getPromotionType(E->getStoredFPFeaturesOrDefault(),



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


[clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)

2024-07-31 Thread Bernhard Kaindl via cfe-commits

bernhardkaindl wrote:

Thanks @JDevlieghere! Could you add this special case?

The authoritatively established and supported way to link with `ncurses` on 
most Linux platforms would be to use `pkg-config --libs ncurses` to the 
`LDFLAGS` for `ncurses` for the given compile target.

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


[clang] [llvm] [Clang] Fix definition of layout-compatible to ignore empty classes (PR #92103)

2024-07-31 Thread John McCall via cfe-commits


@@ -160,6 +160,9 @@ Bug Fixes in This Version
 Bug Fixes to Compiler Builtins
 ^^
 
+- ``__is_layout_compatible`` no longer requires the empty bases to be the same 
in two
+  standard-layout classes. It now only compares non-static data members.

rjmccall wrote:

Is the plan to remove the release note from LLVM 20 if we're able to backport 
the fix?

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


[clang] [Clang] [NFC] Fix potential dereferencing of nullptr (PR #101405)

2024-07-31 Thread via cfe-commits

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


[clang] cf79aba - [Clang] [NFC] Fix potential dereferencing of nullptr (#101405)

2024-07-31 Thread via cfe-commits

Author: smanna12
Date: 2024-07-31T17:36:21-05:00
New Revision: cf79aba99db4909437b8977a59c51bc8899ddb9c

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

LOG: [Clang] [NFC] Fix potential dereferencing of nullptr (#101405)

This patch replaces getAs with castAs and dyn_cast with cast to ensure
type safety and prevents potential null pointer dereferences. These
changes enforce compile-time checks for correct type casting in
ASTContext and CodeGenModule.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a465cdfcf3c89..b0cc7cb826f97 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3283,7 +3283,7 @@ static void encodeTypeForFunctionPointerAuth(const 
ASTContext ,
 return;
 
   case Type::Builtin: {
-const auto *BTy = T->getAs();
+const auto *BTy = T->castAs();
 switch (BTy->getKind()) {
 #define SIGNED_TYPE(Id, SingletonId)   
\
   case BuiltinType::Id:
\
@@ -3366,7 +3366,7 @@ static void encodeTypeForFunctionPointerAuth(const 
ASTContext ,
 llvm_unreachable("should never get here");
   }
   case Type::Record: {
-const RecordDecl *RD = T->getAs()->getDecl();
+const RecordDecl *RD = T->castAs()->getDecl();
 const IdentifierInfo *II = RD->getIdentifier();
 
 // In C++, an immediate typedef of an anonymous struct or union

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 344a0e538f22a..760185d4d51ff 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5659,7 +5659,7 @@ void CodeGenModule::EmitExternalFunctionDeclaration(const 
FunctionDecl *FD) {
 if (getCodeGenOpts().hasReducedDebugInfo()) {
   auto *Ty = getTypes().ConvertType(FD->getType());
   StringRef MangledName = getMangledName(FD);
-  auto *Fn = dyn_cast(
+  auto *Fn = cast(
   GetOrCreateLLVMFunction(MangledName, Ty, FD, /* ForVTable */ false));
   if (!Fn->getSubprogram())
 DI->EmitFunctionDecl(FD, FD->getLocation(), FD->getType(), Fn);



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


[clang] [llvm] [Clang] Fix definition of layout-compatible to ignore empty classes (PR #92103)

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


@@ -160,6 +160,9 @@ Bug Fixes in This Version
 Bug Fixes to Compiler Builtins
 ^^
 
+- ``__is_layout_compatible`` no longer requires the empty bases to be the same 
in two
+  standard-layout classes. It now only compares non-static data members.

Endilll wrote:

That is correct, but the feature made into the 19 branch, whereas this fix did 
not (I hope we can backport it), hence a release note.

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


<    6   7   8   9   10   11   12   13   14   15   >