[llvm-branch-commits] [clang] release/20.x: [clang-format] Keep the space between `not` and a unary operator (#135035) (PR #135118)

2025-04-09 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/135118
___
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] ELF: Only rewrite non-preemptible IFUNCs to IPLT functions if a non-IRELATIVE relocation is needed. (PR #133531)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/133531


___
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] 3e7df27 - Revert "Fix ambiguous reversed operator error in sanitizer_mac.h (#135068)"

2025-04-09 Thread via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2025-04-09T21:08:00-07:00
New Revision: 3e7df27c1d3a9c1a430b2cf471517f8f059d59ed

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

LOG: Revert "Fix ambiguous reversed operator error in sanitizer_mac.h (#135068)"

This reverts commit 433a63e117ebf22365ef1f3f595a49cbe9f0c88e.

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/sanitizer_mac.h

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_mac.h
index 4de0605e18f03..f0a97d098eea0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.h
@@ -37,6 +37,9 @@ struct VersionBase {
 
   VersionBase(u16 major, u16 minor) : major(major), minor(minor) {}
 
+  bool operator==(const VersionType &other) const {
+return major == other.major && minor == other.minor;
+  }
   bool operator>=(const VersionType &other) const {
 return major > other.major ||
(major == other.major && minor >= other.minor);
@@ -44,11 +47,6 @@ struct VersionBase {
   bool operator<(const VersionType &other) const { return !(*this >= other); }
 };
 
-template 
-bool operator==(const VersionType &self, const VersionType &other) {
-  return self.major == other.major && self.minor == other.minor;
-}
-
 struct MacosVersion : VersionBase {
   MacosVersion(u16 major, u16 minor) : VersionBase(major, minor) {}
 };



___
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] ELF: Only rewrite non-preemptible IFUNCs to IPLT functions if a non-IRELATIVE relocation is needed. (PR #133531)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

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


[llvm-branch-commits] [clang] release/20.x: [clang-format] Keep the space between `not` and a unary operator (#135035) (PR #135118)

2025-04-09 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/135118
___
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] 346c905 - Revert "[Clang][CodeGen][UBSan] Add more precise attributes to recoverable ub…"

2025-04-09 Thread via llvm-branch-commits

Author: Yingwei Zheng
Date: 2025-04-10T13:09:28+08:00
New Revision: 346c905e8ab7cb81c537eb5be1d57cc63a41daea

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

LOG: Revert "[Clang][CodeGen][UBSan] Add more precise attributes to recoverable 
ub…"

This reverts commit 0283bb3afcc5dc521f6b2e7d541a830a9546ed80.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/test/CodeGen/allow-ubsan-check.c
clang/test/CodeGen/attr-counted-by.c

Removed: 
clang/test/CodeGen/ubsan-attr.cpp



diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 28068d3408c62..451034395976f 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3621,18 +3621,6 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF,
 .addAttribute(llvm::Attribute::NoUnwind);
   }
   B.addUWTableAttr(llvm::UWTableKind::Default);
-  // Add more precise attributes to recoverable ubsan handlers for better
-  // optimizations.
-  if (CGF.CGM.getCodeGenOpts().OptimizationLevel > 0 && MayReturn) {
-// __ubsan_handle_dynamic_type_cache_miss reads the vtable, which is also
-// accessible by the current module.
-if (CheckHandler != SanitizerHandler::DynamicTypeCacheMiss)
-  B.addMemoryAttr(llvm::MemoryEffects::argMemOnly(llvm::ModRefInfo::Ref) |
-  llvm::MemoryEffects::inaccessibleMemOnly());
-// If the handler does not return, it must interact with the environment in
-// an observable way.
-B.addAttribute(llvm::Attribute::MustProgress);
-  }
 
   llvm::FunctionCallee Fn = CGF.CGM.CreateRuntimeFunction(
   FnType, FnName,

diff  --git a/clang/test/CodeGen/allow-ubsan-check.c 
b/clang/test/CodeGen/allow-ubsan-check.c
index 6358425aa40be..e225fb63f08eb 100644
--- a/clang/test/CodeGen/allow-ubsan-check.c
+++ b/clang/test/CodeGen/allow-ubsan-check.c
@@ -29,7 +29,7 @@
 // CHECK:   [[HANDLER_DIVREM_OVERFLOW]]:
 // CHECK-NEXT:[[TMP10:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
 // CHECK-NEXT:[[TMP11:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
-// CHECK-NEXT:tail call void @__ubsan_handle_divrem_overflow_abort(ptr 
nonnull @[[GLOB1:[0-9]+]], i64 [[TMP10]], i64 [[TMP11]]) #[[ATTR8:[0-9]+]], 
!nosanitize [[META2]]
+// CHECK-NEXT:tail call void @__ubsan_handle_divrem_overflow_abort(ptr 
nonnull @[[GLOB1:[0-9]+]], i64 [[TMP10]], i64 [[TMP11]]) #[[ATTR6:[0-9]+]], 
!nosanitize [[META2]]
 // CHECK-NEXT:unreachable, !nosanitize [[META2]]
 // CHECK:   [[CONT]]:
 // CHECK-NEXT:[[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
@@ -75,7 +75,7 @@
 // REC:   [[HANDLER_DIVREM_OVERFLOW]]:
 // REC-NEXT:[[TMP10:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
 // REC-NEXT:[[TMP11:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
-// REC-NEXT:tail call void @__ubsan_handle_divrem_overflow(ptr nonnull 
@[[GLOB1:[0-9]+]], i64 [[TMP10]], i64 [[TMP11]]) #[[ATTR8:[0-9]+]], !nosanitize 
[[META2]]
+// REC-NEXT:tail call void @__ubsan_handle_divrem_overflow(ptr nonnull 
@[[GLOB1:[0-9]+]], i64 [[TMP10]], i64 [[TMP11]]) #[[ATTR6:[0-9]+]], !nosanitize 
[[META2]]
 // REC-NEXT:br label %[[CONT]], !nosanitize [[META2]]
 // REC:   [[CONT]]:
 // REC-NEXT:[[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
@@ -86,7 +86,7 @@ int div(int x, int y) {
 }
 
 // CHECK-LABEL: define dso_local i32 @null(
-// CHECK-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) 
local_unnamed_addr #[[ATTR3:[0-9]+]] {
+// CHECK-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:[[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
 //
@@ -95,7 +95,7 @@ int div(int x, int y) {
 // CHECK-NEXT:[[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
 // CHECK-NEXT:br i1 [[DOTNOT1]], label %[[HANDLER_TYPE_MISMATCH:.*]], 
label %[[CONT:.*]], !prof [[PROF4:![0-9]+]], !nosanitize [[META2]]
 // CHECK:   [[HANDLER_TYPE_MISMATCH]]:
-// CHECK-NEXT:tail call void @__ubsan_handle_type_mismatch_v1_abort(ptr 
nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR8]], !nosanitize [[META2]]
+// CHECK-NEXT:tail call void @__ubsan_handle_type_mismatch_v1_abort(ptr 
nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR6]], !nosanitize [[META2]]
 // CHECK-NEXT:unreachable, !nosanitize [[META2]]
 // CHECK:   [[CONT]]:
 // CHECK-NEXT:[[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa 
[[TBAA5:![0-9]+]]
@@ -116,14 +116,14 @@ int div(int x, int y) {
 // TR-NEXT:ret i32 [[TMP2]]
 //
 // REC-LABEL: define dso_local i32 @null(
-// REC-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) 
local_unnamed_addr #[[ATTR3:[0-9]+]] {
+// REC-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) 
local_unnamed_addr #[[ATTR0]] {

[llvm-branch-commits] [clang] release/20.x: [clang-format] Keep the space between `not` and a unary operator (#135035) (PR #135118)

2025-04-09 Thread via llvm-branch-commits

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

Backport f34483838937b1a01ee11ee22bdd6e13c81e9fff

Requested by: @owenca

>From 352ee2311f041ca08c1ff7bc4a68dd5094398951 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Wed, 9 Apr 2025 17:52:12 -0700
Subject: [PATCH] [clang-format] Keep the space between `not` and a unary
 operator (#135035)

Also keep the space between `not` and `::`.

Based on the
[documentation](https://releases.llvm.org/20.1.0/tools/clang/docs/ClangFormatStyleOptions.html#spaceafterlogicalnot),
it can be argued that SpaceAfterLogicalNot doesn't cover the alternative
operator `not`.

Closes #125465

(cherry picked from commit f34483838937b1a01ee11ee22bdd6e13c81e9fff)
---
 clang/lib/Format/TokenAnnotator.cpp   | 7 ++-
 clang/unittests/Format/FormatTest.cpp | 5 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 976c4d888e1fd..7ad99b7a9660c 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5437,7 +5437,12 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 // handled.
 if (Left.is(tok::amp) && Right.is(tok::r_square))
   return Style.SpacesInSquareBrackets;
-return Style.SpaceAfterLogicalNot && Left.is(tok::exclaim);
+if (Left.isNot(tok::exclaim))
+  return false;
+if (Left.TokenText == "!")
+  return Style.SpaceAfterLogicalNot;
+assert(Left.TokenText == "not");
+return Right.isOneOf(tok::coloncolon, TT_UnaryOperator);
   }
 
   // If the next token is a binary operator or a selector name, we have
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 6508ca2e7174f..44341fbfe895f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -25067,8 +25067,10 @@ TEST_F(FormatTest, AlternativeOperators) {
   verifyFormat("%:define ABC abc"); // #define ABC abc
   verifyFormat("%:%:"); // ##
 
+  verifyFormat("return not ::f();");
+  verifyFormat("return not *foo;");
+
   verifyFormat("a = v(not;);\n"
-   "b = v(not+);\n"
"c = v(not x);\n"
"d = v(not 1);\n"
"e = v(not 123.f);");
@@ -25076,7 +25078,6 @@ TEST_F(FormatTest, AlternativeOperators) {
   verifyNoChange("#define ASSEMBLER_INSTRUCTION_LIST(V)  \\\n"
  "  V(and)   \\\n"
  "  V(not)   \\\n"
- "  V(not!)  \\\n"
  "  V(other)",
  getLLVMStyleWithColumns(40));
 }

___
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] [KeyInstr][Inline] Don't propagate atoms to inlined nodebug instructions (PR #133485)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT] Gadget scanner: analyze functions without CFG information (PR #133461)

2025-04-09 Thread Anatoly Trosinenko via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT] Gadget scanner: analyze functions without CFG information (PR #133461)

2025-04-09 Thread Anatoly Trosinenko via llvm-branch-commits

https://github.com/atrosinenko updated 
https://github.com/llvm/llvm-project/pull/133461

>From 15823152747e1885f71407eee27601b84a58bc60 Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko 
Date: Wed, 19 Mar 2025 18:58:32 +0300
Subject: [PATCH] [BOLT] Gadget scanner: analyze functions without CFG
 information

Support simple analysis of the functions for which BOLT is unable to
reconstruct the CFG. This patch is inspired by the approach implemented
by Kristof Beyls in the original prototype of gadget scanner, but a
CFG-unaware counterpart of the data-flow analysis is implemented
instead of separate version of gadget detector, as multiple gadget kinds
are detected now.
---
 bolt/include/bolt/Core/BinaryFunction.h   |  13 +
 bolt/include/bolt/Passes/PAuthGadgetScanner.h |  24 +
 bolt/lib/Passes/PAuthGadgetScanner.cpp| 297 ++--
 .../AArch64/gs-pacret-autiasp.s   |  15 +
 .../binary-analysis/AArch64/gs-pauth-calls.s  | 652 ++
 .../AArch64/gs-pauth-debug-output.s   | 116 +++-
 6 files changed, 1028 insertions(+), 89 deletions(-)

diff --git a/bolt/include/bolt/Core/BinaryFunction.h 
b/bolt/include/bolt/Core/BinaryFunction.h
index d3d11f8c5fb73..5cb2cc95af695 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -799,6 +799,19 @@ class BinaryFunction {
 return iterator_range(cie_begin(), cie_end());
   }
 
+  /// Iterate over instructions (only if CFG is unavailable or not built yet).
+  iterator_range instrs() {
+assert(!hasCFG() && "Iterate over basic blocks instead");
+return make_range(Instructions.begin(), Instructions.end());
+  }
+  iterator_range instrs() const {
+assert(!hasCFG() && "Iterate over basic blocks instead");
+return make_range(Instructions.begin(), Instructions.end());
+  }
+
+  /// Returns whether there are any labels at Offset.
+  bool hasLabelAt(unsigned Offset) const { return Labels.count(Offset) != 0; }
+
   /// Iterate over all jump tables associated with this function.
   iterator_range::const_iterator>
   jumpTables() const {
diff --git a/bolt/include/bolt/Passes/PAuthGadgetScanner.h 
b/bolt/include/bolt/Passes/PAuthGadgetScanner.h
index ee69337637da3..6765e2aff414f 100644
--- a/bolt/include/bolt/Passes/PAuthGadgetScanner.h
+++ b/bolt/include/bolt/Passes/PAuthGadgetScanner.h
@@ -67,6 +67,14 @@ struct MCInstInBFReference {
   uint64_t Offset;
   MCInstInBFReference(BinaryFunction *BF, uint64_t Offset)
   : BF(BF), Offset(Offset) {}
+
+  static MCInstInBFReference get(const MCInst *Inst, BinaryFunction &BF) {
+for (auto &I : BF.instrs())
+  if (Inst == &I.second)
+return MCInstInBFReference(&BF, I.first);
+return {};
+  }
+
   MCInstInBFReference() : BF(nullptr), Offset(0) {}
   bool operator==(const MCInstInBFReference &RHS) const {
 return BF == RHS.BF && Offset == RHS.Offset;
@@ -106,6 +114,12 @@ struct MCInstReference {
   MCInstReference(BinaryFunction *BF, uint32_t Offset)
   : MCInstReference(MCInstInBFReference(BF, Offset)) {}
 
+  static MCInstReference get(const MCInst *Inst, BinaryFunction &BF) {
+if (BF.hasCFG())
+  return MCInstInBBReference::get(Inst, BF);
+return MCInstInBFReference::get(Inst, BF);
+  }
+
   bool operator<(const MCInstReference &RHS) const {
 if (ParentKind != RHS.ParentKind)
   return ParentKind < RHS.ParentKind;
@@ -140,6 +154,16 @@ struct MCInstReference {
 llvm_unreachable("");
   }
 
+  operator bool() const {
+switch (ParentKind) {
+case BasicBlockParent:
+  return U.BBRef.BB != nullptr;
+case FunctionParent:
+  return U.BFRef.BF != nullptr;
+}
+llvm_unreachable("");
+  }
+
   uint64_t getAddress() const {
 switch (ParentKind) {
 case BasicBlockParent:
diff --git a/bolt/lib/Passes/PAuthGadgetScanner.cpp 
b/bolt/lib/Passes/PAuthGadgetScanner.cpp
index 2a20bcd09c786..08e0e914501de 100644
--- a/bolt/lib/Passes/PAuthGadgetScanner.cpp
+++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp
@@ -265,21 +265,30 @@ void SrcStatePrinter::print(raw_ostream &OS, const 
SrcState &S) const {
   OS << ">";
 }
 
-class SrcSafetyAnalysis
-: public DataflowAnalysis {
-  using Parent =
-  DataflowAnalysis;
-  friend Parent;
-
+/// Computes which registers are safe to be used by control flow instructions.
+///
+/// This is the base class for two implementations: a dataflow-based analysis
+/// which is intended to be used for most functions and a simplified 
CFG-unaware
+/// version for functions without reconstructed CFG.
+class SrcSafetyAnalysis {
 public:
-  SrcSafetyAnalysis(BinaryFunction &BF, MCPlusBuilder::AllocatorIdTy AllocId,
+  SrcSafetyAnalysis(BinaryFunction &BF,
 const std::vector &RegsToTrackInstsFor)
-  : Parent(BF, AllocId), NumRegs(BF.getBinaryContext().MRI->getNumRegs()),
+  : BC(BF.getBinaryContext()), NumRegs(BC.MRI->getNumRegs()),
 RegsToTrackInstsFor(RegsToTrackInstsFor) {}
+
   virtual ~SrcSafetyAnalysis()

[llvm-branch-commits] [llvm] [BOLT] Gadget scanner: analyze functions without CFG information (PR #133461)

2025-04-09 Thread Anatoly Trosinenko via llvm-branch-commits

https://github.com/atrosinenko updated 
https://github.com/llvm/llvm-project/pull/133461

>From 15823152747e1885f71407eee27601b84a58bc60 Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko 
Date: Wed, 19 Mar 2025 18:58:32 +0300
Subject: [PATCH] [BOLT] Gadget scanner: analyze functions without CFG
 information

Support simple analysis of the functions for which BOLT is unable to
reconstruct the CFG. This patch is inspired by the approach implemented
by Kristof Beyls in the original prototype of gadget scanner, but a
CFG-unaware counterpart of the data-flow analysis is implemented
instead of separate version of gadget detector, as multiple gadget kinds
are detected now.
---
 bolt/include/bolt/Core/BinaryFunction.h   |  13 +
 bolt/include/bolt/Passes/PAuthGadgetScanner.h |  24 +
 bolt/lib/Passes/PAuthGadgetScanner.cpp| 297 ++--
 .../AArch64/gs-pacret-autiasp.s   |  15 +
 .../binary-analysis/AArch64/gs-pauth-calls.s  | 652 ++
 .../AArch64/gs-pauth-debug-output.s   | 116 +++-
 6 files changed, 1028 insertions(+), 89 deletions(-)

diff --git a/bolt/include/bolt/Core/BinaryFunction.h 
b/bolt/include/bolt/Core/BinaryFunction.h
index d3d11f8c5fb73..5cb2cc95af695 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -799,6 +799,19 @@ class BinaryFunction {
 return iterator_range(cie_begin(), cie_end());
   }
 
+  /// Iterate over instructions (only if CFG is unavailable or not built yet).
+  iterator_range instrs() {
+assert(!hasCFG() && "Iterate over basic blocks instead");
+return make_range(Instructions.begin(), Instructions.end());
+  }
+  iterator_range instrs() const {
+assert(!hasCFG() && "Iterate over basic blocks instead");
+return make_range(Instructions.begin(), Instructions.end());
+  }
+
+  /// Returns whether there are any labels at Offset.
+  bool hasLabelAt(unsigned Offset) const { return Labels.count(Offset) != 0; }
+
   /// Iterate over all jump tables associated with this function.
   iterator_range::const_iterator>
   jumpTables() const {
diff --git a/bolt/include/bolt/Passes/PAuthGadgetScanner.h 
b/bolt/include/bolt/Passes/PAuthGadgetScanner.h
index ee69337637da3..6765e2aff414f 100644
--- a/bolt/include/bolt/Passes/PAuthGadgetScanner.h
+++ b/bolt/include/bolt/Passes/PAuthGadgetScanner.h
@@ -67,6 +67,14 @@ struct MCInstInBFReference {
   uint64_t Offset;
   MCInstInBFReference(BinaryFunction *BF, uint64_t Offset)
   : BF(BF), Offset(Offset) {}
+
+  static MCInstInBFReference get(const MCInst *Inst, BinaryFunction &BF) {
+for (auto &I : BF.instrs())
+  if (Inst == &I.second)
+return MCInstInBFReference(&BF, I.first);
+return {};
+  }
+
   MCInstInBFReference() : BF(nullptr), Offset(0) {}
   bool operator==(const MCInstInBFReference &RHS) const {
 return BF == RHS.BF && Offset == RHS.Offset;
@@ -106,6 +114,12 @@ struct MCInstReference {
   MCInstReference(BinaryFunction *BF, uint32_t Offset)
   : MCInstReference(MCInstInBFReference(BF, Offset)) {}
 
+  static MCInstReference get(const MCInst *Inst, BinaryFunction &BF) {
+if (BF.hasCFG())
+  return MCInstInBBReference::get(Inst, BF);
+return MCInstInBFReference::get(Inst, BF);
+  }
+
   bool operator<(const MCInstReference &RHS) const {
 if (ParentKind != RHS.ParentKind)
   return ParentKind < RHS.ParentKind;
@@ -140,6 +154,16 @@ struct MCInstReference {
 llvm_unreachable("");
   }
 
+  operator bool() const {
+switch (ParentKind) {
+case BasicBlockParent:
+  return U.BBRef.BB != nullptr;
+case FunctionParent:
+  return U.BFRef.BF != nullptr;
+}
+llvm_unreachable("");
+  }
+
   uint64_t getAddress() const {
 switch (ParentKind) {
 case BasicBlockParent:
diff --git a/bolt/lib/Passes/PAuthGadgetScanner.cpp 
b/bolt/lib/Passes/PAuthGadgetScanner.cpp
index 2a20bcd09c786..08e0e914501de 100644
--- a/bolt/lib/Passes/PAuthGadgetScanner.cpp
+++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp
@@ -265,21 +265,30 @@ void SrcStatePrinter::print(raw_ostream &OS, const 
SrcState &S) const {
   OS << ">";
 }
 
-class SrcSafetyAnalysis
-: public DataflowAnalysis {
-  using Parent =
-  DataflowAnalysis;
-  friend Parent;
-
+/// Computes which registers are safe to be used by control flow instructions.
+///
+/// This is the base class for two implementations: a dataflow-based analysis
+/// which is intended to be used for most functions and a simplified 
CFG-unaware
+/// version for functions without reconstructed CFG.
+class SrcSafetyAnalysis {
 public:
-  SrcSafetyAnalysis(BinaryFunction &BF, MCPlusBuilder::AllocatorIdTy AllocId,
+  SrcSafetyAnalysis(BinaryFunction &BF,
 const std::vector &RegsToTrackInstsFor)
-  : Parent(BF, AllocId), NumRegs(BF.getBinaryContext().MRI->getNumRegs()),
+  : BC(BF.getBinaryContext()), NumRegs(BC.MRI->getNumRegs()),
 RegsToTrackInstsFor(RegsToTrackInstsFor) {}
+
   virtual ~SrcSafetyAnalysis()

[llvm-branch-commits] [llvm] [BOLT] Gadget scanner: analyze functions without CFG information (PR #133461)

2025-04-09 Thread Anatoly Trosinenko via llvm-branch-commits


@@ -265,21 +286,24 @@ void PacStatePrinter::print(raw_ostream &OS, const State 
&S) const {
   OS << ">";
 }
 
-class PacRetAnalysis
-: public DataflowAnalysis {
-  using Parent =
-  DataflowAnalysis;
-  friend Parent;
-
+class PacRetAnalysis {

atrosinenko wrote:

Moved NFC cleanup to #135073.

https://github.com/llvm/llvm-project/pull/133461
___
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] CodeGen: Trim redundant template argument from defusechain_iterator (PR #135024)

2025-04-09 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm ready_for_review 
https://github.com/llvm/llvm-project/pull/135024
___
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] [X86] Backport new intrinsic and instruction changes in AVX10.2 (PR #133219)

2025-04-09 Thread Phoebe Wang via llvm-branch-commits

phoebewang wrote:

> > Doesn't this break ABI by changing intrinsic / builtin numbers?
> 
> So the headers could still be updated but must use the existing builtins in 
> the backport?

Sounds good, I can try with it. Thanks!

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


[llvm-branch-commits] [mlir] [mlir][LLVM] Delete `getFixedVectorType` and `getScalableVectorType` (PR #135051)

2025-04-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-llvm

Author: Matthias Springer (matthias-springer)


Changes

The LLVM dialect no longer has its own vector types. It uses `mlir::VectorType` 
everywhere. Remove `LLVM::getFixedVectorType/getScalableVectorType` and use 
`VectorType::get` instead. This commit addresses a 
[comment](https://github.com/llvm/llvm-project/pull/133286#discussion_r2022192500)
 on the PR that deleted the LLVM vector types.

Depends on #134981.



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


7 Files Affected:

- (modified) mlir/docs/Dialects/LLVM.md (-4) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h (-8) 
- (modified) mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp (+16-17) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp (-12) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp (+14-9) 
- (modified) mlir/lib/Dialect/NVGPU/Utils/MMAUtils.cpp (+10-14) 
- (modified) mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp (+5-4) 


``diff
diff --git a/mlir/docs/Dialects/LLVM.md b/mlir/docs/Dialects/LLVM.md
index 468f69c419071..4b5d518ca4eab 100644
--- a/mlir/docs/Dialects/LLVM.md
+++ b/mlir/docs/Dialects/LLVM.md
@@ -336,10 +336,6 @@ compatible with the LLVM dialect:
 vector type compatible with the LLVM dialect;
 -   `llvm::ElementCount LLVM::getVectorNumElements(Type)` - returns the number
 of elements in any vector type compatible with the LLVM dialect;
--   `Type LLVM::getFixedVectorType(Type, unsigned)` - gets a fixed vector type
-with the given element type and size; the resulting type is either a
-built-in or an LLVM dialect vector type depending on which one supports the
-given element type.
 
  Examples of Compatible Vector Types
 
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
index a2a76c49a2bda..17561f79d135a 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
@@ -126,14 +126,6 @@ Type getVectorType(Type elementType, unsigned numElements,
 /// and length.
 Type getVectorType(Type elementType, const llvm::ElementCount &numElements);
 
-/// Creates an LLVM dialect-compatible type with the given element type and
-/// length.
-Type getFixedVectorType(Type elementType, unsigned numElements);
-
-/// Creates an LLVM dialect-compatible type with the given element type and
-/// length.
-Type getScalableVectorType(Type elementType, unsigned numElements);
-
 /// Returns the size of the given primitive LLVM dialect-compatible type
 /// (including vectors) in bits, for example, the size of i16 is 16 and
 /// the size of vector<4xi16> is 64. Returns 0 for non-primitive
diff --git a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp 
b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
index 51507c6507b69..69fa62c8196e4 100644
--- a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
+++ b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
@@ -61,13 +61,13 @@ static Value truncToI32(ImplicitLocOpBuilder &b, Value 
value) {
 static Type inferIntrinsicResultType(Type vectorResultType) {
   MLIRContext *ctx = vectorResultType.getContext();
   auto a = cast(vectorResultType);
-  auto f16x2Ty = LLVM::getFixedVectorType(Float16Type::get(ctx), 2);
+  auto f16x2Ty = VectorType::get(2, Float16Type::get(ctx));
   auto i32Ty = IntegerType::get(ctx, 32);
-  auto i32x2Ty = LLVM::getFixedVectorType(i32Ty, 2);
+  auto i32x2Ty = VectorType::get(2, i32Ty);
   Type f64Ty = Float64Type::get(ctx);
-  Type f64x2Ty = LLVM::getFixedVectorType(f64Ty, 2);
+  Type f64x2Ty = VectorType::get(2, f64Ty);
   Type f32Ty = Float32Type::get(ctx);
-  Type f32x2Ty = LLVM::getFixedVectorType(f32Ty, 2);
+  Type f32x2Ty = VectorType::get(2, f32Ty);
   if (a.getElementType() == f16x2Ty) {
 return LLVM::LLVMStructType::getLiteral(
 ctx, SmallVector(a.getNumElements(), f16x2Ty));
@@ -85,7 +85,7 @@ static Type inferIntrinsicResultType(Type vectorResultType) {
 ctx,
 SmallVector(static_cast(a.getNumElements()) * 2, f32Ty));
   }
-  if (a.getElementType() == LLVM::getFixedVectorType(f32Ty, 1)) {
+  if (a.getElementType() == VectorType::get(1, f32Ty)) {
 return LLVM::LLVMStructType::getLiteral(
 ctx, SmallVector(static_cast(a.getNumElements()), 
f32Ty));
   }
@@ -106,11 +106,11 @@ static Value convertIntrinsicResult(Location loc, Type 
intrinsicResultType,
   Type i32Ty = rewriter.getI32Type();
   Type f32Ty = rewriter.getF32Type();
   Type f64Ty = rewriter.getF64Type();
-  Type f16x2Ty = LLVM::getFixedVectorType(rewriter.getF16Type(), 2);
-  Type i32x2Ty = LLVM::getFixedVectorType(i32Ty, 2);
-  Type f64x2Ty = LLVM::getFixedVectorType(f64Ty, 2);
-  Type f32x2Ty = LLVM::getFixedVectorType(f32Ty, 2);
-  Type f32x1Ty = LLVM::getFixedVectorType(f32Ty, 1);
+  Type f16x2Ty = VectorType::get(2, rewriter.getF16Type());
+  Type i32x2Ty = VectorType::get(2, i32Ty);
+  Type f64x2Ty = VectorType::get(2, f64Ty);
+  Type f32x2Ty = VectorType::get

[llvm-branch-commits] [llvm] SCEVExpander: Don't look at uses of constants (PR #134691)

2025-04-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Matt Arsenault (arsenm)


Changes

This could be more relaxed, and look for uses of globals in
the same function but no tests apparently depend on that.

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


1 Files Affected:

- (modified) llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp (+16-13) 


``diff
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp 
b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 41bf202230e22..e25ec6c3b2a58 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -111,20 +111,23 @@ Value *SCEVExpander::ReuseOrCreateCast(Value *V, Type *Ty,
 
   Value *Ret = nullptr;
 
-  // Check to see if there is already a cast!
-  for (User *U : V->users()) {
-if (U->getType() != Ty)
-  continue;
-CastInst *CI = dyn_cast(U);
-if (!CI || CI->getOpcode() != Op)
-  continue;
+  if (!isa(V)) {
+// Check to see if there is already a cast!
+for (User *U : V->users()) {
+  if (U->getType() != Ty)
+continue;
+  CastInst *CI = dyn_cast(U);
+  if (!CI || CI->getOpcode() != Op)
+continue;
 
-// Found a suitable cast that is at IP or comes before IP. Use it. Note 
that
-// the cast must also properly dominate the Builder's insertion point.
-if (IP->getParent() == CI->getParent() && &*BIP != CI &&
-(&*IP == CI || CI->comesBefore(&*IP))) {
-  Ret = CI;
-  break;
+  // Found a suitable cast that is at IP or comes before IP. Use it. Note
+  // that the cast must also properly dominate the Builder's insertion
+  // point.
+  if (IP->getParent() == CI->getParent() && &*BIP != CI &&
+  (&*IP == CI || CI->comesBefore(&*IP))) {
+Ret = CI;
+break;
+  }
 }
   }
 

``




https://github.com/llvm/llvm-project/pull/134691
___
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] [GOFF] Add writing of section symbols (PR #133799)

2025-04-09 Thread via llvm-branch-commits


@@ -2759,6 +2762,29 @@ MCSection 
*TargetLoweringObjectFileXCOFF::getSectionForLSDA(
 
//===--===//
 TargetLoweringObjectFileGOFF::TargetLoweringObjectFileGOFF() = default;
 
+void TargetLoweringObjectFileGOFF::getModuleMetadata(Module &M) {
+  // Construct the default names for the root SD and the ADA PR symbol.
+  StringRef FileName = sys::path::stem(M.getSourceFileName());
+  if (FileName.size() > 1 && FileName.starts_with('<') &&
+  FileName.ends_with('>'))
+FileName = FileName.substr(1, FileName.size() - 2);
+  DefaultRootSDName = Twine(FileName).concat("#C").str();

AidoP wrote:

The default root section should be a private section, a section with a name of 
1 space. The source file name affecting ABI is quite surprising and could 
easily lead to linker errors, especially when taking just the stem. For 
example, `clang src/a.c src/impl/a.c` would have issues.

Additionally I'm not sure if the file name can be relied on at all here. Is it 
guaranteed to be provided by a compiler frontend? Does it make sense for the 
file name to be interpreted as UTF-8 then converted to IBM-1047? It also needs 
to be normalised to deal with characters that are invalid for symbol names.

https://github.com/llvm/llvm-project/pull/133799
___
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] 2ab2276 - [HLSL] Implement the `lit` intrinsic (#134171)

2025-04-09 Thread via llvm-branch-commits

Author: Kaitlin Peng
Date: 2025-04-09T12:12:26-07:00
New Revision: 2ab2276ee079478b7ba9dd42c62b796d3dab1759

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

LOG: [HLSL] Implement the `lit` intrinsic (#134171)

Closes #99135.

Tasks completed:
- Wrote implementation in `hlsl_intrinsics.h`/`hlsl_intrinsic_helpers.h`
- Added codegen tests to `clang/test/CodeGenHLSL/builtins/lit.hlsl`

Added: 
clang/test/CodeGenHLSL/builtins/lit.hlsl

Modified: 
clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
clang/lib/Headers/hlsl/hlsl_intrinsics.h

Removed: 




diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index b5d88ee1f65cb..3a8a9b6fa2a45 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -114,6 +114,18 @@ constexpr vector smoothstep_vec_impl(vector 
Min, vector Max,
 #endif
 }
 
+template  constexpr vector lit_impl(T NDotL, T NDotH, T M) {
+  bool DiffuseCond = NDotL < 0;
+  T Diffuse = select(DiffuseCond, 0, NDotL);
+  vector Result = {1, Diffuse, 0, 1};
+  // clang-format off
+  bool SpecularCond = or(DiffuseCond, (NDotH < 0));
+  // clang-format on
+  T SpecularExp = exp(log(NDotH) * M);
+  Result[2] = select(SpecularCond, 0, SpecularExp);
+  return Result;
+}
+
 } // namespace __detail
 } // namespace hlsl
 

diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 8197b5ddf078d..35ff80052cf43 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -292,6 +292,30 @@ const inline float 
length(__detail::HLSL_FIXED_VECTOR X) {
   return __detail::length_vec_impl(X);
 }
 
+//===--===//
+// lit builtins
+//===--===//
+
+/// \fn vector lit(T NDotL, T NDotH, T M)
+/// \brief Returns a lighting coefficient vector.
+/// \param NDotL The dot product of the normalized surface normal and the
+/// light vector.
+/// \param NDotH The dot product of the half-angle vector and the surface
+/// normal.
+/// \param M A specular exponent.
+///
+/// This function returns a lighting coefficient vector (ambient, 
diff use,
+/// specular, 1).
+
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+const inline half4 lit(half NDotL, half NDotH, half M) {
+  return __detail::lit_impl(NDotL, NDotH, M);
+}
+
+const inline float4 lit(float NDotL, float NDotH, float M) {
+  return __detail::lit_impl(NDotL, NDotH, M);
+}
+
 
//===--===//
 // D3DCOLORtoUBYTE4 builtin
 
//===--===//

diff  --git a/clang/test/CodeGenHLSL/builtins/lit.hlsl 
b/clang/test/CodeGenHLSL/builtins/lit.hlsl
new file mode 100644
index 0..44b3e96ef88bf
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/lit.hlsl
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple 
dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -o - | 
FileCheck %s
+
+// CHECK-LABEL: test_lit_half
+// CHECK: %cmp.i = fcmp reassoc nnan ninf nsz arcp afn olt half %{{.*}}, 
0xH
+// CHECK: %hlsl.select.i = select reassoc nnan ninf nsz arcp afn i1 %{{.*}}, 
half 0xH, half %{{.*}}
+// CHECK: %vecinit.i = insertelement <4 x half> , half %{{.*}}, i32 1
+// CHECK: %vecinit2.i = insertelement <4 x half> %{{.*}}, half 0xH3C00, i32 3
+// CHECK: %cmp4.i = fcmp reassoc nnan ninf nsz arcp afn olt half %{{.*}}, 
0xH
+// CHECK: %hlsl.or.i = or i1 %{{.*}}, %cmp4.i
+// CHECK: %elt.log.i = call reassoc nnan ninf nsz arcp afn half 
@llvm.log.f16(half %{{.*}})
+// CHECK: %mul.i = fmul reassoc nnan ninf nsz arcp afn half %elt.log.i, %{{.*}}
+// CHECK: %elt.exp.i = call reassoc nnan ninf nsz arcp afn half 
@llvm.exp.f16(half %mul.i)
+// CHECK: %hlsl.select7.i = select reassoc nnan ninf nsz arcp afn i1 %{{.*}}, 
half 0xH, half %{{.*}}
+// CHECK: %vecins.i = insertelement <4 x half> %{{.*}}, half %hlsl.select7.i, 
i32 2
+// CHECK: ret <4 x half> %{{.*}}
+half4 test_lit_half(half NDotL, half NDotH, half M) { return lit(NDotL, NDotH, 
M); }
+
+// CHECK-LABEL: test_lit_float
+// CHECK: %cmp.i = fcmp reassoc nnan ninf nsz arcp afn olt float %{{.*}}, 
0.00e+00
+// CHECK: %hlsl.select.i = select reassoc nnan ninf nsz arcp afn i1 %{{.*}}, 
float 0.00e+00, float %{{.*}}
+// CHECK: %vecinit.i = insertelement <4 x float> , float %{{.*}}, i32 1
+// CHECK: %vecinit2.i = insertelement <4 x float> %{{.*}}, float 1.00e+00, 
i32 3
+// CHECK: %cmp4.i = fcmp reassoc nnan ninf nsz arcp afn olt float %{{.*}}, 
0.00e+00
+// CHECK: %hlsl.or.i = or i1 %{{.*

[llvm-branch-commits] [llvm] 989bc69 - llvm-reduce: Trim includes in ReduceInstructions (#135022)

2025-04-09 Thread via llvm-branch-commits

Author: Matt Arsenault
Date: 2025-04-09T21:14:42+02:00
New Revision: 989bc69ceb47e27f402d14166eb2e2ea53e00c84

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

LOG: llvm-reduce: Trim includes in ReduceInstructions (#135022)

Added: 


Modified: 
llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp

Removed: 




diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp 
b/llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
index a906584f75dd7..f1f5d6b83de10 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
@@ -13,10 +13,6 @@
 
 #include "ReduceInstructions.h"
 #include "Utils.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/Transforms/Utils/BasicBlockUtils.h"
-#include "llvm/Transforms/Utils/Cloning.h"
-#include 
 
 using namespace llvm;
 



___
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] IROutliner: Do not look at use lists of constant phi inputs (PR #135019)

2025-04-09 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm ready_for_review 
https://github.com/llvm/llvm-project/pull/135019
___
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] IROutliner: Do not look at use lists of constant phi inputs (PR #135019)

2025-04-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Matt Arsenault (arsenm)


Changes

Theoretically this does a worse job with globals but this is not
covered by existing tests

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


1 Files Affected:

- (modified) llvm/lib/Transforms/IPO/IROutliner.cpp (+2-1) 


``diff
diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp 
b/llvm/lib/Transforms/IPO/IROutliner.cpp
index 8c5946fb07c65..eec869d57a6db 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -1126,7 +1126,8 @@ static void analyzeExitPHIsForOutputUses(
 // outside of the single PHINode we should not skip over it.
 for (unsigned Idx : IncomingVals) {
   Value *V = PN.getIncomingValue(Idx);
-  if (outputHasNonPHI(V, Idx, PN, PotentialExitsFromRegion, RegionBlocks)) 
{
+  if (!isa(V) &&
+  outputHasNonPHI(V, Idx, PN, PotentialExitsFromRegion, RegionBlocks)) 
{
 OutputsWithNonPhiUses.insert(V);
 OutputsReplacedByPHINode.erase(V);
 continue;

``




https://github.com/llvm/llvm-project/pull/135019
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits


@@ -1215,6 +1215,29 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
 #  endif
 
+#  if __has_feature(pointer_field_protection)
+// Force a class to be non-standard layout by giving it two bases with the same
+// type. This is useful when structure protection is enabled because structure
+// protection cannot be applied to standard layout classes. We may use this in
+// cases where the standard does not specify whether a standard library class 
is
+// standard layout. See C++2a [class]p7:
+//   A class S is a standard-layout class if it:
+// -- has at most one base class subobject of any given type
+_LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winaccessible-base")
+class __force_nonstandard_layout_base1 {};
+class __force_nonstandard_layout_base2 : __force_nonstandard_layout_base1 {};
+class __force_nonstandard_layout : __force_nonstandard_layout_base1, 
__force_nonstandard_layout_base2 {};
+_LIBCPP_DIAGNOSTIC_POP
+_LIBCPP_END_NAMESPACE_STD

pcc wrote:

Correct, I later found that adding this caused some `check-libcxx` test 
failures with my feature enabled so I ended up splitting this into a separate 
header.

https://github.com/llvm/llvm-project/pull/133538
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc commented:

> in libc++ we have a pre-commit CI so this feature should be tested in our CI, 
> if you need help with that, best reach out to us on Discord. However I think 
> we first need to look at how we can properly integrate this in libc++.

Sure, I will get in touch once this is closer to landing (everything else in 
https://github.com/orgs/llvm/projects/38 needs to land first). So far I've been 
running the libc++ test suite manually with some hand written cfg files but it 
would be good to get everything hooked up so that the tests can run in CI as 
well.

> I'm not fond of this patch since it mixes LLVM, Clang, and libc++(abi) code. 
> This makes it hard to determine when all reviewer groups are satisfied. Is 
> there a reason why the libc++ and the libc++abi part can't be in two separate 
> patches?

No problem, I'll split up the libc++ and libc++abi parts into separate patches 
the next time I upload.

> (I don't know whether it makes sense to keep the LLVM & Clang part in one 
> patch.)

That would make sense, the changes that add the new LLVM intrinsic can be made 
a prerequisite of the Clang changes.

https://github.com/llvm/llvm-project/pull/133538
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits


@@ -1215,6 +1215,29 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
 #  endif
 
+#  if __has_feature(pointer_field_protection)

pcc wrote:

Makes sense, will do.

https://github.com/llvm/llvm-project/pull/133538
___
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/AMDGPU: Stop looking for oclc_daz_opt_* control libraries (PR #134805)

2025-04-09 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

> LGTM.
> 
> 
> 
> Does this mean device library have no code depending on option 
> `-cl-denorms-are-zero`?

It still has a little but it's implementable as a runtime check with dynamic 
denormal mode. I think it would still be better to find a way to avoid it (I 
think we need one weird peephole to do it)

https://github.com/llvm/llvm-project/pull/134805
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc edited https://github.com/llvm/llvm-project/pull/133538
___
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] [BOLT] Jump table trampoline insertion pass (PR #135103)

2025-04-09 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov created 
https://github.com/llvm/llvm-project/pull/135103



Test Plan: TBD



___
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] [GOFF] Add writing of section symbols (PR #133799)

2025-04-09 Thread Kai Nacke via llvm-branch-commits


@@ -239,6 +298,63 @@ class GOFFWriter {
 GOFFWriter::GOFFWriter(raw_pwrite_stream &OS, MCAssembler &Asm)
 : OS(OS), Asm(Asm) {}
 
+void GOFFWriter::defineSectionSymbols(const MCSectionGOFF &Section) {
+  if (Section.isSD()) {
+GOFFSymbol SD(Section.getName(), Section.getId(),
+  Section.getSDAttributes());
+writeSymbol(SD);
+  }
+
+  if (Section.isED()) {
+GOFFSymbol ED(Section.getName(), Section.getId(),
+  Section.getParent()->getId(), Section.getEDAttributes());
+if (Section.requiresLength())
+  ED.SectionLength = Asm.getSectionAddressSize(Section);
+writeSymbol(ED);
+  }
+
+  if (Section.isPR()) {
+GOFFSymbol PR(Section.getName(), Section.getId(),
+  Section.getParent()->getId(), Section.getPRAttributes());
+PR.SectionLength = Asm.getSectionAddressSize(Section);
+if (Section.requiresNonZeroLength()) {

redstar wrote:

I talked to a colleague. Exactly this ^^^ case will not work. The binder gives 
no warning/error but it will cause problems at runtime because the environment 
parameter is zero.

https://github.com/llvm/llvm-project/pull/133799
___
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] release/20.x: [Sanitizers][Darwin][Test] XFAIL malloc_zone.cpp (PR #133832)

2025-04-09 Thread Mariusz Borsa via llvm-branch-commits

wrotki wrote:

Not sure if I'm perhaps missing some step to have this merged, is there any 
automated process?II don't have permissions to merge this to the release branch 
(Github shows me  'Cannot update this protected ref' status). 

@tstellar , could you merge this on my behalf?

https://github.com/llvm/llvm-project/pull/133832
___
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] 76c510a - Revert "Reland "Symbolize line zero as if no source info is available (#12484…"

2025-04-09 Thread via llvm-branch-commits

Author: Zequan Wu
Date: 2025-04-09T21:02:29-04:00
New Revision: 76c510a2a1b7b7f708ea7b891ef5f7da5c703ca6

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

LOG: Revert "Reland "Symbolize line zero as if no source info is available 
(#12484…"

This reverts commit 348374028970c956f2e49ab7553b495d7408ccd9.

Added: 


Modified: 
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/test/tools/llvm-symbolizer/skip-line-zero.s
llvm/test/tools/llvm-symbolizer/sym-verbose.test
offload/test/sanitizer/kernel_crash_many.c
offload/test/sanitizer/kernel_trap.c
offload/test/sanitizer/kernel_trap.cpp
offload/test/sanitizer/kernel_trap_many.c

Removed: 




diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp 
b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 9c5d43dd4fb77..e76e518ef8595 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1870,7 +1870,7 @@ 
DWARFContext::getInliningInfoForAddress(object::SectionedAddress Address,
   LineTable->getFileLineInfoForAddress(
   {Address.Address, Address.SectionIndex}, Spec.ApproximateLine,
   CU->getCompilationDir(), Spec.FLIKind, Frame);
-  } else if (CallLine != 0) {
+  } else {
 // Otherwise, use call file, call line and call column from
 // previous DIE in inlined chain.
 if (LineTable)

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp 
b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 62bf3d4ecaaf0..55a3bfa459c3c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -1539,8 +1539,7 @@ bool DWARFDebugLine::LineTable::getFileLineInfoForAddress(
 return false;
   // Take file number and line/column from the row.
   const auto &Row = Rows[RowIndex];
-  if (Row.Line == 0 ||
-  !getFileNameByIndex(Row.File, CompDir, Kind, Result.FileName))
+  if (!getFileNameByIndex(Row.File, CompDir, Kind, Result.FileName))
 return false;
   Result.Line = Row.Line;
   Result.Column = Row.Column;

diff  --git a/llvm/test/tools/llvm-symbolizer/skip-line-zero.s 
b/llvm/test/tools/llvm-symbolizer/skip-line-zero.s
index 74dfb5cdc1aae..e9fbea558e0eb 100644
--- a/llvm/test/tools/llvm-symbolizer/skip-line-zero.s
+++ b/llvm/test/tools/llvm-symbolizer/skip-line-zero.s
@@ -20,13 +20,13 @@
 ## Check that without '--skip-line-zero', line zero is displayed for a 
line-table entry which has no source correspondence.
 # RUN: llvm-symbolizer --obj=%t.o -f=none 0x16d4 | FileCheck 
--strict-whitespace --match-full-lines --check-prefix=DISABLE %s
 
-# DISABLE:??:0:0
+# DISABLE:main.c:0:0
 
 ## Check that the '--skip-line-zero' does not cross sequence boundaries.
 ## If it fails to find in the current sequence then line zero is returned for 
the queried address.
 # RUN: llvm-symbolizer --obj=%t.o -f=none --skip-line-zero 0x16c0 | FileCheck 
--strict-whitespace --match-full-lines --check-prefix=FAIL-ACROSS-SEQ %s
 
-# FAIL-ACROSS-SEQ:??:0:0
+# FAIL-ACROSS-SEQ:main.c:0:0
 
 ## Check that with '--skip-line-zero', the last non-zero line in the current 
sequence is displayed.
 # RUN: llvm-symbolizer --obj=%t.o -f=none --skip-line-zero 0x1717 | FileCheck 
--strict-whitespace --match-full-lines --check-prefix=WITHIN-SEQ %s

diff  --git a/llvm/test/tools/llvm-symbolizer/sym-verbose.test 
b/llvm/test/tools/llvm-symbolizer/sym-verbose.test
index 224c317f558a1..831fd6c7f0507 100644
--- a/llvm/test/tools/llvm-symbolizer/sym-verbose.test
+++ b/llvm/test/tools/llvm-symbolizer/sym-verbose.test
@@ -50,12 +50,13 @@ CHECK-NEXT: Column: 0
 
 CHECK: 0x4005ad
 CHECK-NEXT: foo
-CHECK-NEXT: Filename: ??
+CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
 CHECK-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c
 CHECK-NEXT: Function start line: 4
 CHECK-NEXT: Function start address: 0x400590
 CHECK-NEXT: Line: 0
-CHECK-NEXT: Column: 0
+CHECK-NEXT: Column: 30
+CHECK-NEXT: Discriminator: 4
 CHECK-NEXT: main
 CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
 CHECK-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c

diff  --git a/offload/test/sanitizer/kernel_crash_many.c 
b/offload/test/sanitizer/kernel_crash_many.c
index 9fd8af48f51fe..f1d17ca2b76e2 100644
--- a/offload/test/sanitizer/kernel_crash_many.c
+++ b/offload/test/sanitizer/kernel_crash_many.c
@@ -37,36 +37,36 @@ int main(void) {
 // CHECK: Kernel 1: {{.*}} (__omp_offloading_{{.*}}_main_l22)
 // CHECK: launchKernel
 // NDEBG: main
-// DEBUG: main {{.*}}kernel_crash_many.c
+// DEBUG: main {{.*}}kernel_crash_many.c:
 //
 // CHECK: Kernel 2: {{.*}} (__omp_offloading_{{.*}}_main_l22)
 // CHECK: launchKernel
 // NDEBG: main
-// DEBUG: main {{.*}}kernel_crash_many.c
+// DEB

[llvm-branch-commits] [libcxx] libcxx: In gdb test detect execute_mi with feature check instead of version check. (PR #132291)

2025-04-09 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

@philnik777 FWIW I also see a normal diff in the webui.

https://github.com/llvm/llvm-project/pull/132291
___
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] IROutliner: Do not look at use lists of constant phi inputs (PR #135019)

2025-04-09 Thread Matt Arsenault via llvm-branch-commits

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

Theoretically this does a worse job with globals but this is not
covered by existing tests

>From 6e92bcd3daf17aad7e2a3a3ccc166845aa1b317c Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Wed, 9 Apr 2025 13:28:19 +0800
Subject: [PATCH] IROutliner: Do not look at use lists of constant phi inputs

Theoretically this does a worse job with globals but this is not
covered by existing tests
---
 llvm/lib/Transforms/IPO/IROutliner.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp 
b/llvm/lib/Transforms/IPO/IROutliner.cpp
index 8c5946fb07c65..eec869d57a6db 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -1126,7 +1126,8 @@ static void analyzeExitPHIsForOutputUses(
 // outside of the single PHINode we should not skip over it.
 for (unsigned Idx : IncomingVals) {
   Value *V = PN.getIncomingValue(Idx);
-  if (outputHasNonPHI(V, Idx, PN, PotentialExitsFromRegion, RegionBlocks)) 
{
+  if (!isa(V) &&
+  outputHasNonPHI(V, Idx, PN, PotentialExitsFromRegion, RegionBlocks)) 
{
 OutputsWithNonPhiUses.insert(V);
 OutputsReplacedByPHINode.erase(V);
 continue;

___
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] [KeyInstr][Inline] Don't propagate atoms to inlined nodebug instructions (PR #133485)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits


@@ -2145,6 +2145,13 @@ class DILocation : public MDNode {
 return 0;
   }
 
+  const DILocation *getOrCloneWithoutAtom() const {

SLTozer wrote:

I think this could just be "getWithoutAtom", it's already implied with 
DIMetadata that "get" means "find me an existing metadata or create a new one".

https://github.com/llvm/llvm-project/pull/133485
___
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] [KeyInstr][Inline] Don't propagate atoms to inlined nodebug instructions (PR #133485)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits

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

I think conceptually there is some space for copying atom group/rank to the 
inlined instructions, giving the instruction(s) that produce the return value 
(if any) the highest precedence. This would be a separate feature however, and 
this behaviour seems fine to me as a first pass; minor inline comment.

https://github.com/llvm/llvm-project/pull/133485
___
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] e256292 - Revert "[flang][nfc] Support volatility in Fir ops (#134858)"

2025-04-09 Thread via llvm-branch-commits

Author: David Spickett
Date: 2025-04-09T15:41:07+01:00
New Revision: e256292805f7e8bc168a3f207c83c784f307bd55

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

LOG: Revert "[flang][nfc] Support volatility in Fir ops (#134858)"

This reverts commit e42f8609858f3e6ba004032a4750f0bcd5d466be.

Added: 


Modified: 
flang/include/flang/Optimizer/Builder/FIRBuilder.h
flang/include/flang/Optimizer/Dialect/FIROps.h
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/include/flang/Optimizer/Dialect/FIROpsSupport.h
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/lib/Optimizer/Builder/FIRBuilder.cpp
flang/lib/Optimizer/Dialect/FIROps.cpp
flang/test/Fir/cse.fir
flang/test/Fir/invalid.fir

Removed: 




diff  --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h 
b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index 8fca4272636b1..ddd4ef7114a63 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -397,11 +397,6 @@ class FirOpBuilder : public mlir::OpBuilder, public 
mlir::OpBuilder::Listener {
   mlir::Value createConvert(mlir::Location loc, mlir::Type toTy,
 mlir::Value val);
 
-  /// Create a fir.convert op with a volatile cast if the source value's type
-  /// does not match the target type's volatility.
-  mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type 
toTy,
-mlir::Value val);
-
   /// Create a fir.store of \p val into \p addr. A lazy conversion
   /// of \p val to the element type of \p addr is created if needed.
   void createStoreWithConvert(mlir::Location loc, mlir::Value val,

diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.h 
b/flang/include/flang/Optimizer/Dialect/FIROps.h
index f3dbf47351ab8..ed301016ad01c 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.h
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.h
@@ -50,12 +50,6 @@ struct DebuggingResource
   mlir::StringRef getName() final { return "DebuggingResource"; }
 };
 
-/// Model operations which read from/write to volatile memory
-struct VolatileMemoryResource
-: public mlir::SideEffects::Resource::Base {
-  mlir::StringRef getName() final { return "VolatileMemoryResource"; }
-};
-
 class CoordinateIndicesAdaptor;
 using IntOrValue = llvm::PointerUnion;
 

diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td 
b/flang/include/flang/Optimizer/Dialect/FIROps.td
index c7ac2c0397413..753e4bd18dc6d 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -286,8 +286,7 @@ def fir_FreeMemOp : fir_Op<"freemem", 
[MemoryEffects<[MemFree]>]> {
   let assemblyFormat = "$heapref attr-dict `:` qualified(type($heapref))";
 }
 
-def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
-  
DeclareOpInterfaceMethods]> {
+def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface]> {
   let summary = "load a value from a memory reference";
   let description = [{
 Load a value from a memory reference into an ssa-value (virtual register).
@@ -303,7 +302,7 @@ def fir_LoadOp : fir_OneResultOp<"load", 
[FirAliasTagOpInterface,
 or null.
   }];
 
-  let arguments = (ins AnyReferenceLike:$memref,
+  let arguments = (ins Arg:$memref,
   OptionalAttr:$tbaa);
 
   let builders = [OpBuilder<(ins "mlir::Value":$refVal)>,
@@ -316,8 +315,7 @@ def fir_LoadOp : fir_OneResultOp<"load", 
[FirAliasTagOpInterface,
   }];
 }
 
-def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
-   
DeclareOpInterfaceMethods]> {
+def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface]> {
   let summary = "store an SSA-value to a memory location";
 
   let description = [{
@@ -337,7 +335,7 @@ def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
   }];
 
   let arguments = (ins AnyType:$value,
-   AnyReferenceLike:$memref,
+   Arg:$memref,
OptionalAttr:$tbaa);
 
   let builders = [OpBuilder<(ins "mlir::Value":$value, 
"mlir::Value":$memref)>];
@@ -350,7 +348,7 @@ def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
   }];
 }
 
-def fir_CopyOp : fir_Op<"copy", 
[DeclareOpInterfaceMethods]> {
+def fir_CopyOp : fir_Op<"copy", []> {
   let summary = "copy constant size memory";
 
   let description = [{
@@ -371,8 +369,8 @@ def fir_CopyOp : fir_Op<"copy", 
[DeclareOpInterfaceMethods:$source,
+   Arg:$destination,
OptionalAttr:$no_overlap);
 
   let builders = [OpBuilder<(ins "mlir::Value":$source,
@@ -1375,8 +1373,7 @@ def fir_BoxTypeDescOp : 
fir_SimpleOneResul

[llvm-branch-commits] [llvm] 69a55b8 - Revert "[llc] Add -M for InstPrinter options"

2025-04-09 Thread via llvm-branch-commits

Author: Thurston Dang
Date: 2025-04-09T12:07:54-07:00
New Revision: 69a55b8cab98a8f07a9d84e9704fe79ed9d2fbea

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

LOG: Revert "[llc] Add -M for InstPrinter options"

This reverts commit 02b377d8f7252b1acf6ea4fad55a101b6bc3fcf7.

Added: 


Modified: 
llvm/docs/CommandGuide/llc.rst
llvm/include/llvm/MC/MCTargetOptions.h
llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
llvm/test/CodeGen/RISCV/compress-opt-select.ll
llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll
llvm/test/tools/llvm-mc/disassembler-options.test
llvm/tools/llc/llc.cpp
llvm/tools/llvm-mc/llvm-mc.cpp

Removed: 
llvm/test/tools/llc/instprinter-options.ll



diff  --git a/llvm/docs/CommandGuide/llc.rst b/llvm/docs/CommandGuide/llc.rst
index 900649f59c401..7f28ab3a82f7c 100644
--- a/llvm/docs/CommandGuide/llc.rst
+++ b/llvm/docs/CommandGuide/llc.rst
@@ -43,11 +43,6 @@ End-user Options
 
  Print a summary of command line options.
 
-.. option:: -M
-
- Pass target-specific InstPrinter options.
- Refer to the ``-M`` option of :manpage:`llvm-objdump(1)`.
-
 .. option:: -o 
 
  Use  as the output filename. See the summary above for more

diff  --git a/llvm/include/llvm/MC/MCTargetOptions.h 
b/llvm/include/llvm/MC/MCTargetOptions.h
index fd554bc0ba7c6..7b0d81faf73d2 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -105,9 +105,6 @@ class MCTargetOptions {
   /// integrated assembler.
   std::vector IASSearchPaths;
 
-  // InstPrinter options.
-  std::vector InstPrinterOptions;
-
   // Whether to emit compact-unwind for non-canonical personality
   // functions on Darwins.
   bool EmitCompactUnwindNonCanonical : 1;

diff  --git a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp 
b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
index 37611479088be..5757ca1b3adf8 100644
--- a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
+++ b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
@@ -21,7 +21,6 @@
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCCodeEmitter.h"
 #include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCInstPrinter.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCObjectWriter.h"
 #include "llvm/MC/MCRegisterInfo.h"
@@ -133,10 +132,8 @@ bool 
CodeGenTargetMachineImpl::addAsmPrinter(PassManagerBase &PM,
  MCContext &Context) {
   Expected> MCStreamerOrErr =
   createMCStreamer(Out, DwoOut, FileType, Context);
-  if (!MCStreamerOrErr) {
-Context.reportError(SMLoc(), toString(MCStreamerOrErr.takeError()));
+  if (auto Err = MCStreamerOrErr.takeError())
 return true;
-  }
 
   // Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
   FunctionPass *Printer =
@@ -166,9 +163,6 @@ 
CodeGenTargetMachineImpl::createMCStreamer(raw_pwrite_stream &Out,
 getTargetTriple(),
 Options.MCOptions.OutputAsmVariant.value_or(MAI.getAssemblerDialect()),
 MAI, MII, MRI);
-for (StringRef Opt : Options.MCOptions.InstPrinterOptions)
-  if (!InstPrinter->applyTargetSpecificCLOption(Opt))
-return createStringError("invalid InstPrinter option '" + Opt + "'");
 
 // Create a code emitter if asked to show the encoding.
 std::unique_ptr MCE;

diff  --git a/llvm/test/CodeGen/RISCV/compress-opt-select.ll 
b/llvm/test/CodeGen/RISCV/compress-opt-select.ll
index c0234f40cff56..733c84ac23613 100644
--- a/llvm/test/CodeGen/RISCV/compress-opt-select.ll
+++ b/llvm/test/CodeGen/RISCV/compress-opt-select.ll
@@ -1,9 +1,9 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
 ; RUN: llc -mtriple=riscv32 -target-abi ilp32d -mattr=+c,+f,+d \
-; RUN: -M no-aliases < %s \
+; RUN: -riscv-no-aliases < %s \
 ; RUN:   | FileCheck -check-prefix=RV32IFDC %s
 ; RUN: llc -mtriple=riscv32 -target-abi ilp32d -mattr=-c,+f,+d \
-; RUN: -M no-aliases < %s \
+; RUN: -riscv-no-aliases < %s \
 ; RUN:   | FileCheck -check-prefix=RV32IFD %s
 
 ; constant is small and fit in 6 bit (compress imm)

diff  --git a/llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll 
b/llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll
index cf780f4f7f76c..c4e5dcedf5ede 100644
--- a/llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll
+++ b/llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple=riscv64 < %s | FileCheck %s
 ; RUN: llc -mtriple=riscv64 --relocation-model=pic < %s | FileCheck %s
-; RUN: llc -mtriple=riscv64 -mattr=+c -M no-aliases < %s \
+; RUN: llc -mtriple=riscv64 -mattr=+c --riscv-no-aliases < %s \
 ; RUN:   | FileCheck %s --check-prefix=COMPRESS
 
 define ptr @f2(ptr %x0, pt

[llvm-branch-commits] [clang] clang/AMDGPU: Stop looking for oclc_daz_opt_* control libraries (PR #134805)

2025-04-09 Thread Yaxun Liu via llvm-branch-commits

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

LGTM.

Does this mean device library have no code depending on option 
`-cl-denorms-are-zero`?

https://github.com/llvm/llvm-project/pull/134805
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Mark de Wever via llvm-branch-commits


@@ -1215,6 +1215,29 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
 #  endif
 
+#  if __has_feature(pointer_field_protection)

mordante wrote:

Since this feature is an ABI break, it will cause ODR violations to these 
structs. I think we should ABI tag this in `_LIBCPP_ODR_SIGNATURE`.

https://github.com/llvm/llvm-project/pull/133538
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Mark de Wever via llvm-branch-commits


@@ -84,7 +84,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template  */>
-class _LIBCPP_TEMPLATE_VIS vector {
+class _LIBCPP_TEMPLATE_VIS vector _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {

mordante wrote:

`std::vector` is used in the libc++ dylib across the ABI boundary. So this 
means you can only use `pointer_field_protection` when the dylib is build with 
`pointer_field_protection`.

https://github.com/llvm/llvm-project/pull/133538
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Mark de Wever via llvm-branch-commits


@@ -1215,6 +1215,29 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
 #  endif
 
+#  if __has_feature(pointer_field_protection)
+// Force a class to be non-standard layout by giving it two bases with the same
+// type. This is useful when structure protection is enabled because structure
+// protection cannot be applied to standard layout classes. We may use this in
+// cases where the standard does not specify whether a standard library class 
is
+// standard layout. See C++2a [class]p7:
+//   A class S is a standard-layout class if it:
+// -- has at most one base class subobject of any given type
+_LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winaccessible-base")
+class __force_nonstandard_layout_base1 {};
+class __force_nonstandard_layout_base2 : __force_nonstandard_layout_base1 {};
+class __force_nonstandard_layout : __force_nonstandard_layout_base1, 
__force_nonstandard_layout_base2 {};
+_LIBCPP_DIAGNOSTIC_POP
+_LIBCPP_END_NAMESPACE_STD

mordante wrote:

This should be done (conditionally?) is a different header. If we add 
`_LIBCPP_BEGIN_NAMESPACE_STD` to this header it suddenly breaks this.

https://github.com/llvm/llvm-project/pull/133538
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/133538
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Mark de Wever via llvm-branch-commits

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

Some comments from libc++'s perspective:
- As you mentioned you need more tests.
- I think the current approach with a header only libc++ change approach will 
not work due to ABI changes. See review comment for `std::vector`.
- in libc++ we have a pre-commit CI so this feature should be tested in our CI, 
if you need help with that, best reach out to us on Discord. However I think we 
first need to look at how we can properly integrate this in libc++.

I'm not fond of this patch since it mixes LLVM, Clang, and libc++(abi) code. 
This makes it hard to determine when all reviewer groups are satisfied. Is 
there a reason why the libc++ and the libc++abi part can't be in two separate 
patches? 

(I don't know whether it makes sense to keep the LLVM & Clang part in one 
patch.)







https://github.com/llvm/llvm-project/pull/133538
___
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] CodeGen: Trim redundant template argument from defusechain_iterator (PR #135024)

2025-04-09 Thread Matt Arsenault via llvm-branch-commits

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

Only one of ByOperand, ByInstr, or ByBundle should be true. Replace
ByBundle with !ByInstr, and assert that both are not used.

>From 751b2ad5ef572948a57cc0162a4dafc56f9f7d72 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Wed, 9 Apr 2025 12:20:48 +0800
Subject: [PATCH] CodeGen: Trim redundant template argument from
 defusechain_iterator

Only one of ByOperand, ByInstr, or ByBundle should be true. Replace
ByBundle with !ByInstr, and assert that both are not used.
---
 .../llvm/CodeGen/MachineRegisterInfo.h| 25 ---
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h 
b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
index 1d4bcbb8cab9e..8e288cf212360 100644
--- a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
@@ -277,21 +277,18 @@ class MachineRegisterInfo {
   /// reg_begin/reg_end - Provide iteration support to walk over all 
definitions
   /// and uses of a register within the MachineFunction that corresponds to 
this
   /// MachineRegisterInfo object.
-  template
+  template 
   class defusechain_iterator;
   template 
   class defusechain_instr_iterator;
 
   // Make it a friend so it can access getNextOperandForReg().
-  template
-friend class defusechain_iterator;
+  template  friend class defusechain_iterator;
   template  friend class defusechain_instr_iterator;
 
   /// reg_iterator/reg_begin/reg_end - Walk all defs and uses of the specified
   /// register.
-  using reg_iterator =
-  defusechain_iterator;
+  using reg_iterator = defusechain_iterator;
   reg_iterator reg_begin(Register RegNo) const {
 return reg_iterator(getRegUseDefListHead(RegNo));
   }
@@ -339,7 +336,7 @@ class MachineRegisterInfo {
   /// reg_nodbg_iterator/reg_nodbg_begin/reg_nodbg_end - Walk all defs and uses
   /// of the specified register, skipping those marked as Debug.
   using reg_nodbg_iterator =
-  defusechain_iterator;
+  defusechain_iterator;
   reg_nodbg_iterator reg_nodbg_begin(Register RegNo) const {
 return reg_nodbg_iterator(getRegUseDefListHead(RegNo));
   }
@@ -393,8 +390,7 @@ class MachineRegisterInfo {
   }
 
   /// def_iterator/def_begin/def_end - Walk all defs of the specified register.
-  using def_iterator =
-  defusechain_iterator;
+  using def_iterator = defusechain_iterator;
   def_iterator def_begin(Register RegNo) const {
 return def_iterator(getRegUseDefListHead(RegNo));
   }
@@ -473,8 +469,7 @@ class MachineRegisterInfo {
   }
 
   /// use_iterator/use_begin/use_end - Walk all uses of the specified register.
-  using use_iterator =
-  defusechain_iterator;
+  using use_iterator = defusechain_iterator;
   use_iterator use_begin(Register RegNo) const {
 return use_iterator(getRegUseDefListHead(RegNo));
   }
@@ -528,7 +523,7 @@ class MachineRegisterInfo {
   /// use_nodbg_iterator/use_nodbg_begin/use_nodbg_end - Walk all uses of the
   /// specified register, skipping those marked as Debug.
   using use_nodbg_iterator =
-  defusechain_iterator;
+  defusechain_iterator;
   use_nodbg_iterator use_nodbg_begin(Register RegNo) const {
 return use_nodbg_iterator(getRegUseDefListHead(RegNo));
   }
@@ -1045,9 +1040,11 @@ class MachineRegisterInfo {
   /// returns end().  If SkipDebug is true it skips uses marked Debug
   /// when incrementing.
   template 
+bool ByInstr>
   class defusechain_iterator {
 friend class MachineRegisterInfo;
+static_assert(!ByOperand || !ByInstr,
+  "ByOperand and ByInstr are mutually exclusive");
 
   public:
 using iterator_category = std::forward_iterator_tag;
@@ -1110,7 +1107,7 @@ class MachineRegisterInfo {
 do {
   advance();
 } while (Op && Op->getParent() == P);
-  } else if (ByBundle) {
+  } else {
 MachineBasicBlock::instr_iterator P =
 getBundleStart(Op->getParent()->getIterator());
 do {

___
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] 2b8e723 - Revert "[SelectionDAG] Introducing a new ISD::POISON SDNode to represent the …"

2025-04-09 Thread via llvm-branch-commits

Author: Jakub Kuderski
Date: 2025-04-09T13:51:26-04:00
New Revision: 2b8e7230c9fbe55527f6036d40df0c030a0f4ac6

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

LOG: Revert "[SelectionDAG] Introducing a new ISD::POISON SDNode to represent 
the …"

This reverts commit 8fddef8483dc9eb569580ffd13695b8f54d3c058.

Added: 


Modified: 
llvm/include/llvm/CodeGen/ISDOpcodes.h
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/test/CodeGen/AArch64/vector-insert-dag-combines.ll
llvm/test/CodeGen/X86/half.ll
llvm/test/CodeGen/X86/pr119158.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h 
b/llvm/include/llvm/CodeGen/ISDOpcodes.h
index ad8a95a353b56..59f31f8443947 100644
--- a/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -217,9 +217,6 @@ enum NodeType {
   /// UNDEF - An undefined node.
   UNDEF,
 
-  /// POISON - A poison node.
-  POISON,
-
   /// FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or
   /// is evaluated to UNDEF), or returns VAL otherwise. Note that each
   /// read of UNDEF can yield 
diff erent value, but FREEZE(UNDEF) cannot.

diff  --git a/llvm/include/llvm/CodeGen/SelectionDAG.h 
b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 634234632..d06e2b19fa0b5 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -1130,9 +1130,6 @@ class SelectionDAG {
 return getNode(ISD::UNDEF, SDLoc(), VT);
   }
 
-  /// Return a POISON node. POISON does not have a useful SDLoc.
-  SDValue getPOISON(EVT VT) { return getNode(ISD::POISON, SDLoc(), VT); }
-
   /// Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
   SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm,
 bool ConstantFold = true);

diff  --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h 
b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index b62cf08693f63..2283f99202e2f 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -692,10 +692,8 @@ END_TWO_BYTE_PACK()
   /// \ISD namespace).
   bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
 
-  /// Returns true if the node type is UNDEF or POISON.
-  bool isUndef() const {
-return NodeType == ISD::UNDEF || NodeType == ISD::POISON;
-  }
+  /// Return true if the type of the node type undefined.
+  bool isUndef() const { return NodeType == ISD::UNDEF; }
 
   /// Test if this node is a memory intrinsic (with valid pointer information).
   bool isMemIntrinsic() const { return SDNodeBits.IsMemIntrinsic; }

diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 38376de5783ae..8136f1794775e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -16287,8 +16287,7 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
   // Finally, recreate the node, it's operands were updated to use
   // frozen operands, so we just need to use it's "original" operands.
   SmallVector Ops(N0->ops());
-  // TODO: ISD::UNDEF and ISD::POISON should get separate handling, but best
-  // leave for a future patch.
+  // Special-handle ISD::UNDEF, each single one of them can be it's own thing.
   for (SDValue &Op : Ops) {
 if (Op.isUndef())
   Op = DAG.getFreeze(Op);

diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index b8af281e1c24b..754c29b6ba868 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -986,19 +986,6 @@ void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
   TargetLowering::LegalizeAction Action = TargetLowering::Legal;
   bool SimpleFinishLegalizing = true;
   switch (Node->getOpcode()) {
-  // TODO: Currently, POISON is being lowered to UNDEF here. However, there is
-  // an open concern that this transformation may not be ideal, as targets
-  // should ideally handle POISON directly. Changing this behavior would 
require
-  // adding support for POISON in TableGen, which is a large change.
-  // Additionally, many existing test cases rely on th

[llvm-branch-commits] ELF: Remove lock from MTE global relocation handling code. (PR #135123)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc created https://github.com/llvm/llvm-project/pull/135123

This lock is unnecessary because we can add the relocations to
shards and let them be sorted later.



___
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] [BOLT] Jump table trampoline insertion pass (PR #135103)

2025-04-09 Thread Amir Ayupov via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT][NFC] Define AArch64 jump table types (PR #132109)

2025-04-09 Thread Maksim Panchenko via llvm-branch-commits

https://github.com/maksfb commented:

I expect that eventually we will get RISC-V support for jump tables. In this 
context, I would prefer to keep the format of the jump table itself separate 
from the underlying architecture. I.e. we can use JTs with an absolute 64-bit 
addressing on any platform with a proper compiler support. Having one type, 
e.g. `JTT_ABS64`, sounds more convenient. And we can always lookup the target 
architecture if needed, but again it should be orthogonal to the format itself. 
What could be different is endianness, but we can handle it during 
serialization.

Also, in most places we use the number of bits for naming "things". Let's stick 
to this scheme. 

https://github.com/llvm/llvm-project/pull/132109
___
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: Relax x16/x17 constraint on AUT in certain cases. (PR #132857)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/132857


___
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] libcxx: In gdb test detect execute_mi with feature check instead of version check. (PR #132291)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/132291

>From 89ce369ab9b49b8c23a87ad0a888002dd85c094c Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Thu, 20 Mar 2025 15:12:39 -0700
Subject: [PATCH 1/2] Format

Created using spr 1.3.6-beta.1
---
 libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py 
b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
index 630b90c9d77a6..927f8958f4b43 100644
--- a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
+++ b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
@@ -30,7 +30,8 @@
 # we exit.
 has_run_tests = False
 
-has_execute_mi = 'execute_mi' in gdb.__dict__
+has_execute_mi = "execute_mi" in gdb.__dict__
+
 
 class CheckResult(gdb.Command):
 def __init__(self):

>From da2f682a8f1a1af58fbe85f760e1844c808b8093 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Tue, 8 Apr 2025 13:21:06 -0700
Subject: [PATCH 2/2] Use getattr instead

Created using spr 1.3.6-beta.1
---
 libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py 
b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
index 927f8958f4b43..da09092b690c4 100644
--- a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
+++ b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
@@ -30,7 +30,7 @@
 # we exit.
 has_run_tests = False
 
-has_execute_mi = "execute_mi" in gdb.__dict__
+has_execute_mi = getattr(gdb, "execute_mi", None) is not None
 
 
 class CheckResult(gdb.Command):

___
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] ELF: Remove lock from MTE global relocation handling code. (PR #135123)

2025-04-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-lld

Author: Peter Collingbourne (pcc)


Changes

This lock is unnecessary because we can add the relocations to
shards and let them be sorted later.


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


1 Files Affected:

- (modified) lld/ELF/Relocations.cpp (+2-3) 


``diff
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 81de664fd1c23..277acb26987bc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -847,9 +847,8 @@ static void addRelativeReloc(Ctx &ctx, InputSectionBase 
&isec,
   Partition &part = isec.getPartition(ctx);
 
   if (sym.isTagged()) {
-std::lock_guard lock(ctx.relocMutex);
-part.relaDyn->addRelativeReloc(ctx.target->relativeRel, isec, offsetInSec,
-   sym, addend, type, expr);
+part.relaDyn->addRelativeReloc(ctx.target->relativeRel, isec,
+  offsetInSec, sym, addend, type, 
expr);
 // With MTE globals, we always want to derive the address tag by `ldg`-ing
 // the symbol. When we have a RELATIVE relocation though, we no longer have
 // a reference to the symbol. Because of this, when we have an addend that

``




https://github.com/llvm/llvm-project/pull/135123
___
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] ELF: Only rewrite non-preemptible IFUNCs to IPLT functions if a non-IRELATIVE relocation is needed. (PR #133531)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

pcc wrote:

> This patch has a few problems
> 
> * The check in `processAux` was moved to the wrong place (it will never get 
> hit because this is after we deal with all symbols not defined locally). This 
> patch moves it to approximately the right place but will need some logic 
> changes to `isStaticLinkTimeConstant` to recognize ifuncs as not being static 
> link time constants:
> 
> ```
> diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
> index 1439fd859f51..969d71461cb1 100644
> --- a/lld/ELF/Relocations.cpp
> +++ b/lld/ELF/Relocations.cpp
> @@ -1127,6 +1127,8 @@ void RelocationScanner::processAux(RelExpr expr, 
> RelType type, uint64_t offset,
>// handling of GOT-generating relocations.
>if (isStaticLinkTimeConstant(expr, type, sym, offset) ||
>(!ctx.arg.isPic && sym.isUndefWeak())) {
> +if (LLVM_UNLIKELY(isIfunc && !needsGot(expr) && !needsPlt(expr)))
> +  sym.setFlags(HAS_DIRECT_RELOC);
>  sec->addReloc({expr, type, offset, addend, &sym});
>  return;
>}
> @@ -1194,9 +1196,6 @@ void RelocationScanner::processAux(RelExpr expr, 
> RelType type, uint64_t offset,
>  }
>}
>  
> -  if (LLVM_UNLIKELY(isIfunc && !needsGot(expr) && !needsPlt(expr)))
> -sym.setFlags(HAS_DIRECT_RELOC);
> -
>// When producing an executable, we can perform copy relocations (for
>// STT_OBJECT) and canonical PLT (for STT_FUNC) if sym is defined by a DSO.
>// Copy relocations/canonical PLT entries are unsupported for
> ```
> 
> * Need to adjust how IRELATIVE relocations get emitted. Currently we emit 
> relocations with the wrong type (assuming they will be demoted) and fix up 
> the type in `RelocationBaseSection::partitionRels` if they turn out to not be 
> demoted. But this isn't good enough for PDEs which need them to be static 
> relocations. Here's what I think we should do instead:
>   
>   * Always emit ifunc relocations as IRELATIVE during `processAux`
>   * In `handleNonPreemptibleIfunc`, when we demote an ifunc to an iplt entry, 
> loop over all irelatives pointing to the symbol and rewrite them as either 
> relative (for PIE/shared) or static relocations (for PDE). It's fine to loop 
> over the irelatives every time because they are rare.

All of this is done in the latest change (except that I decided to handle the 
demotion in a separate loop instead of `handleNonPreemptibleIfunc`, PTAL

https://github.com/llvm/llvm-project/pull/133531
___
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: Relax x16/x17 constraint on AUT in certain cases. (PR #132857)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/132857


___
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] compiler-rt: Introduce runtime functions for emulated PAC. (PR #133530)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/133530

>From b37a44fff650b06eda249060277d0c007226cad2 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Thu, 3 Apr 2025 21:51:44 -0700
Subject: [PATCH] Fix CMake build

Created using spr 1.3.6-beta.1
---
 compiler-rt/cmake/Modules/AddCompilerRT.cmake | 8 +++-
 compiler-rt/cmake/builtin-config-ix.cmake | 1 +
 compiler-rt/lib/builtins/CMakeLists.txt   | 8 ++--
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index c3e734f72392f..2f6fd4ba1e4c9 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -172,7 +172,7 @@ function(add_compiler_rt_runtime name type)
   cmake_parse_arguments(LIB
 ""
 "PARENT_TARGET"
-
"OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS;EXTENSIONS"
+
"OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS;EXTENSIONS;C_STANDARD;CXX_STANDARD"
 ${ARGN})
   set(libnames)
   # Until we support this some other way, build compiler-rt runtime without LTO
@@ -360,6 +360,12 @@ function(add_compiler_rt_runtime name type)
   set_target_link_flags(${libname} ${extra_link_flags_${libname}})
   set_property(TARGET ${libname} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})
+  if(LIB_C_STANDARD)
+set_property(TARGET ${libname} PROPERTY C_STANDARD ${LIB_C_STANDARD})
+  endif()
+  if(LIB_CXX_STANDARD)
+set_property(TARGET ${libname} PROPERTY CXX_STANDARD 
${LIB_CXX_STANDARD})
+  endif()
   set_target_output_directories(${libname} ${output_dir_${libname}})
   install(TARGETS ${libname}
 ARCHIVE DESTINATION ${install_dir_${libname}}
diff --git a/compiler-rt/cmake/builtin-config-ix.cmake 
b/compiler-rt/cmake/builtin-config-ix.cmake
index 7bd3269bd999d..7bdd30ee67f3d 100644
--- a/compiler-rt/cmake/builtin-config-ix.cmake
+++ b/compiler-rt/cmake/builtin-config-ix.cmake
@@ -26,6 +26,7 @@ builtin_check_c_compiler_flag("-Xclang 
-mcode-object-version=none" COMPILER_RT_H
 builtin_check_c_compiler_flag(-Wbuiltin-declaration-mismatch 
COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG)
 builtin_check_c_compiler_flag(/Zl COMPILER_RT_HAS_ZL_FLAG)
 builtin_check_c_compiler_flag(-fcf-protection=full 
COMPILER_RT_HAS_FCF_PROTECTION_FLAG)
+builtin_check_c_compiler_flag(-nostdinc++  
COMPILER_RT_HAS_NOSTDINCXX_FLAG)
 
 builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD
 "
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index e6c3273eb2859..ca5cc7d218223 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -6,7 +6,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   cmake_minimum_required(VERSION 3.20.0)
 
   set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
-  project(CompilerRTBuiltins C ASM)
+  project(CompilerRTBuiltins C CXX ASM)
   set(COMPILER_RT_STANDALONE_BUILD TRUE)
   set(COMPILER_RT_BUILTINS_STANDALONE_BUILD TRUE)
 
@@ -64,6 +64,8 @@ include(CMakePushCheckState)
 option(COMPILER_RT_BUILTINS_HIDE_SYMBOLS
   "Do not export any symbols from the static library." ON)
 
+include_directories(../../../third-party/siphash/include)
+
 # TODO: Need to add a mechanism for logging errors when builtin source files 
are
 # added to a sub-directory and not this CMakeLists file.
 set(GENERIC_SOURCES
@@ -803,7 +805,7 @@ else ()
 append_list_if(COMPILER_RT_ENABLE_CET -fcf-protection=full BUILTIN_CFLAGS)
   endif()
 
-  append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
+  append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ BUILTIN_CFLAGS)
   append_list_if(COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG 
-Werror=builtin-declaration-mismatch BUILTIN_CFLAGS)
 
   # Don't embed directives for picking any specific CRT
@@ -918,6 +920,8 @@ else ()
   SOURCES ${${arch}_SOURCES}
   DEFS ${BUILTIN_DEFS}
   CFLAGS ${BUILTIN_CFLAGS_${arch}}
+  C_STANDARD 11
+  CXX_STANDARD 17
   PARENT_TARGET builtins)
   cmake_pop_check_state()
 endif ()

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


[llvm-branch-commits] Extract SipHash implementation into a header. (PR #134197)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/134197


___
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] Extract SipHash implementation into a header. (PR #134197)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/134197


___
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] ELF: Only rewrite non-preemptible IFUNCs to IPLT functions if a non-IRELATIVE relocation is needed. (PR #133531)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/133531


___
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] ELF: Only rewrite non-preemptible IFUNCs to IPLT functions if a non-IRELATIVE relocation is needed. (PR #133531)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/133531

>From 96e7da9a083888683c2ba00d97f886fd748ea10b Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Wed, 9 Apr 2025 20:30:57 -0700
Subject: [PATCH] Undo unnecessary change

Created using spr 1.3.6-beta.1
---
 lld/ELF/SyntheticSections.cpp | 2 +-
 lld/ELF/SyntheticSections.h   | 2 +-
 lld/ELF/Writer.cpp| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 8cab71c4c8d94..106749e90a82b 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1696,7 +1696,7 @@ void 
RelocationBaseSection::addAddendOnlyRelocIfNonPreemptible(
  sym, 0, R_ABS, addendRelType);
 }
 
-void RelocationBaseSection::mergeRels(Ctx &ctx) {
+void RelocationBaseSection::mergeRels() {
   size_t newSize = relocs.size();
   for (const auto &v : relocsVec)
 newSize += v.size();
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 7a85906e8601d..2dd4b80eb85bf 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -553,7 +553,7 @@ class RelocationBaseSection : public SyntheticSection {
   }
   size_t getSize() const override { return relocs.size() * this->entsize; }
   size_t getRelativeRelocCount() const { return numRelativeRelocs; }
-  void mergeRels(Ctx &ctx);
+  void mergeRels();
   void partitionRels();
   void finalizeContents() override;
 
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 67004055f1af5..28b24f90716b8 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2076,7 +2076,7 @@ template  void 
Writer::finalizeSections() {
 // symbol table section (dynSymTab) must be the first one.
 for (Partition &part : ctx.partitions) {
   if (part.relaDyn) {
-part.relaDyn->mergeRels(ctx);
+part.relaDyn->mergeRels();
 // Compute DT_RELACOUNT to be used by part.dynamic.
 part.relaDyn->partitionRels();
 finalizeSynthetic(ctx, part.relaDyn.get());

___
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] [GOFF] Add writing of section symbols (PR #133799)

2025-04-09 Thread Ulrich Weigand via llvm-branch-commits


@@ -230,10 +230,11 @@ class MCObjectFileInfo {
   MCSection *GLJMPSection = nullptr;
 
   // GOFF specific sections.
-  MCSection *PPA1Section = nullptr;
-  MCSection *PPA2Section = nullptr;
-  MCSection *PPA2ListSection = nullptr;
-  MCSection *ADASection = nullptr;
+  MCSection *RootSDSection = nullptr;
+  MCSection *PPA2ListEDSection = nullptr;
+  MCSection *PPA2ListPRSection = nullptr;
+  MCSection *ADAEDSection = nullptr;
+  MCSection *ADAPRSection = nullptr;

uweigand wrote:

I don't think we really need two pointers each here.  Just the main section 
(i.e. the one where code is emitted to) should be enough, shouldn't it?

https://github.com/llvm/llvm-project/pull/133799
___
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-reduce: Add new pass to inline call sites (PR #134223)

2025-04-09 Thread Arthur Eubanks via llvm-branch-commits

https://github.com/aeubanks commented:

perhaps a heuristic of reducing the total number of inlinable calls, i.e. the 
function being inlined cannot have any inlinable calls, would be good for not 
letting this run too much

https://github.com/llvm/llvm-project/pull/134223
___
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] implement printing of canonical template arguments of expression kind (PR #135133)

2025-04-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Matheus Izvekov (mizvekov)


Changes

This patch extends the canonicalization printing policy to cover expressions 
and template names, and wires that up to the template argument printer, 
covering expressions.

This is helpful for debugging, or if these template arguments somehow end up in 
diagnostics, as without this patch they can print as completely unrelated 
expressions, which can be quite confusing.

This is because expressions are not uniqued, unlike types, and when a template 
specialization containing an expression is the first to be canonicalized, the 
expression ends up appearing in the canonical type of subsequent equivalent 
specializations.

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

---

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


12 Files Affected:

- (modified) clang/include/clang/AST/PrettyPrinter.h (+3-3) 
- (modified) clang/lib/AST/DeclPrinter.cpp (+2-2) 
- (modified) clang/lib/AST/JSONNodeDumper.cpp (+2) 
- (modified) clang/lib/AST/StmtPrinter.cpp (+5-1) 
- (modified) clang/lib/AST/TemplateBase.cpp (+5-2) 
- (modified) clang/lib/AST/TemplateName.cpp (+8-2) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+2) 
- (modified) clang/lib/AST/TypePrinter.cpp (+4-5) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+1-1) 
- (modified) clang/test/AST/ast-dump-templates.cpp (+1022) 
- (modified) clang/unittests/AST/TypePrinterTest.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 91818776b770c..5a98ae1987b16 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -76,7 +76,7 @@ struct PrintingPolicy {
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
-PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
+PrintAsCanonical(false), PrintInjectedClassNameWithArguments(true),
 UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false),
 CleanUglifiedParameters(false), EntireContentsOfLargeArray(true),
 UseEnumerators(true), UseHLSLTypes(LO.HLSL) {}
@@ -310,9 +310,9 @@ struct PrintingPolicy {
   LLVM_PREFERRED_TYPE(bool)
   unsigned FullyQualifiedName : 1;
 
-  /// Whether to print types as written or canonically.
+  /// Whether to print entities as written or canonically.
   LLVM_PREFERRED_TYPE(bool)
-  unsigned PrintCanonicalTypes : 1;
+  unsigned PrintAsCanonical : 1;
 
   /// Whether to print an InjectedClassNameType with template arguments or as
   /// written. When a template argument is unnamed, printing it results in
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 28098b242d494..22da5bf251ecd 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -735,7 +735,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
 llvm::raw_string_ostream POut(Proto);
 DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
 const auto *TArgAsWritten = D->getTemplateSpecializationArgsAsWritten();
-if (TArgAsWritten && !Policy.PrintCanonicalTypes)
+if (TArgAsWritten && !Policy.PrintAsCanonical)
   TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(), nullptr);
 else if (const TemplateArgumentList *TArgs =
  D->getTemplateSpecializationArgs())
@@ -1124,7 +1124,7 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
   S->getSpecializedTemplate()->getTemplateParameters();
   const ASTTemplateArgumentListInfo *TArgAsWritten =
   S->getTemplateArgsAsWritten();
-  if (TArgAsWritten && !Policy.PrintCanonicalTypes)
+  if (TArgAsWritten && !Policy.PrintAsCanonical)
 printTemplateArguments(TArgAsWritten->arguments(), TParams);
   else
 printTemplateArguments(S->getTemplateArgs().asArray(), TParams);
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index 3420c1f343cf5..725db93b558f6 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1724,6 +1724,8 @@ void 
JSONNodeDumper::VisitTemplateExpansionTemplateArgument(
 void JSONNodeDumper::VisitExpressionTemplateArgument(
 const TemplateArgument &TA) {
   JOS.attribute("isExpr", true);
+  if (TA.isCanonicalExpr())
+JOS.attribute("isCanon", true);
 }
 void JSONNodeDumper::VisitPackTemplateArgument(const TemplateArgument &TA) {
   JOS.attribute("isPack", true);
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index dbe2432d5c799..aae10fd3bd885 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1305,9 +1305,13 @@ void StmtPrinter::Vis

[llvm-branch-commits] [clang] [clang] implement printing of canonical template arguments of expression kind (PR #135133)

2025-04-09 Thread Matheus Izvekov via llvm-branch-commits

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

This patch extends the canonicalization printing policy to cover expressions 
and template names, and wires that up to the template argument printer, 
covering expressions.

This is helpful for debugging, or if these template arguments somehow end up in 
diagnostics, as without this patch they can print as completely unrelated 
expressions, which can be quite confusing.

This is because expressions are not uniqued, unlike types, and when a template 
specialization containing an expression is the first to be canonicalized, the 
expression ends up appearing in the canonical type of subsequent equivalent 
specializations.

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

>From 73aeea58f5078b2be578580985e0b483353385aa Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 10 Apr 2025 02:52:36 -0300
Subject: [PATCH] [clang] implement printing of canonical template arguments of
 expression kind

This patch extends the canonicalization printing policy to cover expressions
and template names, and wires that up to the template argument printer,
covering expressions.

This is helpful for debugging, or if these template arguments somehow end up
in diagnostics, as without this patch they can print as completely unrelated
expressions, which can be quite confusing.

This is because expressions are not uniqued, unlike types, and
when a template specialization containing an expression is the first to be
canonicalized, the expression ends up appearing in the canonical type of
subsequent equivalent specializations.

Fixes https://github.com/llvm/llvm-project/issues/92292
---
 clang/include/clang/AST/PrettyPrinter.h |6 +-
 clang/lib/AST/DeclPrinter.cpp   |4 +-
 clang/lib/AST/JSONNodeDumper.cpp|2 +
 clang/lib/AST/StmtPrinter.cpp   |6 +-
 clang/lib/AST/TemplateBase.cpp  |7 +-
 clang/lib/AST/TemplateName.cpp  |   10 +-
 clang/lib/AST/TextNodeDumper.cpp|2 +
 clang/lib/AST/TypePrinter.cpp   |9 +-
 clang/lib/CodeGen/CGDebugInfo.cpp   |2 +-
 clang/lib/Sema/SemaTemplate.cpp |2 +-
 clang/test/AST/ast-dump-templates.cpp   | 1022 +++
 clang/unittests/AST/TypePrinterTest.cpp |2 +-
 12 files changed, 1056 insertions(+), 18 deletions(-)

diff --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 91818776b770c..5a98ae1987b16 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -76,7 +76,7 @@ struct PrintingPolicy {
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
-PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
+PrintAsCanonical(false), PrintInjectedClassNameWithArguments(true),
 UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false),
 CleanUglifiedParameters(false), EntireContentsOfLargeArray(true),
 UseEnumerators(true), UseHLSLTypes(LO.HLSL) {}
@@ -310,9 +310,9 @@ struct PrintingPolicy {
   LLVM_PREFERRED_TYPE(bool)
   unsigned FullyQualifiedName : 1;
 
-  /// Whether to print types as written or canonically.
+  /// Whether to print entities as written or canonically.
   LLVM_PREFERRED_TYPE(bool)
-  unsigned PrintCanonicalTypes : 1;
+  unsigned PrintAsCanonical : 1;
 
   /// Whether to print an InjectedClassNameType with template arguments or as
   /// written. When a template argument is unnamed, printing it results in
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 28098b242d494..22da5bf251ecd 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -735,7 +735,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
 llvm::raw_string_ostream POut(Proto);
 DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
 const auto *TArgAsWritten = D->getTemplateSpecializationArgsAsWritten();
-if (TArgAsWritten && !Policy.PrintCanonicalTypes)
+if (TArgAsWritten && !Policy.PrintAsCanonical)
   TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(), nullptr);
 else if (const TemplateArgumentList *TArgs =
  D->getTemplateSpecializationArgs())
@@ -1124,7 +1124,7 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
   S->getSpecializedTemplate()->getTemplateParameters();
   const ASTTemplateArgumentListInfo *TArgAsWritten =
   S->getTemplateArgsAsWritten();
-  if (TArgAsWritten && !Policy.PrintCanonicalTypes)
+  if (TArgAsWritten && !Policy.PrintAsCanonical)
 printTemplateArguments(TArgAsWritten->arguments(), TParams);
   else
 printTemplateArguments(S->getTemplateArgs().asArray(), TParams);
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang

[llvm-branch-commits] [lld] ELF: Only rewrite non-preemptible IFUNCs to IPLT functions if a non-IRELATIVE relocation is needed. (PR #133531)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

pcc wrote:

> I’m worried about the added complexity of ifunc and the extra parameter in 
> isStaticLinkTimeConstant, a key component of relocation scanning where 
> performance is critical. (Our scanning process is already noticeably slower 
> than mold’s, and these factors are contributing to the gap.)

Fair enough, I will check the performance after this patch.

> If the security hardening efforts rely on ifunc, I’d strongly suggest 
> reconsidering this approach.

It's not so much "rely" but that the alternatives have downsides that IMO end 
up making them worse than the ifunc approach.

> What’s the next PR in line?

Here is the list: https://github.com/orgs/llvm/projects/38

> If the goal of increasing ifunc adoption is to avoid updating rtld/libc, I 
> don’t see that as a practical solution, and I’d strongly push back against 
> linker changes. We should focus on improving rtld/libc instead. See: 
> https://sourceware.org/bugzilla/show_bug.cgi?id=31959";

On the contrary, I see it as more practical than the alternatives.

If avoiding upgrades were the only reason for this change, I agree with you 
that we should be looking at a static-pie based approach instead. We may even 
consider dropping #133532 as it may be possible to develop another solution 
that uses the static-pie approach.

The main reason for supporting this use case for ifuncs is to decouple the 
pointer encoding scheme (which is a compiler implementation detail) from the 
dynamic loader. For pointer field protection we have these requirements:
- Be able to use deactivation symbols to deactivate pointer encoding in other 
object files.
- Be able to use arbitrary pointer encoding schemes as part of the non-arm64 
support.

The following alternatives were considered:
- Have the compiler generate code in .init_array.0 to initialize the fields. 
This has the downside of making parts of .data.rel.ro writable which goes 
against the overall goal of improving security. Doing things this way *might* 
work if we unprotect relro, apply the pseudo-relocations and protect again, but 
this would need to be done once for the whole binary to avoid substantial 
startup overhead, and there may be restrictions such as mseal that prevent this 
from working. This is probably what I'll do if I get too much pushback from 
this approach, it looks like [glibc will support opting out of 
mseal](https://sourceware.org/pipermail/glibc-cvs/2024q3/086012.html).
- Introduce a new relocation format that would allow specifying a deactivation 
symbol (two operands to a relocation). This would introduce a substantial 
burden on linkers due to the new relocation encoding with an additional operand 
and would still not give us a flexible pointer encoding.
- Introduce new relocation types for every new encoding that may be used 
(combined with the new relocation format). This would substantially reduce our 
velocity as the new encodings would need to be agreed on by every supported 
non-arm64 psabi, as well as introducing complexity to linkers as they would 
need to know about every new relocation type used for encodings (this would be 
basically like introducing a new R_AARCH64_AUTH_ABS64/R_AARCH64_AUTH_RELATIVE 
pair every time).

https://github.com/llvm/llvm-project/pull/133531
___
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] implement printing of canonical template arguments of expression kind (PR #135133)

2025-04-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

This patch extends the canonicalization printing policy to cover expressions 
and template names, and wires that up to the template argument printer, 
covering expressions.

This is helpful for debugging, or if these template arguments somehow end up in 
diagnostics, as without this patch they can print as completely unrelated 
expressions, which can be quite confusing.

This is because expressions are not uniqued, unlike types, and when a template 
specialization containing an expression is the first to be canonicalized, the 
expression ends up appearing in the canonical type of subsequent equivalent 
specializations.

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

---

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


12 Files Affected:

- (modified) clang/include/clang/AST/PrettyPrinter.h (+3-3) 
- (modified) clang/lib/AST/DeclPrinter.cpp (+2-2) 
- (modified) clang/lib/AST/JSONNodeDumper.cpp (+2) 
- (modified) clang/lib/AST/StmtPrinter.cpp (+5-1) 
- (modified) clang/lib/AST/TemplateBase.cpp (+5-2) 
- (modified) clang/lib/AST/TemplateName.cpp (+8-2) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+2) 
- (modified) clang/lib/AST/TypePrinter.cpp (+4-5) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+1-1) 
- (modified) clang/test/AST/ast-dump-templates.cpp (+1022) 
- (modified) clang/unittests/AST/TypePrinterTest.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 91818776b770c..5a98ae1987b16 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -76,7 +76,7 @@ struct PrintingPolicy {
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
-PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
+PrintAsCanonical(false), PrintInjectedClassNameWithArguments(true),
 UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false),
 CleanUglifiedParameters(false), EntireContentsOfLargeArray(true),
 UseEnumerators(true), UseHLSLTypes(LO.HLSL) {}
@@ -310,9 +310,9 @@ struct PrintingPolicy {
   LLVM_PREFERRED_TYPE(bool)
   unsigned FullyQualifiedName : 1;
 
-  /// Whether to print types as written or canonically.
+  /// Whether to print entities as written or canonically.
   LLVM_PREFERRED_TYPE(bool)
-  unsigned PrintCanonicalTypes : 1;
+  unsigned PrintAsCanonical : 1;
 
   /// Whether to print an InjectedClassNameType with template arguments or as
   /// written. When a template argument is unnamed, printing it results in
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 28098b242d494..22da5bf251ecd 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -735,7 +735,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
 llvm::raw_string_ostream POut(Proto);
 DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
 const auto *TArgAsWritten = D->getTemplateSpecializationArgsAsWritten();
-if (TArgAsWritten && !Policy.PrintCanonicalTypes)
+if (TArgAsWritten && !Policy.PrintAsCanonical)
   TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(), nullptr);
 else if (const TemplateArgumentList *TArgs =
  D->getTemplateSpecializationArgs())
@@ -1124,7 +1124,7 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
   S->getSpecializedTemplate()->getTemplateParameters();
   const ASTTemplateArgumentListInfo *TArgAsWritten =
   S->getTemplateArgsAsWritten();
-  if (TArgAsWritten && !Policy.PrintCanonicalTypes)
+  if (TArgAsWritten && !Policy.PrintAsCanonical)
 printTemplateArguments(TArgAsWritten->arguments(), TParams);
   else
 printTemplateArguments(S->getTemplateArgs().asArray(), TParams);
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index 3420c1f343cf5..725db93b558f6 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1724,6 +1724,8 @@ void 
JSONNodeDumper::VisitTemplateExpansionTemplateArgument(
 void JSONNodeDumper::VisitExpressionTemplateArgument(
 const TemplateArgument &TA) {
   JOS.attribute("isExpr", true);
+  if (TA.isCanonicalExpr())
+JOS.attribute("isCanon", true);
 }
 void JSONNodeDumper::VisitPackTemplateArgument(const TemplateArgument &TA) {
   JOS.attribute("isPack", true);
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index dbe2432d5c799..aae10fd3bd885 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1305,9 +1305,13 @@ void StmtPrinter::VisitDeclRe

[llvm-branch-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [LV] Reduce register usage for scaled reductions (PR #133090)

2025-04-09 Thread Sam Tebbs via llvm-branch-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,zcfh <1412805...@qq.com>,Alexey
 Bataev ,Florian Hahn ,Alexey Bataev
 ,Hristo Hristov ,Mircea
 Trofin ,Florian Hahn ,Jonas Devlieghere
 ,Henry Jiang ,Alexander
 Yermolovich <43973793+ayerm...@users.noreply.github.com>,Andy Kaylor
 ,Andy Kaylor ,Florian Hahn
 ,Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Andre Kuhlenschmidt
 ,Jan Svoboda ,Jorge
 Gorbe Moya ,Sumit Agarwal ,Andre
 Kuhlenschmidt ,Louis Dionne
 ,Jason Molenda ,modiking
 ,Ian Anderson ,Aditya Tejpaul
 <97700214+hoarfros...@users.noreply.github.com>,Alex MacLean
 ,Jorge Gorbe Moya ,Michael Jones
 ,Slava Zakharin ,Jerry-Ge
 ,Jerry-Ge ,Sudharsan Veeravalli
 ,Rodrigo Rocha ,Mircea Trofin
 ,Mircea Trofin ,NAKAMURA Takumi
 ,Fangrui Song ,Phoebe Wang
 ,Jacob Lalonde ,Kareem Ergawy
 ,cmtice ,Fangrui Song
 ,Iris <0...@owo.li>,Mats Jun Larsen ,Mats Jun
 Larsen ,Mariya Podchishchaeva
 ,Pavel Labath ,Vladi Krapp
 ,David Sherwood ,Igor Wodiany
 ,Adrian Kuegel ,Tobias Stadler
 ,Florian Hahn ,gbMattN
 ,Alaa Ali ,Durgadoss R
 ,Jerry-Ge ,Florian Hahn
 ,Vladi Krapp ,Sergio Afonso
 ,Paul Walker ,JaydeepChauhan14
 ,Vy Nguyen ,Zahira
 Ammarguellat ,Baranov Victor
 ,Ilya Biryukov ,Ilya
 Biryukov ,Mariya Podchishchaeva
 ,Nashe Mncube ,Asher
 Mancinelli ,Matthias Springer ,Justin
 Bogner ,Aaron Ballman ,Ramkumar
 Ramachandra ,Nikita Popov
 ,Nashe Mncube ,Nikita Popov
 ,David Spickett ,Florian Hahn
 ,=?utf-8?q?Gaëtan?= Bossu ,Peter
 Klausler ,Peter Klausler ,Peter
 Klausler ,Peter Klausler ,Peter
 Klausler ,Peter Klausler ,Peter
 Klausler ,Louis Dionne ,Craig
 Topper ,Evan Wilde ,Kevin Gleason
 ,Paschalis Mpeis ,Matthias
 Springer ,Snehasish Kumar ,Craig Topper
 ,Peter Klausler ,Felipe de
 Azevedo Piovezan ,Alexey Bataev ,Jan
 Svoboda ,Jan Svoboda ,Jan
 Svoboda ,Nico Weber ,Nico Weber
 ,Nico Weber ,Aaron Ballman
 ,Florian Mayer ,Luke Lau
 ,Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Alexey
 Bataev ,Ryosuke Niwa ,LLVM GN
 Syncbot ,LLVM GN Syncbot 
,LLVM
 GN Syncbot ,Maksim Panchenko ,Sirraide
 ,Louis Dionne ,Aaron Ballman
 ,Ryosuke Niwa ,Lei Huang
 ,Zahira Ammarguellat 
,erichkeane
 ,Craig Topper ,Jonas Devlieghere
 ,Michael Jones ,Lei Huang
 ,Florian Hahn ,Eugene Epshteyn
 ,Craig Topper ,Jonas
 Devlieghere ,Craig Topper ,Finn
 Plummer ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Craig Topper
 ,Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Jorge
 Gorbe Moya ,Alex MacLean ,Jerry-Ge
 ,Ashley Coleman ,Austin Schuh
 ,Andy Kaylor ,Un1q32
 ,Jonas Devlieghere ,alx32
 <103613512+al...@users.noreply.github.com>,Slava Zakharin
 ,Michael Jones ,Andy Kaylor
 ,Felipe de Azevedo Piovezan ,weiwei
 chen ,Sudharsan Veeravalli 
,Fangrui
 Song ,jobhdez ,Fangrui Song 
,Fangrui
 Song ,Changpeng Fang ,Reid Kleckner
 ,Fangrui Song ,Aiden Grossman
 ,Aiden Grossman ,Vlad
 Serebrennikov ,Mats Jun Larsen
 ,David CARLIER ,David CARLIER
 ,Andreas Jonson ,Andreas Jonson
 ,Phoebe Wang ,Florian Hahn
 ,James E T Smith 
,Matthias
 Springer ,Martin =?utf-8?q?Storsjö?= ,Antonio
 Frighetto ,Florian Hahn ,Rahul Joshi
 ,Fangrui Song ,Fangrui Song 
,Louis
 Dionne ,Fangrui Song ,Fangrui Song
 ,Aiden Grossman ,Fangrui Song
 ,Florian Hahn ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Owen Pan
 ,Fangrui Song ,Florian Hahn
 ,Fangrui Song ,Fangrui Song 
,junfengd-nv
 ,Fangrui Song ,Fangrui Song 

 =?utf-8?q?,?�ngrui Song ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Alan 
,weiwei
 chen ,Owen Pan ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Florian Hahn 
,Hui
 ,Sergei Barannikov ,Benjamin
 Kramer ,Florian Hahn ,Florian Hahn
 ,Benjamin Kramer ,Florian Hahn
 ,Florian Hahn ,Sergei Barannikov
 ,Fangrui Song ,Fangrui Song
 ,Florian Hahn ,Fangrui Song 
,Florian
 Hahn ,Mats Jun Larsen ,Phoebe Wang
 ,Matheus Izvekov ,Alan
 ,Baranov Victor ,Zhen Wang
 <37195552+wangz...@users.noreply.github.com>,Matheus Izvekov
 ,Matt Arsenault ,Matt
 Arsenault ,Tobias Gysi
 ,Fangrui Song ,Nikita Popov
 ,
=?utf-8?q?Balázs_Kéri?= ,Matt Arsenault
 ,Matt Arsenault ,Robert
 Imschweiler ,Matt Arsenault
 ,Matt Arsenault ,
Juan Manuel Martinez =?utf-8?q?Caamaño?=,Mike ,Luke
 Lau ,Simon Pilgrim ,Simon Pilgrim
 ,Simon Pilgrim ,Matt
 Arsenault ,Matthias Springer 
,Han-Kuan
 Chen ,Abhishek Kaushik 
,Anatoly
 Trosinenko ,
Andrzej =?utf-8?q?Warzyński?= ,Jack Frankland
 ,Anatoly Trosinenko ,Mel
 Chen ,Tom Eccles ,Aaron Ballman
 ,Jorn Tuyls ,Simon
 Pilgrim ,Jay Foad ,Zhaoxin Yang
 ,Uday Bondhugula ,Mats Jun
 Larsen ,Christian Sigg ,Jay Foad
 ,JaydeepChauhan14 
,Matthias
 Springer ,
Andrzej =?utf-8?q?Warzyński?= ,Krisztian
 Rugasi ,Nashe Mncube 
,Farzon
 Lotfi ,Pedro Lobo 
,Asher
 Mancinelli ,Farzon Lotfi
 ,Igor Wodiany ,Farzon
 Lotfi ,zhijian lin ,Matt
 Arsenault ,Justin Bogner 
,Michael
 Klemm ,Matheus Izvekov ,Joseph
 Huber ,Julian Lettner 
,Alexandre
 Ganea ,David Spickett ,Paul
 Kirth ,Rahul Joshi ,Farzon Lotfi
 ,Simon Pilgrim ,Linux
 User ,Ma

[llvm-branch-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [LV] Reduce register usage for scaled reductions (PR #133090)

2025-04-09 Thread Sam Tebbs via llvm-branch-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,zcfh <1412805...@qq.com>,Alexey
 Bataev ,Florian Hahn ,Alexey Bataev
 ,Hristo Hristov ,Mircea
 Trofin ,Florian Hahn ,Jonas Devlieghere
 ,Henry Jiang ,Alexander
 Yermolovich <43973793+ayerm...@users.noreply.github.com>,Andy Kaylor
 ,Andy Kaylor ,Florian Hahn
 ,Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Andre Kuhlenschmidt
 ,Jan Svoboda ,Jorge
 Gorbe Moya ,Sumit Agarwal ,Andre
 Kuhlenschmidt ,Louis Dionne
 ,Jason Molenda ,modiking
 ,Ian Anderson ,Aditya Tejpaul
 <97700214+hoarfros...@users.noreply.github.com>,Alex MacLean
 ,Jorge Gorbe Moya ,Michael Jones
 ,Slava Zakharin ,Jerry-Ge
 ,Jerry-Ge ,Sudharsan Veeravalli
 ,Rodrigo Rocha ,Mircea Trofin
 ,Mircea Trofin ,NAKAMURA Takumi
 ,Fangrui Song ,Phoebe Wang
 ,Jacob Lalonde ,Kareem Ergawy
 ,cmtice ,Fangrui Song
 ,Iris <0...@owo.li>,Mats Jun Larsen ,Mats Jun
 Larsen ,Mariya Podchishchaeva
 ,Pavel Labath ,Vladi Krapp
 ,David Sherwood ,Igor Wodiany
 ,Adrian Kuegel ,Tobias Stadler
 ,Florian Hahn ,gbMattN
 ,Alaa Ali ,Durgadoss R
 ,Jerry-Ge ,Florian Hahn
 ,Vladi Krapp ,Sergio Afonso
 ,Paul Walker ,JaydeepChauhan14
 ,Vy Nguyen ,Zahira
 Ammarguellat ,Baranov Victor
 ,Ilya Biryukov ,Ilya
 Biryukov ,Mariya Podchishchaeva
 ,Nashe Mncube ,Asher
 Mancinelli ,Matthias Springer ,Justin
 Bogner ,Aaron Ballman ,Ramkumar
 Ramachandra ,Nikita Popov
 ,Nashe Mncube ,Nikita Popov
 ,David Spickett ,Florian Hahn
 ,=?utf-8?q?Gaëtan?= Bossu ,Peter
 Klausler ,Peter Klausler ,Peter
 Klausler ,Peter Klausler ,Peter
 Klausler ,Peter Klausler ,Peter
 Klausler ,Louis Dionne ,Craig
 Topper ,Evan Wilde ,Kevin Gleason
 ,Paschalis Mpeis ,Matthias
 Springer ,Snehasish Kumar ,Craig Topper
 ,Peter Klausler ,Felipe de
 Azevedo Piovezan ,Alexey Bataev ,Jan
 Svoboda ,Jan Svoboda ,Jan
 Svoboda ,Nico Weber ,Nico Weber
 ,Nico Weber ,Aaron Ballman
 ,Florian Mayer ,Luke Lau
 ,Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Alexey
 Bataev ,Ryosuke Niwa ,LLVM GN
 Syncbot ,LLVM GN Syncbot 
,LLVM
 GN Syncbot ,Maksim Panchenko ,Sirraide
 ,Louis Dionne ,Aaron Ballman
 ,Ryosuke Niwa ,Lei Huang
 ,Zahira Ammarguellat 
,erichkeane
 ,Craig Topper ,Jonas Devlieghere
 ,Michael Jones ,Lei Huang
 ,Florian Hahn ,Eugene Epshteyn
 ,Craig Topper ,Jonas
 Devlieghere ,Craig Topper ,Finn
 Plummer ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Craig Topper
 ,Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Jorge
 Gorbe Moya ,Alex MacLean ,Jerry-Ge
 ,Ashley Coleman ,Austin Schuh
 ,Andy Kaylor ,Un1q32
 ,Jonas Devlieghere ,alx32
 <103613512+al...@users.noreply.github.com>,Slava Zakharin
 ,Michael Jones ,Andy Kaylor
 ,Felipe de Azevedo Piovezan ,weiwei
 chen ,Sudharsan Veeravalli 
,Fangrui
 Song ,jobhdez ,Fangrui Song 
,Fangrui
 Song ,Changpeng Fang ,Reid Kleckner
 ,Fangrui Song ,Aiden Grossman
 ,Aiden Grossman ,Vlad
 Serebrennikov ,Mats Jun Larsen
 ,David CARLIER ,David CARLIER
 ,Andreas Jonson ,Andreas Jonson
 ,Phoebe Wang ,Florian Hahn
 ,James E T Smith 
,Matthias
 Springer ,Martin =?utf-8?q?Storsjö?= ,Antonio
 Frighetto ,Florian Hahn ,Rahul Joshi
 ,Fangrui Song ,Fangrui Song 
,Louis
 Dionne ,Fangrui Song ,Fangrui Song
 ,Aiden Grossman ,Fangrui Song
 ,Florian Hahn ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Owen Pan
 ,Fangrui Song ,Florian Hahn
 ,Fangrui Song ,Fangrui Song 
,junfengd-nv
 ,Fangrui Song ,Fangrui Song 

 =?utf-8?q?,?�ngrui Song ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Alan 
,weiwei
 chen ,Owen Pan ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,Fangrui Song ,Florian Hahn 
,Hui
 ,Sergei Barannikov ,Benjamin
 Kramer ,Florian Hahn ,Florian Hahn
 ,Benjamin Kramer ,Florian Hahn
 ,Florian Hahn ,Sergei Barannikov
 ,Fangrui Song ,Fangrui Song
 ,Florian Hahn ,Fangrui Song 
,Florian
 Hahn ,Mats Jun Larsen ,Phoebe Wang
 ,Matheus Izvekov ,Alan
 ,Baranov Victor ,Zhen Wang
 <37195552+wangz...@users.noreply.github.com>,Matheus Izvekov
 ,Matt Arsenault ,Matt
 Arsenault ,Tobias Gysi
 ,Fangrui Song ,Nikita Popov
 ,
=?utf-8?q?Balázs_Kéri?= ,Matt Arsenault
 ,Matt Arsenault ,Robert
 Imschweiler ,Matt Arsenault
 ,Matt Arsenault ,
Juan Manuel Martinez =?utf-8?q?Caamaño?=,Mike ,Luke
 Lau ,Simon Pilgrim ,Simon Pilgrim
 ,Simon Pilgrim ,Matt
 Arsenault ,Matthias Springer 
,Han-Kuan
 Chen ,Abhishek Kaushik 
,Anatoly
 Trosinenko ,
Andrzej =?utf-8?q?Warzyński?= ,Jack Frankland
 ,Anatoly Trosinenko ,Mel
 Chen ,Tom Eccles ,Aaron Ballman
 ,Jorn Tuyls ,Simon
 Pilgrim ,Jay Foad ,Zhaoxin Yang
 ,Uday Bondhugula ,Mats Jun
 Larsen ,Christian Sigg ,Jay Foad
 ,JaydeepChauhan14 
,Matthias
 Springer ,
Andrzej =?utf-8?q?Warzyński?= ,Krisztian
 Rugasi ,Nashe Mncube 
,Farzon
 Lotfi ,Pedro Lobo 
,Asher
 Mancinelli ,Farzon Lotfi
 ,Igor Wodiany ,Farzon
 Lotfi ,zhijian lin ,Matt
 Arsenault ,Justin Bogner 
,Michael
 Klemm ,Matheus Izvekov ,Joseph
 Huber ,Julian Lettner 
,Alexandre
 Ganea ,David Spickett ,Paul
 Kirth ,Rahul Joshi ,Farzon Lotfi
 ,Simon Pilgrim ,Linux
 User ,Ma

[llvm-branch-commits] [llvm] d77b786 - Revert "[AArch64][SVE] Pair SVE fill/spill into LDP/STP with -msve-vector-bit…"

2025-04-09 Thread via llvm-branch-commits

Author: David Spickett
Date: 2025-04-09T13:29:42+01:00
New Revision: d77b786ac57008f734cd5552d59c6be34fd05c77

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

LOG: Revert "[AArch64][SVE] Pair SVE fill/spill into LDP/STP with 
-msve-vector-bit…"

This reverts commit c80080ff7e105eb42d486ed473fa9c82fb518b0a.

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp

Removed: 
llvm/test/CodeGen/AArch64/aarch64-sve-fill-spill-pair.ll



diff  --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 74217fad82a7e..d370f8c7ff6ea 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -2760,9 +2760,6 @@ bool AArch64InstrInfo::isPairableLdStInst(const 
MachineInstr &MI) {
   case AArch64::LDRXpre:
   case AArch64::LDURSWi:
   case AArch64::LDRSWpre:
-  // SVE instructions.
-  case AArch64::LDR_ZXI:
-  case AArch64::STR_ZXI:
 return true;
   }
 }
@@ -2915,18 +2912,6 @@ bool AArch64InstrInfo::isCandidateToMergeOrPair(const 
MachineInstr &MI) const {
   return false;
   }
 
-  // Pairing SVE fills/spills is only valid for little-endian targets that
-  // implement VLS 128.
-  switch (MI.getOpcode()) {
-  default:
-break;
-  case AArch64::LDR_ZXI:
-  case AArch64::STR_ZXI:
-if (!Subtarget.isLittleEndian() ||
-Subtarget.getSVEVectorSizeInBits() != 128)
-  return false;
-  }
-
   // Check if this load/store has a hint to avoid pair formation.
   // MachineMemOperands hints are set by the AArch64StorePairSuppress pass.
   if (isLdStPairSuppressed(MI))

diff  --git a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp 
b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
index 68ed68b9e32bc..06e633effe874 100644
--- a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
@@ -298,7 +298,6 @@ static unsigned getMatchingNonSExtOpcode(unsigned Opc,
   case AArch64::STRXui:
   case AArch64::STRXpre:
   case AArch64::STURXi:
-  case AArch64::STR_ZXI:
   case AArch64::LDRDui:
   case AArch64::LDURDi:
   case AArch64::LDRDpre:
@@ -317,7 +316,6 @@ static unsigned getMatchingNonSExtOpcode(unsigned Opc,
   case AArch64::LDRSui:
   case AArch64::LDURSi:
   case AArch64::LDRSpre:
-  case AArch64::LDR_ZXI:
 return Opc;
   case AArch64::LDRSWui:
 return AArch64::LDRWui;
@@ -363,7 +361,6 @@ static unsigned getMatchingPairOpcode(unsigned Opc) {
 return AArch64::STPDpre;
   case AArch64::STRQui:
   case AArch64::STURQi:
-  case AArch64::STR_ZXI:
 return AArch64::STPQi;
   case AArch64::STRQpre:
 return AArch64::STPQpre;
@@ -389,7 +386,6 @@ static unsigned getMatchingPairOpcode(unsigned Opc) {
 return AArch64::LDPDpre;
   case AArch64::LDRQui:
   case AArch64::LDURQi:
-  case AArch64::LDR_ZXI:
 return AArch64::LDPQi;
   case AArch64::LDRQpre:
 return AArch64::LDPQpre;
@@ -1229,16 +1225,6 @@ 
AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
 (void)MIBSXTW;
 LLVM_DEBUG(dbgs() << "  Extend operand:\n");
 LLVM_DEBUG(((MachineInstr *)MIBSXTW)->print(dbgs()));
-  } else if (Opc == AArch64::LDR_ZXI || Opc == AArch64::STR_ZXI) {
-// We are combining SVE fill/spill to LDP/STP, so we need to use the Q
-// variant of the registers.
-MachineOperand &MOp0 = MIB->getOperand(0);
-MachineOperand &MOp1 = MIB->getOperand(1);
-assert(AArch64::ZPRRegClass.contains(MOp0.getReg()) &&
-   AArch64::ZPRRegClass.contains(MOp1.getReg()) && "Invalid 
register.");
-MOp0.setReg(AArch64::Q0 + (MOp0.getReg() - AArch64::Z0));
-MOp1.setReg(AArch64::Q0 + (MOp1.getReg() - AArch64::Z0));
-LLVM_DEBUG(((MachineInstr *)MIB)->print(dbgs()));
   } else {
 LLVM_DEBUG(((MachineInstr *)MIB)->print(dbgs()));
   }
@@ -2673,8 +2659,7 @@ bool 
AArch64LoadStoreOpt::tryToPairLdStInst(MachineBasicBlock::iterator &MBBI) {
   // Get the needed alignments to check them if
   // ldp-aligned-only/stp-aligned-only features are opted.
   uint64_t MemAlignment = MemOp->getAlign().value();
-  uint64_t TypeAlignment =
-  Align(MemOp->getSize().getValue().getKnownMinValue()).value();
+  uint64_t TypeAlignment = Align(MemOp->getSize().getValue()).value();
 
   if (MemAlignment < 2 * TypeAlignment) {
 NumFailedAlignmentCheck++;
@@ -2835,18 +2820,11 @@ bool 
AArch64LoadStoreOpt::optimizeBlock(MachineBasicBlock &MBB,
 }
   // 3) Find loads and stores that can be merged into a single load or store
   //pair instruction.
-  //When compiling for SVE 128, also try to combine SVE fill/spill
-  //instructions into LDP/STP.
   //  e.g.,
   //ldr 

[llvm-branch-commits] [llvm] [KeyInstr][SimplifyCFG] Remap atoms when folding br to common succ into pred (PR #133482)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits


@@ -1182,6 +1187,19 @@ static void 
cloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
   U.set(NewBonusInst);
 }
   }
+
+  // Key Instructions: We may have propagated atom info into the pred. If the
+  // pred's terminator already has atom info do nothing as merging would drop
+  // one atom group anyway. If it doesn't, propagte the remapped atom group

SLTozer wrote:

```suggestion
  // one atom group anyway. If it doesn't, propagate the remapped atom group
```

https://github.com/llvm/llvm-project/pull/133482
___
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] CodeGen: Trim redundant template argument from defusechain_iterator (PR #135024)

2025-04-09 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

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

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




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


https://github.com/llvm/llvm-project/pull/135024
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

> > in libc++ we have a pre-commit CI so this feature should be tested in our 
> > CI, if you need help with that, best reach out to us on Discord. However I 
> > think we first need to look at how we can properly integrate this in libc++.
> 
> Sure, I will get in touch once this is closer to landing (everything else in 
> [Structure Protection](https://github.com/orgs/llvm/projects/38) needs to 
> land first). So far I've been running the libc++ test suite manually with 
> some hand written cfg files but it would be good to get everything hooked up 
> so that the tests can run in CI as well.

SGTM!

Looking at your replies I think we indeed need to add a new configuration for 
this feature, much like building without RTTI or exceptions.

> > I'm not fond of this patch since it mixes LLVM, Clang, and libc++(abi) 
> > code. This makes it hard to determine when all reviewer groups are 
> > satisfied. Is there a reason why the libc++ and the libc++abi part can't be 
> > in two separate patches?
> 
> No problem, I'll split up the libc++ and libc++abi parts into separate 
> patches the next time I upload.

Thanks!

https://github.com/llvm/llvm-project/pull/133538
___
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] Add pointer field protection feature. (PR #133538)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits


@@ -84,7 +84,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template  */>
-class _LIBCPP_TEMPLATE_VIS vector {
+class _LIBCPP_TEMPLATE_VIS vector _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {

pcc wrote:

The intent would be that the user builds libc++.a with 
`pointer_field_protection` and statically links it into their binary. Because 
of the changes to pointer representation there are numerous other ABI 
incompatibilities. This feature is incompatible with dynamic linking so we may 
want to skip building the dynamic library if the feature is enabled.

https://github.com/llvm/llvm-project/pull/133538
___
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/20.x: [fatlto] Add coroutine passes when using FatLTO with ThinLTO (#134434) (PR #134711)

2025-04-09 Thread Yuxuan Chen via llvm-branch-commits

yuxuanchen1997 wrote:

cc @apolloww 

https://github.com/llvm/llvm-project/pull/134711
___
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-tools-extra] [clang-tidy] treat unsigned char and signed char as char type by default in bugprone-unintended-char-ostream-output (PR #134870)

2025-04-09 Thread Congcong Cai via llvm-branch-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/134870

>From 9d29fd3792be9ae10eb58cecaaba313a0eaf85f1 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Tue, 8 Apr 2025 15:27:54 +
Subject: [PATCH 1/2] [clang-tidy] treat unsigned char and signed char as char
 type by default in bugprone-unintended-char-ostream-output

Add `AllowedTypes` options to support custom defined char like type.
treat `unsigned char` and `signed char` as char like type by default.
The allowed types only effect when the var decl or explicit cast to this
non-canonical type names.
---
 .../UnintendedCharOstreamOutputCheck.cpp  | 19 -
 .../UnintendedCharOstreamOutputCheck.h|  1 +
 .../unintended-char-ostream-output.rst|  8 +++
 ...nded-char-ostream-output-allowed-types.cpp | 41 +++
 ...intended-char-ostream-output-cast-type.cpp | 11 +--
 .../unintended-char-ostream-output.cpp| 70 +--
 6 files changed, 106 insertions(+), 44 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/unintended-char-ostream-output-allowed-types.cpp

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
index 7250e4ccb8c69..57e1f744fcd7d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
@@ -7,6 +7,8 @@
 
//===--===//
 
 #include "UnintendedCharOstreamOutputCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
 #include "clang/AST/Type.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
@@ -35,10 +37,14 @@ AST_MATCHER(Type, isChar) {
 
 UnintendedCharOstreamOutputCheck::UnintendedCharOstreamOutputCheck(
 StringRef Name, ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context), CastTypeName(Options.get("CastTypeName")) 
{
-}
+: ClangTidyCheck(Name, Context),
+  AllowedTypes(utils::options::parseStringList(
+  Options.get("AllowedTypes", "unsigned char;signed char"))),
+  CastTypeName(Options.get("CastTypeName")) {}
 void UnintendedCharOstreamOutputCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowedTypes",
+utils::options::serializeStringList(AllowedTypes));
   if (CastTypeName.has_value())
 Options.store(Opts, "CastTypeName", CastTypeName.value());
 }
@@ -50,13 +56,20 @@ void 
UnintendedCharOstreamOutputCheck::registerMatchers(MatchFinder *Finder) {
 // with char / unsigned char / signed char
 classTemplateSpecializationDecl(
 hasTemplateArgument(0, refersToType(isChar();
+  auto IsDeclRefExprFromAllowedTypes = declRefExpr(to(varDecl(
+  hasType(matchers::matchesAnyListedTypeName(AllowedTypes, false);
+  auto IsExplicitCastExprFromAllowedTypes = 
explicitCastExpr(hasDestinationType(
+  matchers::matchesAnyListedTypeName(AllowedTypes, false)));
   Finder->addMatcher(
   cxxOperatorCallExpr(
   hasOverloadedOperatorName("<<"),
   hasLHS(hasType(hasUnqualifiedDesugaredType(
   recordType(hasDeclaration(cxxRecordDecl(
   anyOf(BasicOstream, isDerivedFrom(BasicOstream,
-  hasRHS(hasType(hasUnqualifiedDesugaredType(isNumericChar()
+  hasRHS(expr(hasType(hasUnqualifiedDesugaredType(isNumericChar())),
+  unless(ignoringParenImpCasts(
+  anyOf(IsDeclRefExprFromAllowedTypes,
+IsExplicitCastExprFromAllowedTypes))
   .bind("x"),
   this);
 }
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.h
index 61ea623d139ea..0759e3d1eb460 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.h
@@ -30,6 +30,7 @@ class UnintendedCharOstreamOutputCheck : public 
ClangTidyCheck {
   }
 
 private:
+  const std::vector AllowedTypes;
   const std::optional CastTypeName;
 };
 
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst
index 95d02b3e2ddda..9ad08188d7fb2 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst
@@ -42,6 +42,14 @@ Or cast to char to explicitly indicate that output should be 
a character.
 Options
 ---
 
+.. option:: AllowedTypes
+
+  A semicolon-separated list of type na

[llvm-branch-commits] [llvm] [KeyInstr][SimplifyCFG] Remap atoms after duplication for threading (PR #133484)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits


@@ -3609,11 +3609,11 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst 
*BI, DomTreeUpdater *DTU,
 N->setName(BBI->getName() + ".c");
 
   // Update operands due to translation.
-  for (Use &Op : N->operands()) {
-DenseMap::iterator PI = TranslateMap.find(Op);
-if (PI != TranslateMap.end())
-  Op = PI->second;
-  }
+  // Key Instructions: Remap all the atom groups.
+  if (const DebugLoc &DL = BBI->getDebugLoc())
+mapAtomInstance(DL, TranslateMap);
+  RemapInstruction(N, TranslateMap,
+   RF_IgnoreMissingLocals | RF_NoModuleLevelChanges);

SLTozer wrote:

If I understand right, `RemapInstruction` with these operands will never create 
a new value mapping, only ever return an existing mapping - is that correct?

https://github.com/llvm/llvm-project/pull/133484
___
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] [lldb] 0451084 - Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server …"

2025-04-09 Thread via llvm-branch-commits

Author: David Spickett
Date: 2025-04-09T13:15:33+01:00
New Revision: 0451084e2e64fc5262f480eae8150c9a191eb7dc

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

LOG: Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break 
lldb-server …"

This reverts commit fbc6241d3af45d74ac8e8d3728a57435aab1d5ec.

Added: 


Modified: 
lldb/include/lldb/Core/Mangled.h
lldb/include/lldb/Core/RichManglingContext.h
lldb/include/lldb/Target/Language.h
lldb/source/Core/CMakeLists.txt
lldb/source/Core/Mangled.cpp
lldb/source/Core/Module.cpp
lldb/source/Core/RichManglingContext.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/Language/CMakeLists.txt
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/unittests/Core/CMakeLists.txt
lldb/unittests/Core/RichManglingContextTest.cpp
lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Mangled.h 
b/lldb/include/lldb/Core/Mangled.h
index 7db63eeeb6ee0..5988d919a89b8 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -246,8 +246,6 @@ class Mangled {
   /// for s, otherwise the enumerator for the mangling scheme detected.
   static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name);
 
-  static bool IsMangledName(llvm::StringRef name);
-
   /// Decode a serialized version of this object from data.
   ///
   /// \param data

diff  --git a/lldb/include/lldb/Core/RichManglingContext.h 
b/lldb/include/lldb/Core/RichManglingContext.h
index 50ec2ae361098..3b79924e88a9a 100644
--- a/lldb/include/lldb/Core/RichManglingContext.h
+++ b/lldb/include/lldb/Core/RichManglingContext.h
@@ -12,7 +12,6 @@
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
-#include "lldb/Target/Language.h"
 #include "lldb/Utility/ConstString.h"
 
 #include "llvm/ADT/Any.h"
@@ -68,7 +67,11 @@ class RichManglingContext {
   char *m_ipd_buf;
   size_t m_ipd_buf_size = 2048;
 
-  std::unique_ptr m_cxx_method_parser;
+  /// Members for PluginCxxLanguage
+  /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The
+  /// respective header is in Plugins and including it from here causes cyclic
+  /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp.
+  llvm::Any m_cxx_method_parser;
 
   /// Clean up memory when using PluginCxxLanguage
   void ResetCxxMethodParser();
@@ -78,6 +81,15 @@ class RichManglingContext {
 
   /// Uniform handling of string buffers for ItaniumPartialDemangler.
   llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len);
+
+  /// Cast the given parser to the given type. Ideally we would have a type
+  /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately 
we
+  /// can't access CPlusPlusLanguage::MethodName from within the header.
+  template  static ParserT *get(llvm::Any parser) {
+assert(parser.has_value());
+assert(llvm::any_cast(&parser));
+return *llvm::any_cast(&parser);
+  }
 };
 
 } // namespace lldb_private

diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index d46969cb3b4e4..b699a90aff8e4 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -214,104 +214,6 @@ class Language : public PluginInterface {
 return std::vector();
   };
 
-  class MethodName {
-  public:
-MethodName() {}
-
-MethodName(ConstString full)
-: m_full(full), m_basename(), m_context(), m_arguments(),
-  m_qualifiers(), m_return_type(), m_scope_qualified(), 
m_parsed(false),
-  m_parse_error(false) {}
-
-virtual ~MethodName() {};
-
-void Clear() {
-  m_full.Clear();
-  m_basename = llvm::StringRef();
-  m_context = llvm::StringRef();
-  m_arguments = llvm::StringRef();
-  m_qualifiers = llvm::StringRef();
-  m_return_type = llvm::StringRef();
-  m_scope_qualified.clear();
-  m_parsed = false;
-  m_parse_error = false;
-}
-
-bool IsValid() {
-  if (!m_parsed)
-Parse();
-  if (m_parse_error)
-return false;
-  return (bool)m_full;
-}
-
-ConstString GetFullName() const { return m_full; }
-
-llvm::StringRef GetBasename() {
-  if (!m_parsed)
-Parse();
-  return m_basename;
-}
-
-llvm::StringRef GetContext() {
-  if (!m_parsed)
-Parse();
-  return m_context;
-}
-
-llvm::StringRef GetArguments() {
-  i

[llvm-branch-commits] [mlir] [mlir][LLVM] Delete `getFixedVectorType` and `getScalableVectorType` (PR #135051)

2025-04-09 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer updated 
https://github.com/llvm/llvm-project/pull/135051

>From 120778f6eff8af147add819a4a9f3f31d495f6d8 Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Wed, 9 Apr 2025 19:05:11 +0200
Subject: [PATCH] [mlir][LLVM] Delete `getFixedVectorType` and
 `getScalableVectorType`

---
 mlir/docs/Dialects/LLVM.md|  4 ---
 mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h  |  8 -
 .../Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp| 33 +--
 mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp  | 12 ---
 mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp| 23 -
 mlir/lib/Dialect/NVGPU/Utils/MMAUtils.cpp | 24 ++
 mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp   |  9 ++---
 7 files changed, 45 insertions(+), 68 deletions(-)

diff --git a/mlir/docs/Dialects/LLVM.md b/mlir/docs/Dialects/LLVM.md
index 468f69c419071..4b5d518ca4eab 100644
--- a/mlir/docs/Dialects/LLVM.md
+++ b/mlir/docs/Dialects/LLVM.md
@@ -336,10 +336,6 @@ compatible with the LLVM dialect:
 vector type compatible with the LLVM dialect;
 -   `llvm::ElementCount LLVM::getVectorNumElements(Type)` - returns the number
 of elements in any vector type compatible with the LLVM dialect;
--   `Type LLVM::getFixedVectorType(Type, unsigned)` - gets a fixed vector type
-with the given element type and size; the resulting type is either a
-built-in or an LLVM dialect vector type depending on which one supports the
-given element type.
 
  Examples of Compatible Vector Types
 
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
index a2a76c49a2bda..17561f79d135a 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
@@ -126,14 +126,6 @@ Type getVectorType(Type elementType, unsigned numElements,
 /// and length.
 Type getVectorType(Type elementType, const llvm::ElementCount &numElements);
 
-/// Creates an LLVM dialect-compatible type with the given element type and
-/// length.
-Type getFixedVectorType(Type elementType, unsigned numElements);
-
-/// Creates an LLVM dialect-compatible type with the given element type and
-/// length.
-Type getScalableVectorType(Type elementType, unsigned numElements);
-
 /// Returns the size of the given primitive LLVM dialect-compatible type
 /// (including vectors) in bits, for example, the size of i16 is 16 and
 /// the size of vector<4xi16> is 64. Returns 0 for non-primitive
diff --git a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp 
b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
index 51507c6507b69..69fa62c8196e4 100644
--- a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
+++ b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
@@ -61,13 +61,13 @@ static Value truncToI32(ImplicitLocOpBuilder &b, Value 
value) {
 static Type inferIntrinsicResultType(Type vectorResultType) {
   MLIRContext *ctx = vectorResultType.getContext();
   auto a = cast(vectorResultType);
-  auto f16x2Ty = LLVM::getFixedVectorType(Float16Type::get(ctx), 2);
+  auto f16x2Ty = VectorType::get(2, Float16Type::get(ctx));
   auto i32Ty = IntegerType::get(ctx, 32);
-  auto i32x2Ty = LLVM::getFixedVectorType(i32Ty, 2);
+  auto i32x2Ty = VectorType::get(2, i32Ty);
   Type f64Ty = Float64Type::get(ctx);
-  Type f64x2Ty = LLVM::getFixedVectorType(f64Ty, 2);
+  Type f64x2Ty = VectorType::get(2, f64Ty);
   Type f32Ty = Float32Type::get(ctx);
-  Type f32x2Ty = LLVM::getFixedVectorType(f32Ty, 2);
+  Type f32x2Ty = VectorType::get(2, f32Ty);
   if (a.getElementType() == f16x2Ty) {
 return LLVM::LLVMStructType::getLiteral(
 ctx, SmallVector(a.getNumElements(), f16x2Ty));
@@ -85,7 +85,7 @@ static Type inferIntrinsicResultType(Type vectorResultType) {
 ctx,
 SmallVector(static_cast(a.getNumElements()) * 2, f32Ty));
   }
-  if (a.getElementType() == LLVM::getFixedVectorType(f32Ty, 1)) {
+  if (a.getElementType() == VectorType::get(1, f32Ty)) {
 return LLVM::LLVMStructType::getLiteral(
 ctx, SmallVector(static_cast(a.getNumElements()), 
f32Ty));
   }
@@ -106,11 +106,11 @@ static Value convertIntrinsicResult(Location loc, Type 
intrinsicResultType,
   Type i32Ty = rewriter.getI32Type();
   Type f32Ty = rewriter.getF32Type();
   Type f64Ty = rewriter.getF64Type();
-  Type f16x2Ty = LLVM::getFixedVectorType(rewriter.getF16Type(), 2);
-  Type i32x2Ty = LLVM::getFixedVectorType(i32Ty, 2);
-  Type f64x2Ty = LLVM::getFixedVectorType(f64Ty, 2);
-  Type f32x2Ty = LLVM::getFixedVectorType(f32Ty, 2);
-  Type f32x1Ty = LLVM::getFixedVectorType(f32Ty, 1);
+  Type f16x2Ty = VectorType::get(2, rewriter.getF16Type());
+  Type i32x2Ty = VectorType::get(2, i32Ty);
+  Type f64x2Ty = VectorType::get(2, f64Ty);
+  Type f32x2Ty = VectorType::get(2, f32Ty);
+  Type f32x1Ty = VectorType::get(1, f32Ty);
 
   auto makeConst = [&](int32_t index) -> Value {
 return rewriter.create(loc, IntegerType::get(ctx, 32),
@@ -181,9 +181,9 @@ static Smal

[llvm-branch-commits] [mlir] [mlir][LLVM] Delete `getFixedVectorType` and `getScalableVectorType` (PR #135051)

2025-04-09 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-mlir-gpu

@llvm/pr-subscribers-mlir-nvgpu

Author: Matthias Springer (matthias-springer)


Changes

The LLVM dialect no longer has its own vector types. It uses `mlir::VectorType` 
everywhere. Remove `LLVM::getFixedVectorType/getScalableVectorType` and use 
`VectorType::get` instead. This commit addresses a 
[comment](https://github.com/llvm/llvm-project/pull/133286#discussion_r2022192500)
 on the PR that deleted the LLVM vector types.

Depends on #134981.



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


7 Files Affected:

- (modified) mlir/docs/Dialects/LLVM.md (-4) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h (-8) 
- (modified) mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp (+16-17) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp (-12) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp (+14-9) 
- (modified) mlir/lib/Dialect/NVGPU/Utils/MMAUtils.cpp (+10-14) 
- (modified) mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp (+5-4) 


``diff
diff --git a/mlir/docs/Dialects/LLVM.md b/mlir/docs/Dialects/LLVM.md
index 468f69c419071..4b5d518ca4eab 100644
--- a/mlir/docs/Dialects/LLVM.md
+++ b/mlir/docs/Dialects/LLVM.md
@@ -336,10 +336,6 @@ compatible with the LLVM dialect:
 vector type compatible with the LLVM dialect;
 -   `llvm::ElementCount LLVM::getVectorNumElements(Type)` - returns the number
 of elements in any vector type compatible with the LLVM dialect;
--   `Type LLVM::getFixedVectorType(Type, unsigned)` - gets a fixed vector type
-with the given element type and size; the resulting type is either a
-built-in or an LLVM dialect vector type depending on which one supports the
-given element type.
 
  Examples of Compatible Vector Types
 
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
index a2a76c49a2bda..17561f79d135a 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
@@ -126,14 +126,6 @@ Type getVectorType(Type elementType, unsigned numElements,
 /// and length.
 Type getVectorType(Type elementType, const llvm::ElementCount &numElements);
 
-/// Creates an LLVM dialect-compatible type with the given element type and
-/// length.
-Type getFixedVectorType(Type elementType, unsigned numElements);
-
-/// Creates an LLVM dialect-compatible type with the given element type and
-/// length.
-Type getScalableVectorType(Type elementType, unsigned numElements);
-
 /// Returns the size of the given primitive LLVM dialect-compatible type
 /// (including vectors) in bits, for example, the size of i16 is 16 and
 /// the size of vector<4xi16> is 64. Returns 0 for non-primitive
diff --git a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp 
b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
index 51507c6507b69..69fa62c8196e4 100644
--- a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
+++ b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
@@ -61,13 +61,13 @@ static Value truncToI32(ImplicitLocOpBuilder &b, Value 
value) {
 static Type inferIntrinsicResultType(Type vectorResultType) {
   MLIRContext *ctx = vectorResultType.getContext();
   auto a = cast(vectorResultType);
-  auto f16x2Ty = LLVM::getFixedVectorType(Float16Type::get(ctx), 2);
+  auto f16x2Ty = VectorType::get(2, Float16Type::get(ctx));
   auto i32Ty = IntegerType::get(ctx, 32);
-  auto i32x2Ty = LLVM::getFixedVectorType(i32Ty, 2);
+  auto i32x2Ty = VectorType::get(2, i32Ty);
   Type f64Ty = Float64Type::get(ctx);
-  Type f64x2Ty = LLVM::getFixedVectorType(f64Ty, 2);
+  Type f64x2Ty = VectorType::get(2, f64Ty);
   Type f32Ty = Float32Type::get(ctx);
-  Type f32x2Ty = LLVM::getFixedVectorType(f32Ty, 2);
+  Type f32x2Ty = VectorType::get(2, f32Ty);
   if (a.getElementType() == f16x2Ty) {
 return LLVM::LLVMStructType::getLiteral(
 ctx, SmallVector(a.getNumElements(), f16x2Ty));
@@ -85,7 +85,7 @@ static Type inferIntrinsicResultType(Type vectorResultType) {
 ctx,
 SmallVector(static_cast(a.getNumElements()) * 2, f32Ty));
   }
-  if (a.getElementType() == LLVM::getFixedVectorType(f32Ty, 1)) {
+  if (a.getElementType() == VectorType::get(1, f32Ty)) {
 return LLVM::LLVMStructType::getLiteral(
 ctx, SmallVector(static_cast(a.getNumElements()), 
f32Ty));
   }
@@ -106,11 +106,11 @@ static Value convertIntrinsicResult(Location loc, Type 
intrinsicResultType,
   Type i32Ty = rewriter.getI32Type();
   Type f32Ty = rewriter.getF32Type();
   Type f64Ty = rewriter.getF64Type();
-  Type f16x2Ty = LLVM::getFixedVectorType(rewriter.getF16Type(), 2);
-  Type i32x2Ty = LLVM::getFixedVectorType(i32Ty, 2);
-  Type f64x2Ty = LLVM::getFixedVectorType(f64Ty, 2);
-  Type f32x2Ty = LLVM::getFixedVectorType(f32Ty, 2);
-  Type f32x1Ty = LLVM::getFixedVectorType(f32Ty, 1);
+  Type f16x2Ty = VectorType::get(2, rewriter.getF16Type());
+  Type i32x2Ty = VectorType::get(2, i32Ty);
+  Type f64x2Ty = VectorType::get(2, f64Ty);
+ 

[llvm-branch-commits] [mlir] [mlir][LLVM] Delete `getFixedVectorType` and `getScalableVectorType` (PR #135051)

2025-04-09 Thread via llvm-branch-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- 
mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h 
mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp 
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp 
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp 
mlir/lib/Dialect/NVGPU/Utils/MMAUtils.cpp 
mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
``





View the diff from clang-format here.


``diff
diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
index b9d6952f6..593283f14 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -1222,7 +1222,7 @@ llvm::Intrinsic::ID 
CpAsyncBulkTensorPrefetchOp::getIntrinsicID(int tensorDims,
 : CP_ASYNC_BULK_TENSOR_REDUCE_MODE(op, dim, tile)
 
 #define GET_CP_ASYNC_BULK_TENSOR_ID(op, dims, is_im2col)   
\
-  [&]() -> auto{   
\
+  [&]() -> auto {  
\
 switch (dims) {
\
 case 1:
\
   return CP_ASYNC_BULK_TENSOR_REDUCE_MODE(op, 1, tile);
\
@@ -1237,8 +1237,7 @@ llvm::Intrinsic::ID 
CpAsyncBulkTensorPrefetchOp::getIntrinsicID(int tensorDims,
 default:   
\
   llvm_unreachable("Invalid TensorDim in CpAsyncBulkTensorReduceOp."); 
\
 }  
\
-  }
\
-  ()
+  }()
 
 llvm::Intrinsic::ID CpAsyncBulkTensorReduceOp::getIntrinsicID(
 int tensorDims, NVVM::TMAReduxKind kind, bool isIm2Col) {
@@ -1368,14 +1367,13 @@ Tcgen05CommitOp::getIntrinsicIDAndArgs(Operation &op,
   : TCGEN05_CP_IMPL(shape_mc, src_fmt, _cg1)
 
 #define GET_TCGEN05_CP_ID(shape_mc, src_fmt, is_2cta)  
\
-  [&]() -> auto{   
\
+  [&]() -> auto {  
\
 if (src_fmt == Tcgen05CpSrcFormat::B6x16_P32)  
\
   return TCGEN05_CP_2CTA(shape_mc, _b6x16_p32, is_2cta);   
\
 if (src_fmt == Tcgen05CpSrcFormat::B4x16_P64)  
\
   return TCGEN05_CP_2CTA(shape_mc, _b4x16_p64, is_2cta);   
\
 return TCGEN05_CP_2CTA(shape_mc, , is_2cta);   
\
-  }
\
-  ()
+  }()
 
 llvm::Intrinsic::ID Tcgen05CpOp::getIntrinsicID(Operation &op) {
   auto curOp = cast(op);

``




https://github.com/llvm/llvm-project/pull/135051
___
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] [KeyInstr][SimplifyCFG] Remap atoms after duplication for threading (PR #133484)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits

https://github.com/SLTozer edited 
https://github.com/llvm/llvm-project/pull/133484
___
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] [HLSL] Adding support for Root Constants in LLVM Metadata (PR #135085)

2025-04-09 Thread via llvm-branch-commits

https://github.com/joaosaffran created 
https://github.com/llvm/llvm-project/pull/135085

- Closes [#126637](https://github.com/llvm/llvm-project/issues/126637)

>From 9b59d0108f6b23c039e2c417247216862073cd4b Mon Sep 17 00:00:00 2001
From: joaosaffran 
Date: Wed, 9 Apr 2025 21:05:58 +
Subject: [PATCH 1/2] adding support for root constants in metadata generation

---
 llvm/lib/Target/DirectX/DXILRootSignature.cpp | 120 +-
 llvm/lib/Target/DirectX/DXILRootSignature.h   |   6 +-
 .../RootSignature-Flags-Validation-Error.ll   |   7 +-
 .../RootSignature-RootConstants.ll|  34 +
 ...ature-ShaderVisibility-Validation-Error.ll |  20 +++
 5 files changed, 182 insertions(+), 5 deletions(-)
 create mode 100644 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootConstants.ll
 create mode 100644 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-ShaderVisibility-Validation-Error.ll

diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp 
b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index 412ab7765a7ae..7686918b0fc75 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -40,6 +40,13 @@ static bool reportError(LLVMContext *Ctx, Twine Message,
   return true;
 }
 
+static bool reportValueError(LLVMContext *Ctx, Twine ParamName, uint32_t Value,
+ DiagnosticSeverity Severity = DS_Error) {
+  Ctx->diagnose(DiagnosticInfoGeneric(
+  "Invalid value for " + ParamName + ": " + Twine(Value), Severity));
+  return true;
+}
+
 static bool parseRootFlags(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
MDNode *RootFlagNode) {
 
@@ -52,6 +59,45 @@ static bool parseRootFlags(LLVMContext *Ctx, 
mcdxbc::RootSignatureDesc &RSD,
   return false;
 }
 
+static bool extractMdValue(uint32_t &Value, MDNode *Node, unsigned int OpId) {
+
+  auto *CI = mdconst::extract(Node->getOperand(OpId));
+  if (CI == nullptr)
+return true;
+
+  Value = CI->getZExtValue();
+  return false;
+}
+
+static bool parseRootConstants(LLVMContext *Ctx, mcdxbc::RootSignatureDesc 
&RSD,
+   MDNode *RootFlagNode) {
+
+  if (RootFlagNode->getNumOperands() != 5)
+return reportError(Ctx, "Invalid format for RootConstants Element");
+
+  mcdxbc::RootParameter NewParameter;
+  NewParameter.Header.ParameterType = dxbc::RootParameterType::Constants32Bit;
+
+  uint32_t SV;
+  if (extractMdValue(SV, RootFlagNode, 1))
+return reportError(Ctx, "Invalid value for ShaderVisibility");
+
+  NewParameter.Header.ShaderVisibility = (dxbc::ShaderVisibility)SV;
+
+  if (extractMdValue(NewParameter.Constants.ShaderRegister, RootFlagNode, 2))
+return reportError(Ctx, "Invalid value for ShaderRegister");
+
+  if (extractMdValue(NewParameter.Constants.RegisterSpace, RootFlagNode, 3))
+return reportError(Ctx, "Invalid value for RegisterSpace");
+
+  if (extractMdValue(NewParameter.Constants.Num32BitValues, RootFlagNode, 4))
+return reportError(Ctx, "Invalid value for Num32BitValues");
+
+  RSD.Parameters.push_back(NewParameter);
+
+  return false;
+}
+
 static bool parseRootSignatureElement(LLVMContext *Ctx,
   mcdxbc::RootSignatureDesc &RSD,
   MDNode *Element) {
@@ -62,12 +108,16 @@ static bool parseRootSignatureElement(LLVMContext *Ctx,
   RootSignatureElementKind ElementKind =
   StringSwitch(ElementText->getString())
   .Case("RootFlags", RootSignatureElementKind::RootFlags)
+  .Case("RootConstants", RootSignatureElementKind::RootConstants)
   .Default(RootSignatureElementKind::Error);
 
   switch (ElementKind) {
 
   case RootSignatureElementKind::RootFlags:
 return parseRootFlags(Ctx, RSD, Element);
+  case RootSignatureElementKind::RootConstants:
+return parseRootConstants(Ctx, RSD, Element);
+break;
   case RootSignatureElementKind::Error:
 return reportError(Ctx, "Invalid Root Signature Element: " +
 ElementText->getString());
@@ -94,10 +144,56 @@ static bool parse(LLVMContext *Ctx, 
mcdxbc::RootSignatureDesc &RSD,
 
 static bool verifyRootFlag(uint32_t Flags) { return (Flags & ~0xfff) == 0; }
 
+static bool verifyShaderVisibility(dxbc::ShaderVisibility Flags) {
+  switch (Flags) {
+
+  case dxbc::ShaderVisibility::All:
+  case dxbc::ShaderVisibility::Vertex:
+  case dxbc::ShaderVisibility::Hull:
+  case dxbc::ShaderVisibility::Domain:
+  case dxbc::ShaderVisibility::Geometry:
+  case dxbc::ShaderVisibility::Pixel:
+  case dxbc::ShaderVisibility::Amplification:
+  case dxbc::ShaderVisibility::Mesh:
+return true;
+  }
+
+  return false;
+}
+
+static bool verifyParameterType(dxbc::RootParameterType Flags) {
+  switch (Flags) {
+  case dxbc::RootParameterType::Constants32Bit:
+return true;
+  }
+
+  return false;
+}
+
+static bool verifyVersion(uint32_t Version) {
+  return (Version == 1 || Version == 2);
+}
+

[llvm-branch-commits] [libcxx] libcxx: In gdb test detect execute_mi with feature check instead of version check. (PR #132291)

2025-04-09 Thread Nikolas Klauser via llvm-branch-commits

philnik777 wrote:

Could you not use spr in that case? I can't see the diff as it would be merged 
AFAICT.

https://github.com/llvm/llvm-project/pull/132291
___
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] libcxx: In gdb test detect execute_mi with feature check instead of version check. (PR #132291)

2025-04-09 Thread Peter Collingbourne via llvm-branch-commits

pcc wrote:

Odd, if I go to https://github.com/llvm/llvm-project/pull/132291/files in
an incognito tab it just looks like this to me and that's what would be
applied.

On Wed, Apr 9, 2025, 00:03 Nikolas Klauser ***@***.***> wrote:

> Could you not use spr in that case? I can't see the diff as it would be
> merged AFAICT.
>
> —
> Reply to this email directly, view it on GitHub
> ,
> or unsubscribe
> 
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
> *philnik777* left a comment (llvm/llvm-project#132291)
> 
>
> Could you not use spr in that case? I can't see the diff as it would be
> merged AFAICT.
>
> —
> Reply to this email directly, view it on GitHub
> ,
> or unsubscribe
> 
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>


https://github.com/llvm/llvm-project/pull/132291
___
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] [polly] [Polly] Introduce PhaseManager and remove LPM support (PR #125442)

2025-04-09 Thread Karthika Devi C via llvm-branch-commits

https://github.com/kartcq edited 
https://github.com/llvm/llvm-project/pull/125442
___
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] SCEVExpander: Don't look at uses of constants (PR #134691)

2025-04-09 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

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

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




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


https://github.com/llvm/llvm-project/pull/134691
___
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] [KeyInstr][debugify] Add --debugify-atoms to add key instructions metadata (PR #133483)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/133483
___
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-tools-extra] [clang-tidy] treat unsigned char and signed char as char type by default in bugprone-unintended-char-ostream-output (PR #134870)

2025-04-09 Thread Donát Nagy via llvm-branch-commits

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

Overall looks good to me, I have one suggestion about the documentation.

https://github.com/llvm/llvm-project/pull/134870
___
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] [KeyInstr][SimplifyCFG] Remap atoms when folding br to common succ into pred (PR #133482)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits

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

Some minor nits, but this update looks correct.

https://github.com/llvm/llvm-project/pull/133482
___
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] [KeyInstr][SimplifyCFG] Remap atoms when folding br to common succ into pred (PR #133482)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits

https://github.com/SLTozer edited 
https://github.com/llvm/llvm-project/pull/133482
___
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] [KeyInstr][SimplifyCFG] Remap atoms when folding br to common succ into pred (PR #133482)

2025-04-09 Thread Stephen Tozer via llvm-branch-commits


@@ -1182,6 +1187,19 @@ static void 
cloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
   U.set(NewBonusInst);
 }
   }
+
+  // Key Instructions: We may have propagated atom info into the pred. If the
+  // pred's terminator already has atom info do nothing as merging would drop
+  // one atom group anyway. If it doesn't, propagte the remapped atom group
+  // from BB's terminator.
+  if (auto &PredDL = PredBlock->getTerminator()->getDebugLoc()) {

SLTozer wrote:

```suggestion
  if (auto &PredDL = PTI->getDebugLoc()) {
```
If I understand it, `PTI` is still `PredBlock`'s terminator?

https://github.com/llvm/llvm-project/pull/133482
___
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-tools-extra] [clang-tidy] treat unsigned char and signed char as char type by default in bugprone-unintended-char-ostream-output (PR #134870)

2025-04-09 Thread Donát Nagy via llvm-branch-commits


@@ -42,6 +42,14 @@ Or cast to char to explicitly indicate that output should be 
a character.
 Options
 ---
 
+.. option:: AllowedTypes
+
+  A semicolon-separated list of type names that will be treated as ``char``
+  type. It only contains the non canonical type names without the alias of type
+  names. Explicit casting to these types or use the variable defined with these
+  types will be ignored.

NagyDonat wrote:

```suggestion
  A semicolon-separated list of type names that will be treated like the 
``char``
  type: the check will not report variables declared with with these types or
  explicit cast expressions to these types. Note that this distinguishes type
  aliases from the original type, so specifying e.g. ``unsigned char`` here
  will not suppress reports about ``uint8_t`` even if it is defined as a
  ``typedef`` alias for ``unsigned char``.
```

The sentence "It only contains the non canonical type names without the alias 
of type names." was very difficult to understand, so I suggested an alternative 
(more verbose and – let's hope – more clear) phrasing. However, I'm not 100% 
sure that I understood the intended meaning correctly, so please check it and 
correct it if it's misleading or inaccurate.

https://github.com/llvm/llvm-project/pull/134870
___
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-tools-extra] [clang-tidy] treat unsigned char and signed char as char type by default in bugprone-unintended-char-ostream-output (PR #134870)

2025-04-09 Thread Donát Nagy via llvm-branch-commits

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