[llvm-branch-commits] [clang] [clang] callee_type metadata for indirect calls (PR #117036)

2025-07-21 Thread Prabhu Rajasekaran via llvm-branch-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/117036

>From b7fbe09b32ff02d4f7c52d82fbf8b5cd28138852 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 23 Apr 2025 04:05:47 +
Subject: [PATCH] Address review comments.

Created using spr 1.3.6-beta.1
---
 clang/lib/CodeGen/CGCall.cpp|  8 
 clang/lib/CodeGen/CodeGenModule.cpp | 10 +-
 clang/lib/CodeGen/CodeGenModule.h   |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 185ee1a970aac..d8ab7140f7943 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5780,19 +5780,19 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   if (callOrInvoke) {
 *callOrInvoke = CI;
 if (CGM.getCodeGenOpts().CallGraphSection) {
-  assert((TargetDecl && TargetDecl->getFunctionType() ||
-  Callee.getAbstractInfo().getCalleeFunctionProtoType()) &&
- "cannot find callsite type");
   QualType CST;
   if (TargetDecl && TargetDecl->getFunctionType())
 CST = QualType(TargetDecl->getFunctionType(), 0);
   else if (const auto *FPT =
Callee.getAbstractInfo().getCalleeFunctionProtoType())
 CST = QualType(FPT, 0);
+  else
+llvm_unreachable(
+"Cannot find the callee type to generate callee_type metadata.");
 
   // Set type identifier metadata of indirect calls for call graph section.
   if (!CST.isNull())
-CGM.CreateCalleeTypeMetadataForIcall(CST, *callOrInvoke);
+CGM.createCalleeTypeMetadataForIcall(CST, *callOrInvoke);
 }
   }
 
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 43cd2405571cf..2fc99639a75cb 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2654,7 +2654,7 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   // Skip available_externally functions. They won't be codegen'ed in the
   // current module anyway.
   if (getContext().GetGVALinkageForFunction(FD) != GVA_AvailableExternally)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 }
   }
 
@@ -2868,7 +2868,7 @@ static bool hasExistingGeneralizedTypeMD(llvm::Function 
*F) {
   return MD->hasGeneralizedMDString();
 }
 
-void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
llvm::Function *F) {
   if (CodeGenOpts.CallGraphSection && !hasExistingGeneralizedTypeMD(F) &&
   (!F->hasLocalLinkage() ||
@@ -2898,7 +2898,7 @@ void 
CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
   F->addTypeMetadata(0, llvm::ConstantAsMetadata::get(CrossDsoTypeId));
 }
 
-void CodeGenModule::CreateCalleeTypeMetadataForIcall(const QualType &QT,
+void CodeGenModule::createCalleeTypeMetadataForIcall(const QualType &QT,
  llvm::CallBase *CB) {
   // Only if needed for call graph section and only for indirect calls.
   if (!CodeGenOpts.CallGraphSection || !CB->isIndirectCall())
@@ -2909,7 +2909,7 @@ void 
CodeGenModule::CreateCalleeTypeMetadataForIcall(const QualType &QT,
   getLLVMContext(), {llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
  llvm::Type::getInt64Ty(getLLVMContext()), 0)),
  TypeIdMD});
-  llvm::MDTuple *MDN = llvm::MDNode::get(getLLVMContext(), { TypeTuple });
+  llvm::MDTuple *MDN = llvm::MDNode::get(getLLVMContext(), {TypeTuple});
   CB->setMetadata(llvm::LLVMContext::MD_callee_type, MDN);
 }
 
@@ -3041,7 +3041,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   // jump table.
   if (!CodeGenOpts.SanitizeCfiCrossDso ||
   !CodeGenOpts.SanitizeCfiCanonicalJumpTables)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 
   if (LangOpts.Sanitize.has(SanitizerKind::KCFI))
 setKCFIType(FD, F);
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index dfbe4388349dd..4b53f0f241b52 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1619,11 +1619,11 @@ class CodeGenModule : public CodeGenTypeCache {
   llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T);
 
   /// Create and attach type metadata to the given function.
-  void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+  void createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
   llvm::Function *F);
 
   /// Create and attach type metadata to the given call.
-  void CreateCalleeTypeMetadataForIcall(const QualType &QT, llvm::CallBase 
*CB);
+  void createCa

[llvm-branch-commits] [clang] [clang] callee_type metadata for indirect calls (PR #117036)

2025-07-21 Thread Prabhu Rajasekaran via llvm-branch-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/117036

>From b7fbe09b32ff02d4f7c52d82fbf8b5cd28138852 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 23 Apr 2025 04:05:47 +
Subject: [PATCH] Address review comments.

Created using spr 1.3.6-beta.1
---
 clang/lib/CodeGen/CGCall.cpp|  8 
 clang/lib/CodeGen/CodeGenModule.cpp | 10 +-
 clang/lib/CodeGen/CodeGenModule.h   |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 185ee1a970aac..d8ab7140f7943 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5780,19 +5780,19 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   if (callOrInvoke) {
 *callOrInvoke = CI;
 if (CGM.getCodeGenOpts().CallGraphSection) {
-  assert((TargetDecl && TargetDecl->getFunctionType() ||
-  Callee.getAbstractInfo().getCalleeFunctionProtoType()) &&
- "cannot find callsite type");
   QualType CST;
   if (TargetDecl && TargetDecl->getFunctionType())
 CST = QualType(TargetDecl->getFunctionType(), 0);
   else if (const auto *FPT =
Callee.getAbstractInfo().getCalleeFunctionProtoType())
 CST = QualType(FPT, 0);
+  else
+llvm_unreachable(
+"Cannot find the callee type to generate callee_type metadata.");
 
   // Set type identifier metadata of indirect calls for call graph section.
   if (!CST.isNull())
-CGM.CreateCalleeTypeMetadataForIcall(CST, *callOrInvoke);
+CGM.createCalleeTypeMetadataForIcall(CST, *callOrInvoke);
 }
   }
 
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 43cd2405571cf..2fc99639a75cb 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2654,7 +2654,7 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   // Skip available_externally functions. They won't be codegen'ed in the
   // current module anyway.
   if (getContext().GetGVALinkageForFunction(FD) != GVA_AvailableExternally)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 }
   }
 
@@ -2868,7 +2868,7 @@ static bool hasExistingGeneralizedTypeMD(llvm::Function 
*F) {
   return MD->hasGeneralizedMDString();
 }
 
-void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
llvm::Function *F) {
   if (CodeGenOpts.CallGraphSection && !hasExistingGeneralizedTypeMD(F) &&
   (!F->hasLocalLinkage() ||
@@ -2898,7 +2898,7 @@ void 
CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
   F->addTypeMetadata(0, llvm::ConstantAsMetadata::get(CrossDsoTypeId));
 }
 
-void CodeGenModule::CreateCalleeTypeMetadataForIcall(const QualType &QT,
+void CodeGenModule::createCalleeTypeMetadataForIcall(const QualType &QT,
  llvm::CallBase *CB) {
   // Only if needed for call graph section and only for indirect calls.
   if (!CodeGenOpts.CallGraphSection || !CB->isIndirectCall())
@@ -2909,7 +2909,7 @@ void 
CodeGenModule::CreateCalleeTypeMetadataForIcall(const QualType &QT,
   getLLVMContext(), {llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
  llvm::Type::getInt64Ty(getLLVMContext()), 0)),
  TypeIdMD});
-  llvm::MDTuple *MDN = llvm::MDNode::get(getLLVMContext(), { TypeTuple });
+  llvm::MDTuple *MDN = llvm::MDNode::get(getLLVMContext(), {TypeTuple});
   CB->setMetadata(llvm::LLVMContext::MD_callee_type, MDN);
 }
 
@@ -3041,7 +3041,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   // jump table.
   if (!CodeGenOpts.SanitizeCfiCrossDso ||
   !CodeGenOpts.SanitizeCfiCanonicalJumpTables)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 
   if (LangOpts.Sanitize.has(SanitizerKind::KCFI))
 setKCFIType(FD, F);
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index dfbe4388349dd..4b53f0f241b52 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1619,11 +1619,11 @@ class CodeGenModule : public CodeGenTypeCache {
   llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T);
 
   /// Create and attach type metadata to the given function.
-  void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+  void createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
   llvm::Function *F);
 
   /// Create and attach type metadata to the given call.
-  void CreateCalleeTypeMetadataForIcall(const QualType &QT, llvm::CallBase 
*CB);
+  void createCa

[llvm-branch-commits] [clang] [llvm] [DirectX] Add Range Overlap validation to `DXILPostOptimizationValidation.cpp` (PR #148919)

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

https://github.com/joaosaffran edited 
https://github.com/llvm/llvm-project/pull/148919
___
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] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits


@@ -63,7 +63,7 @@ def test_a_struct(self):
 self.assertIsNotNone(fields[1].translation_unit)
 self.assertEqual(fields[1].spelling, "b")
 self.assertFalse(fields[1].type.is_const_qualified())
-self.assertEqual(fields[1].type.kind, TypeKind.ELABORATED)
+self.assertEqual(fields[1].type.kind, TypeKind.TYPEDEF)

mizvekov wrote:

Alright, I'll leave the enum for now, we will have until clang 22 ships in 
order to revisit this.

https://github.com/llvm/llvm-project/pull/148012
___
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] Introduce CallGraphSection option (PR #117037)

2025-07-21 Thread Prabhu Rajasekaran via llvm-branch-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/117037

>From 6a12be2c5b60a95a06875b0b2c4f14228d1fa882 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Wed, 12 Mar 2025 23:30:01 +
Subject: [PATCH 1/2] Fix EOF newlines.

Created using spr 1.3.6-beta.1
---
 clang/test/Driver/call-graph-section.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Driver/call-graph-section.c 
b/clang/test/Driver/call-graph-section.c
index 108446729d857..5832aa6754137 100644
--- a/clang/test/Driver/call-graph-section.c
+++ b/clang/test/Driver/call-graph-section.c
@@ -2,4 +2,4 @@
 // RUN: %clang -### -S -fcall-graph-section -fno-call-graph-section %s 2>&1 | 
FileCheck --check-prefix=NO-CALL-GRAPH-SECTION %s
 
 // CALL-GRAPH-SECTION: "-fcall-graph-section"
-// NO-CALL-GRAPH-SECTION-NOT: "-fcall-graph-section"
\ No newline at end of file
+// NO-CALL-GRAPH-SECTION-NOT: "-fcall-graph-section"

>From c67f714eaab9a7f1e4d2d76da28641b05710231d Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Mon, 21 Jul 2025 23:53:52 +
Subject: [PATCH 2/2] Fix review comment on test file.

Created using spr 1.3.6-beta.1
---
 clang/test/Driver/call-graph-section.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/call-graph-section.c 
b/clang/test/Driver/call-graph-section.c
index 5832aa6754137..563f36de4119e 100644
--- a/clang/test/Driver/call-graph-section.c
+++ b/clang/test/Driver/call-graph-section.c
@@ -1,5 +1,5 @@
-// RUN: %clang -### -S -fcall-graph-section %s 2>&1 | FileCheck 
--check-prefix=CALL-GRAPH-SECTION %s
-// RUN: %clang -### -S -fcall-graph-section -fno-call-graph-section %s 2>&1 | 
FileCheck --check-prefix=NO-CALL-GRAPH-SECTION %s
+// RUN: %clang -### -fcall-graph-section %s 2>&1 | FileCheck 
--check-prefix=CALL-GRAPH-SECTION %s
+// RUN: %clang -### -fcall-graph-section -fno-call-graph-section %s 2>&1 | 
FileCheck --check-prefix=NO-CALL-GRAPH-SECTION %s
 
 // CALL-GRAPH-SECTION: "-fcall-graph-section"
 // NO-CALL-GRAPH-SECTION-NOT: "-fcall-graph-section"

___
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] [PATCH 4/6] [clang] Improve nested name specifier AST representation (PR #148015)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/148015

>From 07588c1311f9f2149057e2aa765bb4922b06244f Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 10 Jul 2025 14:07:34 -0300
Subject: [PATCH] [PATCH 4/6] [clang] Improve nested name specifier AST
 representation

clang tools extra changes
---
 .../find-all-symbols/FindAllSymbols.cpp   |  3 +-
 .../CrtpConstructorAccessibilityCheck.cpp |  6 ++-
 .../EasilySwappableParametersCheck.cpp| 14 ++---
 .../ForwardDeclarationNamespaceCheck.cpp  | 11 ++--
 .../bugprone/IncorrectEnableIfCheck.cpp   | 19 +++
 .../bugprone/SizeofExpressionCheck.cpp| 10 ++--
 .../NoSuspendWithLockCheck.cpp|  4 +-
 .../google/AvoidCStyleCastsCheck.cpp  | 31 ---
 .../google/UpgradeGoogletestCaseCheck.cpp |  9 +++-
 .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 11 ++--
 .../clang-tidy/misc/MisplacedConstCheck.cpp   | 14 ++---
 .../misc/RedundantExpressionCheck.cpp |  5 +-
 .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp |  6 +--
 .../DeprecatedIosBaseAliasesCheck.cpp | 11 ++--
 .../clang-tidy/modernize/PassByValueCheck.cpp |  3 +-
 .../modernize/ReplaceAutoPtrCheck.cpp | 15 +++---
 .../clang-tidy/modernize/TypeTraitsCheck.cpp  | 34 
 .../clang-tidy/modernize/UseAutoCheck.cpp | 18 +++
 .../modernize/UseConstraintsCheck.cpp |  7 ++-
 .../clang-tidy/modernize/UseEmplaceCheck.cpp  | 53 +--
 .../modernize/UseScopedLockCheck.cpp  | 41 +-
 .../modernize/UseTransparentFunctorsCheck.cpp | 16 +++---
 .../performance/NoAutomaticMoveCheck.cpp  |  8 +--
 .../portability/StdAllocatorConstCheck.cpp| 11 ++--
 .../readability/UseStdMinMaxCheck.cpp |  6 +--
 .../clang-tidy/utils/Matchers.cpp |  2 +-
 .../utils/RenamerClangTidyCheck.cpp   | 30 +++
 clang-tools-extra/clangd/AST.cpp  | 11 ++--
 clang-tools-extra/clangd/AST.h|  3 +-
 clang-tools-extra/clangd/DumpAST.cpp  |  6 ++-
 clang-tools-extra/clangd/FindTarget.cpp   | 36 ++---
 clang-tools-extra/clangd/Hover.cpp| 18 ---
 clang-tools-extra/clangd/InlayHints.cpp   | 28 +-
 clang-tools-extra/clangd/Selection.cpp| 15 +++---
 clang-tools-extra/clangd/XRefs.cpp| 13 +++--
 .../refactor/tweaks/ExtractFunction.cpp   |  5 +-
 .../clangd/unittests/ASTTests.cpp |  7 +--
 .../clangd/unittests/DumpASTTests.cpp | 15 +++---
 .../clangd/unittests/HoverTests.cpp   | 10 ++--
 .../clangd/unittests/InlayHintTests.cpp   |  9 +---
 .../clangd/unittests/QualityTests.cpp | 14 +++--
 .../include-cleaner/lib/WalkAST.cpp   |  6 +--
 .../bugprone/copy-constructor-init.cpp|  1 -
 .../unused-local-non-trivial-variable.cpp |  6 +--
 .../portability/std-allocator-const.cpp   | 22 
 45 files changed, 289 insertions(+), 334 deletions(-)

diff --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp 
b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
index bb48883f88815..1f30d27c0a54f 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -216,8 +216,7 @@ void FindAllSymbols::registerMatchers(MatchFinder 
*MatchFinder) {
   // Uses of most types: just look at what the typeLoc refers to.
   MatchFinder->addMatcher(
   typeLoc(isExpansionInMainFile(),
-  loc(qualType(allOf(unless(elaboratedType()),
- hasDeclaration(Types.bind("use")),
+  loc(qualType(hasDeclaration(Types.bind("use"),
   this);
   // Uses of typedefs: these are often transparent to hasDeclaration, so we 
need
   // to handle them explicitly.
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
index 6565fa3f7c85b..0625468d9da88 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
@@ -43,7 +43,8 @@ static bool isDerivedClassBefriended(const CXXRecordDecl 
*CRTP,
   return false;
 }
 
-return FriendType->getType()->getAsCXXRecordDecl() == Derived;
+return declaresSameEntity(FriendType->getType()->getAsCXXRecordDecl(),
+  Derived);
   });
 }
 
@@ -55,7 +56,8 @@ getDerivedParameter(const ClassTemplateSpecializationDecl 
*CRTP,
   CRTP->getTemplateArgs().asArray(), [&](const TemplateArgument &Arg) {
 ++Idx;
 return Arg.getKind() == TemplateArgument::Type &&
-   Arg.getAsType()->getAsCXXRecordDecl() == Derived;
+   declaresSameEntity(Arg.getAsType()->getAsCXXRecordDecl(

[llvm-branch-commits] [clang-tools-extra] [PATCH 4/6] [clang] Improve nested name specifier AST representation (PR #148015)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/148015

>From 07588c1311f9f2149057e2aa765bb4922b06244f Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 10 Jul 2025 14:07:34 -0300
Subject: [PATCH] [PATCH 4/6] [clang] Improve nested name specifier AST
 representation

clang tools extra changes
---
 .../find-all-symbols/FindAllSymbols.cpp   |  3 +-
 .../CrtpConstructorAccessibilityCheck.cpp |  6 ++-
 .../EasilySwappableParametersCheck.cpp| 14 ++---
 .../ForwardDeclarationNamespaceCheck.cpp  | 11 ++--
 .../bugprone/IncorrectEnableIfCheck.cpp   | 19 +++
 .../bugprone/SizeofExpressionCheck.cpp| 10 ++--
 .../NoSuspendWithLockCheck.cpp|  4 +-
 .../google/AvoidCStyleCastsCheck.cpp  | 31 ---
 .../google/UpgradeGoogletestCaseCheck.cpp |  9 +++-
 .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 11 ++--
 .../clang-tidy/misc/MisplacedConstCheck.cpp   | 14 ++---
 .../misc/RedundantExpressionCheck.cpp |  5 +-
 .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp |  6 +--
 .../DeprecatedIosBaseAliasesCheck.cpp | 11 ++--
 .../clang-tidy/modernize/PassByValueCheck.cpp |  3 +-
 .../modernize/ReplaceAutoPtrCheck.cpp | 15 +++---
 .../clang-tidy/modernize/TypeTraitsCheck.cpp  | 34 
 .../clang-tidy/modernize/UseAutoCheck.cpp | 18 +++
 .../modernize/UseConstraintsCheck.cpp |  7 ++-
 .../clang-tidy/modernize/UseEmplaceCheck.cpp  | 53 +--
 .../modernize/UseScopedLockCheck.cpp  | 41 +-
 .../modernize/UseTransparentFunctorsCheck.cpp | 16 +++---
 .../performance/NoAutomaticMoveCheck.cpp  |  8 +--
 .../portability/StdAllocatorConstCheck.cpp| 11 ++--
 .../readability/UseStdMinMaxCheck.cpp |  6 +--
 .../clang-tidy/utils/Matchers.cpp |  2 +-
 .../utils/RenamerClangTidyCheck.cpp   | 30 +++
 clang-tools-extra/clangd/AST.cpp  | 11 ++--
 clang-tools-extra/clangd/AST.h|  3 +-
 clang-tools-extra/clangd/DumpAST.cpp  |  6 ++-
 clang-tools-extra/clangd/FindTarget.cpp   | 36 ++---
 clang-tools-extra/clangd/Hover.cpp| 18 ---
 clang-tools-extra/clangd/InlayHints.cpp   | 28 +-
 clang-tools-extra/clangd/Selection.cpp| 15 +++---
 clang-tools-extra/clangd/XRefs.cpp| 13 +++--
 .../refactor/tweaks/ExtractFunction.cpp   |  5 +-
 .../clangd/unittests/ASTTests.cpp |  7 +--
 .../clangd/unittests/DumpASTTests.cpp | 15 +++---
 .../clangd/unittests/HoverTests.cpp   | 10 ++--
 .../clangd/unittests/InlayHintTests.cpp   |  9 +---
 .../clangd/unittests/QualityTests.cpp | 14 +++--
 .../include-cleaner/lib/WalkAST.cpp   |  6 +--
 .../bugprone/copy-constructor-init.cpp|  1 -
 .../unused-local-non-trivial-variable.cpp |  6 +--
 .../portability/std-allocator-const.cpp   | 22 
 45 files changed, 289 insertions(+), 334 deletions(-)

diff --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp 
b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
index bb48883f88815..1f30d27c0a54f 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -216,8 +216,7 @@ void FindAllSymbols::registerMatchers(MatchFinder 
*MatchFinder) {
   // Uses of most types: just look at what the typeLoc refers to.
   MatchFinder->addMatcher(
   typeLoc(isExpansionInMainFile(),
-  loc(qualType(allOf(unless(elaboratedType()),
- hasDeclaration(Types.bind("use")),
+  loc(qualType(hasDeclaration(Types.bind("use"),
   this);
   // Uses of typedefs: these are often transparent to hasDeclaration, so we 
need
   // to handle them explicitly.
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
index 6565fa3f7c85b..0625468d9da88 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
@@ -43,7 +43,8 @@ static bool isDerivedClassBefriended(const CXXRecordDecl 
*CRTP,
   return false;
 }
 
-return FriendType->getType()->getAsCXXRecordDecl() == Derived;
+return declaresSameEntity(FriendType->getType()->getAsCXXRecordDecl(),
+  Derived);
   });
 }
 
@@ -55,7 +56,8 @@ getDerivedParameter(const ClassTemplateSpecializationDecl 
*CRTP,
   CRTP->getTemplateArgs().asArray(), [&](const TemplateArgument &Arg) {
 ++Idx;
 return Arg.getKind() == TemplateArgument::Type &&
-   Arg.getAsType()->getAsCXXRecordDecl() == Derived;
+   declaresSameEntity(Arg.getAsType()->getAsCXXRecordDecl(

[llvm-branch-commits] [clang] [clang-tools-extra] [PATCH 6/6] [clang] improve NestedNameSpecifier (PR #149748)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

mizvekov wrote:

@erichkeane this was the only patch in the series you didn't review. FYI in 
case this was an oversight.

https://github.com/llvm/llvm-project/pull/149748
___
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] [DirectX] Add Range Overlap validation to `DXILPostOptimizationValidation.cpp` (PR #148919)

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


@@ -0,0 +1,15 @@
+; RUN: not opt -S -passes='dxil-post-optimization-validation' 
-mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
+; CHECK: error: register CBuffer (space=0, register=0) is overlapping with 
register CBuffer (space=0, register=2), verify your root signature definition
+
+define void @CSMain() "hlsl.shader"="compute" {
+entry:
+  ret void
+}
+
+; RootConstants(num32BitConstants=4, b2), DescriptorTable(CBV(b10, 
numDescriptors=3))

joaosaffran wrote:

Thanks, it was supposed to be: `RootConstants(num32BitConstants=4, b2), 
DescriptorTable(CBV(b0, numDescriptors=3))`. In that case, `b2` will overlap.

https://github.com/llvm/llvm-project/pull/148919
___
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] Drive profile validator from opt (PR #147418)

2025-07-21 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/147418

>From 92334f8f489ca22bc05d7bb34a8793ae758380a1 Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Mon, 7 Jul 2025 12:44:41 -0700
Subject: [PATCH] Drive profile validator from opt

---
 llvm/tools/opt/NewPMDriver.cpp | 8 ++--
 llvm/tools/opt/NewPMDriver.h   | 2 +-
 llvm/tools/opt/optdriver.cpp   | 7 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 7d168a6ceb17c..042ed027639bc 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Transforms/Utils/Debugify.h"
+#include "llvm/Transforms/Utils/ProfileValidation.h"
 
 using namespace llvm;
 using namespace opt_tool;
@@ -356,7 +357,7 @@ bool llvm::runPassPipeline(
 OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder,
 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
-bool UnifiedLTO) {
+bool EnableProfcheck, bool UnifiedLTO) {
   auto FS = vfs::getRealFileSystem();
   std::optional P;
   switch (PGOKindFlag) {
@@ -487,7 +488,8 @@ bool llvm::runPassPipeline(
   if (VerifyDIPreserve)
 MPM.addPass(NewPMDebugifyPass(DebugifyMode::OriginalDebugInfo, "",
   &DebugInfoBeforePass));
-
+  if (EnableProfcheck)
+MPM.addPass(createModuleToFunctionPassAdaptor(ProfileInjectorPass()));
   // Add passes according to the -passes options.
   if (!PassPipeline.empty()) {
 if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
@@ -504,6 +506,8 @@ bool llvm::runPassPipeline(
 MPM.addPass(NewPMCheckDebugifyPass(
 false, "", nullptr, DebugifyMode::OriginalDebugInfo,
 &DebugInfoBeforePass, VerifyDIPreserveExport));
+  if (EnableProfcheck)
+MPM.addPass(createModuleToFunctionPassAdaptor(ProfileVerifierPass()));
 
   // Add any relevant output pass at the end of the pipeline.
   switch (OK) {
diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h
index 2daae571e72c2..6c21d6cae4e75 100644
--- a/llvm/tools/opt/NewPMDriver.h
+++ b/llvm/tools/opt/NewPMDriver.h
@@ -75,7 +75,7 @@ bool runPassPipeline(
 bool ShouldPreserveAssemblyUseListOrder,
 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
-bool UnifiedLTO = false);
+bool EnableProfcheck, bool UnifiedLTO = false);
 } // namespace llvm
 
 #endif
diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp
index de46efa13025d..9b60ae6543336 100644
--- a/llvm/tools/opt/optdriver.cpp
+++ b/llvm/tools/opt/optdriver.cpp
@@ -213,6 +213,10 @@ static cl::opt VerifyDebugInfoPreserve(
 cl::desc("Start the pipeline with collecting and end it with checking of "
  "debug info preservation."));
 
+static cl::opt EnableProfileVerification(
+"enable-profcheck", cl::init(false),
+cl::desc("Start the pipeline with prof-inject and end it with 
prof-check"));
+
 static cl::opt ClDataLayout("data-layout",
  cl::desc("data layout string to use"),
  cl::value_desc("layout-string"),
@@ -731,7 +735,8 @@ extern "C" int optMain(
RemarksFile.get(), Pipeline, PluginList, PassBuilderCallbacks,
OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash,
-   EnableDebugify, VerifyDebugInfoPreserve, UnifiedLTO)
+   EnableDebugify, VerifyDebugInfoPreserve,
+   EnableProfileVerification, UnifiedLTO)
? 0
: 1;
   }

___
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] Drive profile validator from opt (PR #147418)

2025-07-21 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/147418

>From 92334f8f489ca22bc05d7bb34a8793ae758380a1 Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Mon, 7 Jul 2025 12:44:41 -0700
Subject: [PATCH] Drive profile validator from opt

---
 llvm/tools/opt/NewPMDriver.cpp | 8 ++--
 llvm/tools/opt/NewPMDriver.h   | 2 +-
 llvm/tools/opt/optdriver.cpp   | 7 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 7d168a6ceb17c..042ed027639bc 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Transforms/Utils/Debugify.h"
+#include "llvm/Transforms/Utils/ProfileValidation.h"
 
 using namespace llvm;
 using namespace opt_tool;
@@ -356,7 +357,7 @@ bool llvm::runPassPipeline(
 OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder,
 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
-bool UnifiedLTO) {
+bool EnableProfcheck, bool UnifiedLTO) {
   auto FS = vfs::getRealFileSystem();
   std::optional P;
   switch (PGOKindFlag) {
@@ -487,7 +488,8 @@ bool llvm::runPassPipeline(
   if (VerifyDIPreserve)
 MPM.addPass(NewPMDebugifyPass(DebugifyMode::OriginalDebugInfo, "",
   &DebugInfoBeforePass));
-
+  if (EnableProfcheck)
+MPM.addPass(createModuleToFunctionPassAdaptor(ProfileInjectorPass()));
   // Add passes according to the -passes options.
   if (!PassPipeline.empty()) {
 if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
@@ -504,6 +506,8 @@ bool llvm::runPassPipeline(
 MPM.addPass(NewPMCheckDebugifyPass(
 false, "", nullptr, DebugifyMode::OriginalDebugInfo,
 &DebugInfoBeforePass, VerifyDIPreserveExport));
+  if (EnableProfcheck)
+MPM.addPass(createModuleToFunctionPassAdaptor(ProfileVerifierPass()));
 
   // Add any relevant output pass at the end of the pipeline.
   switch (OK) {
diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h
index 2daae571e72c2..6c21d6cae4e75 100644
--- a/llvm/tools/opt/NewPMDriver.h
+++ b/llvm/tools/opt/NewPMDriver.h
@@ -75,7 +75,7 @@ bool runPassPipeline(
 bool ShouldPreserveAssemblyUseListOrder,
 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
-bool UnifiedLTO = false);
+bool EnableProfcheck, bool UnifiedLTO = false);
 } // namespace llvm
 
 #endif
diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp
index de46efa13025d..9b60ae6543336 100644
--- a/llvm/tools/opt/optdriver.cpp
+++ b/llvm/tools/opt/optdriver.cpp
@@ -213,6 +213,10 @@ static cl::opt VerifyDebugInfoPreserve(
 cl::desc("Start the pipeline with collecting and end it with checking of "
  "debug info preservation."));
 
+static cl::opt EnableProfileVerification(
+"enable-profcheck", cl::init(false),
+cl::desc("Start the pipeline with prof-inject and end it with 
prof-check"));
+
 static cl::opt ClDataLayout("data-layout",
  cl::desc("data layout string to use"),
  cl::value_desc("layout-string"),
@@ -731,7 +735,8 @@ extern "C" int optMain(
RemarksFile.get(), Pipeline, PluginList, PassBuilderCallbacks,
OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash,
-   EnableDebugify, VerifyDebugInfoPreserve, UnifiedLTO)
+   EnableDebugify, VerifyDebugInfoPreserve,
+   EnableProfileVerification, UnifiedLTO)
? 0
: 1;
   }

___
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] Draft: [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

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

Test run of the LLDB CI, just checking if anything needs to be updated there.

>From 3c8cbad51fa481cf59392e9d25cdbdc7fdfbeff4 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] Draft: [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB
 changes

Test run of the LLDB CI, just checking if anything needs to be updated there.
---
 lldb/DELETE.ME | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 lldb/DELETE.ME

diff --git a/lldb/DELETE.ME b/lldb/DELETE.ME
new file mode 100644
index 0..e69de29bb2d1d

___
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] Draft: [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

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

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Matheus Izvekov (mizvekov)


Changes

Test run of the LLDB CI, just checking if anything needs to be updated there.

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


1 Files Affected:

- (added) lldb/DELETE.ME () 


``diff
diff --git a/lldb/DELETE.ME b/lldb/DELETE.ME
new file mode 100644
index 0..e69de29bb2d1d

``




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


[llvm-branch-commits] [llvm] release/21.x: [MachinePipeliner] Fix incorrect dependency direction (#149436) (PR #149950)

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

llvmbot wrote:




@llvm/pr-subscribers-backend-hexagon

Author: None (llvmbot)


Changes

Backport 6df012ab48ececd27359bdc9448ee101b39eea7a

Requested by: @kasuga-fj

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


2 Files Affected:

- (modified) llvm/lib/CodeGen/MachinePipeliner.cpp (+2-2) 
- (added) llvm/test/CodeGen/Hexagon/swp-load-to-store-forward.mir (+50) 


``diff
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp 
b/llvm/lib/CodeGen/MachinePipeliner.cpp
index b38a4d1c55af9..90005bd181f3a 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -4279,8 +4279,8 @@ void LoopCarriedEdges::modifySUnits(std::vector 
&SUnits,
 !TII->isGlobalMemoryObject(FromMI) &&
 !TII->isGlobalMemoryObject(ToMI) && !isSuccOrder(From, To)) {
   SDep Pred = Dep;
-  Pred.setSUnit(Src);
-  Dst->addPred(Pred);
+  Pred.setSUnit(From);
+  To->addPred(Pred);
 }
   }
 }
diff --git a/llvm/test/CodeGen/Hexagon/swp-load-to-store-forward.mir 
b/llvm/test/CodeGen/Hexagon/swp-load-to-store-forward.mir
new file mode 100644
index 0..2960343564fca
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/swp-load-to-store-forward.mir
@@ -0,0 +1,50 @@
+# RUN: llc -mtriple=hexagon -run-pass pipeliner %s -o /dev/null
+
+# Check that edges that violate topological order are not added to the
+# SwingSchedulerDAG. This is a case where the crash was caused by PR 145878.
+
+--- |
+  target triple = "hexagon"
+  
+  define void @crash_145878() {
+  entry:
+br label %loop
+  
+  loop: ; preds = %loop, %entry
+%lsr.iv2 = phi i32 [ %lsr.iv.next, %loop ], [ 1, %entry ]
+%lsr.iv = phi ptr [ %cgep3, %loop ], [ inttoptr (i32 -8 to ptr), %entry ]
+%cgep = getelementptr i8, ptr %lsr.iv, i32 12
+%load = load i32, ptr %cgep, align 4
+store i32 %load, ptr %lsr.iv, align 4
+%lsr.iv.next = add nsw i32 %lsr.iv2, -1
+%iv.cmp.not = icmp eq i32 %lsr.iv.next, 0
+%cgep3 = getelementptr i8, ptr %lsr.iv, i32 -8
+br i1 %iv.cmp.not, label %exit, label %loop
+  
+  exit: ; preds = %loop
+ret void
+  }
+...
+---
+name:crash_145878
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+successors: %bb.1(0x8000)
+  
+%5:intregs = A2_tfrsi -8
+J2_loop0i %bb.1, 1, implicit-def $lc0, implicit-def $sa0, implicit-def $usr
+  
+  bb.1.loop (machine-block-address-taken):
+successors: %bb.2(0x0400), %bb.1(0x7c00)
+  
+%1:intregs = PHI %5, %bb.0, %3, %bb.1
+%6:intregs = L2_loadri_io %1, 12 :: (load (s32) from %ir.cgep)
+S2_storeri_io %1, 0, killed %6 :: (store (s32) into %ir.lsr.iv)
+%3:intregs = A2_addi %1, -8
+ENDLOOP0 %bb.1, implicit-def $pc, implicit-def $lc0, implicit $sa0, 
implicit $lc0
+J2_jump %bb.2, implicit-def dead $pc
+  
+  bb.2.exit:
+PS_jmpret $r31, implicit-def dead $pc
+...

``




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


[llvm-branch-commits] [llvm] release/21.x: [MachinePipeliner] Fix incorrect dependency direction (#149436) (PR #149950)

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

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

Backport 6df012ab48ececd27359bdc9448ee101b39eea7a

Requested by: @kasuga-fj

>From e9fe97ff112a6d6aec6319b7d434f3758ef53bcd Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga 
Date: Tue, 22 Jul 2025 09:53:13 +0900
Subject: [PATCH] [MachinePipeliner] Fix incorrect dependency direction
 (#149436)

This patch fixes a bug introduced in #145878. A dependency was added in
the wrong direction, causing an assertion failure due to broken
topological order.

(cherry picked from commit 6df012ab48ececd27359bdc9448ee101b39eea7a)
---
 llvm/lib/CodeGen/MachinePipeliner.cpp |  4 +-
 .../Hexagon/swp-load-to-store-forward.mir | 50 +++
 2 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/Hexagon/swp-load-to-store-forward.mir

diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp 
b/llvm/lib/CodeGen/MachinePipeliner.cpp
index b38a4d1c55af9..90005bd181f3a 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -4279,8 +4279,8 @@ void LoopCarriedEdges::modifySUnits(std::vector 
&SUnits,
 !TII->isGlobalMemoryObject(FromMI) &&
 !TII->isGlobalMemoryObject(ToMI) && !isSuccOrder(From, To)) {
   SDep Pred = Dep;
-  Pred.setSUnit(Src);
-  Dst->addPred(Pred);
+  Pred.setSUnit(From);
+  To->addPred(Pred);
 }
   }
 }
diff --git a/llvm/test/CodeGen/Hexagon/swp-load-to-store-forward.mir 
b/llvm/test/CodeGen/Hexagon/swp-load-to-store-forward.mir
new file mode 100644
index 0..2960343564fca
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/swp-load-to-store-forward.mir
@@ -0,0 +1,50 @@
+# RUN: llc -mtriple=hexagon -run-pass pipeliner %s -o /dev/null
+
+# Check that edges that violate topological order are not added to the
+# SwingSchedulerDAG. This is a case where the crash was caused by PR 145878.
+
+--- |
+  target triple = "hexagon"
+  
+  define void @crash_145878() {
+  entry:
+br label %loop
+  
+  loop: ; preds = %loop, %entry
+%lsr.iv2 = phi i32 [ %lsr.iv.next, %loop ], [ 1, %entry ]
+%lsr.iv = phi ptr [ %cgep3, %loop ], [ inttoptr (i32 -8 to ptr), %entry ]
+%cgep = getelementptr i8, ptr %lsr.iv, i32 12
+%load = load i32, ptr %cgep, align 4
+store i32 %load, ptr %lsr.iv, align 4
+%lsr.iv.next = add nsw i32 %lsr.iv2, -1
+%iv.cmp.not = icmp eq i32 %lsr.iv.next, 0
+%cgep3 = getelementptr i8, ptr %lsr.iv, i32 -8
+br i1 %iv.cmp.not, label %exit, label %loop
+  
+  exit: ; preds = %loop
+ret void
+  }
+...
+---
+name:crash_145878
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+successors: %bb.1(0x8000)
+  
+%5:intregs = A2_tfrsi -8
+J2_loop0i %bb.1, 1, implicit-def $lc0, implicit-def $sa0, implicit-def $usr
+  
+  bb.1.loop (machine-block-address-taken):
+successors: %bb.2(0x0400), %bb.1(0x7c00)
+  
+%1:intregs = PHI %5, %bb.0, %3, %bb.1
+%6:intregs = L2_loadri_io %1, 12 :: (load (s32) from %ir.cgep)
+S2_storeri_io %1, 0, killed %6 :: (store (s32) into %ir.lsr.iv)
+%3:intregs = A2_addi %1, -8
+ENDLOOP0 %bb.1, implicit-def $pc, implicit-def $lc0, implicit $sa0, 
implicit $lc0
+J2_jump %bb.2, implicit-def dead $pc
+  
+  bb.2.exit:
+PS_jmpret $r31, implicit-def dead $pc
+...

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


[llvm-branch-commits] [llvm] release/21.x: [MachinePipeliner] Fix incorrect dependency direction (#149436) (PR #149950)

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

llvmbot wrote:

@aankit-ca What do you think about merging this PR to the release branch?

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


[llvm-branch-commits] [llvm] release/21.x: [MachinePipeliner] Fix incorrect dependency direction (#149436) (PR #149950)

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

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


[llvm-branch-commits] [llvm] release/21.x: [LoongArch] Fix failure to widen operand for `[X]VMSK{LT, GE, NE}Z` (#149442) (PR #149778)

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

tangaac wrote:

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

I agree.

https://github.com/llvm/llvm-project/pull/149778
___
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/21.x: [Mips] Correctly define IntPtrType (#145158) (PR #149846)

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

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


https://github.com/llvm/llvm-project/pull/149846
___
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] [LoongArch] Optimize general fp build_vector lowering (PR #149486)

2025-07-21 Thread Lu Weining via llvm-branch-commits

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

AArch64 has similar logic.
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp#L15259-L15286

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


[llvm-branch-commits] [llvm] release/21.x: [LoongArch] Strengthen stack size estimation for LSX/LASX extension (#146455) (PR #149777)

2025-07-21 Thread Lu Weining via llvm-branch-commits

https://github.com/SixWeining updated 
https://github.com/llvm/llvm-project/pull/149777

>From 4e9b5d1d8acfe3c12ab25d393cf92731016f8fa9 Mon Sep 17 00:00:00 2001
From: tangaac 
Date: Fri, 18 Jul 2025 16:12:11 +0800
Subject: [PATCH] [LoongArch] Strengthen stack size estimation for LSX/LASX
 extension (#146455)

This patch adds an emergency spill slot when ran out of registers.
PR #139201 introduces `vstelm` instructions with only 8-bit imm offset,
it causes no spill slot to store the spill registers.

(cherry picked from commit 64a0478e08829ec6bcae2b05e154aa58c2c46ac0)
---
 .../LoongArch/LoongArchFrameLowering.cpp  |   7 +-
 .../CodeGen/LoongArch/calling-conv-common.ll  |  48 +--
 .../CodeGen/LoongArch/calling-conv-half.ll|  16 +-
 .../LoongArch/can-not-realign-stack.ll|  44 +--
 .../CodeGen/LoongArch/emergency-spill-slot.ll |   4 +-
 llvm/test/CodeGen/LoongArch/frame.ll  | 107 ++-
 .../CodeGen/LoongArch/intrinsic-memcpy.ll |   8 +-
 llvm/test/CodeGen/LoongArch/lasx/fpowi.ll |  88 +++---
 .../lasx/ir-instruction/extractelement.ll | 120 
 .../lasx/ir-instruction/insertelement.ll  | 132 
 llvm/test/CodeGen/LoongArch/llvm.sincos.ll| 150 -
 llvm/test/CodeGen/LoongArch/lsx/pr146455.ll   | 287 ++
 ...realignment-with-variable-sized-objects.ll |  24 +-
 .../CodeGen/LoongArch/stack-realignment.ll|  80 ++---
 .../LoongArch/unaligned-memcpy-inline.ll  |  14 +-
 llvm/test/CodeGen/LoongArch/vararg.ll |  70 ++---
 16 files changed, 783 insertions(+), 416 deletions(-)
 create mode 100644 llvm/test/CodeGen/LoongArch/lsx/pr146455.ll

diff --git a/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp 
b/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp
index ac5e7f3891c72..1493bf4cba695 100644
--- a/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp
@@ -158,7 +158,12 @@ void 
LoongArchFrameLowering::processFunctionBeforeFrameFinalized(
   // estimateStackSize has been observed to under-estimate the final stack
   // size, so give ourselves wiggle-room by checking for stack size
   // representable an 11-bit signed field rather than 12-bits.
-  if (!isInt<11>(MFI.estimateStackSize(MF)))
+  // For [x]vstelm.{b/h/w/d} memory instructions with 8 imm offset, 7-bit
+  // signed field is fine.
+  unsigned EstimateStackSize = MFI.estimateStackSize(MF);
+  if (!isInt<11>(EstimateStackSize) ||
+  (MF.getSubtarget().hasExtLSX() &&
+   !isInt<7>(EstimateStackSize)))
 ScavSlotsNum = std::max(ScavSlotsNum, 1u);
 
   // For CFR spill.
diff --git a/llvm/test/CodeGen/LoongArch/calling-conv-common.ll 
b/llvm/test/CodeGen/LoongArch/calling-conv-common.ll
index d07e2914c753a..f7653af1fa9ba 100644
--- a/llvm/test/CodeGen/LoongArch/calling-conv-common.ll
+++ b/llvm/test/CodeGen/LoongArch/calling-conv-common.ll
@@ -122,23 +122,23 @@ define i64 @callee_large_scalars(i256 %a, i256 %b) 
nounwind {
 define i64 @caller_large_scalars() nounwind {
 ; CHECK-LABEL: caller_large_scalars:
 ; CHECK:   # %bb.0:
-; CHECK-NEXT:addi.d $sp, $sp, -80
-; CHECK-NEXT:st.d $ra, $sp, 72 # 8-byte Folded Spill
-; CHECK-NEXT:st.d $zero, $sp, 24
+; CHECK-NEXT:addi.d $sp, $sp, -96
+; CHECK-NEXT:st.d $ra, $sp, 88 # 8-byte Folded Spill
+; CHECK-NEXT:st.d $zero, $sp, 40
 ; CHECK-NEXT:vrepli.b $vr0, 0
-; CHECK-NEXT:vst $vr0, $sp, 8
+; CHECK-NEXT:vst $vr0, $sp, 24
 ; CHECK-NEXT:ori $a0, $zero, 2
-; CHECK-NEXT:st.d $a0, $sp, 0
-; CHECK-NEXT:st.d $zero, $sp, 56
-; CHECK-NEXT:vst $vr0, $sp, 40
+; CHECK-NEXT:st.d $a0, $sp, 16
+; CHECK-NEXT:st.d $zero, $sp, 72
+; CHECK-NEXT:vst $vr0, $sp, 56
 ; CHECK-NEXT:ori $a2, $zero, 1
-; CHECK-NEXT:addi.d $a0, $sp, 32
-; CHECK-NEXT:addi.d $a1, $sp, 0
-; CHECK-NEXT:st.d $a2, $sp, 32
+; CHECK-NEXT:addi.d $a0, $sp, 48
+; CHECK-NEXT:addi.d $a1, $sp, 16
+; CHECK-NEXT:st.d $a2, $sp, 48
 ; CHECK-NEXT:pcaddu18i $ra, %call36(callee_large_scalars)
 ; CHECK-NEXT:jirl $ra, $ra, 0
-; CHECK-NEXT:ld.d $ra, $sp, 72 # 8-byte Folded Reload
-; CHECK-NEXT:addi.d $sp, $sp, 80
+; CHECK-NEXT:ld.d $ra, $sp, 88 # 8-byte Folded Reload
+; CHECK-NEXT:addi.d $sp, $sp, 96
 ; CHECK-NEXT:ret
   %1 = call i64 @callee_large_scalars(i256 1, i256 2)
   ret i64 %1
@@ -177,20 +177,20 @@ define i64 @callee_large_scalars_exhausted_regs(i64 %a, 
i64 %b, i64 %c, i64 %d,
 define i64 @caller_large_scalars_exhausted_regs() nounwind {
 ; CHECK-LABEL: caller_large_scalars_exhausted_regs:
 ; CHECK:   # %bb.0:
-; CHECK-NEXT:addi.d $sp, $sp, -96
-; CHECK-NEXT:st.d $ra, $sp, 88 # 8-byte Folded Spill
-; CHECK-NEXT:addi.d $a0, $sp, 16
+; CHECK-NEXT:addi.d $sp, $sp, -112
+; CHECK-NEXT:st.d $ra, $sp, 104 # 8-byte Folded Spill
+; CHECK-NEXT:addi.d $a0, $sp, 32
 ; CHECK-NEXT:st.d $a0, $sp, 8
 ; CHECK-NEXT:ori $a0, $zero, 9
 ; CHECK-NEXT:st.d $a0, $sp, 0
-; CHECK-NE

[llvm-branch-commits] [llvm] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-21 Thread Alexander Richardson via llvm-branch-commits

arichardson wrote:

> I'd like to re-raise my comment about a lack of tests for vectors of pointers 
> (unless I missed some new ones)

Ah sorry I missed that one, will add tests!

https://github.com/llvm/llvm-project/pull/139357
___
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] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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

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

>From acc1a7d3da0d2bd5a60096a9f5dc27338342b952 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 16 Jul 2025 08:04:17 -0500
Subject: [PATCH 1/8] [flang][OpenMP] Sema checks, lowering with new format of
 MAP modifiers

OpenMP 6.0 has changed the modifiers on the MAP clause. Previous patch
has introduced parsing support for them. This patch introduces processing
of the new forms in semantic checks and in lowering. This only applies
to existing modifiers, which were updated in the 6.0 spec. Any of the
newly introduced modifiers (SELF and REF) are ignored.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  16 +--
 flang/lib/Lower/OpenMP/Clauses.cpp| 113 --
 flang/lib/Semantics/canonicalize-omp.cpp  |   5 +
 flang/lib/Semantics/check-omp-structure.cpp   | 107 +++--
 flang/lib/Semantics/check-omp-structure.h |   4 +-
 flang/lib/Semantics/openmp-utils.cpp  |  25 
 flang/lib/Semantics/openmp-utils.h|   3 +
 flang/lib/Semantics/resolve-directives.cpp|  50 ++--
 .../Semantics/OpenMP/combined-constructs.f90  |   8 +-
 .../Semantics/OpenMP/device-constructs.f90|   6 +-
 llvm/include/llvm/Frontend/OpenMP/ClauseT.h   |   9 +-
 .../Frontend/OpenMP/ConstructDecompositionT.h |   5 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.h   |   2 +
 llvm/lib/Frontend/OpenMP/OMP.cpp  |  14 +++
 14 files changed, 260 insertions(+), 107 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 74087d42a8e6e..ec71014c36093 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1315,7 +1315,8 @@ bool ClauseProcessor::processMap(
  const parser::CharBlock &source) {
 using Map = omp::clause::Map;
 mlir::Location clauseLocation = converter.genLocation(source);
-const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t;
+const auto &[mapType, typeMods, refMod, mappers, iterator, objects] =
+clause.t;
 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
 std::string mapperIdName = "__implicit_mapper";
@@ -1342,16 +1343,13 @@ bool ClauseProcessor::processMap(
   mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
  llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
   break;
-case Map::MapType::Alloc:
-case Map::MapType::Release:
+case Map::MapType::Storage:
   // alloc and release is the default map_type for the Target Data
   // Ops, i.e. if no bits for map_type is supplied then alloc/release
-  // is implicitly assumed based on the target directive. Default
-  // value for Target Data and Enter Data is alloc and for Exit Data
-  // it is release.
+  // (aka storage in 6.0+) is implicitly assumed based on the target
+  // directive. Default value for Target Data and Enter Data is alloc
+  // and for Exit Data it is release.
   break;
-case Map::MapType::Delete:
-  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
 }
 
 if (typeMods) {
@@ -1362,6 +1360,8 @@ bool ClauseProcessor::processMap(
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+  if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
+mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
 }
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index 22a07219d3a50..18e49719b6013 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -1001,64 +1001,105 @@ Map make(const parser::OmpClause::Map &inp,
  semantics::SemanticsContext &semaCtx) {
   // inp.v -> parser::OmpMapClause
   CLAUSET_ENUM_CONVERT( //
-  convert1, parser::OmpMapType::Value, Map::MapType,
+  convert1, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
   // clang-format off
-  MS(Alloc,Alloc)
-  MS(Delete,   Delete)
-  MS(From, From)
-  MS(Release,  Release)
-  MS(To,   To)
-  MS(Tofrom,   Tofrom)
+  MS(Always,Always)
+  MS(Close, Close)
+  MS(Ompx_Hold, OmpxHold)
+  MS(Present,   Present)
   // clang-format on
   );
 
   CLAUSET_ENUM_CONVERT( //
-  convert2, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
+  convert2, parser::OmpRefModifier::Value, Map::RefModifier,
   // clang-format off
-  MS(Always,Alwa

[llvm-branch-commits] [clang] [clang] "modular_format" attribute for functions using format strings (PR #147431)

2025-07-21 Thread Aaron Ballman via llvm-branch-commits


@@ -9427,3 +9427,37 @@ diagnostics with code like:
   __attribute__((nonstring)) char NotAStr[3] = "foo"; // Not diagnosed
   }];
 }
+
+def ModularFormatDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``modular_format`` attribute can be applied to a function that bears the
+``format`` attribute (or standard library functions) to indicate that the
+implementation is modular on the format string argument. When the format string
+for a given call is constant, the compiler may redirect the call to the symbol
+given as the first argument to the attribute (the modular implementation
+function).
+
+The second argument is a implementation name, and the remaining arguments are
+aspects of the format string for the compiler to report. If the compiler does
+not understand a aspect, it must summarily report that the format string has
+that aspect.
+
+The compiler reports an aspect by issing a relocation for the symbol
+``_``. This arranges for code and data needed to support the
+aspect of the implementation to be brought into the link to satisfy weak
+references in the modular implemenation function.
+
+For example, say ``printf`` is annotated with
+``modular_format(__modular_printf, __printf, float)``. Then, a call to
+``printf(var, 42)`` would be untouched. A call to ``printf("%d", 42)`` would
+become a call to ``__modular_printf`` with the same arguments, as would

AaronBallman wrote:

So will any call to `printf` with a constant format specifier string be 
rewritten to call `__modular_printf`?

Also, who is responsible for writing these attributes? Are they only in the 
libc implementation, or can a user write one of these themselves on their own 
declarations? I'm asking because I wonder about compatibility; e.g., the call 
dispatches to `__modular_printf` but that doesn't know about some particular 
extension being used in the format specifier and so the code appears to 
misbehave.

https://github.com/llvm/llvm-project/pull/147431
___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-21 Thread Krzysztof Drewniak via llvm-branch-commits

krzysz00 wrote:

I'd like to re-raise my comment about a lack of tests for vectors of pointers 
(unless I missed some new ones)

https://github.com/llvm/llvm-project/pull/139357
___
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] Draft: [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/149949

>From 7c873c4058239c2a9deca69db9de37de8ea1e7ed Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes

Patch series starting at https://github.com/llvm/llvm-project/pull/147835
---
 .../Clang/ClangASTImporter.cpp|  36 +--
 .../ExpressionParser/Clang/ClangASTSource.cpp |   5 +-
 .../Clang/ClangExpressionDeclMap.cpp  |   4 +-
 .../Clang/NameSearchContext.cpp   |   2 +-
 .../Plugins/Language/ObjC/NSDictionary.cpp|   3 +-
 .../RegisterTypeBuilderClang.cpp  |   4 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|   5 +-
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  11 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 240 +-
 .../TypeSystem/Clang/TypeSystemClang.h|   9 +-
 10 files changed, 151 insertions(+), 168 deletions(-)

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 2529e78f78bca..9232c8e5ca3b7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -320,7 +320,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang 
&dst,
   DeclContextOverride decl_context_override;
 
   if (auto *t = ClangUtil::GetQualType(src_type)->getAs())
-decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
+decl_context_override.OverrideAllDeclsFromContainingFunction(
+t->getOriginalDecl()->getDefinitionOrSelf());
 
   CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
&src_ctxt->getASTContext());
@@ -377,8 +378,9 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
   } break;
 
   case clang::Type::Enum: {
-clang::EnumDecl *enum_decl =
-llvm::cast(qual_type)->getDecl();
+auto *enum_decl = llvm::cast(qual_type)
+  ->getOriginalDecl()
+  ->getDefinitionOrSelf();
 if (enum_decl) {
   if (GetDeclOrigin(enum_decl).Valid())
 return true;
@@ -414,12 +416,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) 
{
   ->getDeducedType()
   .getAsOpaquePtr()));
 
-  case clang::Type::Elaborated:
-return CanImport(CompilerType(type.GetTypeSystem(),
-  llvm::cast(qual_type)
-  ->getNamedType()
-  .getAsOpaquePtr()));
-
   case clang::Type::Paren:
 return CanImport(CompilerType(
 type.GetTypeSystem(),
@@ -451,8 +447,9 @@ bool ClangASTImporter::Import(const CompilerType &type) {
   } break;
 
   case clang::Type::Enum: {
-clang::EnumDecl *enum_decl =
-llvm::cast(qual_type)->getDecl();
+clang::EnumDecl *enum_decl = llvm::cast(qual_type)
+ ->getOriginalDecl()
+ ->getDefinitionOrSelf();
 if (enum_decl) {
   if (GetDeclOrigin(enum_decl).Valid())
 return CompleteAndFetchChildren(qual_type);
@@ -488,12 +485,6 @@ bool ClangASTImporter::Import(const CompilerType &type) {
->getDeducedType()
.getAsOpaquePtr()));
 
-  case clang::Type::Elaborated:
-return Import(CompilerType(type.GetTypeSystem(),
-   llvm::cast(qual_type)
-   ->getNamedType()
-   .getAsOpaquePtr()));
-
   case clang::Type::Paren:
 return Import(CompilerType(
 type.GetTypeSystem(),
@@ -597,7 +588,7 @@ bool ExtractBaseOffsets(const ASTRecordLayout 
&record_layout,
   return false;
 
 DeclFromUser origin_base_record(
-origin_base_record_type->getDecl());
+origin_base_record_type->getOriginalDecl()->getDefinitionOrSelf());
 
 if (origin_base_record.IsInvalid())
   return false;
@@ -728,7 +719,8 @@ bool ClangASTImporter::importRecordLayoutFromOrigin(
 
 QualType base_type = bi->getType();
 const RecordType *base_record_type = base_type->getAs();
-DeclFromParser base_record(base_record_type->getDecl());
+DeclFromParser base_record(
+base_record_type->getOriginalDecl()->getDefinitionOrSelf());
 DeclFromParser base_cxx_record =
 DynCast(base_record);
 
@@ -860,7 +852,7 @@ bool 
ClangASTImporter::CompleteAndFetchChildren(clang::QualType type) {
   Log *log = GetLog(LLDBLog::Expressions);
 
   if (const TagType *tag_type = type->getAs()) {
-TagDecl *tag_decl = tag_type->getDecl();
+TagDecl *tag_decl = tag_type->getOriginalDecl()->getDefinitionOrSelf();
 
 Dec

[llvm-branch-commits] [clang] [libcxx] [PATCH 3/7] [clang] Improve nested name specifier AST representation (PR #148014)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/148014
___
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] [PATCH 4/7] [clang] Improve nested name specifier AST representation (PR #148015)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/148015
___
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-tools-extra] [PATCH 5/7] [clang] NNS improvement: getOriginalDecl changes (PR #149747)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/149747
___
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-tools-extra] [PATCH 6/7] [clang] improve NestedNameSpecifier (PR #149748)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/149748
___
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] [PATCH 2/7] [clang] Improve nested name specifier AST representation (PR #148012)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/148012
___
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] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/149949
___
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] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/149949
___
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] [PATCH 4/7] [clang] improve NestedNameSpecifier: clang-tools-extra changes (PR #148015)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/148015
___
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] [PATCH 2/7] [clang] improve NestedNameSpecifier: misc changes (PR #148012)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/148012
___
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] [libcxx] [PATCH 3/7] [clang] improve NestedNameSpecifier: test changes (PR #148014)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/148014
___
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] [PATCH 2/7] [clang] improve NestedNameSpecifier: misc small clang changes (PR #148012)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/148012
___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-21 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/139357

>From 25dc175562349410f161ef0e80246301d9a7ba79 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Fri, 9 May 2025 22:43:37 -0700
Subject: [PATCH] fix docs build

Created using spr 1.3.6-beta.1
---
 llvm/docs/LangRef.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 2d18d0d97aaee..38be6918ff73c 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -12435,7 +12435,7 @@ Example:
 .. _i_ptrtoaddr:
 
 '``ptrtoaddr .. to``' Instruction
-
+^
 
 Syntax:
 """

___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-21 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/139357

>From 25dc175562349410f161ef0e80246301d9a7ba79 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Fri, 9 May 2025 22:43:37 -0700
Subject: [PATCH] fix docs build

Created using spr 1.3.6-beta.1
---
 llvm/docs/LangRef.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 2d18d0d97aaee..38be6918ff73c 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -12435,7 +12435,7 @@ Example:
 .. _i_ptrtoaddr:
 
 '``ptrtoaddr .. to``' Instruction
-
+^
 
 Syntax:
 """

___
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/21.x: [Mips] Correctly define IntPtrType (#145158) (PR #149846)

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

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/149846
___
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/21.x: [Mips] Correctly define IntPtrType (#145158) (PR #149846)

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

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

Backport 1390672

Requested by: @alexrp

>From 27f21c9655b7c975273cdba18cf836ceabfac074 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= 
Date: Mon, 21 Jul 2025 18:17:45 +0200
Subject: [PATCH] [Mips] Correctly define IntPtrType (#145158)

Mips was the only architecture having PtrDiffType = SignedInt and
IntPtrType = SignedLong

This fixes a problem on mipsel-windows-gnu triple, where uintptr_t was
wrongly defined as unsigned long instead of unsigned int, leading to
problems in compiler-rt.

compiler-rt/lib/interception/interception_type_test.cpp:24:17: error:
static assertion failed due to requirement
'__sanitizer::is_same::value':
24 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::uptr,
::uintptr_t>::value));
| ^~~

compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44:
note: expanded from macro 'COMPILER_CHECK'
  369 | #define COMPILER_CHECK(pred) static_assert(pred, "")
  |^~~~
compiler-rt/lib/interception/interception_type_test.cpp:25:17: error:
static assertion failed due to requirement '__sanitizer::is_same::value':
25 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::sptr,
::intptr_t>::value));
| ^~

compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44:
note: expanded from macro 'COMPILER_CHECK'
  369 | #define COMPILER_CHECK(pred) static_assert(pred, "")
  |^~~~
compiler-rt/lib/interception/interception_type_test.cpp:27:17: error:
static assertion failed due to requirement '__sanitizer::is_same::value':
27 | COMPILER_CHECK((__sanitizer::is_same<::PTRDIFF_T,
::ptrdiff_t>::value));
| ^

compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44:
note: expanded from macro 'COMPILER_CHECK'
  369 | #define COMPILER_CHECK(pred) static_assert(pred, "")

(cherry picked from commit 13906724ff7aa1bc58202faac62690570dfe0dc3)
---
 clang/lib/Basic/Targets/Mips.h  |  6 +--
 clang/test/Preprocessor/init-mips.c | 64 ++---
 clang/test/Preprocessor/stdint.c| 10 ++---
 3 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 35501ed44ccd7..e199df32f56ee 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -129,7 +129,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 LongWidth = LongAlign = 32;
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
 PointerWidth = PointerAlign = 32;
-PtrDiffType = SignedInt;
+PtrDiffType = IntPtrType = SignedInt;
 SizeType = UnsignedInt;
 SuitableAlign = 64;
   }
@@ -155,7 +155,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 IntMaxType = Int64Type;
 LongWidth = LongAlign = 64;
 PointerWidth = PointerAlign = 64;
-PtrDiffType = SignedLong;
+PtrDiffType = IntPtrType = SignedLong;
 SizeType = UnsignedLong;
   }
 
@@ -165,7 +165,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 IntMaxType = Int64Type;
 LongWidth = LongAlign = 32;
 PointerWidth = PointerAlign = 32;
-PtrDiffType = SignedInt;
+PtrDiffType = IntPtrType = SignedInt;
 SizeType = UnsignedInt;
   }
 
diff --git a/clang/test/Preprocessor/init-mips.c 
b/clang/test/Preprocessor/init-mips.c
index 4fead33bd826e..125872a001bac 100644
--- a/clang/test/Preprocessor/init-mips.c
+++ b/clang/test/Preprocessor/init-mips.c
@@ -80,10 +80,10 @@
 // MIPS32BE:#define __INTMAX_MAX__ 9223372036854775807LL
 // MIPS32BE:#define __INTMAX_TYPE__ long long int
 // MIPS32BE:#define __INTMAX_WIDTH__ 64
-// MIPS32BE:#define __INTPTR_FMTd__ "ld"
-// MIPS32BE:#define __INTPTR_FMTi__ "li"
-// MIPS32BE:#define __INTPTR_MAX__ 2147483647L
-// MIPS32BE:#define __INTPTR_TYPE__ long int
+// MIPS32BE:#define __INTPTR_FMTd__ "d"
+// MIPS32BE:#define __INTPTR_FMTi__ "i"
+// MIPS32BE:#define __INTPTR_MAX__ 2147483647
+// MIPS32BE:#define __INTPTR_TYPE__ int
 // MIPS32BE:#define __INTPTR_WIDTH__ 32
 // MIPS32BE:#define __INT_FAST16_FMTd__ "hd"
 // MIPS32BE:#define __INT_FAST16_FMTi__ "hi"
@@ -185,8 +185,8 @@
 // MIPS32BE:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // MIPS32BE:#define __UINTMAX_TYPE__ long long unsigned int
 // MIPS32BE:#define __UINTMAX_WIDTH__ 64
-// MIPS32BE:#define __UINTPTR_MAX__ 4294967295UL
-// MIPS32BE:#define __UINTPTR_TYPE__ long unsigned int
+// MIPS32BE:#define __UINTPTR_MAX__ 4294967295U
+// MIPS32BE:#define __UINTPTR_TYPE__ unsigned int
 // MIPS32BE:#define __UINTPTR_WIDTH__ 32
 // MIPS32BE:#define __UINT_FAST16_MAX__ 65535
 // MIPS32BE:#define __UINT_FAST16_TYPE__ unsigned short
@@ -300,10 +

[llvm-branch-commits] [llvm] [llvm][AsmPrinter] Emit call graph section (PR #87576)

2025-07-21 Thread Prabhu Rajasekaran via llvm-branch-commits


@@ -0,0 +1,60 @@
+;; Test if temporary labels are generated for each indirect callsite with a 
callee_type metadata.
+;; Test if the .callgraph section contains the numerical callee type id for 
each of the temporary 
+;; labels generated. 
+
+; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -o - < %s | 
FileCheck %s
+
+declare !type !0 void @foo()
+
+declare !type !1 i32 @bar(i8 signext)
+
+declare !type !2 ptr @baz(ptr)
+
+; CHECK: ball:
+; CHECK-NEXT: .Lfunc_begin0:
+define void @ball() {
+entry:
+  %retval = alloca i32, align 4
+  %fp_foo = alloca ptr, align 8
+  %a = alloca i8, align 1
+  %fp_bar = alloca ptr, align 8
+  %fp_baz = alloca ptr, align 8
+  store i32 0, ptr %retval, align 4
+  store ptr @foo, ptr %fp_foo, align 8
+  %fp_foo_val = load ptr, ptr %fp_foo, align 8
+  ; CHECK: .Ltmp0:
+  call void (...) %fp_foo_val(), !callee_type !1
+  store ptr @bar, ptr %fp_bar, align 8
+  %fp_bar_val = load ptr, ptr %fp_bar, align 8
+  %a_val = load i8, ptr %a, align 1
+  ; CHECK: .Ltmp1:
+  %call_fp_bar = call i32 %fp_bar_val(i8 signext %a_val), !callee_type !3
+  store ptr @baz, ptr %fp_baz, align 8
+  %fp_baz_val = load ptr, ptr %fp_baz, align 8
+  ; CHECK: .Ltmp2:
+  %call_fp_baz = call ptr %fp_baz_val(ptr %a), !callee_type !5
+  call void @foo()
+  %a_val_2 = load i8, ptr %a, align 1
+  %call_bar = call i32 @bar(i8 signext %a_val_2)
+  %call_baz = call ptr @baz(ptr %a)
+  ret void
+}

Prabhuk wrote:

Done! PTAL.

https://github.com/llvm/llvm-project/pull/87576
___
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] Drive profile validator from opt (PR #147418)

2025-07-21 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/147418

>From 003c22548f8583ffd7a80115d0a16a50b524 Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Mon, 7 Jul 2025 12:44:41 -0700
Subject: [PATCH] Drive profile validator from opt

---
 llvm/tools/opt/NewPMDriver.cpp | 8 ++--
 llvm/tools/opt/NewPMDriver.h   | 2 +-
 llvm/tools/opt/optdriver.cpp   | 7 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 7d168a6ceb17c..042ed027639bc 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Transforms/Utils/Debugify.h"
+#include "llvm/Transforms/Utils/ProfileValidation.h"
 
 using namespace llvm;
 using namespace opt_tool;
@@ -356,7 +357,7 @@ bool llvm::runPassPipeline(
 OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder,
 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
-bool UnifiedLTO) {
+bool EnableProfcheck, bool UnifiedLTO) {
   auto FS = vfs::getRealFileSystem();
   std::optional P;
   switch (PGOKindFlag) {
@@ -487,7 +488,8 @@ bool llvm::runPassPipeline(
   if (VerifyDIPreserve)
 MPM.addPass(NewPMDebugifyPass(DebugifyMode::OriginalDebugInfo, "",
   &DebugInfoBeforePass));
-
+  if (EnableProfcheck)
+MPM.addPass(createModuleToFunctionPassAdaptor(ProfileInjectorPass()));
   // Add passes according to the -passes options.
   if (!PassPipeline.empty()) {
 if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
@@ -504,6 +506,8 @@ bool llvm::runPassPipeline(
 MPM.addPass(NewPMCheckDebugifyPass(
 false, "", nullptr, DebugifyMode::OriginalDebugInfo,
 &DebugInfoBeforePass, VerifyDIPreserveExport));
+  if (EnableProfcheck)
+MPM.addPass(createModuleToFunctionPassAdaptor(ProfileVerifierPass()));
 
   // Add any relevant output pass at the end of the pipeline.
   switch (OK) {
diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h
index 2daae571e72c2..6c21d6cae4e75 100644
--- a/llvm/tools/opt/NewPMDriver.h
+++ b/llvm/tools/opt/NewPMDriver.h
@@ -75,7 +75,7 @@ bool runPassPipeline(
 bool ShouldPreserveAssemblyUseListOrder,
 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
-bool UnifiedLTO = false);
+bool EnableProfcheck, bool UnifiedLTO = false);
 } // namespace llvm
 
 #endif
diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp
index de46efa13025d..9b60ae6543336 100644
--- a/llvm/tools/opt/optdriver.cpp
+++ b/llvm/tools/opt/optdriver.cpp
@@ -213,6 +213,10 @@ static cl::opt VerifyDebugInfoPreserve(
 cl::desc("Start the pipeline with collecting and end it with checking of "
  "debug info preservation."));
 
+static cl::opt EnableProfileVerification(
+"enable-profcheck", cl::init(false),
+cl::desc("Start the pipeline with prof-inject and end it with 
prof-check"));
+
 static cl::opt ClDataLayout("data-layout",
  cl::desc("data layout string to use"),
  cl::value_desc("layout-string"),
@@ -731,7 +735,8 @@ extern "C" int optMain(
RemarksFile.get(), Pipeline, PluginList, PassBuilderCallbacks,
OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash,
-   EnableDebugify, VerifyDebugInfoPreserve, UnifiedLTO)
+   EnableDebugify, VerifyDebugInfoPreserve,
+   EnableProfileVerification, UnifiedLTO)
? 0
: 1;
   }

___
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] Drive profile validator from opt (PR #147418)

2025-07-21 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/147418

>From 003c22548f8583ffd7a80115d0a16a50b524 Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Mon, 7 Jul 2025 12:44:41 -0700
Subject: [PATCH] Drive profile validator from opt

---
 llvm/tools/opt/NewPMDriver.cpp | 8 ++--
 llvm/tools/opt/NewPMDriver.h   | 2 +-
 llvm/tools/opt/optdriver.cpp   | 7 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 7d168a6ceb17c..042ed027639bc 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Transforms/Utils/Debugify.h"
+#include "llvm/Transforms/Utils/ProfileValidation.h"
 
 using namespace llvm;
 using namespace opt_tool;
@@ -356,7 +357,7 @@ bool llvm::runPassPipeline(
 OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder,
 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
-bool UnifiedLTO) {
+bool EnableProfcheck, bool UnifiedLTO) {
   auto FS = vfs::getRealFileSystem();
   std::optional P;
   switch (PGOKindFlag) {
@@ -487,7 +488,8 @@ bool llvm::runPassPipeline(
   if (VerifyDIPreserve)
 MPM.addPass(NewPMDebugifyPass(DebugifyMode::OriginalDebugInfo, "",
   &DebugInfoBeforePass));
-
+  if (EnableProfcheck)
+MPM.addPass(createModuleToFunctionPassAdaptor(ProfileInjectorPass()));
   // Add passes according to the -passes options.
   if (!PassPipeline.empty()) {
 if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
@@ -504,6 +506,8 @@ bool llvm::runPassPipeline(
 MPM.addPass(NewPMCheckDebugifyPass(
 false, "", nullptr, DebugifyMode::OriginalDebugInfo,
 &DebugInfoBeforePass, VerifyDIPreserveExport));
+  if (EnableProfcheck)
+MPM.addPass(createModuleToFunctionPassAdaptor(ProfileVerifierPass()));
 
   // Add any relevant output pass at the end of the pipeline.
   switch (OK) {
diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h
index 2daae571e72c2..6c21d6cae4e75 100644
--- a/llvm/tools/opt/NewPMDriver.h
+++ b/llvm/tools/opt/NewPMDriver.h
@@ -75,7 +75,7 @@ bool runPassPipeline(
 bool ShouldPreserveAssemblyUseListOrder,
 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
-bool UnifiedLTO = false);
+bool EnableProfcheck, bool UnifiedLTO = false);
 } // namespace llvm
 
 #endif
diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp
index de46efa13025d..9b60ae6543336 100644
--- a/llvm/tools/opt/optdriver.cpp
+++ b/llvm/tools/opt/optdriver.cpp
@@ -213,6 +213,10 @@ static cl::opt VerifyDebugInfoPreserve(
 cl::desc("Start the pipeline with collecting and end it with checking of "
  "debug info preservation."));
 
+static cl::opt EnableProfileVerification(
+"enable-profcheck", cl::init(false),
+cl::desc("Start the pipeline with prof-inject and end it with 
prof-check"));
+
 static cl::opt ClDataLayout("data-layout",
  cl::desc("data layout string to use"),
  cl::value_desc("layout-string"),
@@ -731,7 +735,8 @@ extern "C" int optMain(
RemarksFile.get(), Pipeline, PluginList, PassBuilderCallbacks,
OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash,
-   EnableDebugify, VerifyDebugInfoPreserve, UnifiedLTO)
+   EnableDebugify, VerifyDebugInfoPreserve,
+   EnableProfileVerification, UnifiedLTO)
? 0
: 1;
   }

___
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] 654c0d8 - Revert "[BranchFolding] Kill common hoisted debug instructions (#140091)"

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

Author: Orlando Cazalet-Hyams
Date: 2025-07-21T17:24:11+01:00
New Revision: 654c0d846e5e3af60177aff3219e6d501edc6d44

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

LOG: Revert "[BranchFolding] Kill common hoisted debug instructions (#140091)"

This reverts commit 8ba341eec3929dd26679092196cd45dfdd1e60c6.

Added: 


Modified: 
llvm/lib/CodeGen/BranchFolding.cpp
llvm/test/DebugInfo/X86/branch-folder-dbg.mir

Removed: 




diff  --git a/llvm/lib/CodeGen/BranchFolding.cpp 
b/llvm/lib/CodeGen/BranchFolding.cpp
index c1e9a20328527..3b3e7a418feb5 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -2083,54 +2083,22 @@ bool 
BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
   if (TBB == FBB) {
 MBB->splice(Loc, TBB, TBB->begin(), TIB);
   } else {
-// Merge the debug locations, and hoist and kill the debug instructions 
from
-// both branches. FIXME: We could probably try harder to preserve some 
debug
-// instructions (but at least this isn't producing wrong locations).
-MachineInstrBuilder MIRBuilder(*MBB->getParent(), Loc);
-auto HoistAndKillDbgInstr = [MBB, Loc](MachineBasicBlock::iterator DI) {
-  assert(DI->isDebugInstr() && "Expected a debug instruction");
-  if (DI->isDebugRef()) {
-const TargetInstrInfo *TII =
-MBB->getParent()->getSubtarget().getInstrInfo();
-const MCInstrDesc &DBGV = TII->get(TargetOpcode::DBG_VALUE);
-DI = BuildMI(*MBB->getParent(), DI->getDebugLoc(), DBGV, false, 0,
- DI->getDebugVariable(), DI->getDebugExpression());
-MBB->insert(Loc, &*DI);
-return;
-  }
-
-  DI->setDebugValueUndef();
-  DI->moveBefore(&*Loc);
-};
-
 // TIB and FIB point to the end of the regions to hoist/merge in TBB and
 // FBB.
 MachineBasicBlock::iterator FE = FIB;
 MachineBasicBlock::iterator FI = FBB->begin();
 for (MachineBasicBlock::iterator TI :
  make_early_inc_range(make_range(TBB->begin(), TIB))) {
-  // Hoist and kill debug instructions from FBB. After this loop FI points
-  // to the next non-debug instruction to hoist (checked in assert after 
the
-  // TBB debug instruction handling code).
-  while (FI->isDebugInstr()) {
-assert(FI != FE && "Unexpected end of FBB range");
-MachineBasicBlock::iterator FINext = std::next(FI);
-HoistAndKillDbgInstr(FI);
-FI = FINext;
-  }
-
-  // Kill debug instructions before moving.
-  if (TI->isDebugInstr()) {
-HoistAndKillDbgInstr(TI);
+  // Move debug instructions and pseudo probes without modifying them.
+  // FIXME: This is the wrong thing to do for debug locations, which
+  // should at least be killed (and hoisted from BOTH blocks).
+  if (TI->isDebugOrPseudoInstr()) {
+TI->moveBefore(&*Loc);
 continue;
   }
 
-  // If FI is a debug instruction, skip forward to the next non-debug
-  // instruction.
+  // Get the next non-meta instruction in FBB.
   FI = skipDebugInstructionsForward(FI, FE, false);
-  // Pseudo probes are excluded from the range when identifying foldable
-  // instructions, so we don't expect to see one now.
-  assert(!TI->isPseudoProbe() && "Unexpected pseudo probe in range");
   // NOTE: The loop above checks CheckKillDead but we can't do that here as
   // it modifies some kill markers after the check.
   assert(TI->isIdenticalTo(*FI, MachineInstr::CheckDefs) &&
@@ -2143,7 +2111,6 @@ bool 
BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
   ++FI;
 }
   }
-
   FBB->erase(FBB->begin(), FIB);
 
   if (UpdateLiveIns)

diff  --git a/llvm/test/DebugInfo/X86/branch-folder-dbg.mir 
b/llvm/test/DebugInfo/X86/branch-folder-dbg.mir
index 831b263fdccd4..5c38fd2a43829 100644
--- a/llvm/test/DebugInfo/X86/branch-folder-dbg.mir
+++ b/llvm/test/DebugInfo/X86/branch-folder-dbg.mir
@@ -1,21 +1,16 @@
 # RUN: llc %s --start-before=branch-folder --stop-after=branch-folder -o - | 
FileCheck %s
 
 ## Check that common instructions hoisted from `if.then` and `if.else` into
-## common pred `entry` get merged debug locations. The debug instructions from
-## both branches should get hoisted and killed.
-##
-## The MIR debug instructions have been modified by hand in order to check they
-## can be killed.
+## common pred `entry` get merged debug locations.
+
+## FIXME: The debug instructions handling here is wrong.
 
 # CHECK: bb.0
 # CHECK:  CALL64pcrel32 @f, csr_64, implicit $rsp, implicit $ssp, 
implicit-def $rsp, implicit-def $ssp, implicit-def $rax
-## --- Start splice from bb.2.if.else (and debug instructions from 
bb.1.if.then) ---
-# CHECK-NEXT: DBG_VALUE $noreg

[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

2025-07-21 Thread Tom Eccles via llvm-branch-commits

tblah wrote:

> There is a parsing test that shows the conversion, plus parsing of the new 
> modifiers (in the parsing PR). Do you want something specific to lowering, 
> e.g. show the same MLIR generated for a given modifier with 
> -fopenmp-version=52 and 60?

Ahh okay. Maybe we only need one test then, but it would be good to make sure 
this makes it through the clause processor okay.

https://github.com/llvm/llvm-project/pull/149137
___
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] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)

2025-07-21 Thread Matheus Izvekov via llvm-branch-commits

mizvekov wrote:

> Re: Python bindings changes.
> 
> The tests currently fail because the libclang.so cannot even be built. Is 
> this expected, as in, can it only be built after the last patch again? (I see 
> that the tests passed on patch 6/6).

Yes, but all of the patches will be squashed before merging.

> 
> 
> This should also probably get an entry in the bindings' breaking changes 
> section of the release notes. 

Will do, thanks.

https://github.com/llvm/llvm-project/pull/148012
___
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-doc] separate comments into categories (PR #149590)

2025-07-21 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 updated 
https://github.com/llvm/llvm-project/pull/149590

>From eb171f6b28eac5e7458c1472645d64be9ffb056f Mon Sep 17 00:00:00 2001
From: Erick Velez 
Date: Thu, 17 Jul 2025 15:04:20 -0700
Subject: [PATCH] [clang-doc] separate comments into categories

Comment categories will allow better comment organization in HTML.
Before, comments would just be serialized in whatever order they were
written, so groups like params or notes wouldn't be in the same
sections.
---
 clang-tools-extra/clang-doc/JSONGenerator.cpp | 43 
 .../test/clang-doc/json/class.cpp | 51 +--
 .../test/clang-doc/json/concept.cpp   | 15 +++---
 3 files changed, 64 insertions(+), 45 deletions(-)

diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp 
b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 908e23d24d079..5e2d60a8427e1 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -83,7 +83,21 @@ serializeLocation(const Location &Loc,
   return LocationObj;
 }
 
-static json::Value serializeComment(const CommentInfo &I) {
+static void insertComment(Object &Description, json::Value &Comment,
+  std::string Key) {
+  auto *CommentArray = Description.getArray(Key);
+  if (!CommentArray) {
+auto CommentsArray = json::Array();
+CommentsArray.push_back(Comment);
+Description[Key] = std::move(CommentsArray);
+Description["Has" + Key] = true;
+  } else {
+CommentArray->push_back(Comment);
+Description[Key] = std::move(*CommentArray);
+  }
+}
+
+static Object serializeComment(const CommentInfo &I, Object &Description) {
   // taken from PR #142273
   Object Obj = Object();
 
@@ -94,7 +108,7 @@ static json::Value serializeComment(const CommentInfo &I) {
   auto &CARef = *ChildArr.getAsArray();
   CARef.reserve(I.Children.size());
   for (const auto &C : I.Children)
-CARef.emplace_back(serializeComment(*C));
+CARef.emplace_back(serializeComment(*C, Description));
 
   switch (I.Kind) {
   case CommentKind::CK_TextComment: {
@@ -106,6 +120,8 @@ static json::Value serializeComment(const CommentInfo &I) {
 Child.insert({"Command", I.Name});
 Child.insert({"Children", ChildArr});
 Obj.insert({commentKindToString(I.Kind), ChildVal});
+if (I.Name == "brief")
+  insertComment(Description, ChildVal, "BriefComments");
 return Obj;
   }
 
@@ -137,7 +153,10 @@ static json::Value serializeComment(const CommentInfo &I) {
 if (!I.CloseName.empty())
   Child.insert({"CloseName", I.CloseName});
 Child.insert({"Children", ChildArr});
-Obj.insert({commentKindToString(I.Kind), ChildVal});
+if (I.CloseName == "endcode")
+  insertComment(Description, ChildVal, "CodeComments");
+else if (I.CloseName == "endverbatim")
+  insertComment(Description, ChildVal, "VerbatimComments");
 return Obj;
   }
 
@@ -210,12 +229,18 @@ serializeCommonAttributes(const Info &I, json::Object 
&Obj,
   }
 
   if (!I.Description.empty()) {
-json::Value DescArray = json::Array();
-auto &DescArrayRef = *DescArray.getAsArray();
-DescArrayRef.reserve(I.Description.size());
-for (const auto &Comment : I.Description)
-  DescArrayRef.push_back(serializeComment(Comment));
-Obj["Description"] = DescArray;
+Object Description = Object();
+// Skip straight to the FullComment's children
+auto &Comments = I.Description.at(0).Children;
+for (const auto &CommentInfo : Comments) {
+  json::Value Comment = serializeComment(*CommentInfo, Description);
+  // if a ParagraphComment is returned, then it is a top-level comment that
+  // needs to be inserted manually.
+  if (auto *ParagraphComment =
+  Comment.getAsObject()->get("ParagraphComment"))
+insertComment(Description, *ParagraphComment, "ParagraphComments");
+}
+Obj["Description"] = std::move(Description);
   }
 
   // Namespaces aren't SymbolInfos, so they dont have a DefLoc
diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp 
b/clang-tools-extra/test/clang-doc/json/class.cpp
index a36358982b019..e8fafca28a956 100644
--- a/clang-tools-extra/test/clang-doc/json/class.cpp
+++ b/clang-tools-extra/test/clang-doc/json/class.cpp
@@ -33,33 +33,30 @@ struct MyClass {
 };
 
 // CHECK:   {
-// CHECK-NEXT:"Description": [
-// CHECK-NEXT:  {
-// CHECK-NEXT:   "FullComment": {
-// CHECK-NEXT: "Children": [
-// CHECK-NEXT:   {
-// CHECK-NEXT: "ParagraphComment": {
-// CHECK-NEXT:   "Children": [
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComment": " This is a nice class."
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComment": " It has some nice methods and 
fields."
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComme

[llvm-branch-commits] [clang-tools-extra] [clang-doc] separate comments into categories (PR #149590)

2025-07-21 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 updated 
https://github.com/llvm/llvm-project/pull/149590

>From eb171f6b28eac5e7458c1472645d64be9ffb056f Mon Sep 17 00:00:00 2001
From: Erick Velez 
Date: Thu, 17 Jul 2025 15:04:20 -0700
Subject: [PATCH] [clang-doc] separate comments into categories

Comment categories will allow better comment organization in HTML.
Before, comments would just be serialized in whatever order they were
written, so groups like params or notes wouldn't be in the same
sections.
---
 clang-tools-extra/clang-doc/JSONGenerator.cpp | 43 
 .../test/clang-doc/json/class.cpp | 51 +--
 .../test/clang-doc/json/concept.cpp   | 15 +++---
 3 files changed, 64 insertions(+), 45 deletions(-)

diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp 
b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 908e23d24d079..5e2d60a8427e1 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -83,7 +83,21 @@ serializeLocation(const Location &Loc,
   return LocationObj;
 }
 
-static json::Value serializeComment(const CommentInfo &I) {
+static void insertComment(Object &Description, json::Value &Comment,
+  std::string Key) {
+  auto *CommentArray = Description.getArray(Key);
+  if (!CommentArray) {
+auto CommentsArray = json::Array();
+CommentsArray.push_back(Comment);
+Description[Key] = std::move(CommentsArray);
+Description["Has" + Key] = true;
+  } else {
+CommentArray->push_back(Comment);
+Description[Key] = std::move(*CommentArray);
+  }
+}
+
+static Object serializeComment(const CommentInfo &I, Object &Description) {
   // taken from PR #142273
   Object Obj = Object();
 
@@ -94,7 +108,7 @@ static json::Value serializeComment(const CommentInfo &I) {
   auto &CARef = *ChildArr.getAsArray();
   CARef.reserve(I.Children.size());
   for (const auto &C : I.Children)
-CARef.emplace_back(serializeComment(*C));
+CARef.emplace_back(serializeComment(*C, Description));
 
   switch (I.Kind) {
   case CommentKind::CK_TextComment: {
@@ -106,6 +120,8 @@ static json::Value serializeComment(const CommentInfo &I) {
 Child.insert({"Command", I.Name});
 Child.insert({"Children", ChildArr});
 Obj.insert({commentKindToString(I.Kind), ChildVal});
+if (I.Name == "brief")
+  insertComment(Description, ChildVal, "BriefComments");
 return Obj;
   }
 
@@ -137,7 +153,10 @@ static json::Value serializeComment(const CommentInfo &I) {
 if (!I.CloseName.empty())
   Child.insert({"CloseName", I.CloseName});
 Child.insert({"Children", ChildArr});
-Obj.insert({commentKindToString(I.Kind), ChildVal});
+if (I.CloseName == "endcode")
+  insertComment(Description, ChildVal, "CodeComments");
+else if (I.CloseName == "endverbatim")
+  insertComment(Description, ChildVal, "VerbatimComments");
 return Obj;
   }
 
@@ -210,12 +229,18 @@ serializeCommonAttributes(const Info &I, json::Object 
&Obj,
   }
 
   if (!I.Description.empty()) {
-json::Value DescArray = json::Array();
-auto &DescArrayRef = *DescArray.getAsArray();
-DescArrayRef.reserve(I.Description.size());
-for (const auto &Comment : I.Description)
-  DescArrayRef.push_back(serializeComment(Comment));
-Obj["Description"] = DescArray;
+Object Description = Object();
+// Skip straight to the FullComment's children
+auto &Comments = I.Description.at(0).Children;
+for (const auto &CommentInfo : Comments) {
+  json::Value Comment = serializeComment(*CommentInfo, Description);
+  // if a ParagraphComment is returned, then it is a top-level comment that
+  // needs to be inserted manually.
+  if (auto *ParagraphComment =
+  Comment.getAsObject()->get("ParagraphComment"))
+insertComment(Description, *ParagraphComment, "ParagraphComments");
+}
+Obj["Description"] = std::move(Description);
   }
 
   // Namespaces aren't SymbolInfos, so they dont have a DefLoc
diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp 
b/clang-tools-extra/test/clang-doc/json/class.cpp
index a36358982b019..e8fafca28a956 100644
--- a/clang-tools-extra/test/clang-doc/json/class.cpp
+++ b/clang-tools-extra/test/clang-doc/json/class.cpp
@@ -33,33 +33,30 @@ struct MyClass {
 };
 
 // CHECK:   {
-// CHECK-NEXT:"Description": [
-// CHECK-NEXT:  {
-// CHECK-NEXT:   "FullComment": {
-// CHECK-NEXT: "Children": [
-// CHECK-NEXT:   {
-// CHECK-NEXT: "ParagraphComment": {
-// CHECK-NEXT:   "Children": [
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComment": " This is a nice class."
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComment": " It has some nice methods and 
fields."
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComme

[llvm-branch-commits] [clang-tools-extra] [clang-doc] integrate JSON as the source for Mustache templates (PR #149589)

2025-07-21 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 updated 
https://github.com/llvm/llvm-project/pull/149589

>From c9f121abb503e121a6ab346e992a2f5673a3b235 Mon Sep 17 00:00:00 2001
From: Erick Velez 
Date: Fri, 18 Jul 2025 13:59:44 -0700
Subject: [PATCH] [clang-doc] integrate JSON as the source for Mustache
 templates

---
 .../clang-doc/HTMLMustacheGenerator.cpp   | 487 +++---
 .../clang-doc/assets/class-template.mustache  |  62 +--
 .../clang-doc/assets/enum-template.mustache   |  12 +-
 .../assets/function-template.mustache |   2 +-
 .../assets/namespace-template.mustache|  45 +-
 .../clang-doc/basic-project.mustache.test |  70 +--
 .../test/clang-doc/mustache-index.cpp |  10 +-
 .../clang-doc/mustache-separate-namespace.cpp |   8 +-
 .../clang-doc/HTMLMustacheGeneratorTest.cpp   | 129 -
 9 files changed, 171 insertions(+), 654 deletions(-)

diff --git a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
index 7aeaa1b7cf67d..98e2935a8aada 100644
--- a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
@@ -27,6 +27,9 @@ using namespace llvm::mustache;
 
 namespace clang {
 namespace doc {
+static Error generateDocForJSON(json::Value &JSON, StringRef Filename,
+StringRef Path, raw_fd_ostream &OS,
+const ClangDocContext &CDCtx);
 
 static Error createFileOpenError(StringRef FileName, std::error_code EC) {
   return createFileError("cannot open file " + FileName, EC);
@@ -132,404 +135,65 @@ Error MustacheHTMLGenerator::generateDocs(
   return Err;
   }
 
-  // Track which directories we already tried to create.
-  StringSet<> CreatedDirs;
-  // Collect all output by file name and create the necessary directories.
-  StringMap> FileToInfos;
-  for (const auto &Group : Infos) {
-llvm::TimeTraceScope TS("setup directories");
-doc::Info *Info = Group.getValue().get();
-
-SmallString<128> Path;
-sys::path::native(RootDir, Path);
-sys::path::append(Path, Info->getRelativeFilePath(""));
-if (!CreatedDirs.contains(Path)) {
-  if (std::error_code EC = sys::fs::create_directories(Path))
-return createStringError(EC, "failed to create directory '%s'.",
- Path.c_str());
-  CreatedDirs.insert(Path);
-}
-
-sys::path::append(Path, Info->getFileBaseName() + ".html");
-FileToInfos[Path].push_back(Info);
+  {
+llvm::TimeTraceScope TS("Generate JSON for Mustache");
+if (auto JSONGenerator = findGeneratorByName("json")) {
+  if (Error Err = JSONGenerator.get()->generateDocs(
+  RootDir, std::move(Infos), CDCtx))
+return Err;
+} else
+  return JSONGenerator.takeError();
   }
 
+  StringMap JSONFileMap;
   {
-llvm::TimeTraceScope TS("Generate Docs");
-for (const auto &Group : FileToInfos) {
-  llvm::TimeTraceScope TS("Info to Doc");
+llvm::TimeTraceScope TS("Iterate JSON files");
+std::error_code EC;
+sys::fs::directory_iterator JSONIter(RootDir, EC);
+std::vector JSONFiles;
+JSONFiles.reserve(Infos.size());
+if (EC)
+  return createStringError("Failed to create directory iterator.");
+
+while (JSONIter != sys::fs::directory_iterator()) {
+  if (EC)
+return createStringError(EC, "Failed to iterate directory");
+
+  auto Path = StringRef(JSONIter->path());
+  if (!Path.ends_with(".json")) {
+JSONIter.increment(EC);
+continue;
+  }
+
+  auto File = MemoryBuffer::getFile(Path);
+  if ((EC = File.getError()))
+continue;
+
+  auto Parsed = json::parse((*File)->getBuffer());
+  if (!Parsed)
+return Parsed.takeError();
+
   std::error_code FileErr;
-  raw_fd_ostream InfoOS(Group.getKey(), FileErr, sys::fs::OF_None);
+  SmallString<16> HTMLPath(Path.begin(), Path.end());
+  sys::path::replace_extension(HTMLPath, "html");
+  raw_fd_ostream InfoOS(HTMLPath, FileErr, sys::fs::OF_None);
   if (FileErr)
-return createFileOpenError(Group.getKey(), FileErr);
+return createFileOpenError(Path, FileErr);
 
-  for (const auto &Info : Group.getValue())
-if (Error Err = generateDocForInfo(Info, InfoOS, CDCtx))
-  return Err;
+  if (Error Err = generateDocForJSON(*Parsed, sys::path::stem(HTMLPath),
+ HTMLPath, InfoOS, CDCtx))
+return Err;
+  JSONIter.increment(EC);
 }
   }
-  return Error::success();
-}
-
-static json::Value
-extractValue(const Location &L,
- std::optional RepositoryUrl = std::nullopt) {
-  Object Obj = Object();
-  // TODO: Consider using both Start/End line numbers to improve location 
report
-  Obj.insert({"LineNumber", L.StartLineNumber});
-  Obj.insert({"Filename", L.Filename});
-
-  if (!L.IsFileInRootDir || !RepositoryUrl)
-return Obj;
-  SmallS

[llvm-branch-commits] [clang-tools-extra] [clang-doc] enable comments in class templates (PR #149848)

2025-07-21 Thread Erick Velez via llvm-branch-commits

evelez7 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/149848?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#149848** https://app.graphite.dev/github/pr/llvm/llvm-project/149848?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/149848?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#149590** https://app.graphite.dev/github/pr/llvm/llvm-project/149590?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#149589** https://app.graphite.dev/github/pr/llvm/llvm-project/149589?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#149588** https://app.graphite.dev/github/pr/llvm/llvm-project/149588?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/149848
___
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-doc] enable comments in class templates (PR #149848)

2025-07-21 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 ready_for_review 
https://github.com/llvm/llvm-project/pull/149848
___
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-doc] separate comments into categories (PR #149590)

2025-07-21 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 ready_for_review 
https://github.com/llvm/llvm-project/pull/149590
___
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-doc] enable comments in class templates (PR #149848)

2025-07-21 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 created 
https://github.com/llvm/llvm-project/pull/149848

The Mustache basic project has comments in its headers but the comments were not
serialized. Now we serialize @brief and paragraph comments for classes
and add that output to the basic project test.

>From f52930a1b4f3c725b6233f65f76a9b984a7a617a Mon Sep 17 00:00:00 2001
From: Erick Velez 
Date: Fri, 18 Jul 2025 12:04:20 -0700
Subject: [PATCH] [clang-doc] enable comments in class templates

The Mustache basic project has comments in its headers but the comments were not
serialized. Now we serialize @brief and paragraph comments for classes
and add that output to the basic project test.
---
 .../clang-doc/assets/class-template.mustache  |  4 +-
 .../assets/comment-template.mustache  |  9 +++-
 .../clang-doc/basic-project.mustache.test | 43 +++
 3 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clang-doc/assets/class-template.mustache 
b/clang-tools-extra/clang-doc/assets/class-template.mustache
index a4077323f29e2..b1a7470f7c33a 100644
--- a/clang-tools-extra/clang-doc/assets/class-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/class-template.mustache
@@ -128,11 +128,11 @@
 
 
 {{TagType}} {{Name}}
-{{#RecordComments}}
+{{#Description}}
 
 {{>Comments}}
 
-{{/RecordComments}}
+{{/Description}}
 
 
 {{#HasPublicMembers}}
diff --git a/clang-tools-extra/clang-doc/assets/comment-template.mustache 
b/clang-tools-extra/clang-doc/assets/comment-template.mustache
index 723ace7a0eed1..b793bad55cf6c 100644
--- a/clang-tools-extra/clang-doc/assets/comment-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/comment-template.mustache
@@ -5,11 +5,16 @@
 
 This file defines templates for generating comments
 }}
-{{#FullComment}}
+{{#BriefComments}}
 {{#Children}}
 {{>Comments}}
 {{/Children}}
-{{/FullComment}}
+{{/BriefComments}}
+{{#ParagraphComments}}
+{{#Children}}
+{{>Comments}}
+{{/Children}}
+{{/ParagraphComments}}
 {{#ParagraphComment}}
 {{#Children}}
 {{>Comments}}
diff --git a/clang-tools-extra/test/clang-doc/basic-project.mustache.test 
b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
index 4dd6f4165f65e..4fb38e2b32fcb 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
@@ -60,6 +60,17 @@ HTML-SHAPE: 
 HTML-SHAPE: 
 HTML-SHAPE: 
 HTML-SHAPE: class Shape
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE: Abstract base class for 
shapes.
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE: Provides a common interface 
for different types of shapes.
+HTML-SHAPE:
+HTML-SHAPE:
 HTML-SHAPE: 
 HTML-SHAPE: 
 HTML-SHAPE: 
@@ -172,6 +183,16 @@ HTML-CALC: 
 HTML-CALC: 
 HTML-CALC: 
 HTML-CALC: class 
Calculator
+HTML-CALC:
+HTML-CALC: A simple calculator 
class.
+HTML-CALC:
+HTML-CALC:
+HTML-CALC:
+HTML-CALC:
+HTML-CALC:
+HTML-CALC: Provides basic arithmetic 
operations.
+HTML-CALC:
+HTML-CALC:
 HTML-CALC: 
 HTML-CALC: 
 HTML-CALC: 
@@ -300,6 +321,17 @@ HTML-RECTANGLE: 
 HTML-RECTANGLE: 
 HTML-RECTANGLE: 
 HTML-RECTANGLE: class 
Rectangle
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE: Rectangle class 
derived from Shape.
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE: Represents a rectangle 
with a given width and height.
+H

[llvm-branch-commits] [clang-tools-extra] [clang-doc] separate comments into categories (PR #149590)

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

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Erick Velez (evelez7)


Changes

Comment categories will allow better comment organization in HTML.
Before, comments would just be serialized in whatever order they were
written, so groups like params or notes wouldn't be in the same
sections.

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


3 Files Affected:

- (modified) clang-tools-extra/clang-doc/JSONGenerator.cpp (+34-9) 
- (modified) clang-tools-extra/test/clang-doc/json/class.cpp (+24-27) 
- (modified) clang-tools-extra/test/clang-doc/json/concept.cpp (+6-9) 


``diff
diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp 
b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 908e23d24d079..5e2d60a8427e1 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -83,7 +83,21 @@ serializeLocation(const Location &Loc,
   return LocationObj;
 }
 
-static json::Value serializeComment(const CommentInfo &I) {
+static void insertComment(Object &Description, json::Value &Comment,
+  std::string Key) {
+  auto *CommentArray = Description.getArray(Key);
+  if (!CommentArray) {
+auto CommentsArray = json::Array();
+CommentsArray.push_back(Comment);
+Description[Key] = std::move(CommentsArray);
+Description["Has" + Key] = true;
+  } else {
+CommentArray->push_back(Comment);
+Description[Key] = std::move(*CommentArray);
+  }
+}
+
+static Object serializeComment(const CommentInfo &I, Object &Description) {
   // taken from PR #142273
   Object Obj = Object();
 
@@ -94,7 +108,7 @@ static json::Value serializeComment(const CommentInfo &I) {
   auto &CARef = *ChildArr.getAsArray();
   CARef.reserve(I.Children.size());
   for (const auto &C : I.Children)
-CARef.emplace_back(serializeComment(*C));
+CARef.emplace_back(serializeComment(*C, Description));
 
   switch (I.Kind) {
   case CommentKind::CK_TextComment: {
@@ -106,6 +120,8 @@ static json::Value serializeComment(const CommentInfo &I) {
 Child.insert({"Command", I.Name});
 Child.insert({"Children", ChildArr});
 Obj.insert({commentKindToString(I.Kind), ChildVal});
+if (I.Name == "brief")
+  insertComment(Description, ChildVal, "BriefComments");
 return Obj;
   }
 
@@ -137,7 +153,10 @@ static json::Value serializeComment(const CommentInfo &I) {
 if (!I.CloseName.empty())
   Child.insert({"CloseName", I.CloseName});
 Child.insert({"Children", ChildArr});
-Obj.insert({commentKindToString(I.Kind), ChildVal});
+if (I.CloseName == "endcode")
+  insertComment(Description, ChildVal, "CodeComments");
+else if (I.CloseName == "endverbatim")
+  insertComment(Description, ChildVal, "VerbatimComments");
 return Obj;
   }
 
@@ -210,12 +229,18 @@ serializeCommonAttributes(const Info &I, json::Object 
&Obj,
   }
 
   if (!I.Description.empty()) {
-json::Value DescArray = json::Array();
-auto &DescArrayRef = *DescArray.getAsArray();
-DescArrayRef.reserve(I.Description.size());
-for (const auto &Comment : I.Description)
-  DescArrayRef.push_back(serializeComment(Comment));
-Obj["Description"] = DescArray;
+Object Description = Object();
+// Skip straight to the FullComment's children
+auto &Comments = I.Description.at(0).Children;
+for (const auto &CommentInfo : Comments) {
+  json::Value Comment = serializeComment(*CommentInfo, Description);
+  // if a ParagraphComment is returned, then it is a top-level comment that
+  // needs to be inserted manually.
+  if (auto *ParagraphComment =
+  Comment.getAsObject()->get("ParagraphComment"))
+insertComment(Description, *ParagraphComment, "ParagraphComments");
+}
+Obj["Description"] = std::move(Description);
   }
 
   // Namespaces aren't SymbolInfos, so they dont have a DefLoc
diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp 
b/clang-tools-extra/test/clang-doc/json/class.cpp
index a36358982b019..e8fafca28a956 100644
--- a/clang-tools-extra/test/clang-doc/json/class.cpp
+++ b/clang-tools-extra/test/clang-doc/json/class.cpp
@@ -33,33 +33,30 @@ struct MyClass {
 };
 
 // CHECK:   {
-// CHECK-NEXT:"Description": [
-// CHECK-NEXT:  {
-// CHECK-NEXT:   "FullComment": {
-// CHECK-NEXT: "Children": [
-// CHECK-NEXT:   {
-// CHECK-NEXT: "ParagraphComment": {
-// CHECK-NEXT:   "Children": [
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComment": " This is a nice class."
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComment": " It has some nice methods and 
fields."
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:   "TextComment": ""
-// CHECK-NEXT: }
-// CHECK-NEXT:   ]
-// CHECK:   {
-// CHECK-NEXT:  

[llvm-branch-commits] [clang-tools-extra] [clang-doc] enable comments in class templates (PR #149848)

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

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Erick Velez (evelez7)


Changes

The Mustache basic project has comments in its headers but the comments were not
serialized. Now we serialize @brief and paragraph comments for classes
and add that output to the basic project test.

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


3 Files Affected:

- (modified) clang-tools-extra/clang-doc/assets/class-template.mustache (+2-2) 
- (modified) clang-tools-extra/clang-doc/assets/comment-template.mustache 
(+7-2) 
- (modified) clang-tools-extra/test/clang-doc/basic-project.mustache.test (+43) 


``diff
diff --git a/clang-tools-extra/clang-doc/assets/class-template.mustache 
b/clang-tools-extra/clang-doc/assets/class-template.mustache
index a4077323f29e2..b1a7470f7c33a 100644
--- a/clang-tools-extra/clang-doc/assets/class-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/class-template.mustache
@@ -128,11 +128,11 @@
 
 
 {{TagType}} {{Name}}
-{{#RecordComments}}
+{{#Description}}
 
 {{>Comments}}
 
-{{/RecordComments}}
+{{/Description}}
 
 
 {{#HasPublicMembers}}
diff --git a/clang-tools-extra/clang-doc/assets/comment-template.mustache 
b/clang-tools-extra/clang-doc/assets/comment-template.mustache
index 723ace7a0eed1..b793bad55cf6c 100644
--- a/clang-tools-extra/clang-doc/assets/comment-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/comment-template.mustache
@@ -5,11 +5,16 @@
 
 This file defines templates for generating comments
 }}
-{{#FullComment}}
+{{#BriefComments}}
 {{#Children}}
 {{>Comments}}
 {{/Children}}
-{{/FullComment}}
+{{/BriefComments}}
+{{#ParagraphComments}}
+{{#Children}}
+{{>Comments}}
+{{/Children}}
+{{/ParagraphComments}}
 {{#ParagraphComment}}
 {{#Children}}
 {{>Comments}}
diff --git a/clang-tools-extra/test/clang-doc/basic-project.mustache.test 
b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
index 4dd6f4165f65e..4fb38e2b32fcb 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
@@ -60,6 +60,17 @@ HTML-SHAPE: 
 HTML-SHAPE: 
 HTML-SHAPE: 
 HTML-SHAPE: class Shape
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE: Abstract base class for 
shapes.
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE: Provides a common interface 
for different types of shapes.
+HTML-SHAPE:
+HTML-SHAPE:
 HTML-SHAPE: 
 HTML-SHAPE: 
 HTML-SHAPE: 
@@ -172,6 +183,16 @@ HTML-CALC: 
 HTML-CALC: 
 HTML-CALC: 
 HTML-CALC: class 
Calculator
+HTML-CALC:
+HTML-CALC: A simple calculator 
class.
+HTML-CALC:
+HTML-CALC:
+HTML-CALC:
+HTML-CALC:
+HTML-CALC:
+HTML-CALC: Provides basic arithmetic 
operations.
+HTML-CALC:
+HTML-CALC:
 HTML-CALC: 
 HTML-CALC: 
 HTML-CALC: 
@@ -300,6 +321,17 @@ HTML-RECTANGLE: 
 HTML-RECTANGLE: 
 HTML-RECTANGLE: 
 HTML-RECTANGLE: class 
Rectangle
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE: Rectangle class 
derived from Shape.
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE: Represents a rectangle 
with a given width and height.
+HTML-RECTANGLE:
+HTML-RECTANGLE:
 HTML-RECTANGLE: 
 HTML-RECTANGLE: 
 HTML-RECTANGLE: 
@@ -395,6 +427,17 @@ HTML-CIRCLE: 
 HTML-CIRCLE:  

[llvm-branch-commits] [clang] release/21.x: [clang] Don't warn on zero literals with -std=c2y (#149688) (PR #149842)

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

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


https://github.com/llvm/llvm-project/pull/149842
___
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-doc] enable comments in class templates (PR #149848)

2025-07-21 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 edited 
https://github.com/llvm/llvm-project/pull/149848
___
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] 1abeeab - [RISCV] Pass the MachineInstr flag as argument to allocateStack (#147531)

2025-07-21 Thread Tobias Hieta via llvm-branch-commits

Author: Raphael Moreira Zinsly
Date: 2025-07-21T18:54:42+02:00
New Revision: 1abeeabd65e66940adbafcf84e958704a5b3f132

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

LOG: [RISCV] Pass the MachineInstr flag as argument to allocateStack (#147531)

When not in the prologue we do not want to set the FrameSetup flag, by
passing the flag as argument we can use allocateStack correctly on those
cases.
This fixes the allocation and probe in eliminateCallFramePseudoInstr.

(cherry picked from commit 1db9eb23209826d9e799e68a9a4090f0328bf70c)

Added: 
llvm/test/CodeGen/RISCV/stack-probing-frame-setup.mir

Modified: 
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
llvm/lib/Target/RISCV/RISCVFrameLowering.h

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index a796c910bd449..6c8e3da80b932 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -738,7 +738,8 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
MachineFunction &MF, uint64_t Offset,
uint64_t RealStackSize, bool EmitCFI,
bool NeedProbe, uint64_t ProbeSize,
-   bool DynAllocation) const {
+   bool DynAllocation,
+   MachineInstr::MIFlag Flag) const {
   DebugLoc DL;
   const RISCVRegisterInfo *RI = STI.getRegisterInfo();
   const RISCVInstrInfo *TII = STI.getInstrInfo();
@@ -748,7 +749,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
   // Simply allocate the stack if it's not big enough to require a probe.
   if (!NeedProbe || Offset <= ProbeSize) {
 RI->adjustReg(MBB, MBBI, DL, SPReg, SPReg, StackOffset::getFixed(-Offset),
-  MachineInstr::FrameSetup, getStackAlign());
+  Flag, getStackAlign());
 
 if (EmitCFI)
   CFIBuilder.buildDefCFAOffset(RealStackSize);
@@ -759,7 +760,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
   .addReg(RISCV::X0)
   .addReg(SPReg)
   .addImm(0)
-  .setMIFlags(MachineInstr::FrameSetup);
+  .setMIFlags(Flag);
 }
 
 return;
@@ -770,14 +771,13 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
 uint64_t CurrentOffset = 0;
 while (CurrentOffset + ProbeSize <= Offset) {
   RI->adjustReg(MBB, MBBI, DL, SPReg, SPReg,
-StackOffset::getFixed(-ProbeSize), 
MachineInstr::FrameSetup,
-getStackAlign());
+StackOffset::getFixed(-ProbeSize), Flag, getStackAlign());
   // s[d|w] zero, 0(sp)
   BuildMI(MBB, MBBI, DL, TII->get(IsRV64 ? RISCV::SD : RISCV::SW))
   .addReg(RISCV::X0)
   .addReg(SPReg)
   .addImm(0)
-  .setMIFlags(MachineInstr::FrameSetup);
+  .setMIFlags(Flag);
 
   CurrentOffset += ProbeSize;
   if (EmitCFI)
@@ -787,8 +787,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
 uint64_t Residual = Offset - CurrentOffset;
 if (Residual) {
   RI->adjustReg(MBB, MBBI, DL, SPReg, SPReg,
-StackOffset::getFixed(-Residual), MachineInstr::FrameSetup,
-getStackAlign());
+StackOffset::getFixed(-Residual), Flag, getStackAlign());
   if (EmitCFI)
 CFIBuilder.buildDefCFAOffset(Offset);
 
@@ -798,7 +797,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
 .addReg(RISCV::X0)
 .addReg(SPReg)
 .addImm(0)
-.setMIFlags(MachineInstr::FrameSetup);
+.setMIFlags(Flag);
   }
 }
 
@@ -812,8 +811,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
   Register TargetReg = RISCV::X6;
   // SUB TargetReg, SP, RoundedSize
   RI->adjustReg(MBB, MBBI, DL, TargetReg, SPReg,
-StackOffset::getFixed(-RoundedSize), MachineInstr::FrameSetup,
-getStackAlign());
+StackOffset::getFixed(-RoundedSize), Flag, getStackAlign());
 
   if (EmitCFI) {
 // Set the CFA register to TargetReg.
@@ -830,14 +828,14 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
 
   if (Residual) {
 RI->adjustReg(MBB, MBBI, DL, SPReg, SPReg, 
StackOffset::getFixed(-Residual),
-  MachineInstr::FrameSetup, getStackAlign());
+  Flag, getStackAlign());
 if (DynAllocation) {
   // s[d|w] zero, 0(sp)
   BuildMI(MBB, MBBI, DL, TII->get(IsRV64 ? RISCV::SD : RISCV::SW))
   .addReg(RISCV::X0)
   .addReg(SPReg)
  

[llvm-branch-commits] [llvm] release/21.x: [RISCV] Pass the MachineInstr flag as argument to allocateStack (#147531) (PR #149352)

2025-07-21 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/149352

>From 1abeeabd65e66940adbafcf84e958704a5b3f132 Mon Sep 17 00:00:00 2001
From: Raphael Moreira Zinsly 
Date: Tue, 15 Jul 2025 12:09:18 -0300
Subject: [PATCH] [RISCV] Pass the MachineInstr flag as argument to
 allocateStack (#147531)

When not in the prologue we do not want to set the FrameSetup flag, by
passing the flag as argument we can use allocateStack correctly on those
cases.
This fixes the allocation and probe in eliminateCallFramePseudoInstr.

(cherry picked from commit 1db9eb23209826d9e799e68a9a4090f0328bf70c)
---
 llvm/lib/Target/RISCV/RISCVFrameLowering.cpp  |  32 +--
 llvm/lib/Target/RISCV/RISCVFrameLowering.h|   3 +-
 .../RISCV/stack-probing-frame-setup.mir   | 198 ++
 3 files changed, 216 insertions(+), 17 deletions(-)
 create mode 100644 llvm/test/CodeGen/RISCV/stack-probing-frame-setup.mir

diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index a796c910bd449..6c8e3da80b932 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -738,7 +738,8 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
MachineFunction &MF, uint64_t Offset,
uint64_t RealStackSize, bool EmitCFI,
bool NeedProbe, uint64_t ProbeSize,
-   bool DynAllocation) const {
+   bool DynAllocation,
+   MachineInstr::MIFlag Flag) const {
   DebugLoc DL;
   const RISCVRegisterInfo *RI = STI.getRegisterInfo();
   const RISCVInstrInfo *TII = STI.getInstrInfo();
@@ -748,7 +749,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
   // Simply allocate the stack if it's not big enough to require a probe.
   if (!NeedProbe || Offset <= ProbeSize) {
 RI->adjustReg(MBB, MBBI, DL, SPReg, SPReg, StackOffset::getFixed(-Offset),
-  MachineInstr::FrameSetup, getStackAlign());
+  Flag, getStackAlign());
 
 if (EmitCFI)
   CFIBuilder.buildDefCFAOffset(RealStackSize);
@@ -759,7 +760,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
   .addReg(RISCV::X0)
   .addReg(SPReg)
   .addImm(0)
-  .setMIFlags(MachineInstr::FrameSetup);
+  .setMIFlags(Flag);
 }
 
 return;
@@ -770,14 +771,13 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
 uint64_t CurrentOffset = 0;
 while (CurrentOffset + ProbeSize <= Offset) {
   RI->adjustReg(MBB, MBBI, DL, SPReg, SPReg,
-StackOffset::getFixed(-ProbeSize), 
MachineInstr::FrameSetup,
-getStackAlign());
+StackOffset::getFixed(-ProbeSize), Flag, getStackAlign());
   // s[d|w] zero, 0(sp)
   BuildMI(MBB, MBBI, DL, TII->get(IsRV64 ? RISCV::SD : RISCV::SW))
   .addReg(RISCV::X0)
   .addReg(SPReg)
   .addImm(0)
-  .setMIFlags(MachineInstr::FrameSetup);
+  .setMIFlags(Flag);
 
   CurrentOffset += ProbeSize;
   if (EmitCFI)
@@ -787,8 +787,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
 uint64_t Residual = Offset - CurrentOffset;
 if (Residual) {
   RI->adjustReg(MBB, MBBI, DL, SPReg, SPReg,
-StackOffset::getFixed(-Residual), MachineInstr::FrameSetup,
-getStackAlign());
+StackOffset::getFixed(-Residual), Flag, getStackAlign());
   if (EmitCFI)
 CFIBuilder.buildDefCFAOffset(Offset);
 
@@ -798,7 +797,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
 .addReg(RISCV::X0)
 .addReg(SPReg)
 .addImm(0)
-.setMIFlags(MachineInstr::FrameSetup);
+.setMIFlags(Flag);
   }
 }
 
@@ -812,8 +811,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
   Register TargetReg = RISCV::X6;
   // SUB TargetReg, SP, RoundedSize
   RI->adjustReg(MBB, MBBI, DL, TargetReg, SPReg,
-StackOffset::getFixed(-RoundedSize), MachineInstr::FrameSetup,
-getStackAlign());
+StackOffset::getFixed(-RoundedSize), Flag, getStackAlign());
 
   if (EmitCFI) {
 // Set the CFA register to TargetReg.
@@ -830,14 +828,14 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock 
&MBB,
 
   if (Residual) {
 RI->adjustReg(MBB, MBBI, DL, SPReg, SPReg, 
StackOffset::getFixed(-Residual),
-  MachineInstr::FrameSetup, getStackAlign());
+  Flag, getStackAlign());
 if (DynAllocation) {
   // s[d|w] zero, 0(sp)
   BuildMI(MBB, MBBI, DL, TII->get(IsRV64 ? RISCV::SD : RISCV::SW))
   .addReg(RISCV::X0)
   .addReg(SPReg)
   .addImm(0)
-  .setM

[llvm-branch-commits] [llvm] release/21.x: [RISCV] Pass the MachineInstr flag as argument to allocateStack (#147531) (PR #149352)

2025-07-21 Thread Tobias Hieta via llvm-branch-commits

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


[llvm-branch-commits] [llvm] release/21.x: [RISCV] Pass the MachineInstr flag as argument to allocateStack (#147531) (PR #149352)

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

github-actions[bot] wrote:

@topperc (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/149352
___
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] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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

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

>From acc1a7d3da0d2bd5a60096a9f5dc27338342b952 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 16 Jul 2025 08:04:17 -0500
Subject: [PATCH 1/5] [flang][OpenMP] Sema checks, lowering with new format of
 MAP modifiers

OpenMP 6.0 has changed the modifiers on the MAP clause. Previous patch
has introduced parsing support for them. This patch introduces processing
of the new forms in semantic checks and in lowering. This only applies
to existing modifiers, which were updated in the 6.0 spec. Any of the
newly introduced modifiers (SELF and REF) are ignored.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  16 +--
 flang/lib/Lower/OpenMP/Clauses.cpp| 113 --
 flang/lib/Semantics/canonicalize-omp.cpp  |   5 +
 flang/lib/Semantics/check-omp-structure.cpp   | 107 +++--
 flang/lib/Semantics/check-omp-structure.h |   4 +-
 flang/lib/Semantics/openmp-utils.cpp  |  25 
 flang/lib/Semantics/openmp-utils.h|   3 +
 flang/lib/Semantics/resolve-directives.cpp|  50 ++--
 .../Semantics/OpenMP/combined-constructs.f90  |   8 +-
 .../Semantics/OpenMP/device-constructs.f90|   6 +-
 llvm/include/llvm/Frontend/OpenMP/ClauseT.h   |   9 +-
 .../Frontend/OpenMP/ConstructDecompositionT.h |   5 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.h   |   2 +
 llvm/lib/Frontend/OpenMP/OMP.cpp  |  14 +++
 14 files changed, 260 insertions(+), 107 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 74087d42a8e6e..ec71014c36093 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1315,7 +1315,8 @@ bool ClauseProcessor::processMap(
  const parser::CharBlock &source) {
 using Map = omp::clause::Map;
 mlir::Location clauseLocation = converter.genLocation(source);
-const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t;
+const auto &[mapType, typeMods, refMod, mappers, iterator, objects] =
+clause.t;
 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
 std::string mapperIdName = "__implicit_mapper";
@@ -1342,16 +1343,13 @@ bool ClauseProcessor::processMap(
   mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
  llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
   break;
-case Map::MapType::Alloc:
-case Map::MapType::Release:
+case Map::MapType::Storage:
   // alloc and release is the default map_type for the Target Data
   // Ops, i.e. if no bits for map_type is supplied then alloc/release
-  // is implicitly assumed based on the target directive. Default
-  // value for Target Data and Enter Data is alloc and for Exit Data
-  // it is release.
+  // (aka storage in 6.0+) is implicitly assumed based on the target
+  // directive. Default value for Target Data and Enter Data is alloc
+  // and for Exit Data it is release.
   break;
-case Map::MapType::Delete:
-  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
 }
 
 if (typeMods) {
@@ -1362,6 +1360,8 @@ bool ClauseProcessor::processMap(
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+  if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
+mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
 }
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index 22a07219d3a50..18e49719b6013 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -1001,64 +1001,105 @@ Map make(const parser::OmpClause::Map &inp,
  semantics::SemanticsContext &semaCtx) {
   // inp.v -> parser::OmpMapClause
   CLAUSET_ENUM_CONVERT( //
-  convert1, parser::OmpMapType::Value, Map::MapType,
+  convert1, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
   // clang-format off
-  MS(Alloc,Alloc)
-  MS(Delete,   Delete)
-  MS(From, From)
-  MS(Release,  Release)
-  MS(To,   To)
-  MS(Tofrom,   Tofrom)
+  MS(Always,Always)
+  MS(Close, Close)
+  MS(Ompx_Hold, OmpxHold)
+  MS(Present,   Present)
   // clang-format on
   );
 
   CLAUSET_ENUM_CONVERT( //
-  convert2, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
+  convert2, parser::OmpRefModifier::Value, Map::RefModifier,
   // clang-format off
-  MS(Always,Alwa

[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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

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

>From acc1a7d3da0d2bd5a60096a9f5dc27338342b952 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 16 Jul 2025 08:04:17 -0500
Subject: [PATCH 1/6] [flang][OpenMP] Sema checks, lowering with new format of
 MAP modifiers

OpenMP 6.0 has changed the modifiers on the MAP clause. Previous patch
has introduced parsing support for them. This patch introduces processing
of the new forms in semantic checks and in lowering. This only applies
to existing modifiers, which were updated in the 6.0 spec. Any of the
newly introduced modifiers (SELF and REF) are ignored.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  16 +--
 flang/lib/Lower/OpenMP/Clauses.cpp| 113 --
 flang/lib/Semantics/canonicalize-omp.cpp  |   5 +
 flang/lib/Semantics/check-omp-structure.cpp   | 107 +++--
 flang/lib/Semantics/check-omp-structure.h |   4 +-
 flang/lib/Semantics/openmp-utils.cpp  |  25 
 flang/lib/Semantics/openmp-utils.h|   3 +
 flang/lib/Semantics/resolve-directives.cpp|  50 ++--
 .../Semantics/OpenMP/combined-constructs.f90  |   8 +-
 .../Semantics/OpenMP/device-constructs.f90|   6 +-
 llvm/include/llvm/Frontend/OpenMP/ClauseT.h   |   9 +-
 .../Frontend/OpenMP/ConstructDecompositionT.h |   5 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.h   |   2 +
 llvm/lib/Frontend/OpenMP/OMP.cpp  |  14 +++
 14 files changed, 260 insertions(+), 107 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 74087d42a8e6e..ec71014c36093 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1315,7 +1315,8 @@ bool ClauseProcessor::processMap(
  const parser::CharBlock &source) {
 using Map = omp::clause::Map;
 mlir::Location clauseLocation = converter.genLocation(source);
-const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t;
+const auto &[mapType, typeMods, refMod, mappers, iterator, objects] =
+clause.t;
 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
 std::string mapperIdName = "__implicit_mapper";
@@ -1342,16 +1343,13 @@ bool ClauseProcessor::processMap(
   mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
  llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
   break;
-case Map::MapType::Alloc:
-case Map::MapType::Release:
+case Map::MapType::Storage:
   // alloc and release is the default map_type for the Target Data
   // Ops, i.e. if no bits for map_type is supplied then alloc/release
-  // is implicitly assumed based on the target directive. Default
-  // value for Target Data and Enter Data is alloc and for Exit Data
-  // it is release.
+  // (aka storage in 6.0+) is implicitly assumed based on the target
+  // directive. Default value for Target Data and Enter Data is alloc
+  // and for Exit Data it is release.
   break;
-case Map::MapType::Delete:
-  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
 }
 
 if (typeMods) {
@@ -1362,6 +1360,8 @@ bool ClauseProcessor::processMap(
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+  if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
+mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
 }
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index 22a07219d3a50..18e49719b6013 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -1001,64 +1001,105 @@ Map make(const parser::OmpClause::Map &inp,
  semantics::SemanticsContext &semaCtx) {
   // inp.v -> parser::OmpMapClause
   CLAUSET_ENUM_CONVERT( //
-  convert1, parser::OmpMapType::Value, Map::MapType,
+  convert1, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
   // clang-format off
-  MS(Alloc,Alloc)
-  MS(Delete,   Delete)
-  MS(From, From)
-  MS(Release,  Release)
-  MS(To,   To)
-  MS(Tofrom,   Tofrom)
+  MS(Always,Always)
+  MS(Close, Close)
+  MS(Ompx_Hold, OmpxHold)
+  MS(Present,   Present)
   // clang-format on
   );
 
   CLAUSET_ENUM_CONVERT( //
-  convert2, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
+  convert2, parser::OmpRefModifier::Value, Map::RefModifier,
   // clang-format off
-  MS(Always,Alwa

[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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

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

>From acc1a7d3da0d2bd5a60096a9f5dc27338342b952 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 16 Jul 2025 08:04:17 -0500
Subject: [PATCH 1/7] [flang][OpenMP] Sema checks, lowering with new format of
 MAP modifiers

OpenMP 6.0 has changed the modifiers on the MAP clause. Previous patch
has introduced parsing support for them. This patch introduces processing
of the new forms in semantic checks and in lowering. This only applies
to existing modifiers, which were updated in the 6.0 spec. Any of the
newly introduced modifiers (SELF and REF) are ignored.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  16 +--
 flang/lib/Lower/OpenMP/Clauses.cpp| 113 --
 flang/lib/Semantics/canonicalize-omp.cpp  |   5 +
 flang/lib/Semantics/check-omp-structure.cpp   | 107 +++--
 flang/lib/Semantics/check-omp-structure.h |   4 +-
 flang/lib/Semantics/openmp-utils.cpp  |  25 
 flang/lib/Semantics/openmp-utils.h|   3 +
 flang/lib/Semantics/resolve-directives.cpp|  50 ++--
 .../Semantics/OpenMP/combined-constructs.f90  |   8 +-
 .../Semantics/OpenMP/device-constructs.f90|   6 +-
 llvm/include/llvm/Frontend/OpenMP/ClauseT.h   |   9 +-
 .../Frontend/OpenMP/ConstructDecompositionT.h |   5 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.h   |   2 +
 llvm/lib/Frontend/OpenMP/OMP.cpp  |  14 +++
 14 files changed, 260 insertions(+), 107 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 74087d42a8e6e..ec71014c36093 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1315,7 +1315,8 @@ bool ClauseProcessor::processMap(
  const parser::CharBlock &source) {
 using Map = omp::clause::Map;
 mlir::Location clauseLocation = converter.genLocation(source);
-const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t;
+const auto &[mapType, typeMods, refMod, mappers, iterator, objects] =
+clause.t;
 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
 std::string mapperIdName = "__implicit_mapper";
@@ -1342,16 +1343,13 @@ bool ClauseProcessor::processMap(
   mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
  llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
   break;
-case Map::MapType::Alloc:
-case Map::MapType::Release:
+case Map::MapType::Storage:
   // alloc and release is the default map_type for the Target Data
   // Ops, i.e. if no bits for map_type is supplied then alloc/release
-  // is implicitly assumed based on the target directive. Default
-  // value for Target Data and Enter Data is alloc and for Exit Data
-  // it is release.
+  // (aka storage in 6.0+) is implicitly assumed based on the target
+  // directive. Default value for Target Data and Enter Data is alloc
+  // and for Exit Data it is release.
   break;
-case Map::MapType::Delete:
-  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
 }
 
 if (typeMods) {
@@ -1362,6 +1360,8 @@ bool ClauseProcessor::processMap(
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+  if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
+mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
 }
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index 22a07219d3a50..18e49719b6013 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -1001,64 +1001,105 @@ Map make(const parser::OmpClause::Map &inp,
  semantics::SemanticsContext &semaCtx) {
   // inp.v -> parser::OmpMapClause
   CLAUSET_ENUM_CONVERT( //
-  convert1, parser::OmpMapType::Value, Map::MapType,
+  convert1, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
   // clang-format off
-  MS(Alloc,Alloc)
-  MS(Delete,   Delete)
-  MS(From, From)
-  MS(Release,  Release)
-  MS(To,   To)
-  MS(Tofrom,   Tofrom)
+  MS(Always,Always)
+  MS(Close, Close)
+  MS(Ompx_Hold, OmpxHold)
+  MS(Present,   Present)
   // clang-format on
   );
 
   CLAUSET_ENUM_CONVERT( //
-  convert2, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
+  convert2, parser::OmpRefModifier::Value, Map::RefModifier,
   // clang-format off
-  MS(Always,Alwa

[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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


@@ -1003,12 +1003,13 @@ Map make(const parser::OmpClause::Map &inp,
   CLAUSET_ENUM_CONVERT( //
   convert1, parser::OmpMapType::Value, Map::MapType,

kparzysz wrote:

Done

https://github.com/llvm/llvm-project/pull/149137
___
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] [libclc] [libclc] Revert the recent breaking changes from CMake from the 21.x release branch (PR #149711)

2025-07-21 Thread Fraser Cormack via llvm-branch-commits
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= ,
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= ,
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= ,
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= 
Message-ID:
In-Reply-To: 


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

LGTM. Sorry about that.

https://github.com/llvm/llvm-project/pull/149711
___
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][linalg] Enable scalable vectorization of linalg.unpack (WIP) (PR #149293)

2025-07-21 Thread Andrzej Warzyński via llvm-branch-commits

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


[llvm-branch-commits] [llvm] release/21.x: [Support/BLAKE3] quick fix for Cygwin build (#148635) (PR #149408)

2025-07-21 Thread Michael Kruse via llvm-branch-commits

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


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


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

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

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

>From 8635063657a97c9e22e3a32c8ba9d645eb27e21e Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko 
Date: Mon, 10 Mar 2025 15:14:55 +0300
Subject: [PATCH 1/2] [AArch64][PAC] Precommit tests on merging
 MOVaddr/LOADgotAUTH with PAC*

---
 .../GlobalISel/ptrauth-constant-in-code.ll| 76 +++
 .../AArch64/ptrauth-constant-in-code.ll   | 71 +
 2 files changed, 147 insertions(+)

diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll 
b/llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll
index 12a3448111fcb..140e29f942a79 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll
@@ -78,6 +78,82 @@ define ptr @foo() {
   ret ptr ptrauth (ptr @g, i32 0)
 }
 
+;--- finalize-isel.ll
+
+; RUN: llc < finalize-isel.ll -mtriple aarch64-elf -mattr=+pauth 
-global-isel=1 \
+; RUN:   -verify-machineinstrs -global-isel-abort=1 -stop-after=finalize-isel 
| \
+; RUN:   FileCheck --check-prefixes=ISEL,ISEL-ELF %s
+; RUN: llc < finalize-isel.ll -mtriple arm64-apple-ios -mattr=+pauth 
-global-isel=1 \
+; RUN:   -verify-machineinstrs -global-isel-abort=1 -stop-after=finalize-isel 
| \
+; RUN:   FileCheck --check-prefixes=ISEL %s
+
+@const_table_local = dso_local constant [3 x ptr] [ptr null, ptr null, ptr 
null]
+@const_table_got = constant [3 x ptr] [ptr null, ptr null, ptr null]
+
+define void @store_signed_const_local(ptr %dest) {
+; ISEL-LABEL: name: store_signed_const_local
+; ISEL:   body:
+; ISEL: %0:gpr64common = COPY $x0
+; ISEL-NEXT:%10:gpr64common = MOVaddr target-flags(aarch64-page) 
@const_table_local + 8, target-flags(aarch64-pageoff, aarch64-nc) 
@const_table_local + 8
+; ISEL-NEXT:%2:gpr64noip = MOVKXi %0, 1234
+; ISEL-NEXT:%15:gpr64noip = COPY %0
+; ISEL-NEXT:%4:gpr64 = PAC %10, 2, 1234, %15, implicit-def dead $x17
+; ISEL-NEXT:%14:gpr64 = COPY %4
+; ISEL-NEXT:STRXui %14, %0, 0 :: (store (p0) into %ir.dest)
+; ISEL-NEXT:RET_ReallyLR
+  %dest.i = ptrtoint ptr %dest to i64
+  %discr = call i64 @llvm.ptrauth.blend(i64 %dest.i, i64 1234)
+  %signed.i = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr ([2 
x ptr], ptr @const_table_local, i32 0, i32 1) to i64), i32 2, i64 %discr)
+  %signed.ptr = inttoptr i64 %signed.i to ptr
+  store ptr %signed.ptr, ptr %dest
+  ret void
+}
+
+define void @store_signed_const_got(ptr %dest) {
+; ISEL-ELF-LABEL: name: store_signed_const_got
+; ISEL-ELF:   body:
+; ISEL-ELF: %0:gpr64common = COPY $x0
+; ISEL-ELF-NEXT:%7:gpr64common = LOADgotAUTH target-flags(aarch64-got) 
@const_table_got
+; ISEL-ELF-NEXT:%6:gpr64common = ADDXri %7, 8, 0
+; ISEL-ELF-NEXT:%2:gpr64noip = MOVKXi %0, 1234
+; ISEL-ELF-NEXT:%12:gpr64noip = COPY %0
+; ISEL-ELF-NEXT:%4:gpr64 = PAC %6, 2, 1234, %12, implicit-def dead $x17
+; ISEL-ELF-NEXT:%10:gpr64 = COPY %4
+; ISEL-ELF-NEXT:STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
+; ISEL-ELF-NEXT:RET_ReallyLR
+  %dest.i = ptrtoint ptr %dest to i64
+  %discr = call i64 @llvm.ptrauth.blend(i64 %dest.i, i64 1234)
+  %signed.i = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr ([2 
x ptr], ptr @const_table_got, i32 0, i32 1) to i64), i32 2, i64 %discr)
+  %signed.ptr = inttoptr i64 %signed.i to ptr
+  store ptr %signed.ptr, ptr %dest
+  ret void
+}
+
+define void @store_signed_arg(ptr %dest, ptr %p) {
+; ISEL-LABEL: name: store_signed_arg
+; ISEL:   body:
+; ISEL: %0:gpr64common = COPY $x0
+; ISEL-NEXT:%1:gpr64common = COPY $x1
+; ISEL-NEXT:%3:gpr64noip = MOVKXi %0, 1234
+; ISEL-NEXT:%6:gpr64common = ADDXri %1, 8, 0
+; ISEL-NEXT:%12:gpr64noip = COPY %0
+; ISEL-NEXT:%8:gpr64 = PAC %6, 2, 1234, %12, implicit-def dead $x17
+; ISEL-NEXT:%10:gpr64 = COPY %8
+; ISEL-NEXT:STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
+; ISEL-NEXT:RET_ReallyLR
+  %dest.i = ptrtoint ptr %dest to i64
+  %discr = call i64 @llvm.ptrauth.blend(i64 %dest.i, i64 1234)
+  %p.offset = getelementptr [2 x ptr], ptr %p, i32 0, i32 1
+  %p.offset.i = ptrtoint ptr %p.offset to i64
+  %signed.i = call i64 @llvm.ptrauth.sign(i64 %p.offset.i, i32 2, i64 %discr)
+  %signed.ptr = inttoptr i64 %signed.i to ptr
+  store ptr %signed.ptr, ptr %dest
+  ret void
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 1}
+
 ;--- ok.ll
 
 ; RUN: llc < ok.ll -mtriple aarch64-elf -mattr=+pauth -global-isel=1 \
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-constant-in-code.ll 
b/llvm/test/CodeGen/AArch64/ptrauth-constant-in-code.ll
index 76339a7cc5791..429ff6e5489aa 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-constant-in-code.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-constant-in-code.ll
@@ -69,6 +69,77 @@ define ptr @foo() {
   ret ptr ptrauth (ptr @g, i32 0)
 }
 
+;--- finalize-isel.ll
+
+; RUN: llc < final

[llvm-branch-commits] [clang] [llvm] [mlir] [OpenMPIRBuilder] Introduce OMPRegionInfo managing the stack of OpenMP region constructs. (PR #130135)

2025-07-21 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/130135
___
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] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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


@@ -402,6 +402,11 @@ class CanonicalizationOfOmp {
   // if the specified OpenMP version is less than 6.0, rewrite the affected
   // modifiers back into the pre-6.0 forms.
   void CanonicalizeMapModifiers(parser::OmpMapClause &map) {
+unsigned version{context_.langOptions().OpenMPVersion};
+if (version >= 60) {
+  return;

kparzysz wrote:

The OmpValidateModifiiers function should be doing that.  I can add a testcase 
for that.

https://github.com/llvm/llvm-project/pull/149137
___
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] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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

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

>From acc1a7d3da0d2bd5a60096a9f5dc27338342b952 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 16 Jul 2025 08:04:17 -0500
Subject: [PATCH 1/3] [flang][OpenMP] Sema checks, lowering with new format of
 MAP modifiers

OpenMP 6.0 has changed the modifiers on the MAP clause. Previous patch
has introduced parsing support for them. This patch introduces processing
of the new forms in semantic checks and in lowering. This only applies
to existing modifiers, which were updated in the 6.0 spec. Any of the
newly introduced modifiers (SELF and REF) are ignored.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  16 +--
 flang/lib/Lower/OpenMP/Clauses.cpp| 113 --
 flang/lib/Semantics/canonicalize-omp.cpp  |   5 +
 flang/lib/Semantics/check-omp-structure.cpp   | 107 +++--
 flang/lib/Semantics/check-omp-structure.h |   4 +-
 flang/lib/Semantics/openmp-utils.cpp  |  25 
 flang/lib/Semantics/openmp-utils.h|   3 +
 flang/lib/Semantics/resolve-directives.cpp|  50 ++--
 .../Semantics/OpenMP/combined-constructs.f90  |   8 +-
 .../Semantics/OpenMP/device-constructs.f90|   6 +-
 llvm/include/llvm/Frontend/OpenMP/ClauseT.h   |   9 +-
 .../Frontend/OpenMP/ConstructDecompositionT.h |   5 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.h   |   2 +
 llvm/lib/Frontend/OpenMP/OMP.cpp  |  14 +++
 14 files changed, 260 insertions(+), 107 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 74087d42a8e6e..ec71014c36093 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1315,7 +1315,8 @@ bool ClauseProcessor::processMap(
  const parser::CharBlock &source) {
 using Map = omp::clause::Map;
 mlir::Location clauseLocation = converter.genLocation(source);
-const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t;
+const auto &[mapType, typeMods, refMod, mappers, iterator, objects] =
+clause.t;
 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
 std::string mapperIdName = "__implicit_mapper";
@@ -1342,16 +1343,13 @@ bool ClauseProcessor::processMap(
   mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
  llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
   break;
-case Map::MapType::Alloc:
-case Map::MapType::Release:
+case Map::MapType::Storage:
   // alloc and release is the default map_type for the Target Data
   // Ops, i.e. if no bits for map_type is supplied then alloc/release
-  // is implicitly assumed based on the target directive. Default
-  // value for Target Data and Enter Data is alloc and for Exit Data
-  // it is release.
+  // (aka storage in 6.0+) is implicitly assumed based on the target
+  // directive. Default value for Target Data and Enter Data is alloc
+  // and for Exit Data it is release.
   break;
-case Map::MapType::Delete:
-  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
 }
 
 if (typeMods) {
@@ -1362,6 +1360,8 @@ bool ClauseProcessor::processMap(
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+  if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
+mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
 }
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index 22a07219d3a50..18e49719b6013 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -1001,64 +1001,105 @@ Map make(const parser::OmpClause::Map &inp,
  semantics::SemanticsContext &semaCtx) {
   // inp.v -> parser::OmpMapClause
   CLAUSET_ENUM_CONVERT( //
-  convert1, parser::OmpMapType::Value, Map::MapType,
+  convert1, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
   // clang-format off
-  MS(Alloc,Alloc)
-  MS(Delete,   Delete)
-  MS(From, From)
-  MS(Release,  Release)
-  MS(To,   To)
-  MS(Tofrom,   Tofrom)
+  MS(Always,Always)
+  MS(Close, Close)
+  MS(Ompx_Hold, OmpxHold)
+  MS(Present,   Present)
   // clang-format on
   );
 
   CLAUSET_ENUM_CONVERT( //
-  convert2, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
+  convert2, parser::OmpRefModifier::Value, Map::RefModifier,
   // clang-format off
-  MS(Always,Alwa

[llvm-branch-commits] [polly] [Polly] Introduce PhaseManager and remove LPM support (PR #125442)

2025-07-21 Thread Michael Kruse via llvm-branch-commits


@@ -0,0 +1,419 @@
+//===-- PhaseManager.cpp *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "polly/Pass/PhaseManager.h"
+#include "polly/CodeGen/CodeGeneration.h"
+#include "polly/CodeGen/IslAst.h"
+#include "polly/CodePreparation.h"
+#include "polly/DeLICM.h"
+#include "polly/DeadCodeElimination.h"
+#include "polly/DependenceInfo.h"
+#include "polly/FlattenSchedule.h"
+#include "polly/ForwardOpTree.h"
+#include "polly/JSONExporter.h"
+#include "polly/MaximalStaticExpansion.h"
+#include "polly/PruneUnprofitable.h"
+#include "polly/ScheduleOptimizer.h"
+#include "polly/ScopDetection.h"
+#include "polly/ScopDetectionDiagnostic.h"
+#include "polly/ScopGraphPrinter.h"
+#include "polly/ScopInfo.h"
+#include "polly/Simplify.h"
+#include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
+#include "llvm/IR/Module.h"
+
+#define DEBUG_TYPE "polly-pass"
+
+using namespace polly;
+using namespace llvm;
+
+namespace {
+
+/// Recurse through all subregions and all regions and add them to RQ.
+static void addRegionIntoQueue(Region &R, SmallVector &RQ) {
+  RQ.push_back(&R);
+  for (const auto &E : R)
+addRegionIntoQueue(*E, RQ);
+}
+
+/// The phase pipeline of Polly to be embedded into another pass manager than
+/// runs passes on functions.
+///
+/// Polly holds state besides LLVM-IR (RegionInfo and ScopInfo) between phases
+/// that LLVM pass managers do not consider when scheduling analyses and 
passes.
+/// That is, the ScopInfo must persist between phases that a pass manager must
+/// not invalidate to recompute later.
+class PhaseManager {
+private:
+  Function &F;
+  FunctionAnalysisManager &FAM;
+  PollyPassOptions Opts;
+
+public:
+  PhaseManager(Function &F, FunctionAnalysisManager &FAM, PollyPassOptions 
Opts)
+  : F(F), FAM(FAM), Opts(std::move(Opts)) {}
+
+  /// Execute Polly's phases as indicated by the options.
+  bool run() {
+// Get analyses from the function pass manager.
+// These must be preserved during all phases so that if processing one SCoP
+// has finished, the next SCoP can still use them. Recomputing is not an
+// option because ScopDetection stores references to the old results.
+// TODO: CodePreparation doesn't actually need these analysis, it just 
keeps
+// them up-to-date. If they are not computed yet, can also compute after 
the
+// prepare phase.
+auto &LI = FAM.getResult(F);
+auto &DT = FAM.getResult(F);
+bool ModifiedIR = false;
+
+// Phase: prepare
+// TODO: Setting ModifiedIR will invalidate any anlysis, even if DT, LI are
+// preserved.
+if (Opts.isPhaseEnabled(PassPhase::Prepare))
+  ModifiedIR |= runCodePreparation(F, &DT, &LI, nullptr);
+
+// Can't do anything without detection
+if (!Opts.isPhaseEnabled(PassPhase::Detection))
+  return false;
+
+auto &AA = FAM.getResult(F);
+auto &SE = FAM.getResult(F);
+auto &ORE = FAM.getResult(F);
+
+// ScopDetection is modifying RegionInfo, do not cache it, nor use a cached
+// version.
+RegionInfo RI = RegionInfoAnalysis().run(F, FAM);
+
+// Phase: detection
+ScopDetection SD(DT, SE, LI, RI, AA, ORE);
+SD.detect(F);
+if (Opts.isPhaseEnabled(PassPhase::PrintDetect)) {
+  outs() << "Detected Scops in Function " << F.getName() << "\n";
+  for (const Region *R : SD.ValidRegions)
+outs() << "Valid Region for Scop: " << R->getNameStr() << '\n';
+  outs() << "\n";
+}
+
+if (Opts.isPhaseEnabled(PassPhase::DotScops))
+  printGraphForFunction(F, &SD, "scops", false);
+if (Opts.isPhaseEnabled(PassPhase::DotScopsOnly))
+  printGraphForFunction(F, &SD, "scopsonly", true);
+
+auto ViewScops = [&](const char *Name, bool IsSimply) {
+  if (Opts.ViewFilter.empty() && !F.getName().count(Opts.ViewFilter))
+return;
+
+  if (Opts.ViewAll || std::distance(SD.begin(), SD.end()) > 0)
+viewGraphForFunction(F, &SD, Name, IsSimply);
+};
+if (Opts.isPhaseEnabled(PassPhase::ViewScops))
+  ViewScops("scops", false);
+if (Opts.isPhaseEnabled(PassPhase::ViewScopsOnly))
+  ViewScops("scopsonly", true);
+
+// Phase: scops
+auto &AC = FAM.getResult(F);
+const DataLayout &DL = F.getParent()->getDataLayout();
+ScopInfo Info(DL, SD, SE, LI, AA, DT, AC, ORE);

Meinersbur wrote:

I added `R.dump()` into `ScopBuilder::buildScop` to see in which order regions 
are processed before iterating over `ScopInfo`. Test 
`CodeGen/two-loops-right-after-each-other-2.ll`:

main:
```
# .---command stderr
# |   [1] for.body.310 => for.end.328
# |   [1] for.body.280 => for.body.310
#

[llvm-branch-commits] [clang] [LifetimeSafety] Add loan expiry analysis (PR #148712)

2025-07-21 Thread Yitzhak Mandelbaum via llvm-branch-commits


@@ -832,6 +833,65 @@ class LoanPropagationAnalysis
   }
 };
 
+// = //
+// Expired Loans Analysis
+// = //

ymand wrote:

nit: add dash.

https://github.com/llvm/llvm-project/pull/148712
___
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] [LifetimeSafety] Add loan expiry analysis (PR #148712)

2025-07-21 Thread Yitzhak Mandelbaum via llvm-branch-commits


@@ -832,6 +833,65 @@ class LoanPropagationAnalysis
   }
 };
 
+// = //
+// Expired Loans Analysis
+// = //
+
+/// The dataflow lattice for tracking the set of expired loans.
+struct ExpiredLattice {
+  LoanSet Expired;
+
+  ExpiredLattice() : Expired(nullptr) {};
+  explicit ExpiredLattice(LoanSet S) : Expired(S) {}
+
+  bool operator==(const ExpiredLattice &Other) const {
+return Expired == Other.Expired;
+  }
+  bool operator!=(const ExpiredLattice &Other) const {
+return !(*this == Other);
+  }
+
+  void dump(llvm::raw_ostream &OS) const {
+OS << "ExpiredLattice State:\n";
+if (Expired.isEmpty())
+  OS << "  \n";
+for (const LoanID &LID : Expired)
+  OS << "  Loan " << LID << " is expired\n";
+  }
+};
+
+/// The analysis that tracks which loans have expired.
+class ExpiredLoansAnalysis
+: public DataflowAnalysis {
+
+  LoanSet::Factory &Factory;
+
+public:
+  ExpiredLoansAnalysis(const CFG &C, AnalysisDeclContext &AC, FactManager &F,
+   LifetimeFactory &Factory)
+  : DataflowAnalysis(C, AC, F), Factory(Factory.LoanSetFactory) {}
+
+  using Base::transfer;
+
+  StringRef getAnalysisName() const { return "ExpiredLoans"; }
+
+  Lattice getInitialState() { return Lattice(Factory.getEmptySet()); }
+
+  /// Merges two lattices by taking the union of the expired loan sets.
+  Lattice join(Lattice L1, Lattice L2) const {
+return Lattice(utils::join(L1.Expired, L2.Expired, Factory));
+  }
+
+  Lattice transfer(Lattice In, const ExpireFact &F) {
+return Lattice(Factory.add(In.Expired, F.getLoanID()));
+  }
+
+  Lattice transfer(Lattice In, const IssueFact &F) {
+return Lattice(Factory.remove(In.Expired, F.getLoanID()));

ymand wrote:

Might be worth explaining why this is necessary. Specifically, now its possible 
that the loan would appear in `In.Expired` at all to be worth removing. I 
assume this arises because of backedges.

https://github.com/llvm/llvm-project/pull/148712
___
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] [LifetimeSafety] Add loan expiry analysis (PR #148712)

2025-07-21 Thread Yitzhak Mandelbaum via llvm-branch-commits


@@ -23,14 +23,15 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/TimeProfiler.h"
 #include 
+#include 
 
 namespace clang::lifetimes {
 namespace internal {
 namespace {
-template 
-inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, ID ID) {
-  return OS << ID.Value;
-}
+// template 

ymand wrote:

delete?

https://github.com/llvm/llvm-project/pull/148712
___
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] [LifetimeSafety] Add loan expiry analysis (PR #148712)

2025-07-21 Thread Yitzhak Mandelbaum via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/148712
___
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-07-21 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur 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] [AMDGPU][SDAG] Handle ISD::PTRADD in various special cases (PR #145330)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/145330

>From bf788982995fba2db158251bb78c9cf110b27a49 Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Tue, 17 Jun 2025 04:03:53 -0400
Subject: [PATCH 1/2] [AMDGPU][SDAG] Handle ISD::PTRADD in various special
 cases

There are more places in SIISelLowering.cpp and AMDGPUISelDAGToDAG.cpp
that check for ISD::ADD in a pointer context, but as far as I can tell
those are only relevant for 32-bit pointer arithmetic (like frame
indices/scratch addresses and LDS), for which we don't enable PTRADD
generation yet.

For SWDEV-516125.
---
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp |   2 +-
 .../CodeGen/SelectionDAG/TargetLowering.cpp   |  21 +-
 llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp |   6 +-
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp |   7 +-
 llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll |  67 ++
 .../AMDGPU/ptradd-sdag-optimizations.ll   | 196 ++
 6 files changed, 105 insertions(+), 194 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 5453828177c72..8ec799e56bfec 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -8332,7 +8332,7 @@ static bool isMemSrcFromConstant(SDValue Src, 
ConstantDataArraySlice &Slice) {
   GlobalAddressSDNode *G = nullptr;
   if (Src.getOpcode() == ISD::GlobalAddress)
 G = cast(Src);
-  else if (Src.getOpcode() == ISD::ADD &&
+  else if (Src->isAnyAdd() &&
Src.getOperand(0).getOpcode() == ISD::GlobalAddress &&
Src.getOperand(1).getOpcode() == ISD::Constant) {
 G = cast(Src.getOperand(0));
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index e0597988e8907..3475bb0a66202 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -632,8 +632,14 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned 
BitWidth,
   // operands on the new node are also disjoint.
   SDNodeFlags Flags(Op->getFlags().hasDisjoint() ? SDNodeFlags::Disjoint
  : SDNodeFlags::None);
+  unsigned Opcode = Op.getOpcode();
+  if (Opcode == ISD::PTRADD) {
+// It isn't a ptradd anymore if it doesn't operate on the entire
+// pointer.
+Opcode = ISD::ADD;
+  }
   SDValue X = DAG.getNode(
-  Op.getOpcode(), dl, SmallVT,
+  Opcode, dl, SmallVT,
   DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(0)),
   DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(1)), Flags);
   assert(DemandedSize <= SmallVTBits && "Narrowed below demanded bits?");
@@ -2868,6 +2874,11 @@ bool TargetLowering::SimplifyDemandedBits(
   return TLO.CombineTo(Op, And1);
 }
 [[fallthrough]];
+  case ISD::PTRADD:
+if (Op.getOperand(0).getValueType() != Op.getOperand(1).getValueType())
+  break;
+// PTRADD behaves like ADD if pointers are represented as integers.
+[[fallthrough]];
   case ISD::ADD:
   case ISD::SUB: {
 // Add, Sub, and Mul don't demand any bits in positions beyond that
@@ -2977,10 +2988,10 @@ bool TargetLowering::SimplifyDemandedBits(
 
 if (Op.getOpcode() == ISD::MUL) {
   Known = KnownBits::mul(KnownOp0, KnownOp1);
-} else { // Op.getOpcode() is either ISD::ADD or ISD::SUB.
+} else { // Op.getOpcode() is either ISD::ADD, ISD::PTRADD, or ISD::SUB.
   Known = KnownBits::computeForAddSub(
-  Op.getOpcode() == ISD::ADD, Flags.hasNoSignedWrap(),
-  Flags.hasNoUnsignedWrap(), KnownOp0, KnownOp1);
+  Op->isAnyAdd(), Flags.hasNoSignedWrap(), Flags.hasNoUnsignedWrap(),
+  KnownOp0, KnownOp1);
 }
 break;
   }
@@ -5662,7 +5673,7 @@ bool TargetLowering::isGAPlusOffset(SDNode *WN, const 
GlobalValue *&GA,
 return true;
   }
 
-  if (N->getOpcode() == ISD::ADD) {
+  if (N->isAnyAdd()) {
 SDValue N1 = N->getOperand(0);
 SDValue N2 = N->getOperand(1);
 if (isGAPlusOffset(N1.getNode(), GA, Offset)) {
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
index 25672a52345cb..79522d9b796ec 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
@@ -1478,7 +1478,7 @@ bool AMDGPUDAGToDAGISel::SelectMUBUF(SDValue Addr, 
SDValue &Ptr, SDValue &VAddr,
   C1 = nullptr;
   }
 
-  if (N0.getOpcode() == ISD::ADD) {
+  if (N0->isAnyAdd()) {
 // (add N2, N3) -> addr64, or
 // (add (add N2, N3), C1) -> addr64
 SDValue N2 = N0.getOperand(0);
@@ -1927,7 +1927,7 @@ bool AMDGPUDAGToDAGISel::SelectGlobalSAddr(SDNode *N,
   }
 
   // Match the variable offset.
-  if (Addr.getOpcode() == ISD::ADD) {
+  if (Addr->isAnyAdd()) {
 LHS = Addr.getOperand(0);
 RHS = Addr.getOperand(1);

[llvm-branch-commits] [llvm] [SDAG][AMDGPU] Allow opting in to OOB-generating PTRADD transforms (PR #146074)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/146074

>From ea26451beb2e03cd0a8ae5006d7288f3f6e7a5c3 Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Thu, 26 Jun 2025 06:10:35 -0400
Subject: [PATCH] [SDAG][AMDGPU] Allow opting in to OOB-generating PTRADD
 transforms

This PR adds a TargetLowering hook, canTransformPtrArithOutOfBounds,
that targets can use to allow transformations to introduce out-of-bounds
pointer arithmetic. It also moves two such transformations from the
AMDGPU-specific DAG combines to the generic DAGCombiner.

This is motivated by target features like AArch64's checked pointer
arithmetic, CPA, which does not tolerate the introduction of
out-of-bounds pointer arithmetic.
---
 llvm/include/llvm/CodeGen/TargetLowering.h|   7 +
 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 125 +++---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp |  59 ++---
 llvm/lib/Target/AMDGPU/SIISelLowering.h   |   3 +
 4 files changed, 94 insertions(+), 100 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 1a548a536f088..44dd5234ab693 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -3504,6 +3504,13 @@ class LLVM_ABI TargetLoweringBase {
 return false;
   }
 
+  /// True if the target allows transformations of in-bounds pointer
+  /// arithmetic that cause out-of-bounds intermediate results.
+  virtual bool canTransformPtrArithOutOfBounds(const Function &F,
+   EVT PtrVT) const {
+return false;
+  }
+
   /// Does this target support complex deinterleaving
   virtual bool isComplexDeinterleavingSupported() const { return false; }
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 40464e91f9efc..476a1f3223a28 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2688,59 +2688,82 @@ SDValue DAGCombiner::visitPTRADD(SDNode *N) {
   if (PtrVT == IntVT && isNullConstant(N0))
 return N1;
 
-  if (N0.getOpcode() != ISD::PTRADD ||
-  reassociationCanBreakAddressingModePattern(ISD::PTRADD, DL, N, N0, N1))
-return SDValue();
-
-  SDValue X = N0.getOperand(0);
-  SDValue Y = N0.getOperand(1);
-  SDValue Z = N1;
-  bool N0OneUse = N0.hasOneUse();
-  bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
-  bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
-
-  // (ptradd (ptradd x, y), z) -> (ptradd x, (add y, z)) if:
-  //   * y is a constant and (ptradd x, y) has one use; or
-  //   * y and z are both constants.
-  if ((YIsConstant && N0OneUse) || (YIsConstant && ZIsConstant)) {
-// If both additions in the original were NUW, the new ones are as well.
-SDNodeFlags Flags =
-(N->getFlags() & N0->getFlags()) & SDNodeFlags::NoUnsignedWrap;
-SDValue Add = DAG.getNode(ISD::ADD, DL, IntVT, {Y, Z}, Flags);
-AddToWorklist(Add.getNode());
-return DAG.getMemBasePlusOffset(X, Add, DL, Flags);
+  if (N0.getOpcode() == ISD::PTRADD &&
+  !reassociationCanBreakAddressingModePattern(ISD::PTRADD, DL, N, N0, N1)) 
{
+SDValue X = N0.getOperand(0);
+SDValue Y = N0.getOperand(1);
+SDValue Z = N1;
+bool N0OneUse = N0.hasOneUse();
+bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
+bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
+
+// (ptradd (ptradd x, y), z) -> (ptradd x, (add y, z)) if:
+//   * y is a constant and (ptradd x, y) has one use; or
+//   * y and z are both constants.
+if ((YIsConstant && N0OneUse) || (YIsConstant && ZIsConstant)) {
+  // If both additions in the original were NUW, the new ones are as well.
+  SDNodeFlags Flags =
+  (N->getFlags() & N0->getFlags()) & SDNodeFlags::NoUnsignedWrap;
+  SDValue Add = DAG.getNode(ISD::ADD, DL, IntVT, {Y, Z}, Flags);
+  AddToWorklist(Add.getNode());
+  return DAG.getMemBasePlusOffset(X, Add, DL, Flags);
+}
+  }
+
+  // The following combines can turn in-bounds pointer arithmetic out of 
bounds.
+  // That is problematic for settings like AArch64's CPA, which checks that
+  // intermediate results of pointer arithmetic remain in bounds. The target
+  // therefore needs to opt-in to enable them.
+  if (!TLI.canTransformPtrArithOutOfBounds(
+  DAG.getMachineFunction().getFunction(), PtrVT))
+return SDValue();
+
+  if (N0.getOpcode() == ISD::PTRADD && N1.getOpcode() == ISD::Constant) {
+// Fold (ptradd (ptradd GA, v), c) -> (ptradd (ptradd GA, c) v) with
+// global address GA and constant c, such that c can be folded into GA.
+SDValue GAValue = N0.getOperand(0);
+if (const GlobalAddressSDNode *GA =
+dyn_cast(GAValue)) {
+  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+  if (!LegalOperations && TLI.isOf

[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Enable ISD::PTRADD for 64-bit AS by default (PR #146076)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/146076

>From f78f6c3ae4a580b5dfe22a042dcc6015263060c2 Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Fri, 27 Jun 2025 05:38:52 -0400
Subject: [PATCH] [AMDGPU][SDAG] Enable ISD::PTRADD for 64-bit AS by default

Also removes the command line option to control this feature.

There seem to be mainly two kinds of test changes:
- Some operands of addition instructions are swapped; that is to be expected
  since PTRADD is not commutative.
- Improvements in code generation, probably because the legacy lowering enabled
  some transformations that were sometimes harmful.

For SWDEV-516125.
---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp |  10 +-
 .../identical-subrange-spill-infloop.ll   | 354 +++---
 .../AMDGPU/infer-addrspace-flat-atomic.ll |  14 +-
 llvm/test/CodeGen/AMDGPU/lds-frame-extern.ll  |   8 +-
 .../AMDGPU/lower-module-lds-via-hybrid.ll |   4 +-
 .../AMDGPU/lower-module-lds-via-table.ll  |  16 +-
 .../match-perm-extract-vector-elt-bug.ll  |  22 +-
 llvm/test/CodeGen/AMDGPU/memmove-var-size.ll  |  16 +-
 .../AMDGPU/preload-implicit-kernargs.ll   |   6 +-
 .../AMDGPU/promote-constOffset-to-imm.ll  |   8 +-
 llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll |   7 +-
 .../AMDGPU/ptradd-sdag-optimizations.ll   |  94 ++---
 .../AMDGPU/ptradd-sdag-undef-poison.ll|   6 +-
 llvm/test/CodeGen/AMDGPU/ptradd-sdag.ll   |  27 +-
 llvm/test/CodeGen/AMDGPU/store-weird-sizes.ll |  29 +-
 15 files changed, 311 insertions(+), 310 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index f2161f8cdcad6..cc731d5c1a7a7 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -63,14 +63,6 @@ static cl::opt UseDivergentRegisterIndexing(
 cl::desc("Use indirect register addressing for divergent indexes"),
 cl::init(false));
 
-// TODO: This option should be removed once we switch to always using PTRADD in
-// the SelectionDAG.
-static cl::opt UseSelectionDAGPTRADD(
-"amdgpu-use-sdag-ptradd", cl::Hidden,
-cl::desc("Generate ISD::PTRADD nodes for 64-bit pointer arithmetic in the "
- "SelectionDAG ISel"),
-cl::init(false));
-
 static bool denormalModeIsFlushAllF32(const MachineFunction &MF) {
   const SIMachineFunctionInfo *Info = MF.getInfo();
   return Info->getMode().FP32Denormals == DenormalMode::getPreserveSign();
@@ -10685,7 +10677,7 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue 
Op,
 
 bool SITargetLowering::shouldPreservePtrArith(const Function &F,
   EVT PtrVT) const {
-  return UseSelectionDAGPTRADD && PtrVT == MVT::i64;
+  return PtrVT == MVT::i64;
 }
 
 bool SITargetLowering::canTransformPtrArithOutOfBounds(const Function &F,
diff --git a/llvm/test/CodeGen/AMDGPU/identical-subrange-spill-infloop.ll 
b/llvm/test/CodeGen/AMDGPU/identical-subrange-spill-infloop.ll
index 56ceba258f471..f9fcf489bd389 100644
--- a/llvm/test/CodeGen/AMDGPU/identical-subrange-spill-infloop.ll
+++ b/llvm/test/CodeGen/AMDGPU/identical-subrange-spill-infloop.ll
@@ -6,97 +6,151 @@ define void @main(i1 %arg) #0 {
 ; CHECK:   ; %bb.0: ; %bb
 ; CHECK-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; CHECK-NEXT:s_xor_saveexec_b64 s[4:5], -1
-; CHECK-NEXT:buffer_store_dword v5, off, s[0:3], s32 ; 4-byte Folded Spill
-; CHECK-NEXT:buffer_store_dword v6, off, s[0:3], s32 offset:4 ; 4-byte 
Folded Spill
+; CHECK-NEXT:buffer_store_dword v6, off, s[0:3], s32 ; 4-byte Folded Spill
+; CHECK-NEXT:buffer_store_dword v7, off, s[0:3], s32 offset:4 ; 4-byte 
Folded Spill
 ; CHECK-NEXT:s_mov_b64 exec, s[4:5]
-; CHECK-NEXT:v_writelane_b32 v5, s30, 0
-; CHECK-NEXT:v_writelane_b32 v5, s31, 1
-; CHECK-NEXT:v_writelane_b32 v5, s36, 2
-; CHECK-NEXT:v_writelane_b32 v5, s37, 3
-; CHECK-NEXT:v_writelane_b32 v5, s38, 4
-; CHECK-NEXT:v_writelane_b32 v5, s39, 5
-; CHECK-NEXT:v_writelane_b32 v5, s48, 6
-; CHECK-NEXT:v_writelane_b32 v5, s49, 7
-; CHECK-NEXT:v_writelane_b32 v5, s50, 8
-; CHECK-NEXT:v_writelane_b32 v5, s51, 9
-; CHECK-NEXT:v_writelane_b32 v5, s52, 10
-; CHECK-NEXT:v_writelane_b32 v5, s53, 11
-; CHECK-NEXT:v_writelane_b32 v5, s54, 12
-; CHECK-NEXT:v_writelane_b32 v5, s55, 13
-; CHECK-NEXT:s_getpc_b64 s[24:25]
-; CHECK-NEXT:v_writelane_b32 v5, s64, 14
-; CHECK-NEXT:s_movk_i32 s4, 0xf0
-; CHECK-NEXT:s_mov_b32 s5, s24
-; CHECK-NEXT:v_writelane_b32 v5, s65, 15
-; CHECK-NEXT:s_load_dwordx16 s[8:23], s[4:5], 0x0
-; CHECK-NEXT:s_mov_b64 s[4:5], 0
-; CHECK-NEXT:v_writelane_b32 v5, s66, 16
-; CHECK-NEXT:s_load_dwordx4 s[4:7], s[4:5], 0x0
-; CHECK-NEXT:v_writelane_b32 v5, s67, 17
-; CHECK-NEXT:s_waitcnt lgkmcnt(0)
-; CHECK-NEXT:s_movk_i32 s6, 0x130
-; CHECK-NEXT:s_mov_b32 s7, s24
-; CHECK-NEXT:v_writela

[llvm-branch-commits] [llvm] [AMDGPU][SDAG] DAGCombine PTRADD -> disjoint OR (PR #146075)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/146075

>From 43aa79f3f328e182d17b649f3656b1467ac72e3d Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Fri, 27 Jun 2025 04:23:50 -0400
Subject: [PATCH 1/3] [AMDGPU][SDAG] DAGCombine PTRADD -> disjoint OR

If we can't fold a PTRADD's offset into its users, lowering them to
disjoint ORs is preferable: Often, a 32-bit OR instruction suffices
where we'd otherwise use a pair of 32-bit additions with carry.

This needs to be a DAGCombine (and not a selection rule) because its
main purpose is to enable subsequent DAGCombines for bitwise operations.
We don't want to just turn PTRADDs into disjoint ORs whenever that's
sound because this transform loses the information that the operation
implements pointer arithmetic, which we will soon need to fold offsets
into FLAT instructions. Currently, disjoint ORs can still be used for
offset folding, so that part of the logic can't be tested.

The PR contains a hacky workaround for a situation where an AssertAlign
operand of a PTRADD is not DAGCombined before the PTRADD, causing the
PTRADD to be turned into a disjoint OR although reassociating it with
the operand of the AssertAlign would be better. This wouldn't be a
problem if the DAGCombiner ensured that a node is only processed after
all its operands have been processed.

For SWDEV-516125.
---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 35 
 .../AMDGPU/ptradd-sdag-optimizations.ll   | 56 ++-
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index f2161f8cdcad6..72d398da5f872 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -15236,6 +15236,41 @@ SDValue SITargetLowering::performPtrAddCombine(SDNode 
*N,
   return Folded;
   }
 
+  // Transform (ptradd a, b) -> (or disjoint a, b) if it is equivalent and if
+  // that transformation can't block an offset folding at any use of the 
ptradd.
+  // This should be done late, after legalization, so that it doesn't block
+  // other ptradd combines that could enable more offset folding.
+  bool HasIntermediateAssertAlign =
+  N0->getOpcode() == ISD::AssertAlign && N0->getOperand(0)->isAnyAdd();
+  // This is a hack to work around an ordering problem for DAGs like this:
+  //   (ptradd (AssertAlign (ptradd p, c1), k), c2)
+  // If the outer ptradd is handled first by the DAGCombiner, it can be
+  // transformed into a disjoint or. Then, when the generic AssertAlign combine
+  // pushes the AssertAlign through the inner ptradd, it's too late for the
+  // ptradd reassociation to trigger.
+  if (!DCI.isBeforeLegalizeOps() && !HasIntermediateAssertAlign &&
+  DAG.haveNoCommonBitsSet(N0, N1)) {
+bool TransformCanBreakAddrMode = any_of(N->users(), [&](SDNode *User) {
+  if (auto *LoadStore = dyn_cast(User);
+  LoadStore && LoadStore->getBasePtr().getNode() == N) {
+unsigned AS = LoadStore->getAddressSpace();
+// Currently, we only really need ptradds to fold offsets into flat
+// memory instructions.
+if (AS != AMDGPUAS::FLAT_ADDRESS)
+  return false;
+TargetLoweringBase::AddrMode AM;
+AM.HasBaseReg = true;
+EVT VT = LoadStore->getMemoryVT();
+Type *AccessTy = VT.getTypeForEVT(*DAG.getContext());
+return isLegalAddressingMode(DAG.getDataLayout(), AM, AccessTy, AS);
+  }
+  return false;
+});
+
+if (!TransformCanBreakAddrMode)
+  return DAG.getNode(ISD::OR, DL, VT, N0, N1, SDNodeFlags::Disjoint);
+  }
+
   if (N1.getOpcode() != ISD::ADD || !N1.hasOneUse())
 return SDValue();
 
diff --git a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll 
b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
index 893deb35fe822..64e041103a563 100644
--- a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
+++ b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
@@ -100,7 +100,7 @@ define void @baseptr_null(i64 %offset, i8 %v) {
 
 ; Taken from implicit-kernarg-backend-usage.ll, tests the PTRADD handling in 
the
 ; assertalign DAG combine.
-define amdgpu_kernel void @llvm_amdgcn_queue_ptr(ptr addrspace(1) %ptr)  #0 {
+define amdgpu_kernel void @llvm_amdgcn_queue_ptr(ptr addrspace(1) %ptr) {
 ; GFX942-LABEL: llvm_amdgcn_queue_ptr:
 ; GFX942:   ; %bb.0:
 ; GFX942-NEXT:v_mov_b32_e32 v2, 0
@@ -416,6 +416,60 @@ entry:
   ret void
 }
 
+; Check that ptradds can be lowered to disjoint ORs.
+define ptr @gep_disjoint_or(ptr %base) {
+; GFX942-LABEL: gep_disjoint_or:
+; GFX942:   ; %bb.0:
+; GFX942-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX942-NEXT:v_and_or_b32 v0, v0, -16, 4
+; GFX942-NEXT:s_setpc_b64 s[30:31]
+  %p = call ptr @llvm.ptrmask(ptr %base, i64 s0xf0)
+  %gep = getelementptr nuw inbounds i8, ptr %p, i64 4
+  ret ptr %gep
+}
+
+; Check that AssertAlign no

[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Enable ISD::PTRADD for 64-bit AS by default (PR #146076)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/146076

>From f78f6c3ae4a580b5dfe22a042dcc6015263060c2 Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Fri, 27 Jun 2025 05:38:52 -0400
Subject: [PATCH] [AMDGPU][SDAG] Enable ISD::PTRADD for 64-bit AS by default

Also removes the command line option to control this feature.

There seem to be mainly two kinds of test changes:
- Some operands of addition instructions are swapped; that is to be expected
  since PTRADD is not commutative.
- Improvements in code generation, probably because the legacy lowering enabled
  some transformations that were sometimes harmful.

For SWDEV-516125.
---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp |  10 +-
 .../identical-subrange-spill-infloop.ll   | 354 +++---
 .../AMDGPU/infer-addrspace-flat-atomic.ll |  14 +-
 llvm/test/CodeGen/AMDGPU/lds-frame-extern.ll  |   8 +-
 .../AMDGPU/lower-module-lds-via-hybrid.ll |   4 +-
 .../AMDGPU/lower-module-lds-via-table.ll  |  16 +-
 .../match-perm-extract-vector-elt-bug.ll  |  22 +-
 llvm/test/CodeGen/AMDGPU/memmove-var-size.ll  |  16 +-
 .../AMDGPU/preload-implicit-kernargs.ll   |   6 +-
 .../AMDGPU/promote-constOffset-to-imm.ll  |   8 +-
 llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll |   7 +-
 .../AMDGPU/ptradd-sdag-optimizations.ll   |  94 ++---
 .../AMDGPU/ptradd-sdag-undef-poison.ll|   6 +-
 llvm/test/CodeGen/AMDGPU/ptradd-sdag.ll   |  27 +-
 llvm/test/CodeGen/AMDGPU/store-weird-sizes.ll |  29 +-
 15 files changed, 311 insertions(+), 310 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index f2161f8cdcad6..cc731d5c1a7a7 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -63,14 +63,6 @@ static cl::opt UseDivergentRegisterIndexing(
 cl::desc("Use indirect register addressing for divergent indexes"),
 cl::init(false));
 
-// TODO: This option should be removed once we switch to always using PTRADD in
-// the SelectionDAG.
-static cl::opt UseSelectionDAGPTRADD(
-"amdgpu-use-sdag-ptradd", cl::Hidden,
-cl::desc("Generate ISD::PTRADD nodes for 64-bit pointer arithmetic in the "
- "SelectionDAG ISel"),
-cl::init(false));
-
 static bool denormalModeIsFlushAllF32(const MachineFunction &MF) {
   const SIMachineFunctionInfo *Info = MF.getInfo();
   return Info->getMode().FP32Denormals == DenormalMode::getPreserveSign();
@@ -10685,7 +10677,7 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue 
Op,
 
 bool SITargetLowering::shouldPreservePtrArith(const Function &F,
   EVT PtrVT) const {
-  return UseSelectionDAGPTRADD && PtrVT == MVT::i64;
+  return PtrVT == MVT::i64;
 }
 
 bool SITargetLowering::canTransformPtrArithOutOfBounds(const Function &F,
diff --git a/llvm/test/CodeGen/AMDGPU/identical-subrange-spill-infloop.ll 
b/llvm/test/CodeGen/AMDGPU/identical-subrange-spill-infloop.ll
index 56ceba258f471..f9fcf489bd389 100644
--- a/llvm/test/CodeGen/AMDGPU/identical-subrange-spill-infloop.ll
+++ b/llvm/test/CodeGen/AMDGPU/identical-subrange-spill-infloop.ll
@@ -6,97 +6,151 @@ define void @main(i1 %arg) #0 {
 ; CHECK:   ; %bb.0: ; %bb
 ; CHECK-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; CHECK-NEXT:s_xor_saveexec_b64 s[4:5], -1
-; CHECK-NEXT:buffer_store_dword v5, off, s[0:3], s32 ; 4-byte Folded Spill
-; CHECK-NEXT:buffer_store_dword v6, off, s[0:3], s32 offset:4 ; 4-byte 
Folded Spill
+; CHECK-NEXT:buffer_store_dword v6, off, s[0:3], s32 ; 4-byte Folded Spill
+; CHECK-NEXT:buffer_store_dword v7, off, s[0:3], s32 offset:4 ; 4-byte 
Folded Spill
 ; CHECK-NEXT:s_mov_b64 exec, s[4:5]
-; CHECK-NEXT:v_writelane_b32 v5, s30, 0
-; CHECK-NEXT:v_writelane_b32 v5, s31, 1
-; CHECK-NEXT:v_writelane_b32 v5, s36, 2
-; CHECK-NEXT:v_writelane_b32 v5, s37, 3
-; CHECK-NEXT:v_writelane_b32 v5, s38, 4
-; CHECK-NEXT:v_writelane_b32 v5, s39, 5
-; CHECK-NEXT:v_writelane_b32 v5, s48, 6
-; CHECK-NEXT:v_writelane_b32 v5, s49, 7
-; CHECK-NEXT:v_writelane_b32 v5, s50, 8
-; CHECK-NEXT:v_writelane_b32 v5, s51, 9
-; CHECK-NEXT:v_writelane_b32 v5, s52, 10
-; CHECK-NEXT:v_writelane_b32 v5, s53, 11
-; CHECK-NEXT:v_writelane_b32 v5, s54, 12
-; CHECK-NEXT:v_writelane_b32 v5, s55, 13
-; CHECK-NEXT:s_getpc_b64 s[24:25]
-; CHECK-NEXT:v_writelane_b32 v5, s64, 14
-; CHECK-NEXT:s_movk_i32 s4, 0xf0
-; CHECK-NEXT:s_mov_b32 s5, s24
-; CHECK-NEXT:v_writelane_b32 v5, s65, 15
-; CHECK-NEXT:s_load_dwordx16 s[8:23], s[4:5], 0x0
-; CHECK-NEXT:s_mov_b64 s[4:5], 0
-; CHECK-NEXT:v_writelane_b32 v5, s66, 16
-; CHECK-NEXT:s_load_dwordx4 s[4:7], s[4:5], 0x0
-; CHECK-NEXT:v_writelane_b32 v5, s67, 17
-; CHECK-NEXT:s_waitcnt lgkmcnt(0)
-; CHECK-NEXT:s_movk_i32 s6, 0x130
-; CHECK-NEXT:s_mov_b32 s7, s24
-; CHECK-NEXT:v_writela

[llvm-branch-commits] [llvm] [AMDGPU][SDAG] DAGCombine PTRADD -> disjoint OR (PR #146075)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/146075

>From 43aa79f3f328e182d17b649f3656b1467ac72e3d Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Fri, 27 Jun 2025 04:23:50 -0400
Subject: [PATCH 1/3] [AMDGPU][SDAG] DAGCombine PTRADD -> disjoint OR

If we can't fold a PTRADD's offset into its users, lowering them to
disjoint ORs is preferable: Often, a 32-bit OR instruction suffices
where we'd otherwise use a pair of 32-bit additions with carry.

This needs to be a DAGCombine (and not a selection rule) because its
main purpose is to enable subsequent DAGCombines for bitwise operations.
We don't want to just turn PTRADDs into disjoint ORs whenever that's
sound because this transform loses the information that the operation
implements pointer arithmetic, which we will soon need to fold offsets
into FLAT instructions. Currently, disjoint ORs can still be used for
offset folding, so that part of the logic can't be tested.

The PR contains a hacky workaround for a situation where an AssertAlign
operand of a PTRADD is not DAGCombined before the PTRADD, causing the
PTRADD to be turned into a disjoint OR although reassociating it with
the operand of the AssertAlign would be better. This wouldn't be a
problem if the DAGCombiner ensured that a node is only processed after
all its operands have been processed.

For SWDEV-516125.
---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 35 
 .../AMDGPU/ptradd-sdag-optimizations.ll   | 56 ++-
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index f2161f8cdcad6..72d398da5f872 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -15236,6 +15236,41 @@ SDValue SITargetLowering::performPtrAddCombine(SDNode 
*N,
   return Folded;
   }
 
+  // Transform (ptradd a, b) -> (or disjoint a, b) if it is equivalent and if
+  // that transformation can't block an offset folding at any use of the 
ptradd.
+  // This should be done late, after legalization, so that it doesn't block
+  // other ptradd combines that could enable more offset folding.
+  bool HasIntermediateAssertAlign =
+  N0->getOpcode() == ISD::AssertAlign && N0->getOperand(0)->isAnyAdd();
+  // This is a hack to work around an ordering problem for DAGs like this:
+  //   (ptradd (AssertAlign (ptradd p, c1), k), c2)
+  // If the outer ptradd is handled first by the DAGCombiner, it can be
+  // transformed into a disjoint or. Then, when the generic AssertAlign combine
+  // pushes the AssertAlign through the inner ptradd, it's too late for the
+  // ptradd reassociation to trigger.
+  if (!DCI.isBeforeLegalizeOps() && !HasIntermediateAssertAlign &&
+  DAG.haveNoCommonBitsSet(N0, N1)) {
+bool TransformCanBreakAddrMode = any_of(N->users(), [&](SDNode *User) {
+  if (auto *LoadStore = dyn_cast(User);
+  LoadStore && LoadStore->getBasePtr().getNode() == N) {
+unsigned AS = LoadStore->getAddressSpace();
+// Currently, we only really need ptradds to fold offsets into flat
+// memory instructions.
+if (AS != AMDGPUAS::FLAT_ADDRESS)
+  return false;
+TargetLoweringBase::AddrMode AM;
+AM.HasBaseReg = true;
+EVT VT = LoadStore->getMemoryVT();
+Type *AccessTy = VT.getTypeForEVT(*DAG.getContext());
+return isLegalAddressingMode(DAG.getDataLayout(), AM, AccessTy, AS);
+  }
+  return false;
+});
+
+if (!TransformCanBreakAddrMode)
+  return DAG.getNode(ISD::OR, DL, VT, N0, N1, SDNodeFlags::Disjoint);
+  }
+
   if (N1.getOpcode() != ISD::ADD || !N1.hasOneUse())
 return SDValue();
 
diff --git a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll 
b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
index 893deb35fe822..64e041103a563 100644
--- a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
+++ b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
@@ -100,7 +100,7 @@ define void @baseptr_null(i64 %offset, i8 %v) {
 
 ; Taken from implicit-kernarg-backend-usage.ll, tests the PTRADD handling in 
the
 ; assertalign DAG combine.
-define amdgpu_kernel void @llvm_amdgcn_queue_ptr(ptr addrspace(1) %ptr)  #0 {
+define amdgpu_kernel void @llvm_amdgcn_queue_ptr(ptr addrspace(1) %ptr) {
 ; GFX942-LABEL: llvm_amdgcn_queue_ptr:
 ; GFX942:   ; %bb.0:
 ; GFX942-NEXT:v_mov_b32_e32 v2, 0
@@ -416,6 +416,60 @@ entry:
   ret void
 }
 
+; Check that ptradds can be lowered to disjoint ORs.
+define ptr @gep_disjoint_or(ptr %base) {
+; GFX942-LABEL: gep_disjoint_or:
+; GFX942:   ; %bb.0:
+; GFX942-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX942-NEXT:v_and_or_b32 v0, v0, -16, 4
+; GFX942-NEXT:s_setpc_b64 s[30:31]
+  %p = call ptr @llvm.ptrmask(ptr %base, i64 s0xf0)
+  %gep = getelementptr nuw inbounds i8, ptr %p, i64 4
+  ret ptr %gep
+}
+
+; Check that AssertAlign no

[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Handle ISD::PTRADD in various special cases (PR #145330)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/145330

>From bf788982995fba2db158251bb78c9cf110b27a49 Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Tue, 17 Jun 2025 04:03:53 -0400
Subject: [PATCH 1/2] [AMDGPU][SDAG] Handle ISD::PTRADD in various special
 cases

There are more places in SIISelLowering.cpp and AMDGPUISelDAGToDAG.cpp
that check for ISD::ADD in a pointer context, but as far as I can tell
those are only relevant for 32-bit pointer arithmetic (like frame
indices/scratch addresses and LDS), for which we don't enable PTRADD
generation yet.

For SWDEV-516125.
---
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp |   2 +-
 .../CodeGen/SelectionDAG/TargetLowering.cpp   |  21 +-
 llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp |   6 +-
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp |   7 +-
 llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll |  67 ++
 .../AMDGPU/ptradd-sdag-optimizations.ll   | 196 ++
 6 files changed, 105 insertions(+), 194 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 5453828177c72..8ec799e56bfec 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -8332,7 +8332,7 @@ static bool isMemSrcFromConstant(SDValue Src, 
ConstantDataArraySlice &Slice) {
   GlobalAddressSDNode *G = nullptr;
   if (Src.getOpcode() == ISD::GlobalAddress)
 G = cast(Src);
-  else if (Src.getOpcode() == ISD::ADD &&
+  else if (Src->isAnyAdd() &&
Src.getOperand(0).getOpcode() == ISD::GlobalAddress &&
Src.getOperand(1).getOpcode() == ISD::Constant) {
 G = cast(Src.getOperand(0));
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index e0597988e8907..3475bb0a66202 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -632,8 +632,14 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned 
BitWidth,
   // operands on the new node are also disjoint.
   SDNodeFlags Flags(Op->getFlags().hasDisjoint() ? SDNodeFlags::Disjoint
  : SDNodeFlags::None);
+  unsigned Opcode = Op.getOpcode();
+  if (Opcode == ISD::PTRADD) {
+// It isn't a ptradd anymore if it doesn't operate on the entire
+// pointer.
+Opcode = ISD::ADD;
+  }
   SDValue X = DAG.getNode(
-  Op.getOpcode(), dl, SmallVT,
+  Opcode, dl, SmallVT,
   DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(0)),
   DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(1)), Flags);
   assert(DemandedSize <= SmallVTBits && "Narrowed below demanded bits?");
@@ -2868,6 +2874,11 @@ bool TargetLowering::SimplifyDemandedBits(
   return TLO.CombineTo(Op, And1);
 }
 [[fallthrough]];
+  case ISD::PTRADD:
+if (Op.getOperand(0).getValueType() != Op.getOperand(1).getValueType())
+  break;
+// PTRADD behaves like ADD if pointers are represented as integers.
+[[fallthrough]];
   case ISD::ADD:
   case ISD::SUB: {
 // Add, Sub, and Mul don't demand any bits in positions beyond that
@@ -2977,10 +2988,10 @@ bool TargetLowering::SimplifyDemandedBits(
 
 if (Op.getOpcode() == ISD::MUL) {
   Known = KnownBits::mul(KnownOp0, KnownOp1);
-} else { // Op.getOpcode() is either ISD::ADD or ISD::SUB.
+} else { // Op.getOpcode() is either ISD::ADD, ISD::PTRADD, or ISD::SUB.
   Known = KnownBits::computeForAddSub(
-  Op.getOpcode() == ISD::ADD, Flags.hasNoSignedWrap(),
-  Flags.hasNoUnsignedWrap(), KnownOp0, KnownOp1);
+  Op->isAnyAdd(), Flags.hasNoSignedWrap(), Flags.hasNoUnsignedWrap(),
+  KnownOp0, KnownOp1);
 }
 break;
   }
@@ -5662,7 +5673,7 @@ bool TargetLowering::isGAPlusOffset(SDNode *WN, const 
GlobalValue *&GA,
 return true;
   }
 
-  if (N->getOpcode() == ISD::ADD) {
+  if (N->isAnyAdd()) {
 SDValue N1 = N->getOperand(0);
 SDValue N2 = N->getOperand(1);
 if (isGAPlusOffset(N1.getNode(), GA, Offset)) {
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
index 25672a52345cb..79522d9b796ec 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
@@ -1478,7 +1478,7 @@ bool AMDGPUDAGToDAGISel::SelectMUBUF(SDValue Addr, 
SDValue &Ptr, SDValue &VAddr,
   C1 = nullptr;
   }
 
-  if (N0.getOpcode() == ISD::ADD) {
+  if (N0->isAnyAdd()) {
 // (add N2, N3) -> addr64, or
 // (add (add N2, N3), C1) -> addr64
 SDValue N2 = N0.getOperand(0);
@@ -1927,7 +1927,7 @@ bool AMDGPUDAGToDAGISel::SelectGlobalSAddr(SDNode *N,
   }
 
   // Match the variable offset.
-  if (Addr.getOpcode() == ISD::ADD) {
+  if (Addr->isAnyAdd()) {
 LHS = Addr.getOperand(0);
 RHS = Addr.getOperand(1);

[llvm-branch-commits] [llvm] [SDAG][AMDGPU] Allow opting in to OOB-generating PTRADD transforms (PR #146074)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/146074

>From ea26451beb2e03cd0a8ae5006d7288f3f6e7a5c3 Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Thu, 26 Jun 2025 06:10:35 -0400
Subject: [PATCH] [SDAG][AMDGPU] Allow opting in to OOB-generating PTRADD
 transforms

This PR adds a TargetLowering hook, canTransformPtrArithOutOfBounds,
that targets can use to allow transformations to introduce out-of-bounds
pointer arithmetic. It also moves two such transformations from the
AMDGPU-specific DAG combines to the generic DAGCombiner.

This is motivated by target features like AArch64's checked pointer
arithmetic, CPA, which does not tolerate the introduction of
out-of-bounds pointer arithmetic.
---
 llvm/include/llvm/CodeGen/TargetLowering.h|   7 +
 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 125 +++---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp |  59 ++---
 llvm/lib/Target/AMDGPU/SIISelLowering.h   |   3 +
 4 files changed, 94 insertions(+), 100 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 1a548a536f088..44dd5234ab693 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -3504,6 +3504,13 @@ class LLVM_ABI TargetLoweringBase {
 return false;
   }
 
+  /// True if the target allows transformations of in-bounds pointer
+  /// arithmetic that cause out-of-bounds intermediate results.
+  virtual bool canTransformPtrArithOutOfBounds(const Function &F,
+   EVT PtrVT) const {
+return false;
+  }
+
   /// Does this target support complex deinterleaving
   virtual bool isComplexDeinterleavingSupported() const { return false; }
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 40464e91f9efc..476a1f3223a28 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2688,59 +2688,82 @@ SDValue DAGCombiner::visitPTRADD(SDNode *N) {
   if (PtrVT == IntVT && isNullConstant(N0))
 return N1;
 
-  if (N0.getOpcode() != ISD::PTRADD ||
-  reassociationCanBreakAddressingModePattern(ISD::PTRADD, DL, N, N0, N1))
-return SDValue();
-
-  SDValue X = N0.getOperand(0);
-  SDValue Y = N0.getOperand(1);
-  SDValue Z = N1;
-  bool N0OneUse = N0.hasOneUse();
-  bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
-  bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
-
-  // (ptradd (ptradd x, y), z) -> (ptradd x, (add y, z)) if:
-  //   * y is a constant and (ptradd x, y) has one use; or
-  //   * y and z are both constants.
-  if ((YIsConstant && N0OneUse) || (YIsConstant && ZIsConstant)) {
-// If both additions in the original were NUW, the new ones are as well.
-SDNodeFlags Flags =
-(N->getFlags() & N0->getFlags()) & SDNodeFlags::NoUnsignedWrap;
-SDValue Add = DAG.getNode(ISD::ADD, DL, IntVT, {Y, Z}, Flags);
-AddToWorklist(Add.getNode());
-return DAG.getMemBasePlusOffset(X, Add, DL, Flags);
+  if (N0.getOpcode() == ISD::PTRADD &&
+  !reassociationCanBreakAddressingModePattern(ISD::PTRADD, DL, N, N0, N1)) 
{
+SDValue X = N0.getOperand(0);
+SDValue Y = N0.getOperand(1);
+SDValue Z = N1;
+bool N0OneUse = N0.hasOneUse();
+bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
+bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
+
+// (ptradd (ptradd x, y), z) -> (ptradd x, (add y, z)) if:
+//   * y is a constant and (ptradd x, y) has one use; or
+//   * y and z are both constants.
+if ((YIsConstant && N0OneUse) || (YIsConstant && ZIsConstant)) {
+  // If both additions in the original were NUW, the new ones are as well.
+  SDNodeFlags Flags =
+  (N->getFlags() & N0->getFlags()) & SDNodeFlags::NoUnsignedWrap;
+  SDValue Add = DAG.getNode(ISD::ADD, DL, IntVT, {Y, Z}, Flags);
+  AddToWorklist(Add.getNode());
+  return DAG.getMemBasePlusOffset(X, Add, DL, Flags);
+}
+  }
+
+  // The following combines can turn in-bounds pointer arithmetic out of 
bounds.
+  // That is problematic for settings like AArch64's CPA, which checks that
+  // intermediate results of pointer arithmetic remain in bounds. The target
+  // therefore needs to opt-in to enable them.
+  if (!TLI.canTransformPtrArithOutOfBounds(
+  DAG.getMachineFunction().getFunction(), PtrVT))
+return SDValue();
+
+  if (N0.getOpcode() == ISD::PTRADD && N1.getOpcode() == ISD::Constant) {
+// Fold (ptradd (ptradd GA, v), c) -> (ptradd (ptradd GA, c) v) with
+// global address GA and constant c, such that c can be folded into GA.
+SDValue GAValue = N0.getOperand(0);
+if (const GlobalAddressSDNode *GA =
+dyn_cast(GAValue)) {
+  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+  if (!LegalOperations && TLI.isOf

[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Test ISD::PTRADD handling in various special cases (PR #145329)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/145329

>From 2865c30eb7dc0e716bc0af66636fe95e13a186fa Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Tue, 17 Jun 2025 03:51:19 -0400
Subject: [PATCH] [AMDGPU][SDAG] Test ISD::PTRADD handling in various special
 cases

Pre-committing tests to show improvements in a follow-up PR.
---
 llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll |  63 ++
 .../AMDGPU/ptradd-sdag-optimizations.ll   | 206 ++
 2 files changed, 269 insertions(+)
 create mode 100644 llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll

diff --git a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll 
b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll
new file mode 100644
index 0..fab56383ffa8a
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll
@@ -0,0 +1,63 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=tahiti -amdgpu-use-sdag-ptradd=1 < 
%s | FileCheck --check-prefixes=GFX6,GFX6_PTRADD %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=tahiti -amdgpu-use-sdag-ptradd=0 < 
%s | FileCheck --check-prefixes=GFX6,GFX6_LEGACY %s
+
+; Test PTRADD handling in AMDGPUDAGToDAGISel::SelectMUBUF.
+
+define amdgpu_kernel void @v_add_i32(ptr addrspace(1) %out, ptr addrspace(1) 
%in) {
+; GFX6_PTRADD-LABEL: v_add_i32:
+; GFX6_PTRADD:   ; %bb.0:
+; GFX6_PTRADD-NEXT:s_load_dwordx4 s[0:3], s[8:9], 0x0
+; GFX6_PTRADD-NEXT:v_lshlrev_b32_e32 v0, 2, v0
+; GFX6_PTRADD-NEXT:s_mov_b32 s7, 0x100f000
+; GFX6_PTRADD-NEXT:s_mov_b32 s10, 0
+; GFX6_PTRADD-NEXT:s_mov_b32 s11, s7
+; GFX6_PTRADD-NEXT:s_waitcnt lgkmcnt(0)
+; GFX6_PTRADD-NEXT:v_mov_b32_e32 v1, s3
+; GFX6_PTRADD-NEXT:v_add_i32_e32 v0, vcc, s2, v0
+; GFX6_PTRADD-NEXT:v_addc_u32_e32 v1, vcc, 0, v1, vcc
+; GFX6_PTRADD-NEXT:s_mov_b32 s8, s10
+; GFX6_PTRADD-NEXT:s_mov_b32 s9, s10
+; GFX6_PTRADD-NEXT:buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc
+; GFX6_PTRADD-NEXT:s_waitcnt vmcnt(0)
+; GFX6_PTRADD-NEXT:buffer_load_dword v0, v[0:1], s[8:11], 0 addr64 
offset:4 glc
+; GFX6_PTRADD-NEXT:s_waitcnt vmcnt(0)
+; GFX6_PTRADD-NEXT:s_mov_b32 s6, -1
+; GFX6_PTRADD-NEXT:s_mov_b32 s4, s0
+; GFX6_PTRADD-NEXT:s_mov_b32 s5, s1
+; GFX6_PTRADD-NEXT:v_add_i32_e32 v0, vcc, v2, v0
+; GFX6_PTRADD-NEXT:buffer_store_dword v0, off, s[4:7], 0
+; GFX6_PTRADD-NEXT:s_endpgm
+;
+; GFX6_LEGACY-LABEL: v_add_i32:
+; GFX6_LEGACY:   ; %bb.0:
+; GFX6_LEGACY-NEXT:s_load_dwordx4 s[0:3], s[8:9], 0x0
+; GFX6_LEGACY-NEXT:s_mov_b32 s7, 0x100f000
+; GFX6_LEGACY-NEXT:s_mov_b32 s10, 0
+; GFX6_LEGACY-NEXT:s_mov_b32 s11, s7
+; GFX6_LEGACY-NEXT:v_lshlrev_b32_e32 v0, 2, v0
+; GFX6_LEGACY-NEXT:s_waitcnt lgkmcnt(0)
+; GFX6_LEGACY-NEXT:s_mov_b64 s[8:9], s[2:3]
+; GFX6_LEGACY-NEXT:v_mov_b32_e32 v1, 0
+; GFX6_LEGACY-NEXT:buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc
+; GFX6_LEGACY-NEXT:s_waitcnt vmcnt(0)
+; GFX6_LEGACY-NEXT:buffer_load_dword v0, v[0:1], s[8:11], 0 addr64 
offset:4 glc
+; GFX6_LEGACY-NEXT:s_waitcnt vmcnt(0)
+; GFX6_LEGACY-NEXT:s_mov_b32 s6, -1
+; GFX6_LEGACY-NEXT:s_mov_b32 s4, s0
+; GFX6_LEGACY-NEXT:s_mov_b32 s5, s1
+; GFX6_LEGACY-NEXT:v_add_i32_e32 v0, vcc, v2, v0
+; GFX6_LEGACY-NEXT:buffer_store_dword v0, off, s[4:7], 0
+; GFX6_LEGACY-NEXT:s_endpgm
+  %tid = call i32 @llvm.amdgcn.workitem.id.x()
+  %gep = getelementptr inbounds i32, ptr addrspace(1) %in, i32 %tid
+  %b_ptr = getelementptr i32, ptr addrspace(1) %gep, i32 1
+  %a = load volatile i32, ptr addrspace(1) %gep
+  %b = load volatile i32, ptr addrspace(1) %b_ptr
+  %result = add i32 %a, %b
+  store i32 %result, ptr addrspace(1) %out
+  ret void
+}
+
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
+; GFX6: {{.*}}
diff --git a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll 
b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
index 34bb98550de04..0cd920616c515 100644
--- a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
+++ b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
@@ -291,3 +291,209 @@ define ptr @fold_mul24_into_mad(ptr %base, i64 %a, i64 
%b) {
   %gep = getelementptr inbounds i8, ptr %base, i64 %mul
   ret ptr %gep
 }
+
+; Test PTRADD handling in AMDGPUDAGToDAGISel::SelectGlobalSAddr.
+define amdgpu_kernel void @uniform_base_varying_offset_imm(ptr addrspace(1) 
%p) {
+; GFX942_PTRADD-LABEL: uniform_base_varying_offset_imm:
+; GFX942_PTRADD:   ; %bb.0: ; %entry
+; GFX942_PTRADD-NEXT:s_load_dwordx2 s[0:1], s[4:5], 0x0
+; GFX942_PTRADD-NEXT:v_and_b32_e32 v0, 0x3ff, v0
+; GFX942_PTRADD-NEXT:v_mov_b32_e32 v1, 0
+; GFX942_PTRADD-NEXT:v_lshlrev_b32_e32 v0, 2, v0
+; GFX942_PTRADD-NEXT:v_mov_b32_e32 v2, 1
+; GFX942_PTRADD-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942_PTRADD-NEXT:v_lshl_add_u64 v[0:1], s[0:1], 0, v[0:1]
+; GFX942_PTRAD

[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Test ISD::PTRADD handling in various special cases (PR #145329)

2025-07-21 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a updated 
https://github.com/llvm/llvm-project/pull/145329

>From 2865c30eb7dc0e716bc0af66636fe95e13a186fa Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Tue, 17 Jun 2025 03:51:19 -0400
Subject: [PATCH] [AMDGPU][SDAG] Test ISD::PTRADD handling in various special
 cases

Pre-committing tests to show improvements in a follow-up PR.
---
 llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll |  63 ++
 .../AMDGPU/ptradd-sdag-optimizations.ll   | 206 ++
 2 files changed, 269 insertions(+)
 create mode 100644 llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll

diff --git a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll 
b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll
new file mode 100644
index 0..fab56383ffa8a
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-mubuf.ll
@@ -0,0 +1,63 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=tahiti -amdgpu-use-sdag-ptradd=1 < 
%s | FileCheck --check-prefixes=GFX6,GFX6_PTRADD %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=tahiti -amdgpu-use-sdag-ptradd=0 < 
%s | FileCheck --check-prefixes=GFX6,GFX6_LEGACY %s
+
+; Test PTRADD handling in AMDGPUDAGToDAGISel::SelectMUBUF.
+
+define amdgpu_kernel void @v_add_i32(ptr addrspace(1) %out, ptr addrspace(1) 
%in) {
+; GFX6_PTRADD-LABEL: v_add_i32:
+; GFX6_PTRADD:   ; %bb.0:
+; GFX6_PTRADD-NEXT:s_load_dwordx4 s[0:3], s[8:9], 0x0
+; GFX6_PTRADD-NEXT:v_lshlrev_b32_e32 v0, 2, v0
+; GFX6_PTRADD-NEXT:s_mov_b32 s7, 0x100f000
+; GFX6_PTRADD-NEXT:s_mov_b32 s10, 0
+; GFX6_PTRADD-NEXT:s_mov_b32 s11, s7
+; GFX6_PTRADD-NEXT:s_waitcnt lgkmcnt(0)
+; GFX6_PTRADD-NEXT:v_mov_b32_e32 v1, s3
+; GFX6_PTRADD-NEXT:v_add_i32_e32 v0, vcc, s2, v0
+; GFX6_PTRADD-NEXT:v_addc_u32_e32 v1, vcc, 0, v1, vcc
+; GFX6_PTRADD-NEXT:s_mov_b32 s8, s10
+; GFX6_PTRADD-NEXT:s_mov_b32 s9, s10
+; GFX6_PTRADD-NEXT:buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc
+; GFX6_PTRADD-NEXT:s_waitcnt vmcnt(0)
+; GFX6_PTRADD-NEXT:buffer_load_dword v0, v[0:1], s[8:11], 0 addr64 
offset:4 glc
+; GFX6_PTRADD-NEXT:s_waitcnt vmcnt(0)
+; GFX6_PTRADD-NEXT:s_mov_b32 s6, -1
+; GFX6_PTRADD-NEXT:s_mov_b32 s4, s0
+; GFX6_PTRADD-NEXT:s_mov_b32 s5, s1
+; GFX6_PTRADD-NEXT:v_add_i32_e32 v0, vcc, v2, v0
+; GFX6_PTRADD-NEXT:buffer_store_dword v0, off, s[4:7], 0
+; GFX6_PTRADD-NEXT:s_endpgm
+;
+; GFX6_LEGACY-LABEL: v_add_i32:
+; GFX6_LEGACY:   ; %bb.0:
+; GFX6_LEGACY-NEXT:s_load_dwordx4 s[0:3], s[8:9], 0x0
+; GFX6_LEGACY-NEXT:s_mov_b32 s7, 0x100f000
+; GFX6_LEGACY-NEXT:s_mov_b32 s10, 0
+; GFX6_LEGACY-NEXT:s_mov_b32 s11, s7
+; GFX6_LEGACY-NEXT:v_lshlrev_b32_e32 v0, 2, v0
+; GFX6_LEGACY-NEXT:s_waitcnt lgkmcnt(0)
+; GFX6_LEGACY-NEXT:s_mov_b64 s[8:9], s[2:3]
+; GFX6_LEGACY-NEXT:v_mov_b32_e32 v1, 0
+; GFX6_LEGACY-NEXT:buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc
+; GFX6_LEGACY-NEXT:s_waitcnt vmcnt(0)
+; GFX6_LEGACY-NEXT:buffer_load_dword v0, v[0:1], s[8:11], 0 addr64 
offset:4 glc
+; GFX6_LEGACY-NEXT:s_waitcnt vmcnt(0)
+; GFX6_LEGACY-NEXT:s_mov_b32 s6, -1
+; GFX6_LEGACY-NEXT:s_mov_b32 s4, s0
+; GFX6_LEGACY-NEXT:s_mov_b32 s5, s1
+; GFX6_LEGACY-NEXT:v_add_i32_e32 v0, vcc, v2, v0
+; GFX6_LEGACY-NEXT:buffer_store_dword v0, off, s[4:7], 0
+; GFX6_LEGACY-NEXT:s_endpgm
+  %tid = call i32 @llvm.amdgcn.workitem.id.x()
+  %gep = getelementptr inbounds i32, ptr addrspace(1) %in, i32 %tid
+  %b_ptr = getelementptr i32, ptr addrspace(1) %gep, i32 1
+  %a = load volatile i32, ptr addrspace(1) %gep
+  %b = load volatile i32, ptr addrspace(1) %b_ptr
+  %result = add i32 %a, %b
+  store i32 %result, ptr addrspace(1) %out
+  ret void
+}
+
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
+; GFX6: {{.*}}
diff --git a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll 
b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
index 34bb98550de04..0cd920616c515 100644
--- a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
+++ b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
@@ -291,3 +291,209 @@ define ptr @fold_mul24_into_mad(ptr %base, i64 %a, i64 
%b) {
   %gep = getelementptr inbounds i8, ptr %base, i64 %mul
   ret ptr %gep
 }
+
+; Test PTRADD handling in AMDGPUDAGToDAGISel::SelectGlobalSAddr.
+define amdgpu_kernel void @uniform_base_varying_offset_imm(ptr addrspace(1) 
%p) {
+; GFX942_PTRADD-LABEL: uniform_base_varying_offset_imm:
+; GFX942_PTRADD:   ; %bb.0: ; %entry
+; GFX942_PTRADD-NEXT:s_load_dwordx2 s[0:1], s[4:5], 0x0
+; GFX942_PTRADD-NEXT:v_and_b32_e32 v0, 0x3ff, v0
+; GFX942_PTRADD-NEXT:v_mov_b32_e32 v1, 0
+; GFX942_PTRADD-NEXT:v_lshlrev_b32_e32 v0, 2, v0
+; GFX942_PTRADD-NEXT:v_mov_b32_e32 v2, 1
+; GFX942_PTRADD-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942_PTRADD-NEXT:v_lshl_add_u64 v[0:1], s[0:1], 0, v[0:1]
+; GFX942_PTRAD

[llvm-branch-commits] [polly] [Polly] Introduce PhaseManager and remove LPM support (PR #125442)

2025-07-21 Thread Michael Kruse via llvm-branch-commits


@@ -0,0 +1,419 @@
+//===-- PhaseManager.cpp *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "polly/Pass/PhaseManager.h"
+#include "polly/CodeGen/CodeGeneration.h"
+#include "polly/CodeGen/IslAst.h"
+#include "polly/CodePreparation.h"
+#include "polly/DeLICM.h"
+#include "polly/DeadCodeElimination.h"
+#include "polly/DependenceInfo.h"
+#include "polly/FlattenSchedule.h"
+#include "polly/ForwardOpTree.h"
+#include "polly/JSONExporter.h"
+#include "polly/MaximalStaticExpansion.h"
+#include "polly/PruneUnprofitable.h"
+#include "polly/ScheduleOptimizer.h"
+#include "polly/ScopDetection.h"
+#include "polly/ScopDetectionDiagnostic.h"
+#include "polly/ScopGraphPrinter.h"
+#include "polly/ScopInfo.h"
+#include "polly/Simplify.h"
+#include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
+#include "llvm/IR/Module.h"
+
+#define DEBUG_TYPE "polly-pass"
+
+using namespace polly;
+using namespace llvm;
+
+namespace {
+
+/// Recurse through all subregions and all regions and add them to RQ.
+static void addRegionIntoQueue(Region &R, SmallVector &RQ) {
+  RQ.push_back(&R);
+  for (const auto &E : R)
+addRegionIntoQueue(*E, RQ);
+}
+
+/// The phase pipeline of Polly to be embedded into another pass manager than
+/// runs passes on functions.
+///
+/// Polly holds state besides LLVM-IR (RegionInfo and ScopInfo) between phases
+/// that LLVM pass managers do not consider when scheduling analyses and 
passes.
+/// That is, the ScopInfo must persist between phases that a pass manager must
+/// not invalidate to recompute later.
+class PhaseManager {
+private:
+  Function &F;
+  FunctionAnalysisManager &FAM;
+  PollyPassOptions Opts;
+
+public:
+  PhaseManager(Function &F, FunctionAnalysisManager &FAM, PollyPassOptions 
Opts)
+  : F(F), FAM(FAM), Opts(std::move(Opts)) {}
+
+  /// Execute Polly's phases as indicated by the options.
+  bool run() {
+// Get analyses from the function pass manager.
+// These must be preserved during all phases so that if processing one SCoP
+// has finished, the next SCoP can still use them. Recomputing is not an
+// option because ScopDetection stores references to the old results.
+// TODO: CodePreparation doesn't actually need these analysis, it just 
keeps
+// them up-to-date. If they are not computed yet, can also compute after 
the
+// prepare phase.
+auto &LI = FAM.getResult(F);
+auto &DT = FAM.getResult(F);
+bool ModifiedIR = false;
+
+// Phase: prepare
+// TODO: Setting ModifiedIR will invalidate any anlysis, even if DT, LI are
+// preserved.
+if (Opts.isPhaseEnabled(PassPhase::Prepare))
+  ModifiedIR |= runCodePreparation(F, &DT, &LI, nullptr);
+
+// Can't do anything without detection
+if (!Opts.isPhaseEnabled(PassPhase::Detection))
+  return false;
+
+auto &AA = FAM.getResult(F);
+auto &SE = FAM.getResult(F);
+auto &ORE = FAM.getResult(F);
+
+// ScopDetection is modifying RegionInfo, do not cache it, nor use a cached
+// version.
+RegionInfo RI = RegionInfoAnalysis().run(F, FAM);
+
+// Phase: detection
+ScopDetection SD(DT, SE, LI, RI, AA, ORE);
+SD.detect(F);
+if (Opts.isPhaseEnabled(PassPhase::PrintDetect)) {
+  outs() << "Detected Scops in Function " << F.getName() << "\n";
+  for (const Region *R : SD.ValidRegions)
+outs() << "Valid Region for Scop: " << R->getNameStr() << '\n';
+  outs() << "\n";
+}
+
+if (Opts.isPhaseEnabled(PassPhase::DotScops))
+  printGraphForFunction(F, &SD, "scops", false);
+if (Opts.isPhaseEnabled(PassPhase::DotScopsOnly))
+  printGraphForFunction(F, &SD, "scopsonly", true);
+
+auto ViewScops = [&](const char *Name, bool IsSimply) {
+  if (Opts.ViewFilter.empty() && !F.getName().count(Opts.ViewFilter))
+return;
+
+  if (Opts.ViewAll || std::distance(SD.begin(), SD.end()) > 0)
+viewGraphForFunction(F, &SD, Name, IsSimply);
+};
+if (Opts.isPhaseEnabled(PassPhase::ViewScops))
+  ViewScops("scops", false);
+if (Opts.isPhaseEnabled(PassPhase::ViewScopsOnly))
+  ViewScops("scopsonly", true);
+
+// Phase: scops
+auto &AC = FAM.getResult(F);
+const DataLayout &DL = F.getParent()->getDataLayout();
+ScopInfo Info(DL, SD, SE, LI, AA, DT, AC, ORE);

Meinersbur wrote:

I don't see how. In both cases the order is determined as follows:
1. Iteration over `ScopInfo` -> `Worklist`
2. while-loop over `Worklist` using `pop_back_val()` (i.e. FILO queue)

https://github.com/llvm/llvm-project/pull/125442
___
llvm-branch-commits mailin

[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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

kparzysz wrote:

Stack:
- https://github.com/llvm/llvm-project/pull/149134
- https://github.com/llvm/llvm-project/pull/149137 (this PR)

https://github.com/llvm/llvm-project/pull/149137
___
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] [OpenMP][clang] 6.0: num_threads strict (part 3: codegen) (PR #146405)

2025-07-21 Thread Alexey Bataev via llvm-branch-commits


@@ -2699,18 +2699,33 @@ llvm::Value 
*CGOpenMPRuntime::emitForNext(CodeGenFunction &CGF,
   CGF.getContext().BoolTy, Loc);
 }
 
-void CGOpenMPRuntime::emitNumThreadsClause(CodeGenFunction &CGF,
-   llvm::Value *NumThreads,
-   SourceLocation Loc) {
+void CGOpenMPRuntime::emitNumThreadsClause(
+CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc,
+OpenMPNumThreadsClauseModifier Modifier, OpenMPSeverityClauseKind Severity,
+const Expr *Message) {
   if (!CGF.HaveInsertPoint())
 return;
+  llvm::SmallVector Args(
+  {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
+   CGF.Builder.CreateIntCast(NumThreads, CGF.Int32Ty, /*isSigned*/ true)});
   // Build call __kmpc_push_num_threads(&loc, global_tid, num_threads)
-  llvm::Value *Args[] = {
-  emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
-  CGF.Builder.CreateIntCast(NumThreads, CGF.Int32Ty, /*isSigned*/ true)};
-  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
-  CGM.getModule(), OMPRTL___kmpc_push_num_threads),
-  Args);
+  // or __kmpc_push_num_threads_strict(&loc, global_tid, num_threads, severity,
+  // messsage) if strict modifier is used.
+  RuntimeFunction FnID = OMPRTL___kmpc_push_num_threads;
+  if (Modifier == OMPC_NUMTHREADS_strict) {
+FnID = OMPRTL___kmpc_push_num_threads_strict;
+// OpenMP 6.0, 10.4: "If no severity clause is specified then the effect is
+// as if sev-level is fatal."
+Args.push_back(llvm::ConstantInt::get(
+CGM.Int32Ty, Severity == OMPC_SEVERITY_warning ? 1 : 2));
+if (Message)
+  Args.push_back(CGF.EmitStringLiteralLValue(cast(Message))

alexey-bataev wrote:

Can you generalize it here now and then fix sema analysis?

https://github.com/llvm/llvm-project/pull/146405
___
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] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)

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

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

I did as in depth of a review of this as I could, nothing sticks out to me.

https://github.com/llvm/llvm-project/pull/148012
___
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] [PATCH 3/6] [clang] Improve nested name specifier AST representation (PR #148014)

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

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


https://github.com/llvm/llvm-project/pull/148014
___
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] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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

kparzysz wrote:

There is a parsing test that shows the conversion, plus parsing of the new 
modifiers.  Do you want something specific to lowering, e.g. show the same MLIR 
generated for a given modifier with -fopenmp-version=52 and 60?

https://github.com/llvm/llvm-project/pull/149137
___
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] [PATCH 4/6] [clang] Improve nested name specifier AST representation (PR #148015)

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

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

This one seems pretty mechanical.  LGTM.

https://github.com/llvm/llvm-project/pull/148015
___
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] [LifetimeSafety] Implement a basic use-after-free diagnostic (PR #149731)

2025-07-21 Thread Utkarsh Saxena via llvm-branch-commits

https://github.com/usx95 updated 
https://github.com/llvm/llvm-project/pull/149731

>From a30dad1eb6bf11dbc215f7e98bdfa3f4109c1557 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Sun, 20 Jul 2025 18:33:56 +
Subject: [PATCH] basic error report for use after free

---
 .../clang/Analysis/Analyses/LifetimeSafety.h  |  52 +++-
 clang/include/clang/Basic/DiagnosticGroups.td |   5 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  11 +-
 clang/lib/Analysis/LifetimeSafety.cpp | 272 ++
 clang/lib/Sema/AnalysisBasedWarnings.cpp  |  35 ++-
 clang/test/Sema/warn-lifetime-safety.cpp  | 204 +
 .../unittests/Analysis/LifetimeSafetyTest.cpp |  15 +-
 7 files changed, 525 insertions(+), 69 deletions(-)
 create mode 100644 clang/test/Sema/warn-lifetime-safety.cpp

diff --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety.h 
b/clang/include/clang/Analysis/Analyses/LifetimeSafety.h
index 1c00558d32f63..bd7e76b1bc238 100644
--- a/clang/include/clang/Analysis/Analyses/LifetimeSafety.h
+++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety.h
@@ -19,14 +19,35 @@
 #define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_H
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/ImmutableMap.h"
 #include "llvm/ADT/ImmutableSet.h"
 #include "llvm/ADT/StringMap.h"
 #include 
 
 namespace clang::lifetimes {
 
+/// Enum to track the confidence level of a potential error.
+enum class Confidence {
+  None,
+  Maybe,   // Reported as a potential error (-Wlifetime-safety-strict)
+  Definite // Reported as a definite error (-Wlifetime-safety-permissive)
+};
+
+class LifetimeSafetyReporter {
+public:
+  LifetimeSafetyReporter() = default;
+  virtual ~LifetimeSafetyReporter() = default;
+
+  virtual void reportUseAfterFree(const Expr *IssueExpr, const Expr *UseExpr,
+  SourceLocation FreeLoc,
+  Confidence Confidence) {}
+};
+
 /// The main entry point for the analysis.
-void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC);
+void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC,
+   LifetimeSafetyReporter *Reporter);
 
 namespace internal {
 // Forward declarations of internal types.
@@ -53,6 +74,7 @@ template  struct ID {
 IDBuilder.AddInteger(Value);
   }
 };
+
 template 
 inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, ID ID) {
   return OS << ID.Value;
@@ -66,6 +88,7 @@ using OriginID = ID;
 // TODO(opt): Consider using a bitset to represent the set of loans.
 using LoanSet = llvm::ImmutableSet;
 using OriginSet = llvm::ImmutableSet;
+using ExpiredLoanMap = llvm::ImmutableMap;
 
 /// A `ProgramPoint` identifies a location in the CFG by pointing to a specific
 /// `Fact`. identified by a lifetime-related event (`Fact`).
@@ -78,7 +101,8 @@ using ProgramPoint = const Fact *;
 /// encapsulates the various dataflow analyses.
 class LifetimeSafetyAnalysis {
 public:
-  LifetimeSafetyAnalysis(AnalysisDeclContext &AC);
+  LifetimeSafetyAnalysis(AnalysisDeclContext &AC,
+ LifetimeSafetyReporter *Reporter);
   ~LifetimeSafetyAnalysis();
 
   void run();
@@ -87,7 +111,7 @@ class LifetimeSafetyAnalysis {
   LoanSet getLoansAtPoint(OriginID OID, ProgramPoint PP) const;
 
   /// Returns the set of loans that have expired at a specific program point.
-  LoanSet getExpiredLoansAtPoint(ProgramPoint PP) const;
+  ExpiredLoanMap getExpiredLoansAtPoint(ProgramPoint PP) const;
 
   /// Finds the OriginID for a given declaration.
   /// Returns a null optional if not found.
@@ -110,6 +134,7 @@ class LifetimeSafetyAnalysis {
 
 private:
   AnalysisDeclContext &AC;
+  LifetimeSafetyReporter *Reporter;
   std::unique_ptr Factory;
   std::unique_ptr FactMgr;
   std::unique_ptr LoanPropagation;
@@ -118,4 +143,25 @@ class LifetimeSafetyAnalysis {
 } // namespace internal
 } // namespace clang::lifetimes
 
+namespace llvm {
+template 
+struct DenseMapInfo> {
+  using ID = clang::lifetimes::internal::ID;
+
+  static inline ID getEmptyKey() {
+return {DenseMapInfo::getEmptyKey()};
+  }
+
+  static inline ID getTombstoneKey() {
+return {DenseMapInfo::getTombstoneKey()};
+  }
+
+  static unsigned getHashValue(const ID &Val) {
+return DenseMapInfo::getHashValue(Val.Value);
+  }
+
+  static bool isEqual(const ID &LHS, const ID &RHS) { return LHS == RHS; }
+};
+} // namespace llvm
+
 #endif // LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_H
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index c28a919e35d08..257823e4664d0 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -533,7 +533,10 @@ def Dangling : DiagGroup<"dangling", [DanglingAssignment,
   DanglingGsl,
  

[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (PR #149137)

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

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

>From acc1a7d3da0d2bd5a60096a9f5dc27338342b952 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 16 Jul 2025 08:04:17 -0500
Subject: [PATCH 1/4] [flang][OpenMP] Sema checks, lowering with new format of
 MAP modifiers

OpenMP 6.0 has changed the modifiers on the MAP clause. Previous patch
has introduced parsing support for them. This patch introduces processing
of the new forms in semantic checks and in lowering. This only applies
to existing modifiers, which were updated in the 6.0 spec. Any of the
newly introduced modifiers (SELF and REF) are ignored.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  16 +--
 flang/lib/Lower/OpenMP/Clauses.cpp| 113 --
 flang/lib/Semantics/canonicalize-omp.cpp  |   5 +
 flang/lib/Semantics/check-omp-structure.cpp   | 107 +++--
 flang/lib/Semantics/check-omp-structure.h |   4 +-
 flang/lib/Semantics/openmp-utils.cpp  |  25 
 flang/lib/Semantics/openmp-utils.h|   3 +
 flang/lib/Semantics/resolve-directives.cpp|  50 ++--
 .../Semantics/OpenMP/combined-constructs.f90  |   8 +-
 .../Semantics/OpenMP/device-constructs.f90|   6 +-
 llvm/include/llvm/Frontend/OpenMP/ClauseT.h   |   9 +-
 .../Frontend/OpenMP/ConstructDecompositionT.h |   5 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.h   |   2 +
 llvm/lib/Frontend/OpenMP/OMP.cpp  |  14 +++
 14 files changed, 260 insertions(+), 107 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 74087d42a8e6e..ec71014c36093 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1315,7 +1315,8 @@ bool ClauseProcessor::processMap(
  const parser::CharBlock &source) {
 using Map = omp::clause::Map;
 mlir::Location clauseLocation = converter.genLocation(source);
-const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t;
+const auto &[mapType, typeMods, refMod, mappers, iterator, objects] =
+clause.t;
 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
 std::string mapperIdName = "__implicit_mapper";
@@ -1342,16 +1343,13 @@ bool ClauseProcessor::processMap(
   mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
  llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
   break;
-case Map::MapType::Alloc:
-case Map::MapType::Release:
+case Map::MapType::Storage:
   // alloc and release is the default map_type for the Target Data
   // Ops, i.e. if no bits for map_type is supplied then alloc/release
-  // is implicitly assumed based on the target directive. Default
-  // value for Target Data and Enter Data is alloc and for Exit Data
-  // it is release.
+  // (aka storage in 6.0+) is implicitly assumed based on the target
+  // directive. Default value for Target Data and Enter Data is alloc
+  // and for Exit Data it is release.
   break;
-case Map::MapType::Delete:
-  mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
 }
 
 if (typeMods) {
@@ -1362,6 +1360,8 @@ bool ClauseProcessor::processMap(
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+  if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
+mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
   if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
 mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
 }
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index 22a07219d3a50..18e49719b6013 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -1001,64 +1001,105 @@ Map make(const parser::OmpClause::Map &inp,
  semantics::SemanticsContext &semaCtx) {
   // inp.v -> parser::OmpMapClause
   CLAUSET_ENUM_CONVERT( //
-  convert1, parser::OmpMapType::Value, Map::MapType,
+  convert1, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
   // clang-format off
-  MS(Alloc,Alloc)
-  MS(Delete,   Delete)
-  MS(From, From)
-  MS(Release,  Release)
-  MS(To,   To)
-  MS(Tofrom,   Tofrom)
+  MS(Always,Always)
+  MS(Close, Close)
+  MS(Ompx_Hold, OmpxHold)
+  MS(Present,   Present)
   // clang-format on
   );
 
   CLAUSET_ENUM_CONVERT( //
-  convert2, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier,
+  convert2, parser::OmpRefModifier::Value, Map::RefModifier,
   // clang-format off
-  MS(Always,Alwa

[llvm-branch-commits] [clang] [LifetimeSafety] Add loan expiry analysis (PR #148712)

2025-07-21 Thread Gábor Horváth via llvm-branch-commits

https://github.com/Xazax-hun approved this pull request.

Once the comments are addressed it looks good to me. 

https://github.com/llvm/llvm-project/pull/148712
___
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][AArch64] Lower vector.contract to Neon FEAT_BF16 operations (PR #148198)

2025-07-21 Thread Andrzej Warzyński via llvm-branch-commits

https://github.com/banach-space approved this pull request.

LGTM, thanks for splitting this into two!

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


  1   2   >