[llvm-branch-commits] [clang] fix links on clang 18.1.0rc release page (PR #82739)

2024-02-23 Thread via llvm-branch-commits

https://github.com/h-vetinari created 
https://github.com/llvm/llvm-project/pull/82739

Looking at the [release 
notes](https://prereleases.llvm.org/18.1.0/rc3/tools/clang/docs/ReleaseNotes.html)
 for clang 18.1.0rc, there's some broken links, and many issue numbers 
mis-formatted with an extra colon. Aside from being used inconsistently 
(with/without colon), I think it should be uncontroversial that `See (#62707).` 
is better than `See (#62707:).`

CC @tstellar @AaronBallman 

>From d3ae59831c804f18b3a415c71a7b392d07c40f94 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" 
Date: Fri, 23 Feb 2024 19:03:59 +1100
Subject: [PATCH] fix links on clang 18.1.0rc release page

---
 clang/docs/ReleaseNotes.rst | 46 ++---
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 93a67e7a895592..2f590a51c959dd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -58,12 +58,12 @@ code bases.
 
   To reduce such widespread breakages, as an extension, Clang accepts this code
   with an existing warning ``-Wambiguous-reversed-operator`` warning.
-  Fixes `GH `_.
+  Fixes `#53954 `_.
 
 - The CMake variable ``GCC_INSTALL_PREFIX`` (which sets the default
   ``--gcc-toolchain=``) is deprecated and will be removed. Specify
   ``--gcc-install-dir=`` or ``--gcc-triple=`` in a `configuration file
-  ` as a
+  `_ as a
   replacement.
   (`#77537 `_)
 
@@ -95,7 +95,7 @@ C/C++ Language Potentially Breaking Changes
 
 - Fixed a bug in finding matching `operator!=` while adding reversed 
`operator==` as
   outlined in "The Equality Operator You Are Looking For" (`P2468 
`_).
-  Fixes (`#68901: `_).
+  Fixes (`#68901 `_).
 
 C++ Specific Potentially Breaking Changes
 -
@@ -139,10 +139,10 @@ C++ Specific Potentially Breaking Changes
 
 - Remove the hardcoded path to the imported modules for C++20 named modules. 
Now we
   require all the dependent modules to specified from the command line.
-  See (`#62707: `_).
+  See (`#62707 `_).
 
 - Forbid `import XXX;` in C++ to find module `XXX` comes from explicit clang 
modules.
-  See (`#64755: `_).
+  See (`#64755 `_).
 
 ABI Changes in This Version
 ---
@@ -199,7 +199,7 @@ C++ Language Changes
 
 C++20 Feature Support
 ^
-- Implemented `P1907R1 ` which extends allowed 
non-type template argument
+- Implemented `P1907R1 `_ which extends allowed 
non-type template argument
   kinds with e.g. floating point values and pointers and references to 
subobjects.
   This feature is still experimental. Accordingly, 
``__cpp_nontype_template_args`` was not updated.
   However, its support can be tested with 
``__has_extension(cxx_generalized_nttp)``.
@@ -259,7 +259,7 @@ Resolutions to C++ Defect Reports
 
 - Implemented `CWG2598 `_ and `CWG2096 
`_,
   making unions (that have either no members or at least one literal member) 
literal types.
-  (`#77924: `_).
+  (`#77924 `_).
 
 
 C Language Changes
@@ -415,7 +415,7 @@ Attribute Changes in Clang
   types after default argument promotion. As a result, it's no longer an
   automatic diagnostic to use parameters of types that the format style
   supports but that are never the result of default argument promotion, such as
-  ``float``. (`#59824: `_)
+  ``float``. (`#59824 `_)
 
 - Clang now supports ``[[clang::preferred_type(type-name)]]`` as an attribute
   which can be applied to a bit-field. This attribute helps to map a bit-field
@@ -483,13 +483,13 @@ Improvements to Clang's diagnostics
 - Clang's ``-Wtautological-negation-compare`` flag now diagnoses logical
   tautologies like ``x && !x`` and ``!x || x`` in expressions. This also
   makes ``-Winfinite-recursion`` diagnose more cases.
-  (`#56035: `_).
+  (`#56035 `_).
 - Clang constexpr evaluator now diagnoses compound assignment operators against
   uninitialized variables as a read

[llvm-branch-commits] [clang] fix links on clang 18.1.0rc release page (PR #82739)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (h-vetinari)


Changes

Looking at the [release 
notes](https://prereleases.llvm.org/18.1.0/rc3/tools/clang/docs/ReleaseNotes.html)
 for clang 18.1.0rc, there's some broken links, and many issue numbers 
mis-formatted with an extra colon. Aside from being used inconsistently 
(with/without colon), I think it should be uncontroversial that `See (#62707).` is better than `See (#62707:).`

CC @tstellar @AaronBallman 

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


1 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+23-23) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 93a67e7a895592..2f590a51c959dd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -58,12 +58,12 @@ code bases.
 
   To reduce such widespread breakages, as an extension, Clang accepts this code
   with an existing warning ``-Wambiguous-reversed-operator`` warning.
-  Fixes `GH `_.
+  Fixes `#53954 `_.
 
 - The CMake variable ``GCC_INSTALL_PREFIX`` (which sets the default
   ``--gcc-toolchain=``) is deprecated and will be removed. Specify
   ``--gcc-install-dir=`` or ``--gcc-triple=`` in a `configuration file
-  ` as a
+  `_ as a
   replacement.
   (`#77537 `_)
 
@@ -95,7 +95,7 @@ C/C++ Language Potentially Breaking Changes
 
 - Fixed a bug in finding matching `operator!=` while adding reversed 
`operator==` as
   outlined in "The Equality Operator You Are Looking For" (`P2468 
`_).
-  Fixes (`#68901: `_).
+  Fixes (`#68901 `_).
 
 C++ Specific Potentially Breaking Changes
 -
@@ -139,10 +139,10 @@ C++ Specific Potentially Breaking Changes
 
 - Remove the hardcoded path to the imported modules for C++20 named modules. 
Now we
   require all the dependent modules to specified from the command line.
-  See (`#62707: `_).
+  See (`#62707 `_).
 
 - Forbid `import XXX;` in C++ to find module `XXX` comes from explicit clang 
modules.
-  See (`#64755: `_).
+  See (`#64755 `_).
 
 ABI Changes in This Version
 ---
@@ -199,7 +199,7 @@ C++ Language Changes
 
 C++20 Feature Support
 ^
-- Implemented `P1907R1 ` which extends allowed 
non-type template argument
+- Implemented `P1907R1 `_ which extends allowed 
non-type template argument
   kinds with e.g. floating point values and pointers and references to 
subobjects.
   This feature is still experimental. Accordingly, 
``__cpp_nontype_template_args`` was not updated.
   However, its support can be tested with 
``__has_extension(cxx_generalized_nttp)``.
@@ -259,7 +259,7 @@ Resolutions to C++ Defect Reports
 
 - Implemented `CWG2598 `_ and `CWG2096 
`_,
   making unions (that have either no members or at least one literal member) 
literal types.
-  (`#77924: `_).
+  (`#77924 `_).
 
 
 C Language Changes
@@ -415,7 +415,7 @@ Attribute Changes in Clang
   types after default argument promotion. As a result, it's no longer an
   automatic diagnostic to use parameters of types that the format style
   supports but that are never the result of default argument promotion, such as
-  ``float``. (`#59824: `_)
+  ``float``. (`#59824 `_)
 
 - Clang now supports ``[[clang::preferred_type(type-name)]]`` as an attribute
   which can be applied to a bit-field. This attribute helps to map a bit-field
@@ -483,13 +483,13 @@ Improvements to Clang's diagnostics
 - Clang's ``-Wtautological-negation-compare`` flag now diagnoses logical
   tautologies like ``x && !x`` and ``!x || x`` in expressions. This also
   makes ``-Winfinite-recursion`` diagnose more cases.
-  (`#56035: `_).
+  (`#56035 `_).
 - Clang constexpr evaluator now diagnoses compound assignment operators against
   uninitialized variables as a read of uninitialized object.
   (`#51536 `_)
 - Clang's ``-Wformat-truncation`` now diagnoses ``snprintf`` call that i

[llvm-branch-commits] [AArch64][GlobalISel] Improve codegen for G_VECREDUCE_{SMIN, SMAX, UMIN, UMAX} for odd-sized vectors (PR #81831)

2024-02-23 Thread Dhruv Chawla via llvm-branch-commits

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


[llvm-branch-commits] [AArch64][GlobalISel] Improve codegen for G_VECREDUCE_{SMIN, SMAX, UMIN, UMAX} for odd-sized vectors (PR #81831)

2024-02-23 Thread Dhruv Chawla via llvm-branch-commits

dc03-work wrote:

Merged with #81830 in #82740

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


[llvm-branch-commits] [llvm] ee9c02c - Revert "[llvm][AArch64] Autoupgrade function attributes from Module attribute…"

2024-02-23 Thread via llvm-branch-commits

Author: Vedant Paranjape
Date: 2024-02-23T13:47:58+05:30
New Revision: ee9c02cf74a3e8f83db814363b9e095eb290b083

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

LOG: Revert "[llvm][AArch64] Autoupgrade function attributes from Module 
attribute…"

This reverts commit 531e8c26b3f2626e7f1a997e0e8b61d67d10aded.

Added: 


Modified: 
llvm/include/llvm/IR/AutoUpgrade.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Linker/IRMover.cpp
llvm/test/Bitcode/upgrade-arc-runtime-calls.ll
llvm/test/LTO/AArch64/link-branch-target-enforcement.ll
llvm/test/Linker/link-arm-and-thumb.ll

Removed: 
llvm/test/LTO/AArch64/link-sign-return-address.ll



diff  --git a/llvm/include/llvm/IR/AutoUpgrade.h 
b/llvm/include/llvm/IR/AutoUpgrade.h
index c0d96efc54752a..152f781ffa9b30 100644
--- a/llvm/include/llvm/IR/AutoUpgrade.h
+++ b/llvm/include/llvm/IR/AutoUpgrade.h
@@ -67,8 +67,7 @@ namespace llvm {
   void UpgradeSectionAttributes(Module &M);
 
   /// Correct any IR that is relying on old function attribute behavior.
-  void UpgradeFunctionAttributes(Function &F,
- bool ModuleMetadataIsMaterialized = false);
+  void UpgradeFunctionAttributes(Function &F);
 
   /// If the given TBAA tag uses the scalar TBAA format, create a new node
   /// corresponding to the upgrade to the struct-path aware TBAA format.

diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp 
b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 8c860101afa02b..832907a3f53f5f 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -6706,7 +6706,7 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
   }
 
   // Look for functions that rely on old function attribute behavior.
-  UpgradeFunctionAttributes(*F, true);
+  UpgradeFunctionAttributes(*F);
 
   // Bring in any functions that this function forward-referenced via
   // blockaddresses.

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index edff13c796b31e..b90bbe71ac1896 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5155,46 +5155,7 @@ struct StrictFPUpgradeVisitor : public 
InstVisitor {
 };
 } // namespace
 
-// Check if the module attribute is present and not zero.
-static bool isModuleAttributeSet(const Module *M, const StringRef &ModAttr) {
-  const auto *Attr =
-  mdconst::extract_or_null(M->getModuleFlag(ModAttr));
-  return Attr && Attr->getZExtValue();
-}
-
-// Copy an attribute from module to the function if exists.
-// First value of the pair is used when the module attribute is not zero
-// the second otherwise.
-static void
-CopyModuleAttributeToFunction(Function &F, StringRef FnAttrName,
-  StringRef ModAttrName,
-  std::pair Values) {
-  if (F.hasFnAttribute(FnAttrName))
-return;
-  F.addFnAttr(FnAttrName, isModuleAttributeSet(F.getParent(), ModAttrName)
-  ? Values.first
-  : Values.second);
-}
-
-// Copy a boolean attribute from module to the function if exists.
-// Module attribute treated false if zero otherwise true.
-static void CopyModuleAttributeToFunction(Function &F, StringRef AttrName) {
-  CopyModuleAttributeToFunction(
-  F, AttrName, AttrName,
-  std::make_pair("true", "false"));
-}
-
-// Copy an attribute from module to the function if exists.
-// First value of the pair is used when the module attribute is not zero
-// the second otherwise.
-static void
-CopyModuleAttributeToFunction(Function &F, StringRef AttrName,
-  std::pair Values) {
-  CopyModuleAttributeToFunction(F, AttrName, AttrName, Values);
-}
-
-void llvm::UpgradeFunctionAttributes(Function &F,
- bool ModuleMetadataIsMaterialized) {
+void llvm::UpgradeFunctionAttributes(Function &F) {
   // If a function definition doesn't have the strictfp attribute,
   // convert any callsite strictfp attributes to nobuiltin.
   if (!F.isDeclaration() && !F.hasFnAttribute(Attribute::StrictFP)) {
@@ -5206,37 +5167,6 @@ void llvm::UpgradeFunctionAttributes(Function &F,
   F.removeRetAttrs(AttributeFuncs::typeIncompatible(F.getReturnType()));
   for (auto &Arg : F.args())
 Arg.removeAttrs(AttributeFuncs::typeIncompatible(Arg.getType()));
-
-  if (!ModuleMetadataIsMaterialized)
-return;
-  if (F.isDeclaration())
-return;
-  Module *M = F.getParent();
-  if (!M)
-return;
-
-  Triple T(M->getTargetTriple());
-  // Convert module level attributes to function level attributes because
-  // after merging modules the attributes might change and would have 
diff erent
-  // effect on the functions as the original modul

[llvm-branch-commits] [llvm] [llvm][AArch64] Autoupgrade function attributes from Module attributes (PR #82742)

2024-02-23 Thread via llvm-branch-commits

https://github.com/DanielKristofKiss created 
https://github.com/llvm/llvm-project/pull/82742

`sign-return-address` and similar module attributes should be propagated to the 
function level before modules got merged because module flags may contradict 
and this information is not recoverable. Generated code will match with the 
normal linking flow.
Backport of (#80640)

>From d1bb2b189ab912037a6035927115943668a6ba75 Mon Sep 17 00:00:00 2001
From: Dani 
Date: Fri, 23 Feb 2024 09:04:33 +0100
Subject: [PATCH] [llvm][AArch64] Autoupgrade function attributes from Module
 attributes. (#80640)

`sign-return-address` and similar module attributes should be propagated
to the function level before modules got merged because module flags may
contradict and this information is not recoverable.
Generated code will match with the normal linking flow.
---
 llvm/include/llvm/IR/AutoUpgrade.h|  3 +-
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  2 +-
 llvm/lib/IR/AutoUpgrade.cpp   | 72 ++-
 llvm/lib/Linker/IRMover.cpp   |  4 ++
 .../test/Bitcode/upgrade-arc-runtime-calls.ll |  4 +-
 .../AArch64/link-branch-target-enforcement.ll |  1 +
 .../LTO/AArch64/link-sign-return-address.ll   | 43 +++
 llvm/test/Linker/link-arm-and-thumb.ll|  7 +-
 8 files changed, 128 insertions(+), 8 deletions(-)
 create mode 100644 llvm/test/LTO/AArch64/link-sign-return-address.ll

diff --git a/llvm/include/llvm/IR/AutoUpgrade.h 
b/llvm/include/llvm/IR/AutoUpgrade.h
index 152f781ffa9b30..c0d96efc54752a 100644
--- a/llvm/include/llvm/IR/AutoUpgrade.h
+++ b/llvm/include/llvm/IR/AutoUpgrade.h
@@ -67,7 +67,8 @@ namespace llvm {
   void UpgradeSectionAttributes(Module &M);
 
   /// Correct any IR that is relying on old function attribute behavior.
-  void UpgradeFunctionAttributes(Function &F);
+  void UpgradeFunctionAttributes(Function &F,
+ bool ModuleMetadataIsMaterialized = false);
 
   /// If the given TBAA tag uses the scalar TBAA format, create a new node
   /// corresponding to the upgrade to the struct-path aware TBAA format.
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp 
b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index a027d0c21ba0bb..f6facb37c020b2 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -6702,7 +6702,7 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
   }
 
   // Look for functions that rely on old function attribute behavior.
-  UpgradeFunctionAttributes(*F);
+  UpgradeFunctionAttributes(*F, true);
 
   // Bring in any functions that this function forward-referenced via
   // blockaddresses.
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index b90bbe71ac1896..edff13c796b31e 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5155,7 +5155,46 @@ struct StrictFPUpgradeVisitor : public 
InstVisitor {
 };
 } // namespace
 
-void llvm::UpgradeFunctionAttributes(Function &F) {
+// Check if the module attribute is present and not zero.
+static bool isModuleAttributeSet(const Module *M, const StringRef &ModAttr) {
+  const auto *Attr =
+  mdconst::extract_or_null(M->getModuleFlag(ModAttr));
+  return Attr && Attr->getZExtValue();
+}
+
+// Copy an attribute from module to the function if exists.
+// First value of the pair is used when the module attribute is not zero
+// the second otherwise.
+static void
+CopyModuleAttributeToFunction(Function &F, StringRef FnAttrName,
+  StringRef ModAttrName,
+  std::pair Values) {
+  if (F.hasFnAttribute(FnAttrName))
+return;
+  F.addFnAttr(FnAttrName, isModuleAttributeSet(F.getParent(), ModAttrName)
+  ? Values.first
+  : Values.second);
+}
+
+// Copy a boolean attribute from module to the function if exists.
+// Module attribute treated false if zero otherwise true.
+static void CopyModuleAttributeToFunction(Function &F, StringRef AttrName) {
+  CopyModuleAttributeToFunction(
+  F, AttrName, AttrName,
+  std::make_pair("true", "false"));
+}
+
+// Copy an attribute from module to the function if exists.
+// First value of the pair is used when the module attribute is not zero
+// the second otherwise.
+static void
+CopyModuleAttributeToFunction(Function &F, StringRef AttrName,
+  std::pair Values) {
+  CopyModuleAttributeToFunction(F, AttrName, AttrName, Values);
+}
+
+void llvm::UpgradeFunctionAttributes(Function &F,
+ bool ModuleMetadataIsMaterialized) {
   // If a function definition doesn't have the strictfp attribute,
   // convert any callsite strictfp attributes to nobuiltin.
   if (!F.isDeclaration() && !F.hasFnAttribute(Attribute::StrictFP)) {
@@ -5167,6 +5206,37 @@ void llvm::UpgradeFunctionAttributes(Function &F) {
   F.removeRetAttrs(AttributeFuncs::typeIncompatible(F.g

[llvm-branch-commits] [llvm] [llvm][AArch64] Autoupgrade function attributes from Module attributes (PR #82742)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-lto

Author: Dani (DanielKristofKiss)


Changes

`sign-return-address` and similar module attributes should be propagated to the 
function level before modules got merged because module flags may contradict 
and this information is not recoverable. Generated code will match with the 
normal linking flow.
Backport of (#80640)

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


8 Files Affected:

- (modified) llvm/include/llvm/IR/AutoUpgrade.h (+2-1) 
- (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+1-1) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+71-1) 
- (modified) llvm/lib/Linker/IRMover.cpp (+4) 
- (modified) llvm/test/Bitcode/upgrade-arc-runtime-calls.ll (+2-2) 
- (modified) llvm/test/LTO/AArch64/link-branch-target-enforcement.ll (+1) 
- (added) llvm/test/LTO/AArch64/link-sign-return-address.ll (+43) 
- (modified) llvm/test/Linker/link-arm-and-thumb.ll (+4-3) 


``diff
diff --git a/llvm/include/llvm/IR/AutoUpgrade.h 
b/llvm/include/llvm/IR/AutoUpgrade.h
index 152f781ffa9b30..c0d96efc54752a 100644
--- a/llvm/include/llvm/IR/AutoUpgrade.h
+++ b/llvm/include/llvm/IR/AutoUpgrade.h
@@ -67,7 +67,8 @@ namespace llvm {
   void UpgradeSectionAttributes(Module &M);
 
   /// Correct any IR that is relying on old function attribute behavior.
-  void UpgradeFunctionAttributes(Function &F);
+  void UpgradeFunctionAttributes(Function &F,
+ bool ModuleMetadataIsMaterialized = false);
 
   /// If the given TBAA tag uses the scalar TBAA format, create a new node
   /// corresponding to the upgrade to the struct-path aware TBAA format.
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp 
b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index a027d0c21ba0bb..f6facb37c020b2 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -6702,7 +6702,7 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
   }
 
   // Look for functions that rely on old function attribute behavior.
-  UpgradeFunctionAttributes(*F);
+  UpgradeFunctionAttributes(*F, true);
 
   // Bring in any functions that this function forward-referenced via
   // blockaddresses.
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index b90bbe71ac1896..edff13c796b31e 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5155,7 +5155,46 @@ struct StrictFPUpgradeVisitor : public 
InstVisitor {
 };
 } // namespace
 
-void llvm::UpgradeFunctionAttributes(Function &F) {
+// Check if the module attribute is present and not zero.
+static bool isModuleAttributeSet(const Module *M, const StringRef &ModAttr) {
+  const auto *Attr =
+  mdconst::extract_or_null(M->getModuleFlag(ModAttr));
+  return Attr && Attr->getZExtValue();
+}
+
+// Copy an attribute from module to the function if exists.
+// First value of the pair is used when the module attribute is not zero
+// the second otherwise.
+static void
+CopyModuleAttributeToFunction(Function &F, StringRef FnAttrName,
+  StringRef ModAttrName,
+  std::pair Values) {
+  if (F.hasFnAttribute(FnAttrName))
+return;
+  F.addFnAttr(FnAttrName, isModuleAttributeSet(F.getParent(), ModAttrName)
+  ? Values.first
+  : Values.second);
+}
+
+// Copy a boolean attribute from module to the function if exists.
+// Module attribute treated false if zero otherwise true.
+static void CopyModuleAttributeToFunction(Function &F, StringRef AttrName) {
+  CopyModuleAttributeToFunction(
+  F, AttrName, AttrName,
+  std::make_pair("true", "false"));
+}
+
+// Copy an attribute from module to the function if exists.
+// First value of the pair is used when the module attribute is not zero
+// the second otherwise.
+static void
+CopyModuleAttributeToFunction(Function &F, StringRef AttrName,
+  std::pair Values) {
+  CopyModuleAttributeToFunction(F, AttrName, AttrName, Values);
+}
+
+void llvm::UpgradeFunctionAttributes(Function &F,
+ bool ModuleMetadataIsMaterialized) {
   // If a function definition doesn't have the strictfp attribute,
   // convert any callsite strictfp attributes to nobuiltin.
   if (!F.isDeclaration() && !F.hasFnAttribute(Attribute::StrictFP)) {
@@ -5167,6 +5206,37 @@ void llvm::UpgradeFunctionAttributes(Function &F) {
   F.removeRetAttrs(AttributeFuncs::typeIncompatible(F.getReturnType()));
   for (auto &Arg : F.args())
 Arg.removeAttrs(AttributeFuncs::typeIncompatible(Arg.getType()));
+
+  if (!ModuleMetadataIsMaterialized)
+return;
+  if (F.isDeclaration())
+return;
+  Module *M = F.getParent();
+  if (!M)
+return;
+
+  Triple T(M->getTargetTriple());
+  // Convert module level attributes to function level attributes because
+  // after merging modules the attributes might change and would have diffe

[llvm-branch-commits] [llvm] [llvm][AArch64] Autoupgrade function attributes from Module attributes (PR #82742)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [llvm][AArch64] Do not inline a function with different signing scheme. (#80642) (PR #82743)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [llvm][AArch64] Do not inline a function with different signing scheme. (#80642) (PR #82743)

2024-02-23 Thread via llvm-branch-commits

https://github.com/DanielKristofKiss created 
https://github.com/llvm/llvm-project/pull/82743

f the signing scheme is different that maybe the functions assumes different 
behaviours and dangerous to inline them without analysing them. This should be 
a rare case.


>From f70e8da5f991f003f4af59c8fe1fa0af35949e33 Mon Sep 17 00:00:00 2001
From: Dani 
Date: Fri, 23 Feb 2024 09:30:36 +0100
Subject: [PATCH] [llvm][AArch64] Do not inline a function with different
 signing scheme. (#80642)

If the signing scheme is different that maybe the functions assumes
different behaviours and dangerous to inline them without analysing
them. This should be a rare case.
---
 llvm/include/llvm/IR/Attributes.td|  28 +++--
 llvm/lib/IR/Attributes.cpp|   5 +
 .../Inline/inline-sign-return-address.ll  | 104 ++
 llvm/utils/TableGen/Attributes.cpp|   6 +-
 4 files changed, 135 insertions(+), 8 deletions(-)
 create mode 100644 llvm/test/Transforms/Inline/inline-sign-return-address.ll

diff --git a/llvm/include/llvm/IR/Attributes.td 
b/llvm/include/llvm/IR/Attributes.td
index 864f87f3383891..d22eb76d2292d5 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -339,14 +339,26 @@ def UseSampleProfile : StrBoolAttr<"use-sample-profile">;
 def DenormalFPMath : ComplexStrAttr<"denormal-fp-math", [FnAttr]>;
 def DenormalFPMathF32 : ComplexStrAttr<"denormal-fp-math-f32", [FnAttr]>;
 
+// Attribute compatiblity rules are generated to check the attribute of the
+// caller and callee and decide whether inlining should be allowed. CompatRule
+// and child classes are used for the rule generation. CompatRule takes only a
+// compare function which could be templated with the attribute type.
+// CompatRuleStrAttr takes the compare function and the string attribute for
+// checking compatibility for inline substitution.
 class CompatRule {
-  // The name of the function called to check the attribute of the caller and
-  // callee and decide whether inlining should be allowed. The function's
-  // signature must match "bool(const Function&, const Function &)", where the
-  // first parameter is the reference to the caller and the second parameter is
-  // the reference to the callee. It must return false if the attributes of the
-  // caller and callee are incompatible, and true otherwise.
+  // The function's signature must match "bool(const Function&, const
+  // Function&)", where the first parameter is the reference to the caller and
+  // the second parameter is the reference to the callee. It must return false
+  // if the attributes of the caller and callee are incompatible, and true
+  // otherwise.
   string CompatFunc = F;
+  string AttrName = "";
+}
+
+class CompatRuleStrAttr : CompatRule {
+  // The checker function is extended with an third argument as the function
+  // attribute string "bool(const Function&, const Function&, const 
StringRef&)".
+  string AttrName = Attr;
 }
 
 def : CompatRule<"isEqual">;
@@ -359,7 +371,9 @@ def : CompatRule<"isEqual">;
 def : CompatRule<"isEqual">;
 def : CompatRule<"isEqual">;
 def : CompatRule<"checkDenormMode">;
-
+def : CompatRuleStrAttr<"isEqual", "sign-return-address">;
+def : CompatRuleStrAttr<"isEqual", "sign-return-address-key">;
+def : CompatRuleStrAttr<"isEqual", "branch-protection-pauth-lr">;
 
 class MergeRule {
   // The name of the function called to merge the attributes of the caller and
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index fd5160209506f2..19076771ff2eaf 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -2045,6 +2045,11 @@ static bool isEqual(const Function &Caller, const 
Function &Callee) {
  Callee.getFnAttribute(AttrClass::getKind());
 }
 
+static bool isEqual(const Function &Caller, const Function &Callee,
+const StringRef &AttrName) {
+  return Caller.getFnAttribute(AttrName) == Callee.getFnAttribute(AttrName);
+}
+
 /// Compute the logical AND of the attributes of the caller and the
 /// callee.
 ///
diff --git a/llvm/test/Transforms/Inline/inline-sign-return-address.ll 
b/llvm/test/Transforms/Inline/inline-sign-return-address.ll
new file mode 100644
index 00..c4d85fa671a4f6
--- /dev/null
+++ b/llvm/test/Transforms/Inline/inline-sign-return-address.ll
@@ -0,0 +1,104 @@
+; Check the inliner doesn't inline a function with different sign return 
address schemes.
+; RUN: opt < %s -passes=inline -S | FileCheck %s
+
+define internal void @foo_all() #0 {
+  ret void
+}
+
+define internal void @foo_nonleaf() #1 {
+  ret void
+}
+
+define internal void @foo_none() #2 {
+  ret void
+}
+
+define internal void @foo_lr() #3 {
+  ret void
+}
+
+define internal void @foo_bkey() #4 {
+  ret void
+}
+
+define dso_local void @bar_all() #0 {
+; CHECK-LABEL: bar_all
+; CHECK-NOT: call void @foo_all()
+; CHECK-NEXT:call void @foo_nonleaf()
+; CHECK-NEXT:call void @foo_none()
+; CHE

[llvm-branch-commits] [llvm] [llvm][AArch64] Do not inline a function with different signing scheme. (#80642) (PR #82743)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Dani (DanielKristofKiss)


Changes

f the signing scheme is different that maybe the functions assumes different 
behaviours and dangerous to inline them without analysing them. This should be 
a rare case.


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


4 Files Affected:

- (modified) llvm/include/llvm/IR/Attributes.td (+21-7) 
- (modified) llvm/lib/IR/Attributes.cpp (+5) 
- (added) llvm/test/Transforms/Inline/inline-sign-return-address.ll (+104) 
- (modified) llvm/utils/TableGen/Attributes.cpp (+5-1) 


``diff
diff --git a/llvm/include/llvm/IR/Attributes.td 
b/llvm/include/llvm/IR/Attributes.td
index 864f87f3383891..d22eb76d2292d5 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -339,14 +339,26 @@ def UseSampleProfile : StrBoolAttr<"use-sample-profile">;
 def DenormalFPMath : ComplexStrAttr<"denormal-fp-math", [FnAttr]>;
 def DenormalFPMathF32 : ComplexStrAttr<"denormal-fp-math-f32", [FnAttr]>;
 
+// Attribute compatiblity rules are generated to check the attribute of the
+// caller and callee and decide whether inlining should be allowed. CompatRule
+// and child classes are used for the rule generation. CompatRule takes only a
+// compare function which could be templated with the attribute type.
+// CompatRuleStrAttr takes the compare function and the string attribute for
+// checking compatibility for inline substitution.
 class CompatRule {
-  // The name of the function called to check the attribute of the caller and
-  // callee and decide whether inlining should be allowed. The function's
-  // signature must match "bool(const Function&, const Function &)", where the
-  // first parameter is the reference to the caller and the second parameter is
-  // the reference to the callee. It must return false if the attributes of the
-  // caller and callee are incompatible, and true otherwise.
+  // The function's signature must match "bool(const Function&, const
+  // Function&)", where the first parameter is the reference to the caller and
+  // the second parameter is the reference to the callee. It must return false
+  // if the attributes of the caller and callee are incompatible, and true
+  // otherwise.
   string CompatFunc = F;
+  string AttrName = "";
+}
+
+class CompatRuleStrAttr : CompatRule {
+  // The checker function is extended with an third argument as the function
+  // attribute string "bool(const Function&, const Function&, const 
StringRef&)".
+  string AttrName = Attr;
 }
 
 def : CompatRule<"isEqual">;
@@ -359,7 +371,9 @@ def : CompatRule<"isEqual">;
 def : CompatRule<"isEqual">;
 def : CompatRule<"isEqual">;
 def : CompatRule<"checkDenormMode">;
-
+def : CompatRuleStrAttr<"isEqual", "sign-return-address">;
+def : CompatRuleStrAttr<"isEqual", "sign-return-address-key">;
+def : CompatRuleStrAttr<"isEqual", "branch-protection-pauth-lr">;
 
 class MergeRule {
   // The name of the function called to merge the attributes of the caller and
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index fd5160209506f2..19076771ff2eaf 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -2045,6 +2045,11 @@ static bool isEqual(const Function &Caller, const 
Function &Callee) {
  Callee.getFnAttribute(AttrClass::getKind());
 }
 
+static bool isEqual(const Function &Caller, const Function &Callee,
+const StringRef &AttrName) {
+  return Caller.getFnAttribute(AttrName) == Callee.getFnAttribute(AttrName);
+}
+
 /// Compute the logical AND of the attributes of the caller and the
 /// callee.
 ///
diff --git a/llvm/test/Transforms/Inline/inline-sign-return-address.ll 
b/llvm/test/Transforms/Inline/inline-sign-return-address.ll
new file mode 100644
index 00..c4d85fa671a4f6
--- /dev/null
+++ b/llvm/test/Transforms/Inline/inline-sign-return-address.ll
@@ -0,0 +1,104 @@
+; Check the inliner doesn't inline a function with different sign return 
address schemes.
+; RUN: opt < %s -passes=inline -S | FileCheck %s
+
+define internal void @foo_all() #0 {
+  ret void
+}
+
+define internal void @foo_nonleaf() #1 {
+  ret void
+}
+
+define internal void @foo_none() #2 {
+  ret void
+}
+
+define internal void @foo_lr() #3 {
+  ret void
+}
+
+define internal void @foo_bkey() #4 {
+  ret void
+}
+
+define dso_local void @bar_all() #0 {
+; CHECK-LABEL: bar_all
+; CHECK-NOT: call void @foo_all()
+; CHECK-NEXT:call void @foo_nonleaf()
+; CHECK-NEXT:call void @foo_none()
+; CHECK-NEXT:call void @foo_lr()
+; CHECK-NEXT:call void @foo_bkey()
+  call void @foo_all()
+  call void @foo_nonleaf()
+  call void @foo_none()
+  call void @foo_lr()
+  call void @foo_bkey()
+  ret void
+}
+
+define dso_local void @bar_nonleaf() #1 {
+; CHECK-LABEL: bar_nonleaf
+; CHECK-NEXT:call void @foo_all()
+; CHECK-NOT: call void @foo_nonleaf()
+; CHECK-NEXT:call void @foo_none()
+; CHECK-NEXT: 

[llvm-branch-commits] [llvm] release/18.x: [Loads] Fix crash in isSafeToLoadUnconditionally with scalable accessed type (#82650) (PR #82664)

2024-02-23 Thread Nikita Popov via llvm-branch-commits

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


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


[llvm-branch-commits] [clang] fix links on clang 18.1.0rc release page (PR #82739)

2024-02-23 Thread via llvm-branch-commits

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

LGTM, thanks!

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


[llvm-branch-commits] [llvm] [llvm][AArch64] Autoupgrade function attributes from Module attributes (PR #82742)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [flang] [flang][OpenMP] Convert unique clauses in ClauseProcessor (PR #81622)

2024-02-23 Thread Krzysztof Parzyszek via llvm-branch-commits


@@ -2639,54 +2641,50 @@ bool 
ClauseProcessor::processFinal(Fortran::lower::StatementContext &stmtCtx,
 }
 
 bool ClauseProcessor::processHint(mlir::IntegerAttr &result) const {
-  if (auto *hintClause = findUniqueClause()) {
+  if (auto *clause = findUniqueClause()) {
 fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
-const auto *expr = Fortran::semantics::GetExpr(hintClause->v);
-int64_t hintValue = *Fortran::evaluate::ToInt64(*expr);
+int64_t hintValue = *Fortran::evaluate::ToInt64(clause->v);
 result = firOpBuilder.getI64IntegerAttr(hintValue);
 return true;
   }
   return false;
 }
 
 bool ClauseProcessor::processMergeable(mlir::UnitAttr &result) const {
-  return markClauseOccurrence(result);
+  return markClauseOccurrence(result);
 }
 
 bool ClauseProcessor::processNowait(mlir::UnitAttr &result) const {
-  return markClauseOccurrence(result);
+  return markClauseOccurrence(result);
 }
 
 bool ClauseProcessor::processNumTeams(Fortran::lower::StatementContext 
&stmtCtx,
   mlir::Value &result) const {
   // TODO Get lower and upper bounds for num_teams when parser is updated to
   // accept both.
-  if (auto *numTeamsClause = findUniqueClause()) {
-result = fir::getBase(converter.genExprValue(
-*Fortran::semantics::GetExpr(numTeamsClause->v), stmtCtx));
+  if (auto *clause = findUniqueClause()) {
+result = fir::getBase(converter.genExprValue(clause->v, stmtCtx));
 return true;
   }
   return false;
 }
 
 bool ClauseProcessor::processNumThreads(
 Fortran::lower::StatementContext &stmtCtx, mlir::Value &result) const {
-  if (auto *numThreadsClause = findUniqueClause()) {
+  if (auto *clause = findUniqueClause()) {
 // OMPIRBuilder expects `NUM_THREADS` clause as a `Value`.
-result = fir::getBase(converter.genExprValue(
-*Fortran::semantics::GetExpr(numThreadsClause->v), stmtCtx));
+result = fir::getBase(converter.genExprValue(clause->v, stmtCtx));
 return true;
   }
   return false;
 }
 
 bool ClauseProcessor::processOrdered(mlir::IntegerAttr &result) const {
-  if (auto *orderedClause = findUniqueClause()) {
+  if (auto *clause = findUniqueClause()) {
 fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
 int64_t orderedClauseValue = 0l;
-if (orderedClause->v.has_value()) {
-  const auto *expr = Fortran::semantics::GetExpr(orderedClause->v);
-  orderedClauseValue = *Fortran::evaluate::ToInt64(*expr);
+if (clause->v.has_value()) {

kparzysz wrote:

Done

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


[llvm-branch-commits] [flang] [flang][OpenMP] Convert unique clauses in ClauseProcessor (PR #81622)

2024-02-23 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/81622

>From fafbd98f05958d6983d87803b94536b9041b63dc Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 21 Feb 2024 14:26:11 -0600
Subject: [PATCH] [flang][OpenMP] Convert unique clauses in ClauseProcessor

Temporarily rename old clause list to `clauses2`, old clause iterator
to `ClauseIterator2`.
Change `findUniqueClause` to iterate over `omp::Clause` objects,
modify all handlers to operate on 'omp::clause::xyz` equivalents.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp | 211 +
 flang/lib/Lower/OpenMP/ClauseProcessor.h   |  36 +++-
 flang/lib/Lower/OpenMP/Clauses.cpp |   6 +-
 flang/lib/Lower/OpenMP/Clauses.h   |  15 +-
 4 files changed, 129 insertions(+), 139 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index a41f8312a28c9e..9987cd73fc7670 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "ClauseProcessor.h"
+#include "Clauses.h"
 
 #include "flang/Lower/PFTBuilder.h"
 #include "flang/Parser/tools.h"
@@ -30,64 +31,55 @@ static void checkMapType(mlir::Location location, 
mlir::Type type) {
 }
 
 static mlir::omp::ScheduleModifier
-translateScheduleModifier(const Fortran::parser::OmpScheduleModifierType &m) {
-  switch (m.v) {
-  case Fortran::parser::OmpScheduleModifierType::ModType::Monotonic:
+translateScheduleModifier(const omp::clause::Schedule::ModType &m) {
+  switch (m) {
+  case omp::clause::Schedule::ModType::Monotonic:
 return mlir::omp::ScheduleModifier::monotonic;
-  case Fortran::parser::OmpScheduleModifierType::ModType::Nonmonotonic:
+  case omp::clause::Schedule::ModType::Nonmonotonic:
 return mlir::omp::ScheduleModifier::nonmonotonic;
-  case Fortran::parser::OmpScheduleModifierType::ModType::Simd:
+  case omp::clause::Schedule::ModType::Simd:
 return mlir::omp::ScheduleModifier::simd;
   }
   return mlir::omp::ScheduleModifier::none;
 }
 
 static mlir::omp::ScheduleModifier
-getScheduleModifier(const Fortran::parser::OmpScheduleClause &x) {
-  const auto &modifier =
-  std::get>(x.t);
+getScheduleModifier(const omp::clause::Schedule &clause) {
+  using ScheduleModifier = omp::clause::Schedule::ScheduleModifier;
+  const auto &modifier = std::get>(clause.t);
   // The input may have the modifier any order, so we look for one that isn't
   // SIMD. If modifier is not set at all, fall down to the bottom and return
   // "none".
   if (modifier) {
-const auto &modType1 =
-std::get(modifier->t);
-if (modType1.v.v ==
-Fortran::parser::OmpScheduleModifierType::ModType::Simd) {
-  const auto &modType2 = std::get<
-  std::optional>(
-  modifier->t);
-  if (modType2 &&
-  modType2->v.v !=
-  Fortran::parser::OmpScheduleModifierType::ModType::Simd)
-return translateScheduleModifier(modType2->v);
-
+using ModType = omp::clause::Schedule::ModType;
+const auto &modType1 = std::get(modifier->t);
+if (modType1 == ModType::Simd) {
+  const auto &modType2 = std::get>(modifier->t);
+  if (modType2 && *modType2 != ModType::Simd)
+return translateScheduleModifier(*modType2);
   return mlir::omp::ScheduleModifier::none;
 }
 
-return translateScheduleModifier(modType1.v);
+return translateScheduleModifier(modType1);
   }
   return mlir::omp::ScheduleModifier::none;
 }
 
 static mlir::omp::ScheduleModifier
-getSimdModifier(const Fortran::parser::OmpScheduleClause &x) {
-  const auto &modifier =
-  std::get>(x.t);
+getSimdModifier(const omp::clause::Schedule &clause) {
+  using ScheduleModifier = omp::clause::Schedule::ScheduleModifier;
+  const auto &modifier = std::get>(clause.t);
   // Either of the two possible modifiers in the input can be the SIMD 
modifier,
   // so look in either one, and return simd if we find one. Not found = return
   // "none".
   if (modifier) {
-const auto &modType1 =
-std::get(modifier->t);
-if (modType1.v.v == 
Fortran::parser::OmpScheduleModifierType::ModType::Simd)
+using ModType = omp::clause::Schedule::ModType;
+const auto &modType1 = std::get(modifier->t);
+if (modType1 == ModType::Simd)
   return mlir::omp::ScheduleModifier::simd;
 
-const auto &modType2 = std::get<
-std::optional>(
-modifier->t);
-if (modType2 && modType2->v.v ==
-
Fortran::parser::OmpScheduleModifierType::ModType::Simd)
+const auto &modType2 = std::get>(modifier->t);
+if (modType2 && *modType2 == ModType::Simd)
   return mlir::omp::ScheduleModifier::simd;
   }
   return mlir::omp::ScheduleModifier::none;
@@ -141,21 +133,21 @@ genAllocateClause(Fortran::lower::AbstractConverter 
&converter,
   genObjectList(ompObject

[llvm-branch-commits] [flang] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProc… (PR #81623)

2024-02-23 Thread Krzysztof Parzyszek via llvm-branch-commits


@@ -2865,53 +2865,45 @@ bool ClauseProcessor::processDepend(
 llvm::SmallVectorImpl &dependOperands) const {
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
 
-  return findRepeatableClause(
-  [&](const ClauseTy::Depend *dependClause,
+  return findRepeatableClause(
+  [&](const omp::clause::Depend &clause,
   const Fortran::parser::CharBlock &) {
-const std::list &depVal =
-std::get>(
-std::get(
-dependClause->v.u)
-.t);
+assert(std::holds_alternative(clause.u) &&
+   "Only InOut is handled at the moment");
+const auto &inOut = std::get(clause.u);
+const auto &objects = std::get(inOut.t);
+
 mlir::omp::ClauseTaskDependAttr dependTypeOperand =
-genDependKindAttr(firOpBuilder, dependClause);
-dependTypeOperands.insert(dependTypeOperands.end(), depVal.size(),
-  dependTypeOperand);
-for (const Fortran::parser::Designator &ompObject : depVal) {
-  Fortran::semantics::Symbol *sym = nullptr;
-  std::visit(
-  Fortran::common::visitors{
-  [&](const Fortran::parser::DataRef &designator) {
-if (const Fortran::parser::Name *name =
-std::get_if(&designator.u)) 
{
-  sym = name->symbol;
-} else if (std::get_if>(
-   &designator.u)) {
-  TODO(converter.getCurrentLocation(),
-   "array sections not supported for task depend");
-}
-  },
-  [&](const Fortran::parser::Substring &designator) {
-TODO(converter.getCurrentLocation(),
- "substring not supported for task depend");
-  }},
-  (ompObject).u);
+genDependKindAttr(firOpBuilder, clause);
+dependTypeOperands.append(objects.size(), dependTypeOperand);
+
+for (const omp::Object &object : objects) {
+  assert(object.dsg && "Expecting designator");
+
+  if (Fortran::evaluate::ExtractSubstring(*object.dsg)) {
+TODO(converter.getCurrentLocation(),
+ "substring not supported for task depend");
+  } else if (Fortran::evaluate::IsArrayElement(*object.dsg)) {
+TODO(converter.getCurrentLocation(),
+ "array sections not supported for task depend");
+  }
+
+  Fortran::semantics::Symbol *sym = object.sym;
   const mlir::Value variable = converter.getSymbolAddress(*sym);
   dependOperands.push_back(variable);
 }

kparzysz wrote:

The old code is below for reference.

First, the code created (unconditionally) a list of designators from the list 
of objects.  In my implementation, if an object was a designator, the 
designator would be present in `omp::Object`.  If the object is not a 
designator, the code would fail at runtime in both cases.

Then, a `DataRef` object is obtained from the designator, if present, but 
that's only to get the symbol out of it.  The other two cases (Substring and 
ArrayElement) are both TODO, which is what my code does as well.

```
const std::list &depVal =
std::get>(
std::get(
dependClause->v.u)
.t);
mlir::omp::ClauseTaskDependAttr dependTypeOperand =
genDependKindAttr(firOpBuilder, dependClause);
dependTypeOperands.insert(dependTypeOperands.end(), depVal.size(),
  dependTypeOperand);
for (const Fortran::parser::Designator &ompObject : depVal) {
  Fortran::semantics::Symbol *sym = nullptr;
  std::visit(
  Fortran::common::visitors{
  [&](const Fortran::parser::DataRef &designator) {
if (const Fortran::parser::Name *name =
std::get_if(&designator.u)) {
  sym = name->symbol;
} else if (std::get_if>(
   &designator.u)) {
  TODO(converter.getCurrentLocation(),
   "array sections not supported for task depend");
}
  },
  [&](const Fortran::parser::Substring &designator) {
TODO(converter.getCurrentLocation(),
 "substring not supported for task depend");
  }},
  (ompObject).u);
  const mlir::Value variable = converter.getSymbolAddress(*sym);
```

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

[llvm-branch-commits] [clang] [llvm] release/18.x: [AArch64] Backport Ampere1B support (#81297 , #81341, and #81744) (PR #81857)

2024-02-23 Thread Aaron Ballman via llvm-branch-commits

AaronBallman wrote:

> I'm OK with this kind of change if the AArch64 maintainers are on board. 
> @AaronBallman Do you have a strong objection to this PR?

We don't typically backport *features* unless there's some strongly compelling 
case. This sounds like a nice-to-have but I'm not certain why it can't wait for 
Clang 19 (and have more in-tree time to bake), especially since rc3 is already 
out the door: https://llvm.org/docs/HowToReleaseLLVM.html#release-patch-rules

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


[llvm-branch-commits] [clang] [llvm] release/18.x: [AArch64] Backport Ampere1B support (#81297 , #81341, and #81744) (PR #81857)

2024-02-23 Thread Aaron Ballman via llvm-branch-commits

AaronBallman wrote:

> > I'm OK with this kind of change if the AArch64 maintainers are on board. 
> > @AaronBallman Do you have a strong objection to this PR?
> 
> We don't typically backport _features_ unless there's some strongly 
> compelling case. This sounds like a nice-to-have but I'm not certain why it 
> can't wait for Clang 19 (and have more in-tree time to bake), especially 
> since rc3 is already out the door: 
> https://llvm.org/docs/HowToReleaseLLVM.html#release-patch-rules

To be clear, I'm not strongly opposed, I'm just trying to understand whether 
this meets our usual criteria and if it doesn't, what about this situation 
warrants an exception.

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


[llvm-branch-commits] [flang] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProc… (PR #81623)

2024-02-23 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/81623

>From 655dce519efb87f8d3babf3b7a5d6132bb82e2a6 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 21 Feb 2024 15:51:38 -0600
Subject: [PATCH] [flang][OpenMP] Convert repeatable clauses (except Map) in
 ClauseProcessor

Rename `findRepeatableClause` to `findRepeatableClause2`, and make the
new `findRepeatableClause` operate on new `omp::Clause` objects.

Leave `Map` unchanged, because it will require more changes for it to
work.
---
 flang/include/flang/Evaluate/tools.h  |  23 ++
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp| 218 --
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  29 ++-
 flang/lib/Lower/OpenMP/Clauses.cpp|   6 -
 flang/lib/Lower/OpenMP/Clauses.h  |   6 +
 flang/lib/Lower/OpenMP/OpenMP.cpp | 182 +++
 flang/lib/Lower/OpenMP/ReductionProcessor.cpp | 155 ++---
 flang/lib/Lower/OpenMP/ReductionProcessor.h   |  23 +-
 flang/lib/Lower/OpenMP/Utils.cpp  |  41 ++--
 flang/lib/Lower/OpenMP/Utils.h|  10 +-
 10 files changed, 348 insertions(+), 345 deletions(-)

diff --git a/flang/include/flang/Evaluate/tools.h 
b/flang/include/flang/Evaluate/tools.h
index d257da1a709642..e974944e88 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -430,6 +430,29 @@ template  std::optional 
ExtractCoarrayRef(const A &x) {
   }
 }
 
+struct ExtractSubstringHelper {
+  template  static std::optional visit(T &&) {
+return std::nullopt;
+  }
+
+  static std::optional visit(const Substring &e) { return e; }
+
+  template 
+  static std::optional visit(const Designator &e) {
+return std::visit([](auto &&s) { return visit(s); }, e.u);
+  }
+
+  template 
+  static std::optional visit(const Expr &e) {
+return std::visit([](auto &&s) { return visit(s); }, e.u);
+  }
+};
+
+template 
+std::optional ExtractSubstring(const A &x) {
+  return ExtractSubstringHelper::visit(x);
+}
+
 // If an expression is simply a whole symbol data designator,
 // extract and return that symbol, else null.
 template  const Symbol *UnwrapWholeSymbolDataRef(const A &x) {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 9987cd73fc7670..6e45a939333d62 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -87,7 +87,7 @@ getSimdModifier(const omp::clause::Schedule &clause) {
 
 static void
 genAllocateClause(Fortran::lower::AbstractConverter &converter,
-  const Fortran::parser::OmpAllocateClause &ompAllocateClause,
+  const omp::clause::Allocate &clause,
   llvm::SmallVectorImpl &allocatorOperands,
   llvm::SmallVectorImpl &allocateOperands) {
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
@@ -95,21 +95,18 @@ genAllocateClause(Fortran::lower::AbstractConverter 
&converter,
   Fortran::lower::StatementContext stmtCtx;
 
   mlir::Value allocatorOperand;
-  const Fortran::parser::OmpObjectList &ompObjectList =
-  std::get(ompAllocateClause.t);
-  const auto &allocateModifier = std::get<
-  std::optional>(
-  ompAllocateClause.t);
+  const omp::ObjectList &objectList = std::get(clause.t);
+  const auto &modifier =
+  std::get>(clause.t);
 
   // If the allocate modifier is present, check if we only use the allocator
   // submodifier.  ALIGN in this context is unimplemented
   const bool onlyAllocator =
-  allocateModifier &&
-  std::holds_alternative<
-  Fortran::parser::OmpAllocateClause::AllocateModifier::Allocator>(
-  allocateModifier->u);
+  modifier &&
+  std::holds_alternative(
+  modifier->u);
 
-  if (allocateModifier && !onlyAllocator) {
+  if (modifier && !onlyAllocator) {
 TODO(currentLocation, "OmpAllocateClause ALIGN modifier");
   }
 
@@ -117,20 +114,17 @@ genAllocateClause(Fortran::lower::AbstractConverter 
&converter,
   // to list of allocators, otherwise, add default allocator to
   // list of allocators.
   if (onlyAllocator) {
-const auto &allocatorValue = std::get<
-Fortran::parser::OmpAllocateClause::AllocateModifier::Allocator>(
-allocateModifier->u);
-allocatorOperand = fir::getBase(converter.genExprValue(
-*Fortran::semantics::GetExpr(allocatorValue.v), stmtCtx));
-allocatorOperands.insert(allocatorOperands.end(), ompObjectList.v.size(),
- allocatorOperand);
+const auto &value =
+std::get(modifier->u);
+mlir::Value operand =
+fir::getBase(converter.genExprValue(value.v, stmtCtx));
+allocatorOperands.append(objectList.size(), operand);
   } else {
-allocatorOperand = firOpBuilder.createIntegerConstant(
+mlir::Value operand = firOpBuilder.createIntegerConstant(
 currentLocation, firOpBuilder.getI32Type(), 1);

[llvm-branch-commits] [flang] [flang][Lower] Convert OMP Map and related functions to evaluate::Expr (PR #81626)

2024-02-23 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/81626

>From bf64cd32fdba5af2b40c36c801228adf6ef53405 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 21 Feb 2024 16:39:35 -0600
Subject: [PATCH] [flang][Lower] Convert OMP Map and related functions to
 evaluate::Expr

The related functions are `gatherDataOperandAddrAndBounds` and
`genBoundsOps`. The former is used in OpenACC as well, and it was
updated to pass evaluate::Expr instead of parser objects.

The difference in the test case comes from unfolded conversions
of index expressions, which are explicitly of type integer(kind=8).

Delete now unused `findRepeatableClause2` and `findClause2`.

Add `AsGenericExpr` that takes std::optional. It already returns optional
Expr. Making it accept an optional Expr as input would reduce the number
of necessary checks when handling frequent optional values in evaluator.
---
 flang/include/flang/Evaluate/tools.h   |   8 +
 flang/lib/Lower/DirectivesCommon.h | 389 +
 flang/lib/Lower/OpenACC.cpp|  54 ++-
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp |  44 ++-
 flang/lib/Lower/OpenMP/ClauseProcessor.h   |  59 +---
 flang/lib/Lower/OpenMP/OpenMP.cpp  |  19 +-
 6 files changed, 317 insertions(+), 256 deletions(-)

diff --git a/flang/include/flang/Evaluate/tools.h 
b/flang/include/flang/Evaluate/tools.h
index e974944e88..d5713cfe420a2e 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -148,6 +148,14 @@ inline Expr AsGenericExpr(Expr &&x) { 
return std::move(x); }
 std::optional> AsGenericExpr(DataRef &&);
 std::optional> AsGenericExpr(const Symbol &);
 
+// Propagate std::optional from input to output.
+template 
+std::optional> AsGenericExpr(std::optional &&x) {
+  if (!x)
+return std::nullopt;
+  return AsGenericExpr(std::move(*x));
+}
+
 template 
 common::IfNoLvalue::category>>, A> AsCategoryExpr(
 A &&x) {
diff --git a/flang/lib/Lower/DirectivesCommon.h 
b/flang/lib/Lower/DirectivesCommon.h
index 8d560db34e05bf..2fa90572bc63eb 100644
--- a/flang/lib/Lower/DirectivesCommon.h
+++ b/flang/lib/Lower/DirectivesCommon.h
@@ -808,6 +808,75 @@ genBaseBoundsOps(fir::FirOpBuilder &builder, 
mlir::Location loc,
   return bounds;
 }
 
+namespace detail {
+template  //
+static T &&AsRvalueRef(T &&t) {
+  return std::move(t);
+}
+template  //
+static T AsRvalueRef(T &t) {
+  return t;
+}
+template  //
+static T AsRvalueRef(const T &t) {
+  return t;
+}
+
+// Helper class for stripping enclosing parentheses and a conversion that
+// preserves type category. This is used for triplet elements, which are
+// always of type integer(kind=8). The lower/upper bounds are converted to
+// an "index" type, which is 64-bit, so the explicit conversion to kind=8
+// (if present) is not needed. When it's present, though, it causes generated
+// names to contain "int(..., kind=8)".
+struct PeelConvert {
+  template 
+  static Fortran::semantics::MaybeExpr visit_with_category(
+  const Fortran::evaluate::Expr>
+  &expr) {
+return std::visit(
+[](auto &&s) { return visit_with_category(s); },
+expr.u);
+  }
+  template 
+  static Fortran::semantics::MaybeExpr visit_with_category(
+  const Fortran::evaluate::Convert,
+   Category> &expr) {
+return AsGenericExpr(AsRvalueRef(expr.left()));
+  }
+  template 
+  static Fortran::semantics::MaybeExpr visit_with_category(const T &) {
+return std::nullopt; //
+  }
+  template 
+  static Fortran::semantics::MaybeExpr visit_with_category(const T &) {
+return std::nullopt; //
+  }
+
+  template 
+  static Fortran::semantics::MaybeExpr
+  visit(const Fortran::evaluate::Expr>
+&expr) {
+return std::visit([](auto &&s) { return visit_with_category(s); 
},
+  expr.u);
+  }
+  static Fortran::semantics::MaybeExpr
+  visit(const Fortran::evaluate::Expr &expr) {
+return std::visit([](auto &&s) { return visit(s); }, expr.u);
+  }
+  template  //
+  static Fortran::semantics::MaybeExpr visit(const T &) {
+return std::nullopt;
+  }
+};
+
+static Fortran::semantics::SomeExpr
+peelOuterConvert(Fortran::semantics::SomeExpr &expr) {
+  if (auto peeled = PeelConvert::visit(expr))
+return *peeled;
+  return expr;
+}
+} // namespace detail
+
 /// Generate bounds operations for an array section when subscripts are
 /// provided.
 template 
@@ -815,7 +884,7 @@ llvm::SmallVector
 genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
  Fortran::lower::AbstractConverter &converter,
  Fortran::lower::StatementContext &stmtCtx,
- const std::list &subscripts,
+ const std::vector &subscripts,
  std::stringstream &asFortran, fir::ExtendedValue &dataExv,
  bool dataExvIsAssumedSize, AddrAndBoundsInfo &info,
  bool treatIndexAsSection = false) {
@@ -828,8 +897,7 @@ genBo

[llvm-branch-commits] [flang] [flang][OpenMP] Convert processTODO and remove unused objects (PR #81627)

2024-02-23 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/81627

>From 7e785c4caa8d66457dabab31eca2bab505a05c0d Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 21 Feb 2024 16:56:47 -0600
Subject: [PATCH] [flang][OpenMP] Convert processTODO and remove unused objects

Remove `ClauseIterator2` and `clauses2` from ClauseProcessor.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.h | 16 +++
 flang/lib/Lower/OpenMP/OpenMP.cpp| 54 +---
 2 files changed, 25 insertions(+), 45 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index 47d80024295121..f2d8bcebf0b07a 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -46,13 +46,11 @@ namespace omp {
 /// methods that relate to clauses that can impact the lowering of that
 /// construct.
 class ClauseProcessor {
-  using ClauseTy = Fortran::parser::OmpClause;
-
 public:
   ClauseProcessor(Fortran::lower::AbstractConverter &converter,
   Fortran::semantics::SemanticsContext &semaCtx,
   const Fortran::parser::OmpClauseList &clauses)
-  : converter(converter), semaCtx(semaCtx), clauses2(clauses),
+  : converter(converter), semaCtx(semaCtx),
 clauses(makeList(clauses, semaCtx)) {}
 
   // 'Unique' clauses: They can appear at most once in the clause list.
@@ -157,7 +155,6 @@ class ClauseProcessor {
 
 private:
   using ClauseIterator = List::const_iterator;
-  using ClauseIterator2 = std::list::const_iterator;
 
   /// Utility to find a clause within a range in the clause list.
   template 
@@ -183,7 +180,6 @@ class ClauseProcessor {
 
   Fortran::lower::AbstractConverter &converter;
   Fortran::semantics::SemanticsContext &semaCtx;
-  const Fortran::parser::OmpClauseList &clauses2;
   List clauses;
 };
 
@@ -239,19 +235,17 @@ bool ClauseProcessor::processMotionClauses(
 template 
 void ClauseProcessor::processTODO(mlir::Location currentLocation,
   llvm::omp::Directive directive) const {
-  auto checkUnhandledClause = [&](const auto *x) {
+  auto checkUnhandledClause = [&](llvm::omp::Clause id, const auto *x) {
 if (!x)
   return;
 TODO(currentLocation,
- "Unhandled clause " +
- llvm::StringRef(Fortran::parser::ParseTreeDumper::GetNodeName(*x))
- .upper() +
+ "Unhandled clause " + llvm::omp::getOpenMPClauseName(id).upper() +
  " in " + llvm::omp::getOpenMPDirectiveName(directive).upper() +
  " construct");
   };
 
-  for (ClauseIterator2 it = clauses2.v.begin(); it != clauses2.v.end(); ++it)
-(checkUnhandledClause(std::get_if(&it->u)), ...);
+  for (ClauseIterator it = clauses.begin(); it != clauses.end(); ++it)
+(checkUnhandledClause(it->id, std::get_if(&it->u)), ...);
 }
 
 template 
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index c828fc7919b3bc..a07aba28bd76f6 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -683,9 +683,7 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
   cp.processMergeable(mergeableAttr);
   cp.processPriority(stmtCtx, priorityClauseOperand);
   cp.processDepend(dependTypeOperands, dependOperands);
-  cp.processTODO(
+  cp.processTODO(
   currentLocation, llvm::omp::Directive::OMPD_task);
 
   return genOpWithBody(
@@ -711,8 +709,8 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
   llvm::SmallVector allocateOperands, allocatorOperands;
   ClauseProcessor cp(converter, semaCtx, clauseList);
   cp.processAllocate(allocatorOperands, allocateOperands);
-  cp.processTODO(
-  currentLocation, llvm::omp::Directive::OMPD_taskgroup);
+  cp.processTODO(currentLocation,
+llvm::omp::Directive::OMPD_taskgroup);
   return genOpWithBody(
   OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
   .setGenNested(genNested)
@@ -983,16 +981,12 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
   cp.processMap(currentLocation, directive, stmtCtx, mapOperands, &mapSymTypes,
 &mapSymLocs, &mapSymbols);
 
-  cp.processTODO(
-  currentLocation, llvm::omp::Directive::OMPD_target);
+  cp.processTODO(currentLocation,
+ llvm::omp::Directive::OMPD_target);
+
   // 5.8.1 Implicit Data-Mapping Attribute Rules
   // The following code follows the implicit data-mapping rules to map all the
   // symbols used inside the region that have not been explicitly mapped using
@@ -1097,8 +1091,8 @@ genTeamsOp(Fortran::lower::AbstractConverter &converter,
   cp.processDefault();
   cp.processNumTeams(stmtCtx, numTeamsClauseOperand);
   cp.processThreadLimit(stmtCtx, threadLimitClauseOperand);
-  cp.processTODO(
-  currentLocation, llvm::omp::Directive::OMPD_teams);
+  cp.processTODO(currentLocation,
+   

[llvm-branch-commits] [flang] [flang][OpenMP] Convert DataSharingProcessor to omp::Clause (PR #81629)

2024-02-23 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/81629

>From 158901f346ae6ff3f010b2c96c01129b578291ee Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 21 Feb 2024 17:10:30 -0600
Subject: [PATCH] [flang][OpenMP] Convert DataSharingProcessor to omp::Clause

---
 .../lib/Lower/OpenMP/DataSharingProcessor.cpp | 277 +-
 flang/lib/Lower/OpenMP/DataSharingProcessor.h |  13 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |   6 +-
 3 files changed, 146 insertions(+), 150 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp 
b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 136bda0b582ee3..3b687d03adf371 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -79,30 +79,28 @@ void DataSharingProcessor::copyLastPrivateSymbol(
 }
 
 void DataSharingProcessor::collectOmpObjectListSymbol(
-const Fortran::parser::OmpObjectList &ompObjectList,
+const omp::ObjectList &objects,
 llvm::SetVector &symbolSet) {
-  for (const Fortran::parser::OmpObject &ompObject : ompObjectList.v) {
-Fortran::semantics::Symbol *sym = getOmpObjectSymbol(ompObject);
+  for (const omp::Object &object : objects) {
+Fortran::semantics::Symbol *sym = object.id();
 symbolSet.insert(sym);
   }
 }
 
 void DataSharingProcessor::collectSymbolsForPrivatization() {
   bool hasCollapse = false;
-  for (const Fortran::parser::OmpClause &clause : opClauseList.v) {
+  for (const omp::Clause &clause : clauses) {
 if (const auto &privateClause =
-std::get_if(&clause.u)) {
+std::get_if(&clause.u)) {
   collectOmpObjectListSymbol(privateClause->v, privatizedSymbols);
 } else if (const auto &firstPrivateClause =
-   std::get_if(
-   &clause.u)) {
+   std::get_if(&clause.u)) {
   collectOmpObjectListSymbol(firstPrivateClause->v, privatizedSymbols);
 } else if (const auto &lastPrivateClause =
-   std::get_if(
-   &clause.u)) {
+   std::get_if(&clause.u)) {
   collectOmpObjectListSymbol(lastPrivateClause->v, privatizedSymbols);
   hasLastPrivateOp = true;
-} else if (std::get_if(&clause.u)) {
+} else if (std::get_if(&clause.u)) {
   hasCollapse = true;
 }
   }
@@ -135,138 +133,135 @@ void DataSharingProcessor::insertBarrier() {
 void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
   bool cmpCreated = false;
   mlir::OpBuilder::InsertPoint localInsPt = firOpBuilder.saveInsertionPoint();
-  for (const Fortran::parser::OmpClause &clause : opClauseList.v) {
-if (std::get_if(&clause.u)) {
-  // TODO: Add lastprivate support for simd construct
-  if (mlir::isa(op)) {
-if (&eval == &eval.parentConstruct->getLastNestedEvaluation()) {
-  // For `omp.sections`, lastprivatized variables occur in
-  // lexically final `omp.section` operation. The following FIR
-  // shall be generated for the same:
-  //
-  // omp.sections lastprivate(...) {
-  //  omp.section {...}
-  //  omp.section {...}
-  //  omp.section {
-  //  fir.allocate for `private`/`firstprivate`
-  //  
-  //  fir.if %true {
-  //  ^%lpv_update_blk
-  //  }
-  //  }
-  // }
-  //
-  // To keep code consistency while handling privatization
-  // through this control flow, add a `fir.if` operation
-  // that always evaluates to true, in order to create
-  // a dedicated sub-region in `omp.section` where
-  // lastprivate FIR can reside. Later canonicalizations
-  // will optimize away this operation.
-  if (!eval.lowerAsUnstructured()) {
-auto ifOp = firOpBuilder.create(
-op->getLoc(),
-firOpBuilder.createIntegerConstant(
-op->getLoc(), firOpBuilder.getIntegerType(1), 0x1),
-/*else*/ false);
-firOpBuilder.setInsertionPointToStart(
-&ifOp.getThenRegion().front());
-
-const Fortran::parser::OpenMPConstruct *parentOmpConstruct =
-
eval.parentConstruct->getIf();
-assert(parentOmpConstruct &&
-   "Expected a valid enclosing OpenMP construct");
-const Fortran::parser::OpenMPSectionsConstruct *sectionsConstruct =
-std::get_if(
-&parentOmpConstruct->u);
-assert(sectionsConstruct &&
-   "Expected an enclosing omp.sections construct");
-const Fortran::parser::OmpClauseList §ionsEndClauseList =
-std::get(
-std::get(
-sectionsConstruct->t)
-.t);
-for (const Fortran::parser::OmpClause &otherClause :

[llvm-branch-commits] [clang] [Clang] Fixes to immediate-escalating functions (#82281) (PR #82609)

2024-02-23 Thread Balazs Benics via llvm-branch-commits

https://github.com/steakhal updated 
https://github.com/llvm/llvm-project/pull/82609

>From c96211c576d13c38edb5ea39da3b44b2e0f6feed Mon Sep 17 00:00:00 2001
From: cor3ntin 
Date: Wed, 21 Feb 2024 20:53:44 +0100
Subject: [PATCH] [Clang] Fixes to immediate-escalating functions (#82281)

* Consider that immediate escalating function can appear at global
scope, fixing a crash

* Lambda conversion to function pointer was sometimes not performed in
an immediate function context when it should be.

Fixes #82258

(cherry picked from commit baf6bd303bd58a521809d456dd9b179636982fc5)
---
 clang/docs/ReleaseNotes.rst   |  5 
 clang/include/clang/Sema/Sema.h   |  4 ++-
 clang/lib/Sema/SemaExpr.cpp   |  4 +--
 .../SemaCXX/cxx2b-consteval-propagate.cpp | 26 +++
 4 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 93a67e7a895592..8697f1f3bbe9c2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1099,6 +1099,11 @@ Bug Fixes to C++ Support
 - Fix incorrect code generation caused by the object argument of ``static 
operator()`` and ``static operator[]`` calls not being evaluated.
   Fixes (`#67976 `_)
 
+- Fix crash when using an immediate-escalated function at global scope.
+  (`#82258 `_)
+- Correctly immediate-escalate lambda conversion functions.
+  (`#82258 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1f1cbd11ff7358..6adb8fb7966b3f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1090,7 +1090,9 @@ class Sema final {
   if (FD) {
 FD->setWillHaveBody(true);
 S.ExprEvalContexts.back().InImmediateFunctionContext =
-FD->isImmediateFunction();
+FD->isImmediateFunction() ||
+S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
+.isConstantEvaluated();
 S.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
 S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating();
   } else
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0d9c087ed0cd19..4cce0abc231505 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -18294,7 +18294,6 @@ void Sema::CheckUnusedVolatileAssignment(Expr *E) {
 }
 
 void Sema::MarkExpressionAsImmediateEscalating(Expr *E) {
-  assert(!FunctionScopes.empty() && "Expected a function scope");
   assert(getLangOpts().CPlusPlus20 &&
  ExprEvalContexts.back().InImmediateEscalatingFunctionContext &&
  "Cannot mark an immediate escalating expression outside of an "
@@ -18311,7 +18310,8 @@ void Sema::MarkExpressionAsImmediateEscalating(Expr *E) 
{
   } else {
 assert(false && "expected an immediately escalating expression");
   }
-  getCurFunction()->FoundImmediateEscalatingExpression = true;
+  if (FunctionScopeInfo *FI = getCurFunction())
+FI->FoundImmediateEscalatingExpression = true;
 }
 
 ExprResult Sema::CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl) 
{
diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp 
b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
index 531a6262287335..4a75392045d05a 100644
--- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -368,3 +368,29 @@ vector v{};
 // expected-note@-2 {{in call to 'vector()'}}
 
 }
+
+
+namespace GH82258 {
+
+template 
+constexpr auto none_of(R&& r, Pred pred) -> bool { return true; }
+
+struct info { int value; };
+consteval auto is_invalid(info i) -> bool { return false; }
+constexpr info types[] = { {1}, {3}, {5}};
+
+static_assert(none_of(
+types,
++[](info i) consteval {
+return is_invalid(i);
+}
+));
+
+static_assert(none_of(
+types,
+[]{
+return is_invalid;
+}()
+));
+
+}

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


[llvm-branch-commits] [libcxx] [libc++] Add details about string annotations (PR #82730)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [SLP] Initial vectorization of non-power-of-2 ops. (PR #77790)

2024-02-23 Thread Florian Hahn via llvm-branch-commits

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


[llvm-branch-commits] [flang] [flang][Lower] Convert OMP Map and related functions to evaluate::Expr (PR #81626)

2024-02-23 Thread Krzysztof Parzyszek via llvm-branch-commits

kparzysz wrote:

It's a dangling reference problem: 
https://github.com/llvm/llvm-project/pull/82800.

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


[llvm-branch-commits] [clang] fix links on clang 18.1.0rc release page (PR #82739)

2024-02-23 Thread Aaron Ballman via llvm-branch-commits

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

LGTM!

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


[llvm-branch-commits] [compiler-rt] [scudo] Allow to resize allocation ring buffer (PR #82683)

2024-02-23 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/82683

>From af8afe08ee20a04b2ccb363cac66aa02cfaecd02 Mon Sep 17 00:00:00 2001
From: Florian Mayer 
Date: Thu, 22 Feb 2024 12:37:06 -0800
Subject: [PATCH] update message

Created using spr 1.3.4
---
 compiler-rt/lib/scudo/standalone/combined.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compiler-rt/lib/scudo/standalone/combined.h 
b/compiler-rt/lib/scudo/standalone/combined.h
index 479e49c328e3d7..24ad979a9653e1 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -1600,6 +1600,9 @@ class Allocator {
   }
 
   void swapOutRingBuffer(AllocationRingBuffer *NewRB) {
+// To allow resizeRingBuffer to be called in a multi-threaded context by 
apps,
+// we do not actually unmap, but only madvise(DONTNEED) the pages. That 
way,
+// straggler threads will not crash.
 AllocationRingBuffer *PrevRB = reinterpret_cast(
 atomic_exchange(&RingBufferAddress, reinterpret_cast(NewRB),
 memory_order_acq_rel));

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


[llvm-branch-commits] [compiler-rt] [scudo] Allow to resize allocation ring buffer (PR #82683)

2024-02-23 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/82683

>From af8afe08ee20a04b2ccb363cac66aa02cfaecd02 Mon Sep 17 00:00:00 2001
From: Florian Mayer 
Date: Thu, 22 Feb 2024 12:37:06 -0800
Subject: [PATCH] update message

Created using spr 1.3.4
---
 compiler-rt/lib/scudo/standalone/combined.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compiler-rt/lib/scudo/standalone/combined.h 
b/compiler-rt/lib/scudo/standalone/combined.h
index 479e49c328e3d7..24ad979a9653e1 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -1600,6 +1600,9 @@ class Allocator {
   }
 
   void swapOutRingBuffer(AllocationRingBuffer *NewRB) {
+// To allow resizeRingBuffer to be called in a multi-threaded context by 
apps,
+// we do not actually unmap, but only madvise(DONTNEED) the pages. That 
way,
+// straggler threads will not crash.
 AllocationRingBuffer *PrevRB = reinterpret_cast(
 atomic_exchange(&RingBufferAddress, reinterpret_cast(NewRB),
 memory_order_acq_rel));

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


[llvm-branch-commits] [clang] 1ea6a98 - ReleaseNotes: mention -mtls-dialect=desc (#82731)

2024-02-23 Thread via llvm-branch-commits

Author: Fangrui Song
Date: 2024-02-23T12:43:55-08:00
New Revision: 1ea6a9814233cd1ccf933ed43f95c0efabeab9d7

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

LOG: ReleaseNotes: mention -mtls-dialect=desc (#82731)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 93a67e7a895592..6121ef7fa98c04 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1286,6 +1286,7 @@ RISC-V Support
   for RV64.
 
 - ``__attribute__((rvv_vector_bits(N)))`` is now supported for RVV vbool*_t 
types.
+- ``-mtls-dialect=desc`` is now supported to enable TLS descriptors (TLSDESC).
 
 CUDA/HIP Language Changes
 ^



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


[llvm-branch-commits] [clang] ReleaseNotes: mention -mtls-dialect=desc (PR #82731)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [llvm] release/18.x: [Loads] Fix crash in isSafeToLoadUnconditionally with scalable accessed type (#82650) (PR #82664)

2024-02-23 Thread via llvm-branch-commits

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

>From 4195885b95c87a6584302f951e5268d83c0a58bf Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Fri, 23 Feb 2024 01:49:19 +0800
Subject: [PATCH] [Loads] Fix crash in isSafeToLoadUnconditionally with
 scalable accessed type (#82650)

This fixes #82606 by updating isSafeToLoadUnconditionally to handle
fixed sized loads from a scalable accessed type.

(cherry picked from commit b0edc1c45284586fdb12edd666f95d99f5f62b43)
---
 llvm/lib/Analysis/Loads.cpp   |  6 +++---
 .../VectorCombine/RISCV/load-widening.ll  | 19 +++
 2 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll

diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 6bf0d2f56eb4eb..5916d2ab48ecec 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -364,7 +364,7 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Align 
Alignment, APInt &Size,
 
   if (Size.getBitWidth() > 64)
 return false;
-  const uint64_t LoadSize = Size.getZExtValue();
+  const TypeSize LoadSize = TypeSize::getFixed(Size.getZExtValue());
 
   // Otherwise, be a little bit aggressive by scanning the local block where we
   // want to check to see if the pointer is already being loaded or stored
@@ -414,11 +414,11 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Align 
Alignment, APInt &Size,
 
 // Handle trivial cases.
 if (AccessedPtr == V &&
-LoadSize <= DL.getTypeStoreSize(AccessedTy))
+TypeSize::isKnownLE(LoadSize, DL.getTypeStoreSize(AccessedTy)))
   return true;
 
 if (AreEquivalentAddressValues(AccessedPtr->stripPointerCasts(), V) &&
-LoadSize <= DL.getTypeStoreSize(AccessedTy))
+TypeSize::isKnownLE(LoadSize, DL.getTypeStoreSize(AccessedTy)))
   return true;
   }
   return false;
diff --git a/llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll 
b/llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll
new file mode 100644
index 00..0a43ad2f9a3684
--- /dev/null
+++ b/llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt < %s -passes=vector-combine -S -mtriple=riscv32 -mattr=+v | 
FileCheck %s
+; RUN: opt < %s -passes=vector-combine -S -mtriple=riscv64 -mattr=+v | 
FileCheck %s
+
+define void @fixed_load_scalable_src(ptr %p) {
+; CHECK-LABEL: define void @fixed_load_scalable_src(
+; CHECK-SAME: ptr [[P:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:store  zeroinitializer, ptr [[P]], align 8
+; CHECK-NEXT:[[TMP0:%.*]] = load <4 x i16>, ptr [[P]], align 8
+; CHECK-NEXT:[[TMP1:%.*]] = shufflevector <4 x i16> [[TMP0]], <4 x i16> 
zeroinitializer, <8 x i32> 
+; CHECK-NEXT:ret void
+;
+entry:
+  store  zeroinitializer, ptr %p
+  %0 = load <4 x i16>, ptr %p
+  %1 = shufflevector <4 x i16> %0, <4 x i16> zeroinitializer, <8 x i32> 
+  ret void
+}

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


[llvm-branch-commits] [llvm] 4195885 - [Loads] Fix crash in isSafeToLoadUnconditionally with scalable accessed type (#82650)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

Author: Luke Lau
Date: 2024-02-23T12:44:49-08:00
New Revision: 4195885b95c87a6584302f951e5268d83c0a58bf

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

LOG: [Loads] Fix crash in isSafeToLoadUnconditionally with scalable accessed 
type (#82650)

This fixes #82606 by updating isSafeToLoadUnconditionally to handle
fixed sized loads from a scalable accessed type.

(cherry picked from commit b0edc1c45284586fdb12edd666f95d99f5f62b43)

Added: 
llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll

Modified: 
llvm/lib/Analysis/Loads.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 6bf0d2f56eb4eb..5916d2ab48ecec 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -364,7 +364,7 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Align 
Alignment, APInt &Size,
 
   if (Size.getBitWidth() > 64)
 return false;
-  const uint64_t LoadSize = Size.getZExtValue();
+  const TypeSize LoadSize = TypeSize::getFixed(Size.getZExtValue());
 
   // Otherwise, be a little bit aggressive by scanning the local block where we
   // want to check to see if the pointer is already being loaded or stored
@@ -414,11 +414,11 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Align 
Alignment, APInt &Size,
 
 // Handle trivial cases.
 if (AccessedPtr == V &&
-LoadSize <= DL.getTypeStoreSize(AccessedTy))
+TypeSize::isKnownLE(LoadSize, DL.getTypeStoreSize(AccessedTy)))
   return true;
 
 if (AreEquivalentAddressValues(AccessedPtr->stripPointerCasts(), V) &&
-LoadSize <= DL.getTypeStoreSize(AccessedTy))
+TypeSize::isKnownLE(LoadSize, DL.getTypeStoreSize(AccessedTy)))
   return true;
   }
   return false;

diff  --git a/llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll 
b/llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll
new file mode 100644
index 00..0a43ad2f9a3684
--- /dev/null
+++ b/llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt < %s -passes=vector-combine -S -mtriple=riscv32 -mattr=+v | 
FileCheck %s
+; RUN: opt < %s -passes=vector-combine -S -mtriple=riscv64 -mattr=+v | 
FileCheck %s
+
+define void @fixed_load_scalable_src(ptr %p) {
+; CHECK-LABEL: define void @fixed_load_scalable_src(
+; CHECK-SAME: ptr [[P:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:store  zeroinitializer, ptr [[P]], align 8
+; CHECK-NEXT:[[TMP0:%.*]] = load <4 x i16>, ptr [[P]], align 8
+; CHECK-NEXT:[[TMP1:%.*]] = shufflevector <4 x i16> [[TMP0]], <4 x i16> 
zeroinitializer, <8 x i32> 
+; CHECK-NEXT:ret void
+;
+entry:
+  store  zeroinitializer, ptr %p
+  %0 = load <4 x i16>, ptr %p
+  %1 = shufflevector <4 x i16> %0, <4 x i16> zeroinitializer, <8 x i32> 
+  ret void
+}



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


[llvm-branch-commits] [llvm] release/18.x: [Loads] Fix crash in isSafeToLoadUnconditionally with scalable accessed type (#82650) (PR #82664)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [libcxx] release/18.x: [libc++] Only include from the C library if it exists (#81887) (PR #82045)

2024-02-23 Thread via llvm-branch-commits

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

>From 9c434b47332a7e4128e5bedba44e4de18eadd564 Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Fri, 16 Feb 2024 16:45:00 -0500
Subject: [PATCH] [libc++] Only include  from the C library if it
 exists (#81887)

In 2cea1babefbb, we removed the  header provided by libc++. However, 
we did not conditionally include the underlying 
header only if the C library provides one, which we otherwise do consistently 
(see e.g. 647ddc08f43c).

rdar://122978778
(cherry picked from commit d8278b682386f51dfba204849c624672a3df40c7)
---
 libcxx/include/csetjmp | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libcxx/include/csetjmp b/libcxx/include/csetjmp
index d219c8e6cb2250..9012cad22ebe74 100644
--- a/libcxx/include/csetjmp
+++ b/libcxx/include/csetjmp
@@ -33,7 +33,13 @@ void longjmp(jmp_buf env, int val);
 #include <__assert> // all public C++ headers provide the assertion handler
 #include <__config>
 
-#include 
+//  is not provided by libc++
+#if __has_include()
+#  include 
+#  ifdef _LIBCPP_SETJMP_H
+#error "If libc++ starts defining , the __has_include check 
should move to libc++'s "
+#  endif
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

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


[llvm-branch-commits] [libcxx] 9c434b4 - [libc++] Only include from the C library if it exists (#81887)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

Author: Louis Dionne
Date: 2024-02-23T12:46:52-08:00
New Revision: 9c434b47332a7e4128e5bedba44e4de18eadd564

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

LOG: [libc++] Only include  from the C library if it exists (#81887)

In 2cea1babefbb, we removed the  header provided by libc++. However, 
we did not conditionally include the underlying 
header only if the C library provides one, which we otherwise do consistently 
(see e.g. 647ddc08f43c).

rdar://122978778
(cherry picked from commit d8278b682386f51dfba204849c624672a3df40c7)

Added: 


Modified: 
libcxx/include/csetjmp

Removed: 




diff  --git a/libcxx/include/csetjmp b/libcxx/include/csetjmp
index d219c8e6cb2250..9012cad22ebe74 100644
--- a/libcxx/include/csetjmp
+++ b/libcxx/include/csetjmp
@@ -33,7 +33,13 @@ void longjmp(jmp_buf env, int val);
 #include <__assert> // all public C++ headers provide the assertion handler
 #include <__config>
 
-#include 
+//  is not provided by libc++
+#if __has_include()
+#  include 
+#  ifdef _LIBCPP_SETJMP_H
+#error "If libc++ starts defining , the __has_include check 
should move to libc++'s "
+#  endif
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header



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


[llvm-branch-commits] [libcxx] release/18.x: [libc++] Only include from the C library if it exists (#81887) (PR #82045)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [llvm] release/18.x: [docs][llvm-objcopy] Add missing formats (#81981) (PR #82470)

2024-02-23 Thread via llvm-branch-commits

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

>From 710314502424782d49c7c57e0d8959a8231e5db1 Mon Sep 17 00:00:00 2001
From: Ulrich Weigand 
Date: Fri, 16 Feb 2024 12:11:04 +0100
Subject: [PATCH] [docs][llvm-objcopy] Add missing formats (#81981)

Bring list of supported formats in docs back in sync with the code.

(cherry picked from commit bf471c915d14035a24ec027fb2bb0373cefdabe1)
---
 llvm/docs/CommandGuide/llvm-objcopy.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/llvm/docs/CommandGuide/llvm-objcopy.rst 
b/llvm/docs/CommandGuide/llvm-objcopy.rst
index 6e13cd94b92fda..01a96f2f4f770e 100644
--- a/llvm/docs/CommandGuide/llvm-objcopy.rst
+++ b/llvm/docs/CommandGuide/llvm-objcopy.rst
@@ -538,6 +538,10 @@ options. For GNU :program:`objcopy` compatibility, the 
values are all bfdnames.
 - `elf64-tradlittlemips`
 - `elf32-sparc`
 - `elf32-sparcel`
+- `elf32-hexagon`
+- `elf32-loongarch`
+- `elf64-loongarch`
+- `elf64-s390`
 
 Additionally, all targets except `binary` and `ihex` can have `-freebsd` as a
 suffix.

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


[llvm-branch-commits] [llvm] 7103145 - [docs][llvm-objcopy] Add missing formats (#81981)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

Author: Ulrich Weigand
Date: 2024-02-23T12:48:38-08:00
New Revision: 710314502424782d49c7c57e0d8959a8231e5db1

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

LOG: [docs][llvm-objcopy] Add missing formats (#81981)

Bring list of supported formats in docs back in sync with the code.

(cherry picked from commit bf471c915d14035a24ec027fb2bb0373cefdabe1)

Added: 


Modified: 
llvm/docs/CommandGuide/llvm-objcopy.rst

Removed: 




diff  --git a/llvm/docs/CommandGuide/llvm-objcopy.rst 
b/llvm/docs/CommandGuide/llvm-objcopy.rst
index 6e13cd94b92fda..01a96f2f4f770e 100644
--- a/llvm/docs/CommandGuide/llvm-objcopy.rst
+++ b/llvm/docs/CommandGuide/llvm-objcopy.rst
@@ -538,6 +538,10 @@ options. For GNU :program:`objcopy` compatibility, the 
values are all bfdnames.
 - `elf64-tradlittlemips`
 - `elf32-sparc`
 - `elf32-sparcel`
+- `elf32-hexagon`
+- `elf32-loongarch`
+- `elf64-loongarch`
+- `elf64-s390`
 
 Additionally, all targets except `binary` and `ihex` can have `-freebsd` as a
 suffix.



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


[llvm-branch-commits] [llvm] release/18.x: [docs][llvm-objcopy] Add missing formats (#81981) (PR #82470)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj, ELF] Support --decompress/-z (#82594) (PR #82718)

2024-02-23 Thread via llvm-branch-commits

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

>From 4ba68ab9b41f8c4d1fd6d31d64e8030fe224c02e Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 22 Feb 2024 09:24:21 -0800
Subject: [PATCH] [llvm-readobj,ELF] Support --decompress/-z (#82594)

When a section has the SHF_COMPRESSED flag, -p/-x dump the compressed
content by default. In GNU readelf, if --decompress/-z is specified,
-p/-x will dump the decompressed content. This patch implements the
option.

Close #82507

(cherry picked from commit 26d71d9ed56c4c23e6284dac7a9bdf603a5801f3)
---
 llvm/docs/CommandGuide/llvm-readelf.rst   |  5 ++
 llvm/docs/CommandGuide/llvm-readobj.rst   |  5 ++
 .../ELF/decompress-zlib-unsupported.test  | 32 
 .../llvm-readobj/ELF/decompress-zlib.test | 76 +++
 .../ELF/decompress-zstd-unsupported.test  | 31 
 .../llvm-readobj/ELF/decompress-zstd.test | 28 +++
 llvm/tools/llvm-readobj/ObjDumper.cpp | 26 ++-
 llvm/tools/llvm-readobj/ObjDumper.h   |  4 +-
 llvm/tools/llvm-readobj/Opts.td   |  2 +
 llvm/tools/llvm-readobj/llvm-readobj.cpp  |  6 +-
 10 files changed, 209 insertions(+), 6 deletions(-)
 create mode 100644 
llvm/test/tools/llvm-readobj/ELF/decompress-zlib-unsupported.test
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/decompress-zlib.test
 create mode 100644 
llvm/test/tools/llvm-readobj/ELF/decompress-zstd-unsupported.test
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/decompress-zstd.test

diff --git a/llvm/docs/CommandGuide/llvm-readelf.rst 
b/llvm/docs/CommandGuide/llvm-readelf.rst
index 6ee4a5dfb15917..675628fdda45ec 100644
--- a/llvm/docs/CommandGuide/llvm-readelf.rst
+++ b/llvm/docs/CommandGuide/llvm-readelf.rst
@@ -38,6 +38,11 @@ OPTIONS
  Display the contents of the basic block address map section(s), which contain 
the
  address of each function, along with the relative offset of each basic block.
 
+.. option:: --decompress, -z
+
+  Dump decompressed section content when used with ``-x`` or ``-p``.
+  If the section(s) are not compressed, they are displayed as is.
+
 .. option:: --demangle, -C
 
  Display demangled symbol names in the output.
diff --git a/llvm/docs/CommandGuide/llvm-readobj.rst 
b/llvm/docs/CommandGuide/llvm-readobj.rst
index cb9232ef5e560a..6d78a038723445 100644
--- a/llvm/docs/CommandGuide/llvm-readobj.rst
+++ b/llvm/docs/CommandGuide/llvm-readobj.rst
@@ -56,6 +56,11 @@ file formats.
 
  Display the address-significance table.
 
+.. option:: --decompress, -z
+
+  Dump decompressed section content when used with ``-x`` or ``-p``.
+  If the section(s) are not compressed, they are displayed as is.
+
 .. option:: --expand-relocs
 
  When used with :option:`--relocs`, display each relocation in an expanded
diff --git a/llvm/test/tools/llvm-readobj/ELF/decompress-zlib-unsupported.test 
b/llvm/test/tools/llvm-readobj/ELF/decompress-zlib-unsupported.test
new file mode 100644
index 00..f4c73de7ca6c9d
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/decompress-zlib-unsupported.test
@@ -0,0 +1,32 @@
+# UNSUPPORTED: zlib
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj -z -p .a -x .b %t 2>&1 | FileCheck %s -DFILE=%t
+
+# CHECK:  String dump of section '.a':
+# CHECK-NEXT: warning: '[[FILE]]': LLVM was not built with LLVM_ENABLE_ZLIB or 
did not find zlib at build time
+# CHECK-NEXT: [ 0] .
+# CHECK-NEXT: [ 8] .
+# CHECK-NEXT: [10] .
+# CHECK-NEXT: [18] x.c.
+# CHECK-NEXT: [1e] .
+# CHECK-NEXT: [20] .
+# CHECK-NEXT: Hex dump of section '.b':
+# CHECK-NEXT: warning: '[[FILE]]': LLVM was not built with LLVM_ENABLE_ZLIB or 
did not find zlib at build time
+# CHECK-NEXT: 0x 0100  0100  
+# CHECK-NEXT: 0x0010 0100  789c6304 0200 x.c.
+# CHECK-NEXT: 0x0020 02  .
+
+--- !ELF
+FileHeader:
+  Class: ELFCLASS64
+  Data:  ELFDATA2LSB
+  Type:  ET_REL
+Sections:
+  - Name: .a
+Type: SHT_PROGBITS
+Flags: [SHF_COMPRESSED]
+Content: 010001000100789c6304020002
+  - Name: .b
+Type: SHT_PROGBITS
+Flags: [SHF_COMPRESSED]
+Content: 010001000100789c6304020002
diff --git a/llvm/test/tools/llvm-readobj/ELF/decompress-zlib.test 
b/llvm/test/tools/llvm-readobj/ELF/decompress-zlib.test
new file mode 100644
index 00..ea7a8854eb1a0c
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/decompress-zlib.test
@@ -0,0 +1,76 @@
+# REQUIRES: zlib
+## Test --decompress/-z.
+
+# RUN: yaml2obj %s -o %t
+
+# RUN: llvm-readelf -z -x .strings -x .not_null_terminated %t | FileCheck %s 
--check-prefix=HEX
+# RUN: llvm-readobj --decompress -p .strings -p .not_null_terminated %t | 
FileCheck %s --check-prefix=STR
+
+# HEX:  Hex dump of section '.strings':
+# HEX-NEXT: 0x 68657265 00617265 00736f6d 65007374 here.are.so

[llvm-branch-commits] [llvm] 4ba68ab - [llvm-readobj, ELF] Support --decompress/-z (#82594)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

Author: Fangrui Song
Date: 2024-02-23T12:51:05-08:00
New Revision: 4ba68ab9b41f8c4d1fd6d31d64e8030fe224c02e

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

LOG: [llvm-readobj,ELF] Support --decompress/-z (#82594)

When a section has the SHF_COMPRESSED flag, -p/-x dump the compressed
content by default. In GNU readelf, if --decompress/-z is specified,
-p/-x will dump the decompressed content. This patch implements the
option.

Close #82507

(cherry picked from commit 26d71d9ed56c4c23e6284dac7a9bdf603a5801f3)

Added: 
llvm/test/tools/llvm-readobj/ELF/decompress-zlib-unsupported.test
llvm/test/tools/llvm-readobj/ELF/decompress-zlib.test
llvm/test/tools/llvm-readobj/ELF/decompress-zstd-unsupported.test
llvm/test/tools/llvm-readobj/ELF/decompress-zstd.test

Modified: 
llvm/docs/CommandGuide/llvm-readelf.rst
llvm/docs/CommandGuide/llvm-readobj.rst
llvm/tools/llvm-readobj/ObjDumper.cpp
llvm/tools/llvm-readobj/ObjDumper.h
llvm/tools/llvm-readobj/Opts.td
llvm/tools/llvm-readobj/llvm-readobj.cpp

Removed: 




diff  --git a/llvm/docs/CommandGuide/llvm-readelf.rst 
b/llvm/docs/CommandGuide/llvm-readelf.rst
index 6ee4a5dfb15917..675628fdda45ec 100644
--- a/llvm/docs/CommandGuide/llvm-readelf.rst
+++ b/llvm/docs/CommandGuide/llvm-readelf.rst
@@ -38,6 +38,11 @@ OPTIONS
  Display the contents of the basic block address map section(s), which contain 
the
  address of each function, along with the relative offset of each basic block.
 
+.. option:: --decompress, -z
+
+  Dump decompressed section content when used with ``-x`` or ``-p``.
+  If the section(s) are not compressed, they are displayed as is.
+
 .. option:: --demangle, -C
 
  Display demangled symbol names in the output.

diff  --git a/llvm/docs/CommandGuide/llvm-readobj.rst 
b/llvm/docs/CommandGuide/llvm-readobj.rst
index cb9232ef5e560a..6d78a038723445 100644
--- a/llvm/docs/CommandGuide/llvm-readobj.rst
+++ b/llvm/docs/CommandGuide/llvm-readobj.rst
@@ -56,6 +56,11 @@ file formats.
 
  Display the address-significance table.
 
+.. option:: --decompress, -z
+
+  Dump decompressed section content when used with ``-x`` or ``-p``.
+  If the section(s) are not compressed, they are displayed as is.
+
 .. option:: --expand-relocs
 
  When used with :option:`--relocs`, display each relocation in an expanded

diff  --git a/llvm/test/tools/llvm-readobj/ELF/decompress-zlib-unsupported.test 
b/llvm/test/tools/llvm-readobj/ELF/decompress-zlib-unsupported.test
new file mode 100644
index 00..f4c73de7ca6c9d
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/decompress-zlib-unsupported.test
@@ -0,0 +1,32 @@
+# UNSUPPORTED: zlib
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj -z -p .a -x .b %t 2>&1 | FileCheck %s -DFILE=%t
+
+# CHECK:  String dump of section '.a':
+# CHECK-NEXT: warning: '[[FILE]]': LLVM was not built with LLVM_ENABLE_ZLIB or 
did not find zlib at build time
+# CHECK-NEXT: [ 0] .
+# CHECK-NEXT: [ 8] .
+# CHECK-NEXT: [10] .
+# CHECK-NEXT: [18] x.c.
+# CHECK-NEXT: [1e] .
+# CHECK-NEXT: [20] .
+# CHECK-NEXT: Hex dump of section '.b':
+# CHECK-NEXT: warning: '[[FILE]]': LLVM was not built with LLVM_ENABLE_ZLIB or 
did not find zlib at build time
+# CHECK-NEXT: 0x 0100  0100  
+# CHECK-NEXT: 0x0010 0100  789c6304 0200 x.c.
+# CHECK-NEXT: 0x0020 02  .
+
+--- !ELF
+FileHeader:
+  Class: ELFCLASS64
+  Data:  ELFDATA2LSB
+  Type:  ET_REL
+Sections:
+  - Name: .a
+Type: SHT_PROGBITS
+Flags: [SHF_COMPRESSED]
+Content: 010001000100789c6304020002
+  - Name: .b
+Type: SHT_PROGBITS
+Flags: [SHF_COMPRESSED]
+Content: 010001000100789c6304020002

diff  --git a/llvm/test/tools/llvm-readobj/ELF/decompress-zlib.test 
b/llvm/test/tools/llvm-readobj/ELF/decompress-zlib.test
new file mode 100644
index 00..ea7a8854eb1a0c
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/decompress-zlib.test
@@ -0,0 +1,76 @@
+# REQUIRES: zlib
+## Test --decompress/-z.
+
+# RUN: yaml2obj %s -o %t
+
+# RUN: llvm-readelf -z -x .strings -x .not_null_terminated %t | FileCheck %s 
--check-prefix=HEX
+# RUN: llvm-readobj --decompress -p .strings -p .not_null_terminated %t | 
FileCheck %s --check-prefix=STR
+
+# HEX:  Hex dump of section '.strings':
+# HEX-NEXT: 0x 68657265 00617265 00736f6d 65007374 here.are.some.st
+# HEX-NEXT: 0x0010 72696e67 7300   rings.
+# HEX:  Hex dump of section '.not_null_terminated':
+# HEX-NEXT: 0x 6e6f006e 756c6c no.null
+
+# STR:  String dump of section '.strings':
+# STR-NEXT: [ 

[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj, ELF] Support --decompress/-z (#82594) (PR #82718)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [llvm] Backport 0bf4f82 to release/18.x (PR #82571)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

@evodius96 What do you think about backporting this?

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


[llvm-branch-commits] [clang] [Clang] Fixes to immediate-escalating functions (#82281) (PR #82609)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

@cor3ntin @AaronBallman What do you think about backporting this?

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


[llvm-branch-commits] [clang] [Clang] Fixes to immediate-escalating functions (#82281) (PR #82609)

2024-02-23 Thread via llvm-branch-commits

cor3ntin wrote:

Makes sense to me!

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


[llvm-branch-commits] [llvm] [llvm][AArch64] Do not inline a function with different signing scheme. (#80642) (PR #82743)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

@nickdesaulniers What do you think about backporting this?

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


[llvm-branch-commits] [libcxx] c65d48d - [libc++] Add details about string annotations (#82730)

2024-02-23 Thread via llvm-branch-commits

Author: Tacet
Date: 2024-02-23T13:06:47-08:00
New Revision: c65d48da924b850d4f6b72243f0ef932b499c825

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

LOG: [libc++] Add details about string annotations (#82730)

This commit adds information that only long strings are annotated, and
with all allocators by default.

To read why short string annotations are not turned on yet, read
comments in a related PR:
https://github.com/llvm/llvm-project/pull/79536

Upstreamed in: 7661ade5d1ac4fc8e1e2339b2476cb8e45c24641
Upstream PR: #80912

-

Co-authored-by: Mark de Wever 

Co-authored-by: Mark de Wever 

Added: 


Modified: 
libcxx/docs/ReleaseNotes/18.rst

Removed: 




diff  --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 391e0ebc52a428..7ea13e6943dd4c 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -125,6 +125,8 @@ Improvements and New Features
   ``${PREFIX}/share/libc++/v1``.
 
 - AddressSanitizer annotations have been added to ``std::basic_string``.
+  These annotations are enabled for all allocators by default.
+  It's only enabled for long strings, strings using the small buffer 
optimization are not annotated.
 
 - The libc++ source code has been formatted with ``clang-format``. This
   `discourse thread 
`_



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


[llvm-branch-commits] [libcxx] [libc++] Add details about string annotations (PR #82730)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [llvm] Backport 0bf4f82 to release/18.x (PR #82571)

2024-02-23 Thread Alan Phipps via llvm-branch-commits

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

I think this needs to be on 18.x

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


[llvm-branch-commits] [Flang][OpenMP][MLIR] Extend derived (record) type map support in Flang OpenMP by adding some initial support for explicit member mapping (PR #81511)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [Flang][OpenMP][MLIR] Extend derived (record) type map support in Flang OpenMP by adding some initial support for explicit member mapping (PR #81511)

2024-02-23 Thread via llvm-branch-commits

agozillon wrote:

Going to close this and re-open it with the rest of the stack (one of the 
commit names was a little too long, so going to shorten them in general if I 
can). 

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


[llvm-branch-commits] [OpenMP][MLIR] Extend explicit derived type member mapping support for OpenMP dialects lowering to LLVM-IR (PR #81510)

2024-02-23 Thread via llvm-branch-commits

agozillon wrote:

Going to close this and re-open it with the rest of the stack (one of the 
commit names was a little too long, so going to shorten them in general if I 
can).

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


[llvm-branch-commits] [OpenMP][MLIR] Extend explicit derived type member mapping support for OpenMP dialects lowering to LLVM-IR (PR #81510)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [OpenMP][MLIR] Add new partial_map and members_index arguments to omp.map_info operations to help support record type mapping (PR #81509)

2024-02-23 Thread via llvm-branch-commits

agozillon wrote:

Going to close this and re-open it with the rest of the stack (one of the 
commit names was a little too long, so going to shorten them in general if I 
can).

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


[llvm-branch-commits] [OpenMP][MLIR] Add new partial_map and members_index arguments to omp.map_info operations to help support record type mapping (PR #81509)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] 95b6a7f - Backport 0bf4f82 to release/18.x (#82571)

2024-02-23 Thread via llvm-branch-commits

Author: Wentao Zhang
Date: 2024-02-23T16:07:23-08:00
New Revision: 95b6a7f2b38c821d6e8d2a11f32b53ae4d9a1522

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

LOG: Backport 0bf4f82 to release/18.x (#82571)

Manually cherry-pick 0bf4f82f661817c79bd538c82c99515837cf1cf8 (#80952)
and resolve conflicts

Closes #82570

Added: 


Modified: 
llvm/test/tools/llvm-cov/mcdc-general-none.test
llvm/test/tools/llvm-cov/mcdc-general.test
llvm/tools/llvm-cov/SourceCoverageView.cpp
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
llvm/tools/llvm-cov/SourceCoverageViewText.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-cov/mcdc-general-none.test 
b/llvm/test/tools/llvm-cov/mcdc-general-none.test
index bcf8f3cbd05d45..a373075cc5e37c 100644
--- a/llvm/test/tools/llvm-cov/mcdc-general-none.test
+++ b/llvm/test/tools/llvm-cov/mcdc-general-none.test
@@ -52,7 +52,7 @@
 // Test html output.
 // RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o 
-instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs 
%S/Inputs/mcdc-general.cpp -format html -o %t.html.dir
 // RUN: FileCheck -check-prefix=HTML 
-input-file=%t.html.dir/coverage/tmp/mcdc-general.cpp.html %s
-// HTML-COUNT-4: MC/DC Decision Region (
+// HTML-COUNT-4: MC/DC Decision Region (
 
 // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html 
%s
 // HTML-INDEX-LABEL: 

diff  --git a/llvm/test/tools/llvm-cov/mcdc-general.test 
b/llvm/test/tools/llvm-cov/mcdc-general.test
index 588aed09c16a5e..ded2f3eb1c9a5d 100644
--- a/llvm/test/tools/llvm-cov/mcdc-general.test
+++ b/llvm/test/tools/llvm-cov/mcdc-general.test
@@ -118,7 +118,7 @@
 // Test html output.
 // RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o 
-instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs 
%S/Inputs/mcdc-general.cpp -format html -o %t.html.dir
 // RUN: FileCheck -check-prefix=HTML 
-input-file=%t.html.dir/coverage/tmp/mcdc-general.cpp.html %s
-// HTML-COUNT-4: MC/DC Decision Region (
+// HTML-COUNT-4: MC/DC Decision Region (
 
 // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html 
%s
 // HTML-INDEX-LABEL: 

diff  --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp 
b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index 71edd5fec4280a..5b85d7d86bfb94 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -139,7 +139,7 @@ bool SourceCoverageView::shouldRenderRegionMarkers(
 
 bool SourceCoverageView::hasSubViews() const {
   return !ExpansionSubViews.empty() || !InstantiationSubViews.empty() ||
- !BranchSubViews.empty();
+ !BranchSubViews.empty() || !MCDCSubViews.empty();
 }
 
 std::unique_ptr

diff  --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp 
b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index abc4c49ecae98e..b93d8cb035306b 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -246,6 +246,9 @@ tr:hover {
 tr:last-child {
   border-bottom: none;
 }
+tr:has(> td >a:target) > td.code > pre {
+  background-color: #ffa;
+}
 )";
 
 const char *EndHeader = "";
@@ -990,15 +993,13 @@ void SourceCoverageViewHTML::renderMCDCView(raw_ostream 
&OS, MCDCView &MRV,
 std::string ColNoStr = Twine(DecisionRegion.ColumnStart).str();
 std::string TargetName = "L" + LineNoStr;
 OS << tag("span",
-  a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr),
-TargetName),
+  a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)),
   "line-number") +
   ") to (";
 LineNoStr = utostr(uint64_t(DecisionRegion.LineEnd));
 ColNoStr = utostr(uint64_t(DecisionRegion.ColumnEnd));
 OS << tag("span",
-  a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr),
-TargetName),
+  a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)),
   "line-number") +
   ")\n\n";
 

diff  --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp 
b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index 73b7ffe16a9637..580da45ecfc0d8 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -382,7 +382,8 @@ void SourceCoverageViewText::renderMCDCView(raw_ostream 
&OS, MCDCView &MRV,
 colored_ostream(OS, raw_ostream::RED,
 getOptions().Colors && Record.getPercentCovered() < 100.0,
 /*Bold=*/false, /*BG=*/true)
-<< format("%0.2f", Record.getPercentCovered()) << "%\n";
+<< format("%0.2f", Record.getPercentCovered()) << "%";
+OS << "\n";
 renderLinePrefix(OS, ViewDepth);
 OS << "\n";

[llvm-branch-commits] [llvm] Backport 0bf4f82 to release/18.x (PR #82571)

2024-02-23 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [OpenMP][MLIR] Add new arguments to map_info to help support record type maps (PR #82851)

2024-02-23 Thread via llvm-branch-commits

https://github.com/agozillon created 
https://github.com/llvm/llvm-project/pull/82851

This PR adds two new fields to omp.map_info, one BoolAttr and one I64ArrayAttr.

The BoolAttr is named partial_map, and is a flag that indicates if the record 
type captured by
the map_info operation is a partial map, or if it is mapped in its entirety, 
this currently helps
the later lowering determine the type of map entries that need to be generated.

The I64ArrayAttr named members_index is intended to track the placement of each 
member
map_info operations (and by extension mapped member variable) placement in the 
parent
record type. This may need to be extended to an N-D array for nested member 
mapping.



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


[llvm-branch-commits] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-02-23 Thread via llvm-branch-commits

https://github.com/agozillon created 
https://github.com/llvm/llvm-project/pull/82852

This patch seeks to refactor slightly and extend the current record type map
support that was put in place for Fortran's descriptor types to handle explicit
member mapping for record types at a single level of depth (the case of explicit
mapping of nested record types is currently unsupported).

This patch seeks to support this by extending the OpenMPToLLVMIRTranslation 
phase
to more generally support record types, building on the prior groundwork in the
Fortran allocatables/pointers patch. It now supports different kinds of record 
type
mapping, in this case full record type mapping and then explicit member mapping
in which there is a special case for certain types when mapped individually to 
not
require any parent map link in the kernel argument structure. To facilitate this
required:
   *  The movement of the setting of the map flag type "ptr_and_obj" to 
respective
 frontends, now supporting it as a possible flag that can be read and 
printed
 in mlir form. Some minor changes to declare target map type setting was
 neccesary for this.
   * The addition of a member index array operand, which tracks the position
   of the member in the parent, required for caclulating the appropriate 
size
   to offload to the target, alongside the parents offload pointer (always 
the
   first member currently being mapped).
   * A partial mapping attribute operand, to indicate if the entire record type 
is
   being mapped or just member components, aiding the ability to lower
   record types in the different manners that are possible.
   * Refactoring bounds calculation for record types and general arrays to one
   location (as well as load/store generation prior to assigning to the 
kernel
   argument structure), as a side affect enter/exit/update/data mapping
   should now be more correct and fully support bounds mapping, previously
   this would have only worked for target.



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


[llvm-branch-commits] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-02-23 Thread via llvm-branch-commits

https://github.com/agozillon created 
https://github.com/llvm/llvm-project/pull/82853

This patch is one in a series of four patches that seeks to refactor
slightly and extend the current record type map support that was
put in place for Fortran's descriptor types to handle explicit
member mapping for record types at a single level of depth.

For example, the below case where two members of a Fortran
derived type are mapped explicitly:


  type :: scalar_and_array
real(4) :: real
integer(4) :: array(10)
integer(4) :: int
  end type scalar_and_array
  type(scalar_and_array) :: scalar_arr

  !$omp target map(tofrom: scalar_arr%int, scalar_arr%real)


Current cases of derived type mapping left for future work are:
  > explicit member mapping of nested members (e.g. two layers of
 record types where we explicitly map a member from the internal
 record type)
  > Fortran's automagical mapping of all elements and nested elements
 of a derived type
  > explicit member mapping of a derived type and then constituient members
 (redundant in Fortran due to former case but still legal as far as I am 
aware)
  > explicit member mapping of a record type (may be handled reasonably, just
 not fully tested in this iteration)
  > explicit member mapping for Fortran allocatable types (a variation of nested
 record types)

This patch seeks to support this by extending the Flang-new OpenMP lowering to
support generation of this newly required information, creating the neccessary
parent <-to-> member map_info links, calculating the member indices and
setting if it's a partial map.

The OMPDescriptorMapInfoGen pass has also been generalized into a map
finalization phase, now named OMPMapInfoFinalization. This pass was extended
to support the insertion of member maps into the BlockArg and MapOperands of
relevant map carrying operations. Similar to the method in which descriptor 
types
are expanded and constituient members inserted.



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


[llvm-branch-commits] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-llvm

Author: None (agozillon)


Changes

This patch seeks to refactor slightly and extend the current record type map
support that was put in place for Fortran's descriptor types to handle explicit
member mapping for record types at a single level of depth (the case of explicit
mapping of nested record types is currently unsupported).

This patch seeks to support this by extending the OpenMPToLLVMIRTranslation 
phase
to more generally support record types, building on the prior groundwork in the
Fortran allocatables/pointers patch. It now supports different kinds of record 
type
mapping, in this case full record type mapping and then explicit member mapping
in which there is a special case for certain types when mapped individually to 
not
require any parent map link in the kernel argument structure. To facilitate this
required:
   *  The movement of the setting of the map flag type "ptr_and_obj" to 
respective
 frontends, now supporting it as a possible flag that can be read and 
printed
 in mlir form. Some minor changes to declare target map type setting was
 neccesary for this.
   * The addition of a member index array operand, which tracks the position
   of the member in the parent, required for caclulating the appropriate 
size
   to offload to the target, alongside the parents offload pointer (always 
the
   first member currently being mapped).
   * A partial mapping attribute operand, to indicate if the entire record type 
is
   being mapped or just member components, aiding the ability to lower
   record types in the different manners that are possible.
   * Refactoring bounds calculation for record types and general arrays to one
   location (as well as load/store generation prior to assigning to the 
kernel
   argument structure), as a side affect enter/exit/update/data mapping
   should now be more correct and fully support bounds mapping, previously
   this would have only worked for target.


---

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


4 Files Affected:

- (modified) 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+345-206) 
- (modified) 
mlir/test/Target/LLVMIR/omptarget-fortran-allocatable-types-host.mlir (+14-16) 
- (modified) mlir/test/Target/LLVMIR/omptarget-llvm.mlir (+27-22) 
- (added) mlir/test/Target/LLVMIR/omptarget-record-type-mapping-host.mlir (+63) 


``diff
diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 6e53d801a0d2f0..f234fcee388e30 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -33,6 +33,7 @@
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 
 #include 
+#include 
 #include 
 #include 
 
@@ -1750,9 +1751,9 @@ void collectMapDataFromMapOperands(MapInfoData &mapData,
 
   mapData.BaseType.push_back(
   moduleTranslation.convertType(mapOp.getVarType()));
-  mapData.Sizes.push_back(getSizeInBytes(
-  dl, mapOp.getVarType(), mapOp, mapData.BasePointers.back(),
-  mapData.BaseType.back(), builder, moduleTranslation));
+  mapData.Sizes.push_back(
+  getSizeInBytes(dl, mapOp.getVarType(), mapOp, 
mapData.Pointers.back(),
+ mapData.BaseType.back(), builder, moduleTranslation));
   mapData.MapClause.push_back(mapOp.getOperation());
   mapData.Types.push_back(
   llvm::omp::OpenMPOffloadMappingFlags(mapOp.getMapType().value()));
@@ -1783,6 +1784,134 @@ void collectMapDataFromMapOperands(MapInfoData &mapData,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData &mapData,
+   mlir::omp::MapInfoOp memberOp) {
+  auto *res = llvm::find(mapData.MapClause, memberOp);
+  assert(res != mapData.MapClause.end());
+  return std::distance(mapData.MapClause.begin(), res);
+}
+
+static mlir::omp::MapInfoOp
+getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
+  // Only 1 member has been mapped, we can return it.
+  if (mapInfo.getMembersIndex()->size() == 1)
+if (auto mapOp = mlir::dyn_cast(
+mapInfo.getMembers()[0].getDefiningOp()))
+  return mapOp;
+
+  std::vector indices(mapInfo.getMembersIndexAttr().size());
+  std::iota(indices.begin(), indices.end(), 0);
+  llvm::sort(indices.begin(), indices.end(),
+ [&](const size_t a, const size_t b) {
+   return mapInfo.getMembersIndexAttr()[a]
+  .cast()
+  .getInt() < mapInfo.getMembersIndexAttr()[b]
+  .cast()
+  .getInt();
+ });
+
+  if (auto mapOp = mlir::dyn_cast(
+  mapInfo.getMembers()[((first) ?

[llvm-branch-commits] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-flang-openmp

@llvm/pr-subscribers-flang-fir-hlfir

Author: None (agozillon)


Changes

This patch is one in a series of four patches that seeks to refactor
slightly and extend the current record type map support that was
put in place for Fortran's descriptor types to handle explicit
member mapping for record types at a single level of depth.

For example, the below case where two members of a Fortran
derived type are mapped explicitly:


  type :: scalar_and_array
real(4) :: real
integer(4) :: array(10)
integer(4) :: int
  end type scalar_and_array
  type(scalar_and_array) :: scalar_arr

  !$omp target map(tofrom: scalar_arr%int, scalar_arr%real)


Current cases of derived type mapping left for future work are:
  > explicit member mapping of nested members (e.g. two layers of
 record types where we explicitly map a member from the internal
 record type)
  > Fortran's automagical mapping of all elements and nested elements
 of a derived type
  > explicit member mapping of a derived type and then constituient members
 (redundant in Fortran due to former case but still legal as far as I am 
aware)
  > explicit member mapping of a record type (may be handled reasonably, just
 not fully tested in this iteration)
  > explicit member mapping for Fortran allocatable types (a variation of 
nested
 record types)

This patch seeks to support this by extending the Flang-new OpenMP lowering to
support generation of this newly required information, creating the neccessary
parent <-to-> member map_info links, calculating the member indices and
setting if it's a partial map.

The OMPDescriptorMapInfoGen pass has also been generalized into a map
finalization phase, now named OMPMapInfoFinalization. This pass was extended
to support the insertion of member maps into the BlockArg and MapOperands of
relevant map carrying operations. Similar to the method in which descriptor 
types
are expanded and constituient members inserted.


---

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


24 Files Affected:

- (modified) flang/docs/OpenMP-descriptor-management.md (+2-2) 
- (modified) flang/include/flang/Optimizer/Transforms/Passes.h (+1-1) 
- (modified) flang/include/flang/Optimizer/Transforms/Passes.td (+3-3) 
- (modified) flang/include/flang/Tools/CLOptions.inc (+1-1) 
- (modified) flang/lib/Lower/OpenMP/ClauseProcessor.cpp (+50-18) 
- (modified) flang/lib/Lower/OpenMP/ClauseProcessor.h (+47-13) 
- (modified) flang/lib/Lower/OpenMP/OpenMP.cpp (+12-8) 
- (modified) flang/lib/Lower/OpenMP/Utils.cpp (+101-1) 
- (modified) flang/lib/Lower/OpenMP/Utils.h (+27-3) 
- (modified) flang/lib/Optimizer/Transforms/CMakeLists.txt (+1-1) 
- (removed) flang/lib/Optimizer/Transforms/OMPDescriptorMapInfoGen.cpp (-168) 
- (added) flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp (+264) 
- (modified) flang/test/Fir/convert-to-llvm-openmp-and-fir.fir (+31-4) 
- (modified) flang/test/Integration/OpenMP/map-types-and-sizes.f90 (+153-1) 
- (modified) flang/test/Lower/OpenMP/FIR/array-bounds.f90 (+4-4) 
- (modified) flang/test/Lower/OpenMP/FIR/map-component-ref.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/FIR/target.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/allocatable-array-bounds.f90 (+6-6) 
- (modified) flang/test/Lower/OpenMP/allocatable-map.f90 (+4-4) 
- (modified) flang/test/Lower/OpenMP/array-bounds.f90 (+4-4) 
- (added) flang/test/Lower/OpenMP/derived-type-map.f90 (+133) 
- (modified) flang/test/Lower/OpenMP/map-component-ref.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/target.f90 (+2-2) 
- (renamed) flang/test/Transforms/omp-map-info-finalization.fir (+29-5) 


``diff
diff --git a/flang/docs/OpenMP-descriptor-management.md 
b/flang/docs/OpenMP-descriptor-management.md
index 90a20282e05126..af02b3a99cb07d 100644
--- a/flang/docs/OpenMP-descriptor-management.md
+++ b/flang/docs/OpenMP-descriptor-management.md
@@ -44,7 +44,7 @@ Currently, Flang will lower these descriptor types in the 
OpenMP lowering (lower
 to all other map types, generating an omp.MapInfoOp containing relevant 
information required for lowering
 the OpenMP dialect to LLVM-IR during the final stages of the MLIR lowering. 
However, after 
 the lowering to FIR/HLFIR has been performed an OpenMP dialect specific pass 
for Fortran, 
-`OMPDescriptorMapInfoGenPass` (Optimizer/OMPDescriptorMapInfoGen.cpp) will 
expand the 
+`OMPMapInfoFinalizationPass` (Optimizer/OMPMapInfoFinalization.cpp) will 
expand the 
 `omp.MapInfoOp`'s containing descriptors (which currently will be a `BoxType` 
or `BoxAddrOp`) into multiple 
 mappings, with one extra per pointer member in the descriptor that is 
supported on top of the original
 descriptor map operation. These pointers members are linked to the parent 
descriptor by adding them to 
@@ -52,7 +52,7 @@ the member field of the original descriptor map operation, 
t

[llvm-branch-commits] [OpenMP][MLIR] Add new arguments to map_info to help support record type maps (PR #82851)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-flang-openmp

Author: None (agozillon)


Changes

This PR adds two new fields to omp.map_info, one BoolAttr and one I64ArrayAttr.

The BoolAttr is named partial_map, and is a flag that indicates if the record 
type captured by
the map_info operation is a partial map, or if it is mapped in its entirety, 
this currently helps
the later lowering determine the type of map entries that need to be generated.

The I64ArrayAttr named members_index is intended to track the placement of each 
member
map_info operations (and by extension mapped member variable) placement in the 
parent
record type. This may need to be extended to an N-D array for nested member 
mapping.


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


3 Files Affected:

- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td (+12-4) 
- (modified) mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp (+7) 
- (modified) mlir/test/Dialect/OpenMP/ops.mlir (+23-6) 


``diff
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index f907e21e9b4de2..98013dff032cc8 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -1298,10 +1298,12 @@ def MapInfoOp : OpenMP_Op<"map_info", 
[AttrSizedOperandSegments]> {
TypeAttr:$var_type,
Optional:$var_ptr_ptr,
Variadic:$members,
+   OptionalAttr:$members_index,
Variadic:$bounds, /* rank-0 to 
rank-{n-1} */
OptionalAttr:$map_type,
OptionalAttr:$map_capture_type,
-   OptionalAttr:$name);
+   OptionalAttr:$name,
+   DefaultValuedAttr:$partial_map);
   let results = (outs OpenMP_PointerLikeType:$omp_ptr);
 
   let description = [{
@@ -1337,10 +1339,14 @@ def MapInfoOp : OpenMP_Op<"map_info", 
[AttrSizedOperandSegments]> {
 - `var_type`: The type of the variable to copy.
 - `var_ptr_ptr`: Used when the variable copied is a member of a class, 
structure
   or derived type and refers to the originating struct.
-- `members`:  Used to indicate mapped child members for the current 
MapInfoOp, 
+- `members`: Used to indicate mapped child members for the current 
MapInfoOp, 
represented as other MapInfoOp's, utilised in cases where a parent 
structure 
type and members of the structure type are being mapped at the same 
time. 
-   For example: map(to: parent, parent->member, parent->member2[:10])  
+   For example: map(to: parent, parent->member, parent->member2[:10])
+- `members_index`: Used to indicate the ordering of members within the 
containing 
+   parent (generally a record type such as a structure, class or derived 
type),
+   e.g. struct {int x, float y, double z}, x would be 0, y would be 1, and 
z 
+   would be 2. This aids the mapping 
 - `bounds`: Used when copying slices of array's, pointers or pointer 
members of
objects (e.g. derived types or classes), indicates the bounds to be 
copied
of the variable. When it's an array slice it is in rank order where 
rank 0
@@ -1351,6 +1357,8 @@ def MapInfoOp : OpenMP_Op<"map_info", 
[AttrSizedOperandSegments]> {
 - 'map_capture_type': Capture type for the variable e.g. this, byref, 
byvalue, byvla
this can affect how the variable is lowered.
 - `name`: Holds the name of variable as specified in user clause 
(including bounds).
+- `partial_map`: The record type being mapped will not be mapped in its 
entirety, 
+   it may be used however, in a mapping to bind it's mapped components 
together.
   }];
 
   let assemblyFormat = [{
@@ -1359,7 +1367,7 @@ def MapInfoOp : OpenMP_Op<"map_info", 
[AttrSizedOperandSegments]> {
 `var_ptr_ptr` `(` $var_ptr_ptr `:` type($var_ptr_ptr) `)`
   | `map_clauses` `(` custom($map_type) `)`
   | `capture` `(` custom($map_capture_type) `)`
-  | `members` `(` $members `:` type($members) `)`
+  | `members` `(` $members `:` type($members) `:` $members_index `)`
   | `bounds` `(` $bounds `)`
 ) `->` type($omp_ptr) attr-dict
   }];
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp 
b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index c2b471ab96183f..771ff40736af8b 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -915,6 +915,9 @@ static ParseResult parseMapClause(OpAsmParser &parser, 
IntegerAttr &mapType) {
 if (mapTypeMod == "delete")
   mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
 
+if (mapTypeMod == "ptr_and_obj")
+  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ;
+
 return success();
   };
 
@@ -951,6 +954,10 @@ static void printMapClause(OpAsmPrinter &p, Operation *op,
   if (mapT

[llvm-branch-commits] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-02-23 Thread Valentin Clement バレンタイン クレメン via llvm-branch-commits

clementval wrote:

You could do the renaming of the pass as an NFC PR so it would make the non NFC 
changes more obvious to spot at. Not necessary to do it for this time but next 
time it would be nice. 

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


[llvm-branch-commits] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-02-23 Thread via llvm-branch-commits

agozillon wrote:

> You could do the renaming of the pass as an NFC PR so it would make the non 
> NFC changes more obvious to spot at. Not necessary to do it for this time but 
> next time it would be nice.

I'm very sorry about that! I didn't realise it would be a problem, but I will 
keep it in mind for the future for any renaming + change sets I aim to 
upstream. Thank you for bringing it up. 

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


[llvm-branch-commits] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-02-23 Thread Valentin Clement バレンタイン クレメン via llvm-branch-commits

clementval wrote:

> > You could do the renaming of the pass as an NFC PR so it would make the non 
> > NFC changes more obvious to spot at. Not necessary to do it for this time 
> > but next time it would be nice.
> 
> I'm very sorry about that! I didn't realise it would be a problem, but I will 
> keep it in mind for the future for any renaming + change sets I aim to 
> upstream. Thank you for bringing it up.

Not an issue at all. It's just simpler to look at small PRs :-) 

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


[llvm-branch-commits] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-02-23 Thread via llvm-branch-commits

agozillon wrote:

I have opened PRs again on the entire stack, hopefully they shouldn't cause 
problems for windows users anymore, I've checked the length of the largest PR 
and I believe it fits within the maximum that we're planning on enforcing.

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


[llvm-branch-commits] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-02-23 Thread via llvm-branch-commits

agozillon wrote:

> > > You could do the renaming of the pass as an NFC PR so it would make the 
> > > non NFC changes more obvious to spot at. Not necessary to do it for this 
> > > time but next time it would be nice.
> > 
> > 
> > I'm very sorry about that! I didn't realise it would be a problem, but I 
> > will keep it in mind for the future for any renaming + change sets I aim to 
> > upstream. Thank you for bringing it up.
> 
> Not an issue at all. It's just simpler to look at small PRs :-)

Yes, I am sorry about that, I'd like to make it as easy as possible to review 
for you all as I know it's not an easy task and I greatly appreciate the effort 
you all put in, so I will most definitely keep it mind in the future! 

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


[llvm-branch-commits] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-02-23 Thread Valentin Clement バレンタイン クレメン via llvm-branch-commits

clementval wrote:

> Yes, I am sorry about that, I'd like to make it as easy as possible to review 
> for you all as I know it's not an easy task and I greatly appreciate the 
> effort you all put in, so I will most definitely keep it mind in the future!

Thanks! 


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


[llvm-branch-commits] [clang] release/18.x: [clang][CodeGen] Keep processing the rest of AST after encountering unsupported MC/DC expressions (#82464) (PR #82866)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [clang] release/18.x: [clang][CodeGen] Keep processing the rest of AST after encountering unsupported MC/DC expressions (#82464) (PR #82866)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:

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

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


[llvm-branch-commits] [clang] release/18.x: [clang][CodeGen] Keep processing the rest of AST after encountering unsupported MC/DC expressions (#82464) (PR #82866)

2024-02-23 Thread via llvm-branch-commits

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

Backport d4bfca3b2e673789f7c278d46a199ae8910ddd37

Requested by: @whentojump

>From a64e5aab54b372df13c1756ed66bb9fc5cd59927 Mon Sep 17 00:00:00 2001
From: Wentao Zhang <35722712+whentoj...@users.noreply.github.com>
Date: Thu, 22 Feb 2024 16:04:25 -0600
Subject: [PATCH] [clang][CodeGen] Keep processing the rest of AST after
 encountering unsupported MC/DC expressions (#82464)

Currently, upon seeing unsupported decisions (more than 6 conditions, or
split nesting), the post-visitor hook dataTraverseStmtPost() returns a
false. As a result, in the rest of tree even supported decisions will
be skipped as well. Like in the below code:

{ // CompoundStmt
  a && b;   // 1: BinaryOperator (supported)
  a && foo(b && c); // 2: BinaryOperator (not yet supported due to split
//nesting)
  a && b;   // 3: BinaryOperator (supported)
}

Decision 3 will not be processed at all. And only one "Decision" region
will be emitted. Compiler explorer example:
https://godbolt.org/z/Px61sesoo

We hope to process such cases and emit two "Decision" regions (1 and 3)
in the above example.

(cherry picked from commit d4bfca3b2e673789f7c278d46a199ae8910ddd37)
---
 clang/lib/CodeGen/CodeGenPGO.cpp | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 5d7c3847745762..fb4e86e8bd8053 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -240,9 +240,12 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 if (MCDCMaxCond == 0)
   return true;
 
-/// At the top of the logical operator nest, reset the number of 
conditions.
-if (LogOpStack.empty())
+/// At the top of the logical operator nest, reset the number of 
conditions,
+/// also forget previously seen split nesting cases.
+if (LogOpStack.empty()) {
   NumCond = 0;
+  SplitNestedLogicalOp = false;
+}
 
 if (const Expr *E = dyn_cast(S)) {
   const BinaryOperator *BinOp = 
dyn_cast(E->IgnoreParens());
@@ -293,7 +296,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 "contains an operation with a nested boolean expression. "
 "Expression will not be covered");
 Diag.Report(S->getBeginLoc(), DiagID);
-return false;
+return true;
   }
 
   /// Was the maximum number of conditions encountered?
@@ -304,7 +307,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 "number of conditions (%0) exceeds max (%1). "
 "Expression will not be covered");
 Diag.Report(S->getBeginLoc(), DiagID) << NumCond << MCDCMaxCond;
-return false;
+return true;
   }
 
   // Otherwise, allocate the number of bytes required for the bitmap

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


[llvm-branch-commits] [clang] release/18.x: [clang][CodeGen] Keep processing the rest of AST after encountering unsupported MC/DC expressions (#82464) (PR #82866)

2024-02-23 Thread via llvm-branch-commits

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

>From b058dd52590462f564238275527e7f061ff9e08a Mon Sep 17 00:00:00 2001
From: Wentao Zhang <35722712+whentoj...@users.noreply.github.com>
Date: Thu, 22 Feb 2024 16:04:25 -0600
Subject: [PATCH] [clang][CodeGen] Keep processing the rest of AST after
 encountering unsupported MC/DC expressions (#82464)

Currently, upon seeing unsupported decisions (more than 6 conditions, or
split nesting), the post-visitor hook dataTraverseStmtPost() returns a
false. As a result, in the rest of tree even supported decisions will
be skipped as well. Like in the below code:

{ // CompoundStmt
  a && b;   // 1: BinaryOperator (supported)
  a && foo(b && c); // 2: BinaryOperator (not yet supported due to split
//nesting)
  a && b;   // 3: BinaryOperator (supported)
}

Decision 3 will not be processed at all. And only one "Decision" region
will be emitted. Compiler explorer example:
https://godbolt.org/z/Px61sesoo

We hope to process such cases and emit two "Decision" regions (1 and 3)
in the above example.

(cherry picked from commit d4bfca3b2e673789f7c278d46a199ae8910ddd37)
---
 clang/lib/CodeGen/CodeGenPGO.cpp | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 5d7c3847745762..fb4e86e8bd8053 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -240,9 +240,12 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 if (MCDCMaxCond == 0)
   return true;
 
-/// At the top of the logical operator nest, reset the number of 
conditions.
-if (LogOpStack.empty())
+/// At the top of the logical operator nest, reset the number of 
conditions,
+/// also forget previously seen split nesting cases.
+if (LogOpStack.empty()) {
   NumCond = 0;
+  SplitNestedLogicalOp = false;
+}
 
 if (const Expr *E = dyn_cast(S)) {
   const BinaryOperator *BinOp = 
dyn_cast(E->IgnoreParens());
@@ -293,7 +296,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 "contains an operation with a nested boolean expression. "
 "Expression will not be covered");
 Diag.Report(S->getBeginLoc(), DiagID);
-return false;
+return true;
   }
 
   /// Was the maximum number of conditions encountered?
@@ -304,7 +307,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 "number of conditions (%0) exceeds max (%1). "
 "Expression will not be covered");
 Diag.Report(S->getBeginLoc(), DiagID) << NumCond << MCDCMaxCond;
-return false;
+return true;
   }
 
   // Otherwise, allocate the number of bytes required for the bitmap

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


[llvm-branch-commits] [clang] release/18.x: [clang][CodeGen] Keep processing the rest of AST after encountering unsupported MC/DC expressions (#82464) (PR #82866)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: None (llvmbot)


Changes

Backport d4bfca3b2e673789f7c278d46a199ae8910ddd37

Requested by: @whentojump

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


1 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenPGO.cpp (+7-4) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 5d7c3847745762..fb4e86e8bd8053 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -240,9 +240,12 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 if (MCDCMaxCond == 0)
   return true;
 
-/// At the top of the logical operator nest, reset the number of 
conditions.
-if (LogOpStack.empty())
+/// At the top of the logical operator nest, reset the number of 
conditions,
+/// also forget previously seen split nesting cases.
+if (LogOpStack.empty()) {
   NumCond = 0;
+  SplitNestedLogicalOp = false;
+}
 
 if (const Expr *E = dyn_cast(S)) {
   const BinaryOperator *BinOp = 
dyn_cast(E->IgnoreParens());
@@ -293,7 +296,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 "contains an operation with a nested boolean expression. "
 "Expression will not be covered");
 Diag.Report(S->getBeginLoc(), DiagID);
-return false;
+return true;
   }
 
   /// Was the maximum number of conditions encountered?
@@ -304,7 +307,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 "number of conditions (%0) exceeds max (%1). "
 "Expression will not be covered");
 Diag.Report(S->getBeginLoc(), DiagID) << NumCond << MCDCMaxCond;
-return false;
+return true;
   }
 
   // Otherwise, allocate the number of bytes required for the bitmap

``




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


[llvm-branch-commits] [lld] [llvm] release/18.x: [Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291) (PR #82870)

2024-02-23 Thread via llvm-branch-commits

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

Backport 96abee5eef31274415681018553e1d4a16dc16c9

Requested by: @brad0

>From ba7653eaae378e3805c6f2c47c3850a145d5b6e4 Mon Sep 17 00:00:00 2001
From: yingopq <115543042+ying...@users.noreply.github.com>
Date: Sat, 24 Feb 2024 15:13:43 +0800
Subject: [PATCH] =?UTF-8?q?[Mips]=20Fix=20unable=20to=20handle=20inline=20?=
 =?UTF-8?q?assembly=20ends=20with=20compat-branch=20o=E2=80=A6=20(#77291)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

…n MIPS

Modify:
Add a global variable 'CurForbiddenSlotAttr' to save current
instruction's forbidden slot and whether set reorder. This is the
judgment condition for whether to add nop. We would add a couple of
'.set noreorder' and '.set reorder' to wrap the current instruction and
the next instruction.
Then we can get previous instruction`s forbidden slot attribute and
whether set reorder by 'CurForbiddenSlotAttr'.
If previous instruction has forbidden slot and .set reorder is active
and current instruction is CTI. Then emit a NOP after it.

Fix https://github.com/llvm/llvm-project/issues/61045.

Because https://reviews.llvm.org/D158589 was 'Needs Review' state, not
ending, so we commit pull request again.

(cherry picked from commit 96abee5eef31274415681018553e1d4a16dc16c9)
---
 lld/test/ELF/mips-pc-relocs.s | 18 +++--
 .../Target/Mips/AsmParser/MipsAsmParser.cpp   | 78 ++-
 .../CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll | 71 +
 llvm/test/MC/Mips/forbidden-slot.s| 18 +
 llvm/test/MC/Mips/mips32r6/relocations.s  | 22 +++---
 llvm/test/MC/Mips/mips64r6/relocations.s  | 26 +++
 llvm/test/MC/Mips/relocation.s|  4 +-
 7 files changed, 202 insertions(+), 35 deletions(-)
 create mode 100644 llvm/test/CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll
 create mode 100644 llvm/test/MC/Mips/forbidden-slot.s

diff --git a/lld/test/ELF/mips-pc-relocs.s b/lld/test/ELF/mips-pc-relocs.s
index 5e7dbed94ca7c4..7d23f9d7469a48 100644
--- a/lld/test/ELF/mips-pc-relocs.s
+++ b/lld/test/ELF/mips-pc-relocs.s
@@ -40,11 +40,13 @@ __start:
 # ^-- (0x20020-0x2)>>2
 # CHECK-NEXT:20004:   beqc$5, $6, 0x20020
 # ^-- (0x20020-4-0x20004)>>2
-# CHECK-NEXT:20008:   beqzc   $9, 0x20020
-# ^-- (0x20020-4-0x20008)>>2
-# CHECK-NEXT:2000c:   bc  0x20020
-# ^-- (0x20020-4-0x2000c)>>2
-# CHECK-NEXT:20010:   aluipc  $2, 0
-# ^-- %hi(0x20020-0x20010)
-# CHECK-NEXT:20014:   addiu   $2, $2, 12
-# ^-- %lo(0x20020-0x20014)
+# CHECK-NEXT:20008:   nop
+# CHECK-NEXT:2000c:   beqzc   $9, 0x20020
+# ^-- (0x20020-4-0x2000c)>>2
+# CHECK-NEXT:20010:   nop
+# CHECK-NEXT:20014:   bc  0x20020
+# ^-- (0x20020-4-0x200014)>>2
+# CHECK-NEXT:20018:   aluipc  $2, 0
+# ^-- %hi(0x20020-0x20018)
+# CHECK-NEXT:2001c:   addiu   $2, $2, 4
+# ^-- %lo(0x20020-0x2001c)
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp 
b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 36aab383da68d2..9d6e8dc573a8d1 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -150,6 +150,7 @@ class MipsAsmParser : public MCTargetAsmParser {
   bool IsLittleEndian;
   bool IsPicEnabled;
   bool IsCpRestoreSet;
+  bool CurForbiddenSlotAttr;
   int CpRestoreOffset;
   unsigned GPReg;
   unsigned CpSaveLocation;
@@ -552,6 +553,7 @@ class MipsAsmParser : public MCTargetAsmParser {
 
 CurrentFn = nullptr;
 
+CurForbiddenSlotAttr = false;
 IsPicEnabled = getContext().getObjectFileInfo()->isPositionIndependent();
 
 IsCpRestoreSet = false;
@@ -723,6 +725,16 @@ class MipsAsmParser : public MCTargetAsmParser {
 return getSTI().hasFeature(Mips::FeatureGINV);
   }
 
+  bool hasForbiddenSlot(const MCInstrDesc &MCID) const {
+return !inMicroMipsMode() && (MCID.TSFlags & MipsII::HasForbiddenSlot);
+  }
+
+  bool SafeInForbiddenSlot(const MCInstrDesc &MCID) const {
+return !(MCID.TSFlags & MipsII::IsCTI);
+  }
+
+  void onEndOfFile() override;
+
   /// Warn if RegIndex is the same as the current AT.
   void warnIfRegIndexIsAT(unsigned RegIndex, SMLoc Loc);
 
@@ -2307,7 +2319,41 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, 
SMLoc IDLoc,
 
   bool FillDelaySlot =
   MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder();
-  if (FillDelaySlot)
+
+  // Get previous instruction`s forbidden slot attribute and
+  // whether set reorder.
+  bool PrevFor

[llvm-branch-commits] [lld] [llvm] release/18.x: [Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291) (PR #82870)

2024-02-23 Thread via llvm-branch-commits

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


[llvm-branch-commits] [lld] [llvm] release/18.x: [Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291) (PR #82870)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:

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

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


[llvm-branch-commits] [lld] [llvm] release/18.x: [Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291) (PR #82870)

2024-02-23 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-lld-elf

Author: None (llvmbot)


Changes

Backport 96abee5eef31274415681018553e1d4a16dc16c9

Requested by: @brad0

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


7 Files Affected:

- (modified) lld/test/ELF/mips-pc-relocs.s (+10-8) 
- (modified) llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (+77-1) 
- (added) llvm/test/CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll (+71) 
- (added) llvm/test/MC/Mips/forbidden-slot.s (+18) 
- (modified) llvm/test/MC/Mips/mips32r6/relocations.s (+11-11) 
- (modified) llvm/test/MC/Mips/mips64r6/relocations.s (+13-13) 
- (modified) llvm/test/MC/Mips/relocation.s (+2-2) 


``diff
diff --git a/lld/test/ELF/mips-pc-relocs.s b/lld/test/ELF/mips-pc-relocs.s
index 5e7dbed94ca7c4..7d23f9d7469a48 100644
--- a/lld/test/ELF/mips-pc-relocs.s
+++ b/lld/test/ELF/mips-pc-relocs.s
@@ -40,11 +40,13 @@ __start:
 # ^-- (0x20020-0x2)>>2
 # CHECK-NEXT:20004:   beqc$5, $6, 0x20020
 # ^-- (0x20020-4-0x20004)>>2
-# CHECK-NEXT:20008:   beqzc   $9, 0x20020
-# ^-- (0x20020-4-0x20008)>>2
-# CHECK-NEXT:2000c:   bc  0x20020
-# ^-- (0x20020-4-0x2000c)>>2
-# CHECK-NEXT:20010:   aluipc  $2, 0
-# ^-- %hi(0x20020-0x20010)
-# CHECK-NEXT:20014:   addiu   $2, $2, 12
-# ^-- %lo(0x20020-0x20014)
+# CHECK-NEXT:20008:   nop
+# CHECK-NEXT:2000c:   beqzc   $9, 0x20020
+# ^-- (0x20020-4-0x2000c)>>2
+# CHECK-NEXT:20010:   nop
+# CHECK-NEXT:20014:   bc  0x20020
+# ^-- (0x20020-4-0x200014)>>2
+# CHECK-NEXT:20018:   aluipc  $2, 0
+# ^-- %hi(0x20020-0x20018)
+# CHECK-NEXT:2001c:   addiu   $2, $2, 4
+# ^-- %lo(0x20020-0x2001c)
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp 
b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 36aab383da68d2..9d6e8dc573a8d1 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -150,6 +150,7 @@ class MipsAsmParser : public MCTargetAsmParser {
   bool IsLittleEndian;
   bool IsPicEnabled;
   bool IsCpRestoreSet;
+  bool CurForbiddenSlotAttr;
   int CpRestoreOffset;
   unsigned GPReg;
   unsigned CpSaveLocation;
@@ -552,6 +553,7 @@ class MipsAsmParser : public MCTargetAsmParser {
 
 CurrentFn = nullptr;
 
+CurForbiddenSlotAttr = false;
 IsPicEnabled = getContext().getObjectFileInfo()->isPositionIndependent();
 
 IsCpRestoreSet = false;
@@ -723,6 +725,16 @@ class MipsAsmParser : public MCTargetAsmParser {
 return getSTI().hasFeature(Mips::FeatureGINV);
   }
 
+  bool hasForbiddenSlot(const MCInstrDesc &MCID) const {
+return !inMicroMipsMode() && (MCID.TSFlags & MipsII::HasForbiddenSlot);
+  }
+
+  bool SafeInForbiddenSlot(const MCInstrDesc &MCID) const {
+return !(MCID.TSFlags & MipsII::IsCTI);
+  }
+
+  void onEndOfFile() override;
+
   /// Warn if RegIndex is the same as the current AT.
   void warnIfRegIndexIsAT(unsigned RegIndex, SMLoc Loc);
 
@@ -2307,7 +2319,41 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, 
SMLoc IDLoc,
 
   bool FillDelaySlot =
   MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder();
-  if (FillDelaySlot)
+
+  // Get previous instruction`s forbidden slot attribute and
+  // whether set reorder.
+  bool PrevForbiddenSlotAttr = CurForbiddenSlotAttr;
+
+  // Flag represents we set reorder after nop.
+  bool SetReorderAfterNop = false;
+
+  // If previous instruction has forbidden slot and .set reorder
+  // is active and current instruction is CTI.
+  // Then emit a NOP after it.
+  if (PrevForbiddenSlotAttr && !SafeInForbiddenSlot(MCID)) {
+TOut.emitEmptyDelaySlot(false, IDLoc, STI);
+// When 'FillDelaySlot' is true, the existing logic will add
+// noreorder before instruction and reorder after it. So there
+// need exclude this case avoiding two '.set reorder'.
+// The format of the first case is:
+// .set noreorder
+// bnezc
+// nop
+// .set reorder
+if (AssemblerOptions.back()->isReorder() && !FillDelaySlot) {
+  SetReorderAfterNop = true;
+  TOut.emitDirectiveSetReorder();
+}
+  }
+
+  // Save current instruction`s forbidden slot and whether set reorder.
+  // This is the judgment condition for whether to add nop.
+  // We would add a couple of '.set noreorder' and '.set reorder' to
+  // wrap the current instruction and the next instruction.
+  CurForbiddenSlotAttr =
+  hasForbiddenSlot(MCID) && AssemblerOptions.back()->isReorder();
+
+  if (FillDelaySlot || CurForbiddenSlotAttr)
 TOut.emitDirectiveSetNoReorder()