[llvm-branch-commits] [libcxx] [llvm] Bump version to 19.1.6 (PR #120051)

2024-12-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Tobias Hieta (tru)


Changes



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


5 Files Affected:

- (modified) cmake/Modules/LLVMVersion.cmake (+1-1) 
- (modified) libcxx/include/__config (+1-1) 
- (modified) llvm/utils/gn/secondary/llvm/version.gni (+1-1) 
- (modified) llvm/utils/lit/lit/__init__.py (+1-1) 
- (modified) llvm/utils/mlgo-utils/mlgo/__init__.py (+1-1) 


``diff
diff --git a/cmake/Modules/LLVMVersion.cmake b/cmake/Modules/LLVMVersion.cmake
index 9b39550118c4968..93d36736439b189 100644
--- a/cmake/Modules/LLVMVersion.cmake
+++ b/cmake/Modules/LLVMVersion.cmake
@@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 5)
+  set(LLVM_VERSION_PATCH 6)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 33e0043136fee78..e97669bca411e59 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -27,7 +27,7 @@
 // _LIBCPP_VERSION represents the version of libc++, which matches the version 
of LLVM.
 // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), 
_LIBCPP_VERSION is
 // defined to XXYYZZ.
-#  define _LIBCPP_VERSION 190105
+#  define _LIBCPP_VERSION 190106
 
 #  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
 #  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
diff --git a/llvm/utils/gn/secondary/llvm/version.gni 
b/llvm/utils/gn/secondary/llvm/version.gni
index c32a040dcba67a3..c46d2abdb8ef2de 100644
--- a/llvm/utils/gn/secondary/llvm/version.gni
+++ b/llvm/utils/gn/secondary/llvm/version.gni
@@ -1,4 +1,4 @@
 llvm_version_major = 19
 llvm_version_minor = 1
-llvm_version_patch = 5
+llvm_version_patch = 6
 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch"
diff --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index 8557e5a061d1d9e..ee0a3b2240e1e93 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = "Daniel Dunbar"
 __email__ = "dan...@minormatter.com"
-__versioninfo__ = (19, 1, 5)
+__versioninfo__ = (19, 1, 6)
 __version__ = ".".join(str(v) for v in __versioninfo__) + "dev"
 
 __all__ = []
diff --git a/llvm/utils/mlgo-utils/mlgo/__init__.py 
b/llvm/utils/mlgo-utils/mlgo/__init__.py
index e2f8ca88d91ec14..cec9ca8b2f648bc 100644
--- a/llvm/utils/mlgo-utils/mlgo/__init__.py
+++ b/llvm/utils/mlgo-utils/mlgo/__init__.py
@@ -4,7 +4,7 @@
 
 from datetime import timezone, datetime
 
-__versioninfo__ = (19, 1, 5)
+__versioninfo__ = (19, 1, 6)
 __version__ = (
 ".".join(str(v) for v in __versioninfo__)
 + "dev"

``




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


[llvm-branch-commits] [libcxx] [llvm] Bump version to 19.1.6 (PR #120051)

2024-12-16 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru created https://github.com/llvm/llvm-project/pull/120051

None

>From c9e72b3945f1672f0507539ce903c9696b3479ba Mon Sep 17 00:00:00 2001
From: Tobias Hieta 
Date: Fri, 13 Dec 2024 14:49:03 +0100
Subject: [PATCH] Bump version to 19.1.6

---
 cmake/Modules/LLVMVersion.cmake  | 2 +-
 libcxx/include/__config  | 2 +-
 llvm/utils/gn/secondary/llvm/version.gni | 2 +-
 llvm/utils/lit/lit/__init__.py   | 2 +-
 llvm/utils/mlgo-utils/mlgo/__init__.py   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/cmake/Modules/LLVMVersion.cmake b/cmake/Modules/LLVMVersion.cmake
index 9b39550118c4968..93d36736439b189 100644
--- a/cmake/Modules/LLVMVersion.cmake
+++ b/cmake/Modules/LLVMVersion.cmake
@@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 5)
+  set(LLVM_VERSION_PATCH 6)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 33e0043136fee78..e97669bca411e59 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -27,7 +27,7 @@
 // _LIBCPP_VERSION represents the version of libc++, which matches the version 
of LLVM.
 // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), 
_LIBCPP_VERSION is
 // defined to XXYYZZ.
-#  define _LIBCPP_VERSION 190105
+#  define _LIBCPP_VERSION 190106
 
 #  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
 #  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
diff --git a/llvm/utils/gn/secondary/llvm/version.gni 
b/llvm/utils/gn/secondary/llvm/version.gni
index c32a040dcba67a3..c46d2abdb8ef2de 100644
--- a/llvm/utils/gn/secondary/llvm/version.gni
+++ b/llvm/utils/gn/secondary/llvm/version.gni
@@ -1,4 +1,4 @@
 llvm_version_major = 19
 llvm_version_minor = 1
-llvm_version_patch = 5
+llvm_version_patch = 6
 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch"
diff --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index 8557e5a061d1d9e..ee0a3b2240e1e93 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = "Daniel Dunbar"
 __email__ = "dan...@minormatter.com"
-__versioninfo__ = (19, 1, 5)
+__versioninfo__ = (19, 1, 6)
 __version__ = ".".join(str(v) for v in __versioninfo__) + "dev"
 
 __all__ = []
diff --git a/llvm/utils/mlgo-utils/mlgo/__init__.py 
b/llvm/utils/mlgo-utils/mlgo/__init__.py
index e2f8ca88d91ec14..cec9ca8b2f648bc 100644
--- a/llvm/utils/mlgo-utils/mlgo/__init__.py
+++ b/llvm/utils/mlgo-utils/mlgo/__init__.py
@@ -4,7 +4,7 @@
 
 from datetime import timezone, datetime
 
-__versioninfo__ = (19, 1, 5)
+__versioninfo__ = (19, 1, 6)
 __version__ = (
 ".".join(str(v) for v in __versioninfo__)
 + "dev"

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


[llvm-branch-commits] [libcxx] [llvm] Bump version to 19.1.6 (PR #120051)

2024-12-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-testing-tools

Author: Tobias Hieta (tru)


Changes



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


5 Files Affected:

- (modified) cmake/Modules/LLVMVersion.cmake (+1-1) 
- (modified) libcxx/include/__config (+1-1) 
- (modified) llvm/utils/gn/secondary/llvm/version.gni (+1-1) 
- (modified) llvm/utils/lit/lit/__init__.py (+1-1) 
- (modified) llvm/utils/mlgo-utils/mlgo/__init__.py (+1-1) 


``diff
diff --git a/cmake/Modules/LLVMVersion.cmake b/cmake/Modules/LLVMVersion.cmake
index 9b39550118c4968..93d36736439b189 100644
--- a/cmake/Modules/LLVMVersion.cmake
+++ b/cmake/Modules/LLVMVersion.cmake
@@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 5)
+  set(LLVM_VERSION_PATCH 6)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 33e0043136fee78..e97669bca411e59 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -27,7 +27,7 @@
 // _LIBCPP_VERSION represents the version of libc++, which matches the version 
of LLVM.
 // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), 
_LIBCPP_VERSION is
 // defined to XXYYZZ.
-#  define _LIBCPP_VERSION 190105
+#  define _LIBCPP_VERSION 190106
 
 #  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
 #  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
diff --git a/llvm/utils/gn/secondary/llvm/version.gni 
b/llvm/utils/gn/secondary/llvm/version.gni
index c32a040dcba67a3..c46d2abdb8ef2de 100644
--- a/llvm/utils/gn/secondary/llvm/version.gni
+++ b/llvm/utils/gn/secondary/llvm/version.gni
@@ -1,4 +1,4 @@
 llvm_version_major = 19
 llvm_version_minor = 1
-llvm_version_patch = 5
+llvm_version_patch = 6
 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch"
diff --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index 8557e5a061d1d9e..ee0a3b2240e1e93 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = "Daniel Dunbar"
 __email__ = "dan...@minormatter.com"
-__versioninfo__ = (19, 1, 5)
+__versioninfo__ = (19, 1, 6)
 __version__ = ".".join(str(v) for v in __versioninfo__) + "dev"
 
 __all__ = []
diff --git a/llvm/utils/mlgo-utils/mlgo/__init__.py 
b/llvm/utils/mlgo-utils/mlgo/__init__.py
index e2f8ca88d91ec14..cec9ca8b2f648bc 100644
--- a/llvm/utils/mlgo-utils/mlgo/__init__.py
+++ b/llvm/utils/mlgo-utils/mlgo/__init__.py
@@ -4,7 +4,7 @@
 
 from datetime import timezone, datetime
 
-__versioninfo__ = (19, 1, 5)
+__versioninfo__ = (19, 1, 6)
 __version__ = (
 ".".join(str(v) for v in __versioninfo__)
 + "dev"

``




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


[llvm-branch-commits] [lld] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)

2024-12-16 Thread Nikita Popov via llvm-branch-commits

nikic wrote:

@dschuff For backport PRs, please rebase instead of merge. They do not use 
squash merge.

https://github.com/llvm/llvm-project/pull/119723
___
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] [NFC][Utils] Extract CloneFunctionBodyInto from CloneFunctionInto (PR #118624)

2024-12-16 Thread Felipe de Azevedo Piovezan via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/118624
___
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] [NFC][Utils] Eliminate DISubprogram set from BuildDebugInfoMDMap (PR #118625)

2024-12-16 Thread Felipe de Azevedo Piovezan via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/118625
___
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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

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

clementval wrote:

Don't we have buildbots testing shared libs? 
https://lab.llvm.org/buildbot/#/builders/80

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


[llvm-branch-commits] [lld] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)

2024-12-16 Thread Derek Schuff via llvm-branch-commits

https://github.com/dschuff updated 
https://github.com/llvm/llvm-project/pull/119723

>From fc310d328d3954207a775d0f0b17f9796912777a Mon Sep 17 00:00:00 2001
From: Sam Clegg 
Date: Mon, 9 Sep 2024 09:28:08 -0700
Subject: [PATCH] [lld][WebAssembly] Fix use of uninitialized stack data with
 --wasm64 (#107780)

In the case of `--wasm64` we were setting the type of the init expression
to be 64-bit but were only setting the low 32-bits of the value (by
assigning to Int32).

Fixes: https://github.com/emscripten-core/emscripten/issues/22538
(cherry picked from commit 5c8fd1eece8fff69871cef57a2363dc0f734a7d1)
---
 lld/wasm/SyntheticSections.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index f02f55519a2512..72d08b849d8e86 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -587,8 +587,7 @@ void ElemSection::writeBody() {
 initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex();
   } else {
 bool is64 = config->is64.value_or(false);
-initExpr.Inst.Opcode = is64 ? WASM_OPCODE_I64_CONST : 
WASM_OPCODE_I32_CONST;
-initExpr.Inst.Value.Int32 = config->tableBase;
+initExpr = intConst(config->tableBase, is64);
   }
   writeInitExpr(os, initExpr);
 

___
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/GlobalISel: RegBankLegalize rules for load (PR #112882)

2024-12-16 Thread Petar Avramovic via llvm-branch-commits

https://github.com/petar-avramovic updated 
https://github.com/llvm/llvm-project/pull/112882

>From 3fa31aeeb48e3b4a1dcac77d67dc6a1d205c8dce Mon Sep 17 00:00:00 2001
From: Petar Avramovic 
Date: Wed, 30 Oct 2024 15:37:59 +0100
Subject: [PATCH] AMDGPU/GlobalISel: RegBankLegalize rules for load

Add IDs for bit width that cover multiple LLTs: B32 B64 etc.
"Predicate" wrapper class for bool predicate functions used to
write pretty rules. Predicates can be combined using &&, || and !.
Lowering for splitting and widening loads.
Write rules for loads to not change existing mir tests from old
regbankselect.
---
 .../AMDGPU/AMDGPURegBankLegalizeHelper.cpp| 288 +++-
 .../AMDGPU/AMDGPURegBankLegalizeHelper.h  |   5 +
 .../AMDGPU/AMDGPURegBankLegalizeRules.cpp | 278 ++-
 .../AMDGPU/AMDGPURegBankLegalizeRules.h   |  65 +++-
 .../AMDGPU/GlobalISel/regbankselect-load.mir  | 320 +++---
 .../GlobalISel/regbankselect-zextload.mir |   9 +-
 6 files changed, 900 insertions(+), 65 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeHelper.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeHelper.cpp
index 6d9cf487c6dd25..6e78e29555ee11 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeHelper.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeHelper.cpp
@@ -38,6 +38,83 @@ void 
RegBankLegalizeHelper::findRuleAndApplyMapping(MachineInstr &MI) {
   lower(MI, Mapping, WaterfallSgprs);
 }
 
+void RegBankLegalizeHelper::splitLoad(MachineInstr &MI,
+  ArrayRef LLTBreakdown, LLT MergeTy) 
{
+  MachineFunction &MF = B.getMF();
+  assert(MI.getNumMemOperands() == 1);
+  MachineMemOperand &BaseMMO = **MI.memoperands_begin();
+  Register Dst = MI.getOperand(0).getReg();
+  const RegisterBank *DstRB = MRI.getRegBankOrNull(Dst);
+  Register Base = MI.getOperand(1).getReg();
+  LLT PtrTy = MRI.getType(Base);
+  const RegisterBank *PtrRB = MRI.getRegBankOrNull(Base);
+  LLT OffsetTy = LLT::scalar(PtrTy.getSizeInBits());
+  SmallVector LoadPartRegs;
+
+  unsigned ByteOffset = 0;
+  for (LLT PartTy : LLTBreakdown) {
+Register BasePlusOffset;
+if (ByteOffset == 0) {
+  BasePlusOffset = Base;
+} else {
+  auto Offset = B.buildConstant({PtrRB, OffsetTy}, ByteOffset);
+  BasePlusOffset = B.buildPtrAdd({PtrRB, PtrTy}, Base, Offset).getReg(0);
+}
+auto *OffsetMMO = MF.getMachineMemOperand(&BaseMMO, ByteOffset, PartTy);
+auto LoadPart = B.buildLoad({DstRB, PartTy}, BasePlusOffset, *OffsetMMO);
+LoadPartRegs.push_back(LoadPart.getReg(0));
+ByteOffset += PartTy.getSizeInBytes();
+  }
+
+  if (!MergeTy.isValid()) {
+// Loads are of same size, concat or merge them together.
+B.buildMergeLikeInstr(Dst, LoadPartRegs);
+  } else {
+// Loads are not all of same size, need to unmerge them to smaller pieces
+// of MergeTy type, then merge pieces to Dst.
+SmallVector MergeTyParts;
+for (Register Reg : LoadPartRegs) {
+  if (MRI.getType(Reg) == MergeTy) {
+MergeTyParts.push_back(Reg);
+  } else {
+auto Unmerge = B.buildUnmerge({DstRB, MergeTy}, Reg);
+for (unsigned i = 0; i < Unmerge->getNumOperands() - 1; ++i)
+  MergeTyParts.push_back(Unmerge.getReg(i));
+  }
+}
+B.buildMergeLikeInstr(Dst, MergeTyParts);
+  }
+  MI.eraseFromParent();
+}
+
+void RegBankLegalizeHelper::widenLoad(MachineInstr &MI, LLT WideTy,
+  LLT MergeTy) {
+  MachineFunction &MF = B.getMF();
+  assert(MI.getNumMemOperands() == 1);
+  MachineMemOperand &BaseMMO = **MI.memoperands_begin();
+  Register Dst = MI.getOperand(0).getReg();
+  const RegisterBank *DstRB = MRI.getRegBankOrNull(Dst);
+  Register Base = MI.getOperand(1).getReg();
+
+  MachineMemOperand *WideMMO = MF.getMachineMemOperand(&BaseMMO, 0, WideTy);
+  auto WideLoad = B.buildLoad({DstRB, WideTy}, Base, *WideMMO);
+
+  if (WideTy.isScalar()) {
+B.buildTrunc(Dst, WideLoad);
+  } else {
+SmallVector MergeTyParts;
+auto Unmerge = B.buildUnmerge({DstRB, MergeTy}, WideLoad);
+
+LLT DstTy = MRI.getType(Dst);
+unsigned NumElts = DstTy.getSizeInBits() / MergeTy.getSizeInBits();
+for (unsigned i = 0; i < NumElts; ++i) {
+  MergeTyParts.push_back(Unmerge.getReg(i));
+}
+B.buildMergeLikeInstr(Dst, MergeTyParts);
+  }
+  MI.eraseFromParent();
+}
+
 void RegBankLegalizeHelper::lower(MachineInstr &MI,
   const RegBankLLTMapping &Mapping,
   SmallSet &WaterfallSgprs) {
@@ -116,6 +193,54 @@ void RegBankLegalizeHelper::lower(MachineInstr &MI,
 MI.eraseFromParent();
 break;
   }
+  case SplitLoad: {
+LLT DstTy = MRI.getType(MI.getOperand(0).getReg());
+unsigned Size = DstTy.getSizeInBits();
+// Even split to 128-bit loads
+if (Size > 128) {
+  LLT B128;
+  if (DstTy.isVector()) {
+LLT EltTy = DstTy.getElementType();
+B128 = LLT::f

[llvm-branch-commits] [llvm] MachineUniformityAnalysis: Improve isConstantOrUndefValuePhi (PR #112866)

2024-12-16 Thread Petar Avramovic via llvm-branch-commits

https://github.com/petar-avramovic updated 
https://github.com/llvm/llvm-project/pull/112866

>From ada22e8d25b8ca05c048b83307edb60fbdf6a774 Mon Sep 17 00:00:00 2001
From: Petar Avramovic 
Date: Thu, 31 Oct 2024 14:10:57 +0100
Subject: [PATCH] MachineUniformityAnalysis: Improve isConstantOrUndefValuePhi

Change existing code for G_PHI to match what LLVM-IR version is doing
via PHINode::hasConstantOrUndefValue. This is not safe for regular PHI
since it may appear with an undef operand and getVRegDef can fail.
Most notably this improves number of values that can be allocated
to sgpr register bank in AMDGPURegBankSelect.
Common case here are phis that appear in structurize-cfg lowering
for cycles with multiple exits:
Undef incoming value is coming from block that reached cycle exit
condition, if other incoming is uniform keep the phi uniform despite
the fact it is joining values from pair of blocks that are entered
via divergent condition branch.
---
 llvm/lib/CodeGen/MachineSSAContext.cpp| 27 +-
 .../AMDGPU/MIR/hidden-diverge-gmir.mir| 28 +++
 .../AMDGPU/MIR/hidden-loop-diverge.mir|  4 +-
 .../AMDGPU/MIR/uses-value-from-cycle.mir  |  8 +-
 .../GlobalISel/divergence-structurizer.mir| 80 --
 .../regbankselect-mui-regbanklegalize.mir | 69 ---
 .../regbankselect-mui-regbankselect.mir   | 18 ++--
 .../AMDGPU/GlobalISel/regbankselect-mui.ll| 84 ++-
 .../AMDGPU/GlobalISel/regbankselect-mui.mir   | 51 ++-
 9 files changed, 191 insertions(+), 178 deletions(-)

diff --git a/llvm/lib/CodeGen/MachineSSAContext.cpp 
b/llvm/lib/CodeGen/MachineSSAContext.cpp
index e384187b6e8593..8e13c0916dd9e1 100644
--- a/llvm/lib/CodeGen/MachineSSAContext.cpp
+++ b/llvm/lib/CodeGen/MachineSSAContext.cpp
@@ -54,9 +54,34 @@ const MachineBasicBlock 
*MachineSSAContext::getDefBlock(Register value) const {
   return F->getRegInfo().getVRegDef(value)->getParent();
 }
 
+static bool isUndef(const MachineInstr &MI) {
+  return MI.getOpcode() == TargetOpcode::G_IMPLICIT_DEF ||
+ MI.getOpcode() == TargetOpcode::IMPLICIT_DEF;
+}
+
+/// MachineInstr equivalent of PHINode::hasConstantOrUndefValue() for G_PHI.
 template <>
 bool MachineSSAContext::isConstantOrUndefValuePhi(const MachineInstr &Phi) {
-  return Phi.isConstantValuePHI();
+  if (!Phi.isPHI())
+return false;
+
+  // In later passes PHI may appear with an undef operand, getVRegDef can fail.
+  if (Phi.getOpcode() == TargetOpcode::PHI)
+return Phi.isConstantValuePHI();
+
+  // For G_PHI we do equivalent of PHINode::hasConstantOrUndefValue().
+  const MachineRegisterInfo &MRI = Phi.getMF()->getRegInfo();
+  Register This = Phi.getOperand(0).getReg();
+  Register ConstantValue;
+  for (unsigned i = 1, e = Phi.getNumOperands(); i < e; i += 2) {
+Register Incoming = Phi.getOperand(i).getReg();
+if (Incoming != This && !isUndef(*MRI.getVRegDef(Incoming))) {
+  if (ConstantValue && ConstantValue != Incoming)
+return false;
+  ConstantValue = Incoming;
+}
+  }
+  return true;
 }
 
 template <>
diff --git 
a/llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/hidden-diverge-gmir.mir 
b/llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/hidden-diverge-gmir.mir
index ce00edf3363f77..9694a340b5e906 100644
--- a/llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/hidden-diverge-gmir.mir
+++ b/llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/hidden-diverge-gmir.mir
@@ -1,24 +1,24 @@
 # RUN: llc -mtriple=amdgcn-- -run-pass=print-machine-uniformity -o - %s 2>&1 | 
FileCheck %s
 # CHECK-LABEL: MachineUniformityInfo for function: hidden_diverge
 # CHECK-LABEL: BLOCK bb.0
-# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s32) = G_INTRINSIC 
intrinsic(@llvm.amdgcn.workitem.id.x)
-# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s1) = G_ICMP intpred(slt)
-# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s1) = G_XOR %{{[0-9]*}}:_, 
%{{[0-9]*}}:_
-# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s1), %{{[0-9]*}}:_(s64) = 
G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.if)
-# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s1), %{{[0-9]*}}:_(s64) = 
G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.if)
-# CHECK: DIVERGENT: G_BRCOND %{{[0-9]*}}:_(s1), %bb.1
-# CHECK: DIVERGENT: G_BR %bb.2
+# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s32) = G_INTRINSIC 
intrinsic(@llvm.amdgcn.workitem.id.x)
+# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s1) = G_ICMP intpred(slt)
+# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s1) = G_XOR %{{[0-9]*}}:_, 
%{{[0-9]*}}:_
+# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s1), %{{[0-9]*}}:_(s64) = 
G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.if)
+# CHECK: DIVERGENT: %{{[0-9]*}}: %{{[0-9]*}}:_(s1), %{{[0-9]*}}:_(s64) = 
G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.if)
+# CHECK: DIVERGENT: G_BRCOND %{{[0-9]*}}:_(s1), %bb.1
+# CHECK: DIVERGENT: G_BR %bb.2
 # CHECK-LABEL: BLOCK bb.1
 # CHECK-LABEL: BLOCK bb.2
-# CHECK: D

[llvm-branch-commits] [llvm] MachineUniformityAnalysis: Improve isConstantOrUndefValuePhi (PR #112866)

2024-12-16 Thread via llvm-branch-commits

github-actions[bot] wrote:




:warning: undef deprecator found issues in your code. :warning:



You can test this locally with the following command:


``bash
git diff -U0 --pickaxe-regex -S 
'([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' 
3fa31aeeb48e3b4a1dcac77d67dc6a1d205c8dce 
ada22e8d25b8ca05c048b83307edb60fbdf6a774 llvm/lib/CodeGen/MachineSSAContext.cpp 
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-mui.ll
``




The following files introduce new uses of undef:
 - llvm/lib/CodeGen/MachineSSAContext.cpp

[Undef](https://llvm.org/docs/LangRef.html#undefined-values) is now deprecated 
and should only be used in the rare cases where no replacement is possible. For 
example, a load of uninitialized memory yields `undef`. You should use `poison` 
values for placeholders instead.

In tests, avoid using `undef` and having tests that trigger undefined behavior. 
If you need an operand with some unimportant value, you can add a new argument 
to the function and use that instead.

For example, this is considered a bad practice:
```llvm
define void @fn() {
  ...
  br i1 undef, ...
}
```

Please use the following instead:
```llvm
define void @fn(i1 %cond) {
  ...
  br i1 %cond, ...
}
```

Please refer to the [Undefined Behavior 
Manual](https://llvm.org/docs/UndefinedBehavior.html) for more information.



https://github.com/llvm/llvm-project/pull/112866
___
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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-12-16 Thread via llvm-branch-commits

jeanPerier wrote:

> The new machanism will be different from BUILD_SHARED_LIBS so not reusing any 
> of its code. On the other side it would be a significant burden now since it 
> doubles the number of configurations I have to get working and testing now 
> while it will be replaced in the short term anyway. I hope you are not 
> planning a release that requires to contain a .so for compatibility reasons?

We use it in our CI and it just makes testing and investigating runtime related 
issues a lot easier (e.g., using LD_PRELOAD to bisect runtime change issues 
without having to fully recompile big apps, or to switch between debug/release 
runtime versions).

I am not asking for a a fully tested option, I am fine with an undocumented 
-DFLANG_RT_EXPERIMENTAL_DISABLE_STATIC option that forces this removes this 
`STATIC` keyword, and I can test myself with the configuration I use.

https://github.com/llvm/llvm-project/pull/110217
___
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] [DirectX] Split resource info into type and binding info. NFC (PR #119773)

2024-12-16 Thread Justin Bogner via llvm-branch-commits


@@ -303,44 +289,157 @@ class ResourceInfo {
   dxil::SamplerFeedbackType getFeedbackType() const;
   uint32_t getMultiSampleCount() const;
 
-  StringRef getName() const {
-// TODO: Get the name from the symbol once we include one here.
-return "";
-  }
   dxil::ResourceClass getResourceClass() const { return RC; }
   dxil::ResourceKind getResourceKind() const { return Kind; }
 
+  bool operator==(const ResourceTypeInfo &RHS) const;
+  bool operator!=(const ResourceTypeInfo &RHS) const { return !(*this == RHS); 
}
+  bool operator<(const ResourceTypeInfo &RHS) const;
+
+  void print(raw_ostream &OS, const DataLayout &DL) const;
+};
+
+//===--===//
+
+class ResourceBindingInfo {
+public:
+  struct ResourceBinding {
+uint32_t RecordID;
+uint32_t Space;
+uint32_t LowerBound;
+uint32_t Size;
+
+bool operator==(const ResourceBinding &RHS) const {
+  return std::tie(RecordID, Space, LowerBound, Size) ==
+ std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);
+}
+bool operator!=(const ResourceBinding &RHS) const {
+  return !(*this == RHS);
+}
+bool operator<(const ResourceBinding &RHS) const {
+  return std::tie(RecordID, Space, LowerBound, Size) <
+ std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);
+}
+  };
+
+private:
+  ResourceBinding Binding;
+  TargetExtType *HandleTy;
+
+public:
+  ResourceBindingInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound,
+  uint32_t Size, TargetExtType *HandleTy)
+  : Binding{RecordID, Space, LowerBound, Size}, HandleTy(HandleTy) {}
+
   void setBindingID(unsigned ID) { Binding.RecordID = ID; }
 
   const ResourceBinding &getBinding() const { return Binding; }
+  TargetExtType *getHandleTy() const { return HandleTy; }
+  const StringRef getName() const {
+// TODO: Get the name from the symbol once we include one here.
+return "";
+  }
 
-  MDTuple *getAsMetadata(Module &M) const;
-  std::pair getAnnotateProps(Module &M) const;
+  MDTuple *getAsMetadata(Module &M, DXILResourceTypeMap &DRTM) const;
+  MDTuple *getAsMetadata(Module &M, dxil::ResourceTypeInfo RTI) const;
 
-  bool operator==(const ResourceInfo &RHS) const;
-  bool operator!=(const ResourceInfo &RHS) const { return !(*this == RHS); }
-  bool operator<(const ResourceInfo &RHS) const;
+  std::pair
+  getAnnotateProps(Module &M, DXILResourceTypeMap &DRTM) const;
+  std::pair
+  getAnnotateProps(Module &M, dxil::ResourceTypeInfo RTI) const;
 
-  void print(raw_ostream &OS, const DataLayout &DL) const;
+  bool operator==(const ResourceBindingInfo &RHS) const {
+return std::tie(Binding, HandleTy) == std::tie(RHS.Binding, RHS.HandleTy);
+  }
+  bool operator!=(const ResourceBindingInfo &RHS) const {
+return !(*this == RHS);
+  }
+  bool operator<(const ResourceBindingInfo &RHS) const {
+return Binding < RHS.Binding;
+  }
+
+  void print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
+ const DataLayout &DL) const;
+  void print(raw_ostream &OS, dxil::ResourceTypeInfo RTI,
+ const DataLayout &DL) const;
 };
 
 } // namespace dxil
 
 
//===--===//
 
-class DXILResourceMap {
-  SmallVector Infos;
+class DXILResourceTypeMap {
+  struct Info {
+dxil::ResourceClass RC;
+dxil::ResourceKind Kind;
+bool GloballyCoherent;
+bool HasCounter;
+  };
+  DenseMap Infos;

bogner wrote:

There are a couple of reasons I structured it this way.
1. The map as is only has the pieces of information that aren't derived from 
the target type itself, making it easier to see that the `ResourceTypeInfo` is 
a simple convenience API wrapper
2. Storing the pointer as both the key and as a value in the map is redundant, 
both wasting size and making it less clear what the invariants are.

https://github.com/llvm/llvm-project/pull/119773
___
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] [DirectX] Split resource info into type and binding info. NFC (PR #119773)

2024-12-16 Thread Justin Bogner via llvm-branch-commits


@@ -303,44 +289,157 @@ class ResourceInfo {
   dxil::SamplerFeedbackType getFeedbackType() const;
   uint32_t getMultiSampleCount() const;
 
-  StringRef getName() const {
-// TODO: Get the name from the symbol once we include one here.
-return "";
-  }
   dxil::ResourceClass getResourceClass() const { return RC; }
   dxil::ResourceKind getResourceKind() const { return Kind; }
 
+  bool operator==(const ResourceTypeInfo &RHS) const;
+  bool operator!=(const ResourceTypeInfo &RHS) const { return !(*this == RHS); 
}
+  bool operator<(const ResourceTypeInfo &RHS) const;
+
+  void print(raw_ostream &OS, const DataLayout &DL) const;
+};
+
+//===--===//
+
+class ResourceBindingInfo {
+public:
+  struct ResourceBinding {
+uint32_t RecordID;
+uint32_t Space;
+uint32_t LowerBound;
+uint32_t Size;
+
+bool operator==(const ResourceBinding &RHS) const {
+  return std::tie(RecordID, Space, LowerBound, Size) ==
+ std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);
+}
+bool operator!=(const ResourceBinding &RHS) const {
+  return !(*this == RHS);
+}
+bool operator<(const ResourceBinding &RHS) const {
+  return std::tie(RecordID, Space, LowerBound, Size) <
+ std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);
+}
+  };
+
+private:
+  ResourceBinding Binding;
+  TargetExtType *HandleTy;
+
+public:
+  ResourceBindingInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound,
+  uint32_t Size, TargetExtType *HandleTy)
+  : Binding{RecordID, Space, LowerBound, Size}, HandleTy(HandleTy) {}
+
   void setBindingID(unsigned ID) { Binding.RecordID = ID; }
 
   const ResourceBinding &getBinding() const { return Binding; }
+  TargetExtType *getHandleTy() const { return HandleTy; }
+  const StringRef getName() const {
+// TODO: Get the name from the symbol once we include one here.
+return "";
+  }
 
-  MDTuple *getAsMetadata(Module &M) const;
-  std::pair getAnnotateProps(Module &M) const;
+  MDTuple *getAsMetadata(Module &M, DXILResourceTypeMap &DRTM) const;
+  MDTuple *getAsMetadata(Module &M, dxil::ResourceTypeInfo RTI) const;
 
-  bool operator==(const ResourceInfo &RHS) const;
-  bool operator!=(const ResourceInfo &RHS) const { return !(*this == RHS); }
-  bool operator<(const ResourceInfo &RHS) const;
+  std::pair
+  getAnnotateProps(Module &M, DXILResourceTypeMap &DRTM) const;
+  std::pair
+  getAnnotateProps(Module &M, dxil::ResourceTypeInfo RTI) const;
 
-  void print(raw_ostream &OS, const DataLayout &DL) const;
+  bool operator==(const ResourceBindingInfo &RHS) const {
+return std::tie(Binding, HandleTy) == std::tie(RHS.Binding, RHS.HandleTy);
+  }
+  bool operator!=(const ResourceBindingInfo &RHS) const {
+return !(*this == RHS);
+  }
+  bool operator<(const ResourceBindingInfo &RHS) const {
+return Binding < RHS.Binding;
+  }
+
+  void print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
+ const DataLayout &DL) const;
+  void print(raw_ostream &OS, dxil::ResourceTypeInfo RTI,
+ const DataLayout &DL) const;
 };
 
 } // namespace dxil
 
 
//===--===//
 
-class DXILResourceMap {
-  SmallVector Infos;
+class DXILResourceTypeMap {
+  struct Info {
+dxil::ResourceClass RC;
+dxil::ResourceKind Kind;
+bool GloballyCoherent;
+bool HasCounter;
+  };
+  DenseMap Infos;
+
+public:
+  bool invalidate(Module &M, const PreservedAnalyses &PA,
+  ModuleAnalysisManager::Invalidator &Inv);
+
+  dxil::ResourceTypeInfo operator[](TargetExtType *Ty) {
+Info I = Infos[Ty];
+return dxil::ResourceTypeInfo(Ty, I.RC, I.Kind, I.GloballyCoherent,
+  I.HasCounter);
+  }
+
+  void setGloballyCoherent(TargetExtType *Ty, bool GloballyCoherent) {
+Infos[Ty].GloballyCoherent = GloballyCoherent;
+  }
+
+  void setHasCounter(TargetExtType *Ty, bool HasCounter) {
+Infos[Ty].HasCounter = HasCounter;
+  }
+};
+
+class DXILResourceTypeAnalysis
+: public AnalysisInfoMixin {
+  friend AnalysisInfoMixin;
+
+  static AnalysisKey Key;
+
+public:
+  using Result = DXILResourceTypeMap;
+
+  DXILResourceTypeMap run(Module &M, ModuleAnalysisManager &AM) {
+return Result();
+  }

bogner wrote:

It's populated on demand. Currently this mostly occurs in 
DXILResourceBindingAnalysis, but when earlier passes need to query the analysis 
they'll populate it as well.

I've added a comment about this.

https://github.com/llvm/llvm-project/pull/119773
___
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] [NFC][Utils] Eliminate DISubprogram set from BuildDebugInfoMDMap (PR #118625)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118625

>From eba5202f2e8cb535c2e14b5175ed8ea99dc7d892 Mon Sep 17 00:00:00 2001
From: Artem Pianykh 
Date: Sat, 14 Sep 2024 16:02:51 -0700
Subject: [PATCH] [NFC][Utils] Eliminate DISubprogram set from
 BuildDebugInfoMDMap

Summary:
Previously, we'd add all SPs distinct from the cloned one into a set.
Then when cloning a local scope we'd check if it's from one of those
'distinct' SPs by checking if it's in the set. We don't need to do that.
We can just check against the cloned SP directly and drop the set.

Test Plan:
ninja check-llvm-unit check-llvm

stack-info: PR: https://github.com/llvm/llvm-project/pull/118625, branch: 
users/artempyanykh/fast-coro-upstream/6
---
 llvm/lib/Transforms/Utils/CloneFunction.cpp | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp 
b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index d47633a05fce96..8863dff4482a1a 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -172,18 +172,15 @@ bool llvm::BuildDebugInfoMDMap(DenseMap &MD,
 };
 
 // Avoid cloning types, compile units, and (other) subprograms.
-SmallPtrSet MappedToSelfSPs;
 for (DISubprogram *ISP : DIFinder.subprograms()) {
-  if (ISP != SPClonedWithinModule) {
+  if (ISP != SPClonedWithinModule)
 mapToSelfIfNew(ISP);
-MappedToSelfSPs.insert(ISP);
-  }
 }
 
 // If a subprogram isn't going to be cloned skip its lexical blocks as 
well.
 for (DIScope *S : DIFinder.scopes()) {
   auto *LScope = dyn_cast(S);
-  if (LScope && MappedToSelfSPs.count(LScope->getSubprogram()))
+  if (LScope && LScope->getSubprogram() != SPClonedWithinModule)
 mapToSelfIfNew(S);
 }
 

___
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] [Coro] Prebuild a module-level debug info set and share it between all coroutine clones (PR #118628)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118628

>From f58b71db85166f2ea422af235226f1df4a944f77 Mon Sep 17 00:00:00 2001
From: Artem Pianykh 
Date: Tue, 19 Nov 2024 17:19:27 -0700
Subject: [PATCH] [Coro] Prebuild a module-level debug info set and share it
 between all coroutine clones

Summary:
CoroCloner, by calling into CloneFunctionInto, does a lot of repeated
work priming DIFinder and building a list of common module-level debug
info metadata. For programs compiled with full debug info this can get
very expensive.

This diff builds the data once and shares it between all clones.

Anecdata for a sample cpp source file compiled with full debug info:

| | Baseline | IdentityMD set | Prebuilt CommonDI (cur.) |
|-|--||--|
| CoroSplitPass   | 306ms| 221ms  | 68ms |
| CoroCloner  | 101ms| 72ms   | 0.5ms|
| CollectGlobalDI | -| -  | 63ms |
| Speed up| 1x   | 1.4x   | 4.5x |

Note that CollectCommonDebugInfo happens once *per coroutine* rather than per 
clone.

Test Plan:
ninja check-llvm-unit
ninja check-llvm

Compiled a sample internal source file, checked time trace output for scope 
timings.

stack-info: PR: https://github.com/llvm/llvm-project/pull/118628, branch: 
users/artempyanykh/fast-coro-upstream/9
---
 llvm/lib/Transforms/Coroutines/CoroCloner.h  | 31 +++-
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp | 50 +---
 2 files changed, 63 insertions(+), 18 deletions(-)

diff --git a/llvm/lib/Transforms/Coroutines/CoroCloner.h 
b/llvm/lib/Transforms/Coroutines/CoroCloner.h
index d1887980fb3bcb..b817e55cad9fc3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroCloner.h
+++ b/llvm/lib/Transforms/Coroutines/CoroCloner.h
@@ -48,6 +48,9 @@ class BaseCloner {
   CloneKind FKind;
   IRBuilder<> Builder;
   TargetTransformInfo &TTI;
+  // Common module-level metadata that's shared between all coroutine clones 
and
+  // doesn't need to be cloned itself.
+  const MetadataSetTy &CommonDebugInfo;
 
   ValueToValueMapTy VMap;
   Function *NewF = nullptr;
@@ -60,12 +63,12 @@ class BaseCloner {
   /// Create a cloner for a continuation lowering.
   BaseCloner(Function &OrigF, const Twine &Suffix, coro::Shape &Shape,
  Function *NewF, AnyCoroSuspendInst *ActiveSuspend,
- TargetTransformInfo &TTI)
+ TargetTransformInfo &TTI, const MetadataSetTy &CommonDebugInfo)
   : OrigF(OrigF), Suffix(Suffix), Shape(Shape),
 FKind(Shape.ABI == ABI::Async ? CloneKind::Async
   : CloneKind::Continuation),
-Builder(OrigF.getContext()), TTI(TTI), NewF(NewF),
-ActiveSuspend(ActiveSuspend) {
+Builder(OrigF.getContext()), TTI(TTI), 
CommonDebugInfo(CommonDebugInfo),
+NewF(NewF), ActiveSuspend(ActiveSuspend) {
 assert(Shape.ABI == ABI::Retcon || Shape.ABI == ABI::RetconOnce ||
Shape.ABI == ABI::Async);
 assert(NewF && "need existing function for continuation");
@@ -74,9 +77,11 @@ class BaseCloner {
 
 public:
   BaseCloner(Function &OrigF, const Twine &Suffix, coro::Shape &Shape,
- CloneKind FKind, TargetTransformInfo &TTI)
+ CloneKind FKind, TargetTransformInfo &TTI,
+ const MetadataSetTy &CommonDebugInfo)
   : OrigF(OrigF), Suffix(Suffix), Shape(Shape), FKind(FKind),
-Builder(OrigF.getContext()), TTI(TTI) {}
+Builder(OrigF.getContext()), TTI(TTI),
+CommonDebugInfo(CommonDebugInfo) {}
 
   virtual ~BaseCloner() {}
 
@@ -84,12 +89,14 @@ class BaseCloner {
   static Function *createClone(Function &OrigF, const Twine &Suffix,
coro::Shape &Shape, Function *NewF,
AnyCoroSuspendInst *ActiveSuspend,
-   TargetTransformInfo &TTI) {
+   TargetTransformInfo &TTI,
+   const MetadataSetTy &CommonDebugInfo) {
 assert(Shape.ABI == ABI::Retcon || Shape.ABI == ABI::RetconOnce ||
Shape.ABI == ABI::Async);
 TimeTraceScope FunctionScope("BaseCloner");
 
-BaseCloner Cloner(OrigF, Suffix, Shape, NewF, ActiveSuspend, TTI);
+BaseCloner Cloner(OrigF, Suffix, Shape, NewF, ActiveSuspend, TTI,
+  CommonDebugInfo);
 Cloner.create();
 return Cloner.getFunction();
   }
@@ -129,8 +136,9 @@ class SwitchCloner : public BaseCloner {
 protected:
   /// Create a cloner for a switch lowering.
   SwitchCloner(Function &OrigF, const Twine &Suffix, coro::Shape &Shape,
-   CloneKind FKind, TargetTransformInfo &TTI)
-  : BaseCloner(OrigF, Suffix, Shape, FKind, TTI) {}
+   CloneKind FKind, TargetTransformInfo &TTI,
+   const MetadataSetTy &CommonDebugInfo)
+  

[llvm-branch-commits] [llvm] [Analysis] Add DebugInfoCache analysis (PR #118629)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118629

>From b743d6ca1e081305f0b8fc9a1f2d270ef07272d5 Mon Sep 17 00:00:00 2001
From: Artem Pianykh 
Date: Sun, 15 Sep 2024 10:51:38 -0700
Subject: [PATCH] [Analysis] Add DebugInfoCache analysis

Summary:
The analysis simply primes and caches DebugInfoFinders for each DICompileUnit 
in a module. This
allows (future) callers like CoroSplitPass to compute global debug info 
metadata (required for
coroutine function cloning) much faster. Specifically, pay the price of 
DICompileUnit processing
only once per compile unit, rather than once per coroutine.

Test Plan:
Added a smoke test for the new analysis
ninja check-llvm-unit check-llvm

stack-info: PR: https://github.com/llvm/llvm-project/pull/118629, branch: 
users/artempyanykh/fast-coro-upstream/10
---
 llvm/include/llvm/Analysis/DebugInfoCache.h   |  50 +
 llvm/include/llvm/IR/DebugInfo.h  |   4 +-
 llvm/lib/Analysis/CMakeLists.txt  |   1 +
 llvm/lib/Analysis/DebugInfoCache.cpp  |  47 
 llvm/lib/Passes/PassBuilder.cpp   |   1 +
 llvm/lib/Passes/PassRegistry.def  |   1 +
 llvm/unittests/Analysis/CMakeLists.txt|   1 +
 .../unittests/Analysis/DebugInfoCacheTest.cpp | 211 ++
 8 files changed, 315 insertions(+), 1 deletion(-)
 create mode 100644 llvm/include/llvm/Analysis/DebugInfoCache.h
 create mode 100644 llvm/lib/Analysis/DebugInfoCache.cpp
 create mode 100644 llvm/unittests/Analysis/DebugInfoCacheTest.cpp

diff --git a/llvm/include/llvm/Analysis/DebugInfoCache.h 
b/llvm/include/llvm/Analysis/DebugInfoCache.h
new file mode 100644
index 00..dbd6802c99ea01
--- /dev/null
+++ b/llvm/include/llvm/Analysis/DebugInfoCache.h
@@ -0,0 +1,50 @@
+//===- llvm/Analysis/DebugInfoCache.h - debug info cache *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains an analysis that builds a cache of debug info for each
+// DICompileUnit in a module.
+//
+//===--===//
+
+#ifndef LLVM_ANALYSIS_DEBUGINFOCACHE_H
+#define LLVM_ANALYSIS_DEBUGINFOCACHE_H
+
+#include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+/// Processes and caches debug info for each DICompileUnit in a module.
+///
+/// The result of the analysis is a set of DebugInfoFinders primed on their
+/// respective DICompileUnit. Such DebugInfoFinders can be used to speed up
+/// function cloning which otherwise requires an expensive traversal of
+/// DICompileUnit-level debug info. See an example usage in CoroSplit.
+class DebugInfoCache {
+public:
+  using DIFinderCache = SmallDenseMap;
+  DIFinderCache Result;
+
+  DebugInfoCache(const Module &M);
+
+  bool invalidate(Module &, const PreservedAnalyses &,
+  ModuleAnalysisManager::Invalidator &);
+};
+
+class DebugInfoCacheAnalysis
+: public AnalysisInfoMixin {
+  friend AnalysisInfoMixin;
+  static AnalysisKey Key;
+
+public:
+  using Result = DebugInfoCache;
+  Result run(Module &M, ModuleAnalysisManager &);
+};
+} // namespace llvm
+
+#endif
diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h
index 73f45c3769be44..11907fbb7f20b3 100644
--- a/llvm/include/llvm/IR/DebugInfo.h
+++ b/llvm/include/llvm/IR/DebugInfo.h
@@ -120,11 +120,13 @@ class DebugInfoFinder {
   /// Process subprogram.
   void processSubprogram(DISubprogram *SP);
 
+  /// Process a compile unit.
+  void processCompileUnit(DICompileUnit *CU);
+
   /// Clear all lists.
   void reset();
 
 private:
-  void processCompileUnit(DICompileUnit *CU);
   void processScope(DIScope *Scope);
   void processType(DIType *DT);
   bool addCompileUnit(DICompileUnit *CU);
diff --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index 0db5b80f336cb5..db9a569e301563 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -52,6 +52,7 @@ add_llvm_component_library(LLVMAnalysis
   DDGPrinter.cpp
   ConstraintSystem.cpp
   Delinearization.cpp
+  DebugInfoCache.cpp
   DemandedBits.cpp
   DependenceAnalysis.cpp
   DependenceGraphBuilder.cpp
diff --git a/llvm/lib/Analysis/DebugInfoCache.cpp 
b/llvm/lib/Analysis/DebugInfoCache.cpp
new file mode 100644
index 00..c1a3e89f0a6ccf
--- /dev/null
+++ b/llvm/lib/Analysis/DebugInfoCache.cpp
@@ -0,0 +1,47 @@
+//===- llvm/Analysis/DebugInfoCache.cpp - debug info cache 
===//
+//
+// 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
+//
+//===-

[llvm-branch-commits] [llvm] [Utils] Identity map module-level debug info on first use in CloneFunction* (PR #118627)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118627

>From fbe503b84acfb10ac6ae92248079c01467669439 Mon Sep 17 00:00:00 2001
From: Artem Pianykh 
Date: Sun, 15 Sep 2024 04:39:20 -0700
Subject: [PATCH] [Utils] Identity map module-level debug info on first use in
 CloneFunction*

Summary:
To avoid cloning module-level debug info (owned by the module rather
than the function), CloneFunction implementation used to eagerly
identity map such debug info into ValueMap's MD map. In larger modules
with meaningful volume of debug info this gets very expensive.

By passing such debug info metadata via an IdentityMD set for the
ValueMapper to map on first use, we get several benefits:

1. Mapping metadata is not cheap, particularly because of tracking. When
   cloning a Function we identity map lots of global module-level
   metadata to avoid cloning it, while only a fraction of it is actually
   used by the function. Mapping on first use is a lot faster for
   modules with meaningful amount of debug info.

2. Eagerly identity mapping metadata makes it harder to cache
   module-level data (e.g. a set of metadata nodes in a \a DICompileUnit).
   With this patch we can cache certain module-level metadata
   calculations to speed things up further.

Anecdata from compiling a sample cpp file with full debug info shows that this 
moderately speeds up
CoroSplitPass which is one of the heavier users of cloning:

| | Baseline | IdentityMD set |
|-|--||
| CoroSplitPass   | 306ms| 221ms  |
| CoroCloner  | 101ms| 72ms   |
| Speed up| 1x   | 1.4x   |

Test Plan:
ninja check-llvm-unit
ninja check-llvm

stack-info: PR: https://github.com/llvm/llvm-project/pull/118627, branch: 
users/artempyanykh/fast-coro-upstream/8
---
 llvm/include/llvm/Transforms/Utils/Cloning.h  | 19 +++---
 .../llvm/Transforms/Utils/ValueMapper.h   | 67 ++-
 llvm/lib/Transforms/Utils/CloneFunction.cpp   | 60 -
 llvm/lib/Transforms/Utils/ValueMapper.cpp | 19 --
 4 files changed, 104 insertions(+), 61 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Utils/Cloning.h 
b/llvm/include/llvm/Transforms/Utils/Cloning.h
index 2fcb64206387ed..72d3eebabc5c9a 100644
--- a/llvm/include/llvm/Transforms/Utils/Cloning.h
+++ b/llvm/include/llvm/Transforms/Utils/Cloning.h
@@ -193,7 +193,8 @@ void CloneFunctionAttributesInto(Function *NewFunc, const 
Function *OldFunc,
 void CloneFunctionMetadataInto(Function &NewFunc, const Function &OldFunc,
ValueToValueMapTy &VMap, RemapFlags RemapFlag,
ValueMapTypeRemapper *TypeMapper = nullptr,
-   ValueMaterializer *Materializer = nullptr);
+   ValueMaterializer *Materializer = nullptr,
+   const MetadataSetTy *IdentityMD = nullptr);
 
 /// Clone OldFunc's body into NewFunc.
 void CloneFunctionBodyInto(Function &NewFunc, const Function &OldFunc,
@@ -202,7 +203,8 @@ void CloneFunctionBodyInto(Function &NewFunc, const 
Function &OldFunc,
const char *NameSuffix = "",
ClonedCodeInfo *CodeInfo = nullptr,
ValueMapTypeRemapper *TypeMapper = nullptr,
-   ValueMaterializer *Materializer = nullptr);
+   ValueMaterializer *Materializer = nullptr,
+   const MetadataSetTy *IdentityMD = nullptr);
 
 void CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
const Instruction *StartingInst,
@@ -242,13 +244,12 @@ DISubprogram *CollectDebugInfoForCloning(const Function 
&F,
  CloneFunctionChangeType Changes,
  DebugInfoFinder &DIFinder);
 
-/// Build a map of debug info to use during Metadata cloning.
-/// Returns true if cloning would need module level changes and false if there
-/// would only be local changes.
-bool BuildDebugInfoMDMap(DenseMap &MD,
- CloneFunctionChangeType Changes,
- DebugInfoFinder &DIFinder,
- DISubprogram *SPClonedWithinModule);
+/// Based on \p Changes and \p DIFinder populate \p MD with debug info that
+/// needs to be identity mapped during Metadata cloning.
+void FindDebugInfoToIdentityMap(MetadataSetTy &MD,
+CloneFunctionChangeType Changes,
+DebugInfoFinder &DIFinder,
+DISubprogram *SPClonedWithinModule);
 
 /// This class captures the data input to the InlineFunction call, and records
 /// the auxiliary results produced by it.
diff --git a/llvm/include/llvm/Transforms/Utils/ValueMapper.h 
b/llvm/include/llvm/Transforms/Utils/ValueMapper.h
index 743c

[llvm-branch-commits] [llvm] [Coro] Use DebugInfoCache to speed up cloning in CoroSplitPass (PR #118630)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118630

>From c3724f4dcb7fee75d637cfd5c7955ac2346c0fe9 Mon Sep 17 00:00:00 2001
From: Artem Pianykh 
Date: Sun, 15 Sep 2024 11:00:00 -0700
Subject: [PATCH] [Coro] Use DebugInfoCache to speed up cloning in
 CoroSplitPass

Summary:
We can use a DebugInfoFinder from DebugInfoCache which is already primed on a 
compile unit to speed
up collection of module-level debug info.

The pass could likely be another 2x+ faster if we avoid rebuilding the set of 
global debug
info. This needs further massaging of CloneFunction and ValueMapper, though, 
and can be done
incrementally on top of this.

Comparing performance of CoroSplitPass at various points in this stack, this is 
anecdata from a sample
cpp file compiled with full debug info:
| | Baseline | IdentityMD set | Prebuilt CommonDI | Cached CU 
DIFinder (cur.) |
|-|--||---|---|
| CoroSplitPass   | 306ms| 221ms  | 68ms  | 17ms
  |
| CoroCloner  | 101ms| 72ms   | 0.5ms | 0.5ms   
  |
| CollectGlobalDI | -| -  | 63ms  | 13ms
  |
| Speed up| 1x   | 1.4x   | 4.5x  | 18x 
  |

Test Plan:
ninja check-llvm-unit
ninja check-llvm

Compiled a sample cpp file with time trace to get the avg. duration of the pass 
and inner scopes.

stack-info: PR: https://github.com/llvm/llvm-project/pull/118630, branch: 
users/artempyanykh/fast-coro-upstream/11
---
 llvm/include/llvm/Transforms/Coroutines/ABI.h | 13 +++--
 llvm/lib/Analysis/CGSCCPassManager.cpp|  7 +++
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  | 55 +++
 llvm/test/Other/new-pass-manager.ll   |  1 +
 llvm/test/Other/new-pm-defaults.ll|  1 +
 llvm/test/Other/new-pm-lto-defaults.ll|  1 +
 llvm/test/Other/new-pm-pgo-preinline.ll   |  1 +
 .../Other/new-pm-thinlto-postlink-defaults.ll |  1 +
 .../new-pm-thinlto-postlink-pgo-defaults.ll   |  1 +
 ...-pm-thinlto-postlink-samplepgo-defaults.ll |  1 +
 .../Other/new-pm-thinlto-prelink-defaults.ll  |  1 +
 .../new-pm-thinlto-prelink-pgo-defaults.ll|  1 +
 ...w-pm-thinlto-prelink-samplepgo-defaults.ll |  1 +
 .../Analysis/CGSCCPassManagerTest.cpp |  4 +-
 14 files changed, 72 insertions(+), 17 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Coroutines/ABI.h 
b/llvm/include/llvm/Transforms/Coroutines/ABI.h
index 0b2d405f3caec4..2cf614b6bb1e2a 100644
--- a/llvm/include/llvm/Transforms/Coroutines/ABI.h
+++ b/llvm/include/llvm/Transforms/Coroutines/ABI.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_TRANSFORMS_COROUTINES_ABI_H
 #define LLVM_TRANSFORMS_COROUTINES_ABI_H
 
+#include "llvm/Analysis/DebugInfoCache.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Transforms/Coroutines/CoroShape.h"
 #include "llvm/Transforms/Coroutines/MaterializationUtils.h"
@@ -53,7 +54,8 @@ class BaseABI {
   // Perform the function splitting according to the ABI.
   virtual void splitCoroutine(Function &F, coro::Shape &Shape,
   SmallVectorImpl &Clones,
-  TargetTransformInfo &TTI) = 0;
+  TargetTransformInfo &TTI,
+  const DebugInfoCache *DICache) = 0;
 
   Function &F;
   coro::Shape &Shape;
@@ -73,7 +75,8 @@ class SwitchABI : public BaseABI {
 
   void splitCoroutine(Function &F, coro::Shape &Shape,
   SmallVectorImpl &Clones,
-  TargetTransformInfo &TTI) override;
+  TargetTransformInfo &TTI,
+  const DebugInfoCache *DICache) override;
 };
 
 class AsyncABI : public BaseABI {
@@ -86,7 +89,8 @@ class AsyncABI : public BaseABI {
 
   void splitCoroutine(Function &F, coro::Shape &Shape,
   SmallVectorImpl &Clones,
-  TargetTransformInfo &TTI) override;
+  TargetTransformInfo &TTI,
+  const DebugInfoCache *DICache) override;
 };
 
 class AnyRetconABI : public BaseABI {
@@ -99,7 +103,8 @@ class AnyRetconABI : public BaseABI {
 
   void splitCoroutine(Function &F, coro::Shape &Shape,
   SmallVectorImpl &Clones,
-  TargetTransformInfo &TTI) override;
+  TargetTransformInfo &TTI,
+  const DebugInfoCache *DICache) override;
 };
 
 } // end namespace coro
diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp 
b/llvm/lib/Analysis/CGSCCPassManager.cpp
index 948bc2435ab275..3ba085cdb0be8b 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Analy

[llvm-branch-commits] [clang] [llvm] [Utils] Identity map module-level debug info on first use in CloneFunction* (PR #118627)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118627

>From 8c163237573df097a99b65a83280757d1b39062c Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Mon, 16 Dec 2024 13:25:21 -0800
Subject: [PATCH 1/3] [OpenACC/NFC] Make 'trailing objects' use private
 inheritence.

I noticed this while working on something else, these are supposed to be
privately inherited.
---
 clang/include/clang/AST/OpenACCClause.h | 57 -
 clang/include/clang/AST/StmtOpenACC.h   | 23 ++
 2 files changed, 53 insertions(+), 27 deletions(-)

diff --git a/clang/include/clang/AST/OpenACCClause.h 
b/clang/include/clang/AST/OpenACCClause.h
index 7a1b17cc4e44e3..51db58d484a25f 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -191,8 +191,9 @@ using DeviceTypeArgument = std::pair;
 /// an identifier. The 'asterisk' means 'the rest'.
 class OpenACCDeviceTypeClause final
 : public OpenACCClauseWithParams,
-  public llvm::TrailingObjects {
+  friend TrailingObjects;
   // Data stored in trailing objects as IdentifierInfo* /SourceLocation pairs. 
A
   // nullptr IdentifierInfo* represents an asterisk.
   unsigned NumArchs;
@@ -377,7 +378,8 @@ class OpenACCClauseWithExprs : public 
OpenACCClauseWithParams {
 // Represents the 'devnum' and expressions lists for the 'wait' clause.
 class OpenACCWaitClause final
 : public OpenACCClauseWithExprs,
-  public llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
   SourceLocation QueuesLoc;
   OpenACCWaitClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
 Expr *DevNumExpr, SourceLocation QueuesLoc,
@@ -419,7 +421,8 @@ class OpenACCWaitClause final
 
 class OpenACCNumGangsClause final
 : public OpenACCClauseWithExprs,
-  public llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
 
   OpenACCNumGangsClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
 ArrayRef IntExprs, SourceLocation EndLoc)
@@ -449,7 +452,8 @@ class OpenACCNumGangsClause final
 
 class OpenACCTileClause final
 : public OpenACCClauseWithExprs,
-  public llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
   OpenACCTileClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
 ArrayRef SizeExprs, SourceLocation EndLoc)
   : OpenACCClauseWithExprs(OpenACCClauseKind::Tile, BeginLoc, LParenLoc,
@@ -503,7 +507,8 @@ class OpenACCClauseWithSingleIntExpr : public 
OpenACCClauseWithExprs {
 
 class OpenACCGangClause final
 : public OpenACCClauseWithExprs,
-  public llvm::TrailingObjects 
{
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
 protected:
   OpenACCGangClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
 ArrayRef GangKinds,
@@ -658,7 +663,8 @@ class OpenACCClauseWithVarList : public 
OpenACCClauseWithExprs {
 
 class OpenACCPrivateClause final
 : public OpenACCClauseWithVarList,
-  public llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
 
   OpenACCPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef VarList, SourceLocation EndLoc)
@@ -680,7 +686,8 @@ class OpenACCPrivateClause final
 
 class OpenACCFirstPrivateClause final
 : public OpenACCClauseWithVarList,
-  public llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
 
   OpenACCFirstPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
 ArrayRef VarList, SourceLocation EndLoc)
@@ -702,7 +709,8 @@ class OpenACCFirstPrivateClause final
 
 class OpenACCDevicePtrClause final
 : public OpenACCClauseWithVarList,
-  public llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
 
   OpenACCDevicePtrClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
  ArrayRef VarList, SourceLocation EndLoc)
@@ -724,7 +732,8 @@ class OpenACCDevicePtrClause final
 
 class OpenACCAttachClause final
 : public OpenACCClauseWithVarList,
-  public llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
 
   OpenACCAttachClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
   ArrayRef VarList, SourceLocation EndLoc)
@@ -746,7 +755,8 @@ class OpenACCAttachClause final
 
 class OpenACCDetachClause final
 : public OpenACCClauseWithVarList,
-  public llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
 
   OpenACCDetachClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
   ArrayRef VarList, SourceLocation EndLoc)
@@ -768,7 +778,8 @@ class OpenACCDetachClause final
 
 class OpenACCDeleteClause final
 : public OpenACCClauseWithVarList,
-  

[llvm-branch-commits] [llvm] [Coro] Prebuild a module-level debug info set and share it between all coroutine clones (PR #118628)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118628

>From c613ae3e67106550529bef26d112b54f0def17e5 Mon Sep 17 00:00:00 2001
From: Artem Pianykh 
Date: Tue, 19 Nov 2024 17:19:27 -0700
Subject: [PATCH] [Coro] Prebuild a module-level debug info set and share it
 between all coroutine clones

Summary:
CoroCloner, by calling into CloneFunctionInto, does a lot of repeated
work priming DIFinder and building a list of common module-level debug
info metadata. For programs compiled with full debug info this can get
very expensive.

This diff builds the data once and shares it between all clones.

Anecdata for a sample cpp source file compiled with full debug info:

| | Baseline | IdentityMD set | Prebuilt CommonDI (cur.) |
|-|--||--|
| CoroSplitPass   | 306ms| 221ms  | 68ms |
| CoroCloner  | 101ms| 72ms   | 0.5ms|
| CollectGlobalDI | -| -  | 63ms |
| Speed up| 1x   | 1.4x   | 4.5x |

Note that CollectCommonDebugInfo happens once *per coroutine* rather than per 
clone.

Test Plan:
ninja check-llvm-unit
ninja check-llvm

Compiled a sample internal source file, checked time trace output for scope 
timings.

stack-info: PR: https://github.com/llvm/llvm-project/pull/118628, branch: 
users/artempyanykh/fast-coro-upstream/9
---
 llvm/lib/Transforms/Coroutines/CoroCloner.h  | 31 +++-
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp | 50 +---
 2 files changed, 63 insertions(+), 18 deletions(-)

diff --git a/llvm/lib/Transforms/Coroutines/CoroCloner.h 
b/llvm/lib/Transforms/Coroutines/CoroCloner.h
index d1887980fb3bcb..b817e55cad9fc3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroCloner.h
+++ b/llvm/lib/Transforms/Coroutines/CoroCloner.h
@@ -48,6 +48,9 @@ class BaseCloner {
   CloneKind FKind;
   IRBuilder<> Builder;
   TargetTransformInfo &TTI;
+  // Common module-level metadata that's shared between all coroutine clones 
and
+  // doesn't need to be cloned itself.
+  const MetadataSetTy &CommonDebugInfo;
 
   ValueToValueMapTy VMap;
   Function *NewF = nullptr;
@@ -60,12 +63,12 @@ class BaseCloner {
   /// Create a cloner for a continuation lowering.
   BaseCloner(Function &OrigF, const Twine &Suffix, coro::Shape &Shape,
  Function *NewF, AnyCoroSuspendInst *ActiveSuspend,
- TargetTransformInfo &TTI)
+ TargetTransformInfo &TTI, const MetadataSetTy &CommonDebugInfo)
   : OrigF(OrigF), Suffix(Suffix), Shape(Shape),
 FKind(Shape.ABI == ABI::Async ? CloneKind::Async
   : CloneKind::Continuation),
-Builder(OrigF.getContext()), TTI(TTI), NewF(NewF),
-ActiveSuspend(ActiveSuspend) {
+Builder(OrigF.getContext()), TTI(TTI), 
CommonDebugInfo(CommonDebugInfo),
+NewF(NewF), ActiveSuspend(ActiveSuspend) {
 assert(Shape.ABI == ABI::Retcon || Shape.ABI == ABI::RetconOnce ||
Shape.ABI == ABI::Async);
 assert(NewF && "need existing function for continuation");
@@ -74,9 +77,11 @@ class BaseCloner {
 
 public:
   BaseCloner(Function &OrigF, const Twine &Suffix, coro::Shape &Shape,
- CloneKind FKind, TargetTransformInfo &TTI)
+ CloneKind FKind, TargetTransformInfo &TTI,
+ const MetadataSetTy &CommonDebugInfo)
   : OrigF(OrigF), Suffix(Suffix), Shape(Shape), FKind(FKind),
-Builder(OrigF.getContext()), TTI(TTI) {}
+Builder(OrigF.getContext()), TTI(TTI),
+CommonDebugInfo(CommonDebugInfo) {}
 
   virtual ~BaseCloner() {}
 
@@ -84,12 +89,14 @@ class BaseCloner {
   static Function *createClone(Function &OrigF, const Twine &Suffix,
coro::Shape &Shape, Function *NewF,
AnyCoroSuspendInst *ActiveSuspend,
-   TargetTransformInfo &TTI) {
+   TargetTransformInfo &TTI,
+   const MetadataSetTy &CommonDebugInfo) {
 assert(Shape.ABI == ABI::Retcon || Shape.ABI == ABI::RetconOnce ||
Shape.ABI == ABI::Async);
 TimeTraceScope FunctionScope("BaseCloner");
 
-BaseCloner Cloner(OrigF, Suffix, Shape, NewF, ActiveSuspend, TTI);
+BaseCloner Cloner(OrigF, Suffix, Shape, NewF, ActiveSuspend, TTI,
+  CommonDebugInfo);
 Cloner.create();
 return Cloner.getFunction();
   }
@@ -129,8 +136,9 @@ class SwitchCloner : public BaseCloner {
 protected:
   /// Create a cloner for a switch lowering.
   SwitchCloner(Function &OrigF, const Twine &Suffix, coro::Shape &Shape,
-   CloneKind FKind, TargetTransformInfo &TTI)
-  : BaseCloner(OrigF, Suffix, Shape, FKind, TTI) {}
+   CloneKind FKind, TargetTransformInfo &TTI,
+   const MetadataSetTy &CommonDebugInfo)
+  

[llvm-branch-commits] [llvm] [Analysis] Add DebugInfoCache analysis (PR #118629)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118629

>From 40407dfbacb560a7128c1e57d32675e7e7c95e8f Mon Sep 17 00:00:00 2001
From: Artem Pianykh 
Date: Sun, 15 Sep 2024 10:51:38 -0700
Subject: [PATCH] [Analysis] Add DebugInfoCache analysis

Summary:
The analysis simply primes and caches DebugInfoFinders for each DICompileUnit 
in a module. This
allows (future) callers like CoroSplitPass to compute global debug info 
metadata (required for
coroutine function cloning) much faster. Specifically, pay the price of 
DICompileUnit processing
only once per compile unit, rather than once per coroutine.

Test Plan:
Added a smoke test for the new analysis
ninja check-llvm-unit check-llvm

stack-info: PR: https://github.com/llvm/llvm-project/pull/118629, branch: 
users/artempyanykh/fast-coro-upstream/10
---
 llvm/include/llvm/Analysis/DebugInfoCache.h   |  50 +
 llvm/include/llvm/IR/DebugInfo.h  |   4 +-
 llvm/lib/Analysis/CMakeLists.txt  |   1 +
 llvm/lib/Analysis/DebugInfoCache.cpp  |  47 
 llvm/lib/Passes/PassBuilder.cpp   |   1 +
 llvm/lib/Passes/PassRegistry.def  |   1 +
 llvm/unittests/Analysis/CMakeLists.txt|   1 +
 .../unittests/Analysis/DebugInfoCacheTest.cpp | 211 ++
 8 files changed, 315 insertions(+), 1 deletion(-)
 create mode 100644 llvm/include/llvm/Analysis/DebugInfoCache.h
 create mode 100644 llvm/lib/Analysis/DebugInfoCache.cpp
 create mode 100644 llvm/unittests/Analysis/DebugInfoCacheTest.cpp

diff --git a/llvm/include/llvm/Analysis/DebugInfoCache.h 
b/llvm/include/llvm/Analysis/DebugInfoCache.h
new file mode 100644
index 00..dbd6802c99ea01
--- /dev/null
+++ b/llvm/include/llvm/Analysis/DebugInfoCache.h
@@ -0,0 +1,50 @@
+//===- llvm/Analysis/DebugInfoCache.h - debug info cache *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains an analysis that builds a cache of debug info for each
+// DICompileUnit in a module.
+//
+//===--===//
+
+#ifndef LLVM_ANALYSIS_DEBUGINFOCACHE_H
+#define LLVM_ANALYSIS_DEBUGINFOCACHE_H
+
+#include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+/// Processes and caches debug info for each DICompileUnit in a module.
+///
+/// The result of the analysis is a set of DebugInfoFinders primed on their
+/// respective DICompileUnit. Such DebugInfoFinders can be used to speed up
+/// function cloning which otherwise requires an expensive traversal of
+/// DICompileUnit-level debug info. See an example usage in CoroSplit.
+class DebugInfoCache {
+public:
+  using DIFinderCache = SmallDenseMap;
+  DIFinderCache Result;
+
+  DebugInfoCache(const Module &M);
+
+  bool invalidate(Module &, const PreservedAnalyses &,
+  ModuleAnalysisManager::Invalidator &);
+};
+
+class DebugInfoCacheAnalysis
+: public AnalysisInfoMixin {
+  friend AnalysisInfoMixin;
+  static AnalysisKey Key;
+
+public:
+  using Result = DebugInfoCache;
+  Result run(Module &M, ModuleAnalysisManager &);
+};
+} // namespace llvm
+
+#endif
diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h
index 73f45c3769be44..11907fbb7f20b3 100644
--- a/llvm/include/llvm/IR/DebugInfo.h
+++ b/llvm/include/llvm/IR/DebugInfo.h
@@ -120,11 +120,13 @@ class DebugInfoFinder {
   /// Process subprogram.
   void processSubprogram(DISubprogram *SP);
 
+  /// Process a compile unit.
+  void processCompileUnit(DICompileUnit *CU);
+
   /// Clear all lists.
   void reset();
 
 private:
-  void processCompileUnit(DICompileUnit *CU);
   void processScope(DIScope *Scope);
   void processType(DIType *DT);
   bool addCompileUnit(DICompileUnit *CU);
diff --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index 0db5b80f336cb5..db9a569e301563 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -52,6 +52,7 @@ add_llvm_component_library(LLVMAnalysis
   DDGPrinter.cpp
   ConstraintSystem.cpp
   Delinearization.cpp
+  DebugInfoCache.cpp
   DemandedBits.cpp
   DependenceAnalysis.cpp
   DependenceGraphBuilder.cpp
diff --git a/llvm/lib/Analysis/DebugInfoCache.cpp 
b/llvm/lib/Analysis/DebugInfoCache.cpp
new file mode 100644
index 00..c1a3e89f0a6ccf
--- /dev/null
+++ b/llvm/lib/Analysis/DebugInfoCache.cpp
@@ -0,0 +1,47 @@
+//===- llvm/Analysis/DebugInfoCache.cpp - debug info cache 
===//
+//
+// 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
+//
+//===-

[llvm-branch-commits] [llvm] [Coro] Use DebugInfoCache to speed up cloning in CoroSplitPass (PR #118630)

2024-12-16 Thread Artem Pianykh via llvm-branch-commits

https://github.com/artempyanykh updated 
https://github.com/llvm/llvm-project/pull/118630

>From b81f6f778a8ae4f6cde59acba71ac2ba73cff31d Mon Sep 17 00:00:00 2001
From: Artem Pianykh 
Date: Sun, 15 Sep 2024 11:00:00 -0700
Subject: [PATCH] [Coro] Use DebugInfoCache to speed up cloning in
 CoroSplitPass

Summary:
We can use a DebugInfoFinder from DebugInfoCache which is already primed on a 
compile unit to speed
up collection of module-level debug info.

The pass could likely be another 2x+ faster if we avoid rebuilding the set of 
global debug
info. This needs further massaging of CloneFunction and ValueMapper, though, 
and can be done
incrementally on top of this.

Comparing performance of CoroSplitPass at various points in this stack, this is 
anecdata from a sample
cpp file compiled with full debug info:
| | Baseline | IdentityMD set | Prebuilt CommonDI | Cached CU 
DIFinder (cur.) |
|-|--||---|---|
| CoroSplitPass   | 306ms| 221ms  | 68ms  | 17ms
  |
| CoroCloner  | 101ms| 72ms   | 0.5ms | 0.5ms   
  |
| CollectGlobalDI | -| -  | 63ms  | 13ms
  |
| Speed up| 1x   | 1.4x   | 4.5x  | 18x 
  |

Test Plan:
ninja check-llvm-unit
ninja check-llvm

Compiled a sample cpp file with time trace to get the avg. duration of the pass 
and inner scopes.

stack-info: PR: https://github.com/llvm/llvm-project/pull/118630, branch: 
users/artempyanykh/fast-coro-upstream/11
---
 llvm/include/llvm/Transforms/Coroutines/ABI.h | 13 +++--
 llvm/lib/Analysis/CGSCCPassManager.cpp|  7 +++
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  | 55 +++
 llvm/test/Other/new-pass-manager.ll   |  1 +
 llvm/test/Other/new-pm-defaults.ll|  1 +
 llvm/test/Other/new-pm-lto-defaults.ll|  1 +
 llvm/test/Other/new-pm-pgo-preinline.ll   |  1 +
 .../Other/new-pm-thinlto-postlink-defaults.ll |  1 +
 .../new-pm-thinlto-postlink-pgo-defaults.ll   |  1 +
 ...-pm-thinlto-postlink-samplepgo-defaults.ll |  1 +
 .../Other/new-pm-thinlto-prelink-defaults.ll  |  1 +
 .../new-pm-thinlto-prelink-pgo-defaults.ll|  1 +
 ...w-pm-thinlto-prelink-samplepgo-defaults.ll |  1 +
 .../Analysis/CGSCCPassManagerTest.cpp |  4 +-
 14 files changed, 72 insertions(+), 17 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Coroutines/ABI.h 
b/llvm/include/llvm/Transforms/Coroutines/ABI.h
index 0b2d405f3caec4..2cf614b6bb1e2a 100644
--- a/llvm/include/llvm/Transforms/Coroutines/ABI.h
+++ b/llvm/include/llvm/Transforms/Coroutines/ABI.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_TRANSFORMS_COROUTINES_ABI_H
 #define LLVM_TRANSFORMS_COROUTINES_ABI_H
 
+#include "llvm/Analysis/DebugInfoCache.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Transforms/Coroutines/CoroShape.h"
 #include "llvm/Transforms/Coroutines/MaterializationUtils.h"
@@ -53,7 +54,8 @@ class BaseABI {
   // Perform the function splitting according to the ABI.
   virtual void splitCoroutine(Function &F, coro::Shape &Shape,
   SmallVectorImpl &Clones,
-  TargetTransformInfo &TTI) = 0;
+  TargetTransformInfo &TTI,
+  const DebugInfoCache *DICache) = 0;
 
   Function &F;
   coro::Shape &Shape;
@@ -73,7 +75,8 @@ class SwitchABI : public BaseABI {
 
   void splitCoroutine(Function &F, coro::Shape &Shape,
   SmallVectorImpl &Clones,
-  TargetTransformInfo &TTI) override;
+  TargetTransformInfo &TTI,
+  const DebugInfoCache *DICache) override;
 };
 
 class AsyncABI : public BaseABI {
@@ -86,7 +89,8 @@ class AsyncABI : public BaseABI {
 
   void splitCoroutine(Function &F, coro::Shape &Shape,
   SmallVectorImpl &Clones,
-  TargetTransformInfo &TTI) override;
+  TargetTransformInfo &TTI,
+  const DebugInfoCache *DICache) override;
 };
 
 class AnyRetconABI : public BaseABI {
@@ -99,7 +103,8 @@ class AnyRetconABI : public BaseABI {
 
   void splitCoroutine(Function &F, coro::Shape &Shape,
   SmallVectorImpl &Clones,
-  TargetTransformInfo &TTI) override;
+  TargetTransformInfo &TTI,
+  const DebugInfoCache *DICache) override;
 };
 
 } // end namespace coro
diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp 
b/llvm/lib/Analysis/CGSCCPassManager.cpp
index 948bc2435ab275..3ba085cdb0be8b 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Analy

[llvm-branch-commits] [llvm] [DirectX] Split resource info into type and binding info. NFC (PR #119773)

2024-12-16 Thread Chris B via llvm-branch-commits

https://github.com/llvm-beanz approved this pull request.


https://github.com/llvm/llvm-project/pull/119773
___
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] [DirectX] Lower ops after translating metadata (PR #120157)

2024-12-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-directx

Author: Justin Bogner (bogner)


Changes

Move the DXILOpLoweringPass after DXILTranslateMetadata, and add asserts in 
DXILShaderFlags to ensure it isn't scheduled after op lowering. This will allow 
us to rely on DirectX intrinsics in the shader flags analysis rather than 
having to recover information from lowered operations.

Fixes #120119.

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


7 Files Affected:

- (modified) llvm/lib/Target/DirectX/DXILOpLowering.cpp (+8) 
- (modified) llvm/lib/Target/DirectX/DXILShaderFlags.cpp (+4-1) 
- (modified) llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp (+1) 
- (modified) llvm/lib/Target/DirectX/DirectXTargetMachine.cpp (+1-1) 
- (modified) llvm/test/CodeGen/DirectX/CreateHandle.ll (+1-1) 
- (modified) llvm/test/CodeGen/DirectX/CreateHandleFromBinding.ll (+1-1) 
- (modified) llvm/test/CodeGen/DirectX/llc-pipeline.ll (+18-5) 


``diff
diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp 
b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
index c66b24442d4bd0..91123769930b09 100644
--- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
@@ -10,8 +10,11 @@
 #include "DXILConstants.h"
 #include "DXILIntrinsicExpansion.h"
 #include "DXILOpBuilder.h"
+#include "DXILResourceAnalysis.h"
+#include "DXILShaderFlags.h"
 #include "DirectX.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Analysis/DXILMetadataAnalysis.h"
 #include "llvm/Analysis/DXILResource.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/IR/DiagnosticInfo.h"
@@ -751,6 +754,8 @@ PreservedAnalyses DXILOpLowering::run(Module &M, 
ModuleAnalysisManager &MAM) {
 return PreservedAnalyses::all();
   PreservedAnalyses PA;
   PA.preserve();
+  PA.preserve();
+  PA.preserve();
   return PA;
 }
 
@@ -773,6 +778,9 @@ class DXILOpLoweringLegacy : public ModulePass {
 AU.addRequired();
 AU.addRequired();
 AU.addPreserved();
+AU.addPreserved();
+AU.addPreserved();
+AU.addPreserved();
   }
 };
 char DXILOpLoweringLegacy::ID = 0;
diff --git a/llvm/lib/Target/DirectX/DXILShaderFlags.cpp 
b/llvm/lib/Target/DirectX/DXILShaderFlags.cpp
index d6917dce98abd5..2db4c1729c39fc 100644
--- a/llvm/lib/Target/DirectX/DXILShaderFlags.cpp
+++ b/llvm/lib/Target/DirectX/DXILShaderFlags.cpp
@@ -49,8 +49,11 @@ static void updateFunctionFlags(ComputedShaderFlags &CSF,
 void ModuleShaderFlags::initialize(const Module &M) {
   // Collect shader flags for each of the functions
   for (const auto &F : M.getFunctionList()) {
-if (F.isDeclaration())
+if (F.isDeclaration()) {
+  assert(!F.getName().starts_with("dx.op.") &&
+ "DXIL Shader Flag analysis should not be run post-lowering.");
   continue;
+}
 ComputedShaderFlags CSF;
 for (const auto &BB : F)
   for (const auto &I : BB)
diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp 
b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
index 9763fe6a8a3455..6929d67fdcc64f 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -389,6 +389,7 @@ class DXILTranslateMetadataLegacy : public ModulePass {
 AU.addPreserved();
 AU.addPreserved();
 AU.addPreserved();
+AU.addPreserved();
   }
 
   bool runOnModule(Module &M) override {
diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp 
b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
index de14c8d9f13e8d..f6ad6e690c2bf4 100644
--- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
+++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
@@ -96,8 +96,8 @@ class DirectXPassConfig : public TargetPassConfig {
 DxilScalarOptions.ScalarizeLoadStore = true;
 addPass(createDXILFlattenArraysLegacyPass());
 addPass(createScalarizerPass(DxilScalarOptions));
-addPass(createDXILOpLoweringLegacyPass());
 addPass(createDXILTranslateMetadataLegacyPass());
+addPass(createDXILOpLoweringLegacyPass());
 addPass(createDXILPrepareModulePass());
   }
 };
diff --git a/llvm/test/CodeGen/DirectX/CreateHandle.ll 
b/llvm/test/CodeGen/DirectX/CreateHandle.ll
index 234d4e035bf1d5..c9969c9c7ffdbf 100644
--- a/llvm/test/CodeGen/DirectX/CreateHandle.ll
+++ b/llvm/test/CodeGen/DirectX/CreateHandle.ll
@@ -1,4 +1,4 @@
-; RUN: opt -S -passes=dxil-op-lower,dxil-translate-metadata %s | FileCheck %s
+; RUN: opt -S -passes=dxil-translate-metadata,dxil-op-lower %s | FileCheck %s
 ; RUN: opt -S -passes=dxil-pretty-printer %s 2>&1 >/dev/null | FileCheck 
--check-prefix=CHECK-PRETTY %s
 
 ; CHECK-PRETTY:   Type  Format Dim  ID  HLSL Bind Count
diff --git a/llvm/test/CodeGen/DirectX/CreateHandleFromBinding.ll 
b/llvm/test/CodeGen/DirectX/CreateHandleFromBinding.ll
index aa143dfa8211d0..425084e2a65a97 100644
--- a/llvm/test/CodeGen/DirectX/CreateHandleFromBinding.ll
+++ b/llvm/test/CodeGen/DirectX/CreateHandleFromBinding.ll
@@ -1,4 +1,4 @@
-; RUN: opt

[llvm-branch-commits] [clang] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex
+
+sh_quote = shlex.quote
+except:
+import pipes
+
+sh_quote = pipes.quote
+
+
+def get_required_attr(config, attr_name):
+attr_value = getattr(config, attr_name, None)
+if attr_value == None:

fmayer wrote:

`is None`

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex
+
+sh_quote = shlex.quote
+except:
+import pipes
+
+sh_quote = pipes.quote
+
+
+def get_required_attr(config, attr_name):
+attr_value = getattr(config, attr_name, None)
+if attr_value == None:
+lit_config.fatal(
+"No attribute %r in test configuration! You may need to run "
+"tests from your build directory or add this attribute "
+"to lit.site.cfg.py " % attr_name
+)
+return attr_value
+
+
+def push_dynamic_library_lookup_path(config, new_path):
+if platform.system() == "Windows":
+dynamic_library_lookup_var = "PATH"
+elif platform.system() == "Darwin":
+dynamic_library_lookup_var = "DYLD_LIBRARY_PATH"
+else:
+dynamic_library_lookup_var = "LD_LIBRARY_PATH"
+
+new_ld_library_path = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_library_path
+
+if platform.system() == "FreeBSD":
+dynamic_library_lookup_var = "LD_32_LIBRARY_PATH"
+new_ld_32_library_path = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_32_library_path
+
+if platform.system() == "SunOS":
+dynamic_library_lookup_var = "LD_LIBRARY_PATH_32"
+new_ld_library_path_32 = os.path.pathsep.join(

fmayer wrote:

as above

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex
+
+sh_quote = shlex.quote
+except:
+import pipes
+
+sh_quote = pipes.quote
+
+
+def get_required_attr(config, attr_name):
+attr_value = getattr(config, attr_name, None)
+if attr_value == None:
+lit_config.fatal(
+"No attribute %r in test configuration! You may need to run "
+"tests from your build directory or add this attribute "
+"to lit.site.cfg.py " % attr_name
+)
+return attr_value
+
+
+def push_dynamic_library_lookup_path(config, new_path):
+if platform.system() == "Windows":
+dynamic_library_lookup_var = "PATH"
+elif platform.system() == "Darwin":
+dynamic_library_lookup_var = "DYLD_LIBRARY_PATH"
+else:
+dynamic_library_lookup_var = "LD_LIBRARY_PATH"
+
+new_ld_library_path = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_library_path
+
+if platform.system() == "FreeBSD":
+dynamic_library_lookup_var = "LD_32_LIBRARY_PATH"
+new_ld_32_library_path = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_32_library_path
+
+if platform.system() == "SunOS":
+dynamic_library_lookup_var = "LD_LIBRARY_PATH_32"
+new_ld_library_path_32 = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_library_path_32
+
+dynamic_library_lookup_var = "LD_LIBRARY_PATH_64"
+new_ld_library_path_64 = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_library_path_64
+
+
+# Setup config name.
+config.name = "TypeSanitizer" + config.name_suffix
+
+# Platform-specific default TYSAN_OPTIONS for lit tests.
+default_tysan_opts = list(config.default_sanitizer_opts)
+
+# On Darwin, leak checking is not enabled by default. Enable on macOS
+# tests to prevent regressions
+if config.host_os == "Darwin" and config.apple_platform == "osx":

fmayer wrote:

this looks like a leftover? what does tysan have to do with leak checking?

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex
+
+sh_quote = shlex.quote
+except:
+import pipes

fmayer wrote:

as above

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex
+
+sh_quote = shlex.quote
+except:
+import pipes
+
+sh_quote = pipes.quote
+
+
+def get_required_attr(config, attr_name):
+attr_value = getattr(config, attr_name, None)
+if attr_value == None:
+lit_config.fatal(
+"No attribute %r in test configuration! You may need to run "
+"tests from your build directory or add this attribute "
+"to lit.site.cfg.py " % attr_name
+)
+return attr_value
+
+
+def push_dynamic_library_lookup_path(config, new_path):
+if platform.system() == "Windows":
+dynamic_library_lookup_var = "PATH"
+elif platform.system() == "Darwin":
+dynamic_library_lookup_var = "DYLD_LIBRARY_PATH"
+else:
+dynamic_library_lookup_var = "LD_LIBRARY_PATH"
+
+new_ld_library_path = os.path.pathsep.join(

fmayer wrote:

why not `os.path.join`

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex
+
+sh_quote = shlex.quote
+except:
+import pipes
+
+sh_quote = pipes.quote
+
+
+def get_required_attr(config, attr_name):
+attr_value = getattr(config, attr_name, None)
+if attr_value == None:
+lit_config.fatal(
+"No attribute %r in test configuration! You may need to run "
+"tests from your build directory or add this attribute "
+"to lit.site.cfg.py " % attr_name
+)
+return attr_value
+
+
+def push_dynamic_library_lookup_path(config, new_path):
+if platform.system() == "Windows":
+dynamic_library_lookup_var = "PATH"
+elif platform.system() == "Darwin":
+dynamic_library_lookup_var = "DYLD_LIBRARY_PATH"
+else:
+dynamic_library_lookup_var = "LD_LIBRARY_PATH"
+
+new_ld_library_path = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_library_path
+
+if platform.system() == "FreeBSD":
+dynamic_library_lookup_var = "LD_32_LIBRARY_PATH"
+new_ld_32_library_path = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_32_library_path
+
+if platform.system() == "SunOS":
+dynamic_library_lookup_var = "LD_LIBRARY_PATH_32"
+new_ld_library_path_32 = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_library_path_32
+
+dynamic_library_lookup_var = "LD_LIBRARY_PATH_64"
+new_ld_library_path_64 = os.path.pathsep.join(

fmayer wrote:

as above

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex
+
+sh_quote = shlex.quote
+except:

fmayer wrote:

except ImportError?

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,347 @@
+//===-- tysan.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of TypeSanitizer.
+//
+// TypeSanitizer runtime.
+//===--===//
+
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flag_parser.h"
+#include "sanitizer_common/sanitizer_flags.h"
+#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_report_decorator.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+#include "tysan/tysan.h"
+
+#include 
+
+using namespace __sanitizer;
+using namespace __tysan;
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_set_type_unknown(const void *addr, uptr size) {
+  if (tysan_inited)
+internal_memset(shadow_for(addr), 0, size * sizeof(uptr));
+}
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_copy_types(const void *daddr, const void *saddr, uptr size) {
+  if (tysan_inited)
+internal_memmove(shadow_for(daddr), shadow_for(saddr), size * 
sizeof(uptr));
+}
+
+static const char *getDisplayName(const char *Name) {
+  if (Name[0] == '\0')
+return "";
+
+  // Clang generates tags for C++ types that demangle as typeinfo. Remove the
+  // prefix from the generated string.
+  const char *TIPrefix = "typeinfo name for ";
+  size_t TIPrefixLen = strlen(TIPrefix);
+
+  const char *DName = Symbolizer::GetOrInit()->Demangle(Name);
+  if (!internal_strncmp(DName, TIPrefix, TIPrefixLen))
+DName += TIPrefixLen;
+
+  return DName;
+}
+
+static void printTDName(tysan_type_descriptor *td) {
+  if (((sptr)td) <= 0) {
+Printf("");
+return;
+  }
+
+  switch (td->Tag) {
+  default:
+DCHECK(0);

fmayer wrote:

as below

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex

fmayer wrote:

`from shlex import quote as sh_quote`?

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,161 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+import shlex
+
+sh_quote = shlex.quote
+except:
+import pipes
+
+sh_quote = pipes.quote
+
+
+def get_required_attr(config, attr_name):
+attr_value = getattr(config, attr_name, None)
+if attr_value == None:
+lit_config.fatal(
+"No attribute %r in test configuration! You may need to run "
+"tests from your build directory or add this attribute "
+"to lit.site.cfg.py " % attr_name
+)
+return attr_value
+
+
+def push_dynamic_library_lookup_path(config, new_path):
+if platform.system() == "Windows":
+dynamic_library_lookup_var = "PATH"
+elif platform.system() == "Darwin":
+dynamic_library_lookup_var = "DYLD_LIBRARY_PATH"
+else:
+dynamic_library_lookup_var = "LD_LIBRARY_PATH"
+
+new_ld_library_path = os.path.pathsep.join(
+(new_path, config.environment.get(dynamic_library_lookup_var, ""))
+)
+config.environment[dynamic_library_lookup_var] = new_ld_library_path
+
+if platform.system() == "FreeBSD":
+dynamic_library_lookup_var = "LD_32_LIBRARY_PATH"
+new_ld_32_library_path = os.path.pathsep.join(

fmayer wrote:

as above

https://github.com/llvm/llvm-project/pull/76261
___
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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-12-16 Thread Michael Kruse via llvm-branch-commits


@@ -0,0 +1,226 @@
+#===-- CMakeLists.txt 
--===#
+#
+# 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
+#
+#======#
+#
+# Build instructions for the flang-rt library. This is file is intended to be
+# included using the LLVM_ENABLE_RUNTIMES mechanism.
+#
+#======#
+
+set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
+set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(FLANG_RT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang")
+
+
+# CMake 3.24 is the first version of CMake that directly recognizes Flang.
+# LLVM's requirement is only CMake 3.20, teach CMake 3.20-3.23 how to use 
Flang.
+if (CMAKE_VERSION VERSION_LESS "3.24")
+  cmake_path(GET CMAKE_Fortran_COMPILER STEM _Fortran_COMPILER_STEM)
+  if (_Fortran_COMPILER_STEM STREQUAL "flang-new" OR _Fortran_COMPILER_STEM 
STREQUAL "flang")
+include(CMakeForceCompiler)
+CMAKE_FORCE_Fortran_COMPILER("${CMAKE_Fortran_COMPILER}" "LLVMFlang")
+
+set(CMAKE_Fortran_COMPILER_ID "LLVMFlang")
+set(CMAKE_Fortran_COMPILER_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
+
+set(CMAKE_Fortran_SUBMODULE_SEP "-")
+set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
+
+set(CMAKE_Fortran_PREPROCESS_SOURCE
+  " -cpp-E  
> ")
+
+set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
+set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")
+
+set(CMAKE_Fortran_MODDIR_FLAG "-module-dir")
+
+set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp")
+set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp")
+set(CMAKE_Fortran_POSTPROCESS_FLAG "-ffixed-line-length-72")
+
+set(CMAKE_Fortran_COMPILE_OPTIONS_TARGET "--target=")
+
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,")
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",")
+  endif ()
+endif ()
+enable_language(Fortran)
+
+
+list(APPEND CMAKE_MODULE_PATH
+"${FLANG_RT_SOURCE_DIR}/cmake/modules"
+"${FLANG_SOURCE_DIR}/cmake/modules"
+  )
+include(AddFlangRT)
+include(FlangCommon)
+
+
+
+# Build Mode Introspection #
+
+
+# Setting these variables from an LLVM build is sufficient that flang-rt can
+# construct the output paths, so it can behave as if it was in-tree here.
+set(LLVM_TREE_AVAILABLE OFF)
+if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND 
PACKAGE_VERSION)
+  # This is a bootstap build
+  set(LLVM_TREE_AVAILABLE ON)
+endif()
+
+# Path to LLVM development tools (FileCheck, llvm-lit, not, ...)
+set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin")
+
+if (LLVM_TREE_AVAILABLE)
+  # In a bootstrap build emit the libraries into a default search path in the
+  # build directory of the just-built compiler. This allows using the
+  # just-built compiler without specifying paths to runtime libraries.
+  #
+  # Despite Clang in the name, get_clang_resource_dir does not depend on Clang
+  # being added to the build. Flang uses the same resource dir as clang.
+  include(GetClangResourceDir)
+  get_clang_resource_dir(FLANG_RT_BUILD_LIB_DIR PREFIX 
"${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
+  get_clang_resource_dir(FLANG_RT_INSTALL_LIB_DIR SUBDIR 
"lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the 
install prefix itself
+else ()
+  # In a runtimes build never write into LLVM's build dir. It might be reused
+  # for mutliple Flang-RT builds (e.g. Debug/Release). Instead create our own
+  # library directory.
+  #
+  # TODO: Support multi-config generators
+  set(FLANG_RT_BUILD_LIB_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
+  set(FLANG_RT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
+endif ()
+
+if (DEFINED WIN32)
+  set(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_BUILD_LIB_DIR}/windows")
+  set(FLANG_RT_INSTALL_LIB_DIR "${FLANG_RT_INSTALL_LIB_DIR}/windows")
+elseif (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+  set(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+  set(FLANG_RT_INSTALL_LIB_DIR 
"${FLANG_RT_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+endif ()
+
+
+#
+# Build Options #
+#
+
+# Important: flang-rt user options must be prefixed with "FLANG_RT_". Variables
+# with this prefix will be forwarded in bootstrap builds.
+
+option(FLANG_RT_INCLUDE_TESTS "Generate build targets for the flang-rt unit 
and regression-tests." "${LLVM_INCLUDE_TESTS}")
+
+
+set(FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT "" CACHE STRING "Compile Flang-RT 
with GPU support (CUDA or OpenMP)")
+set_property(CACHE FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT PROPERTY STRINGS
+""
+CUDA
+OpenMP
+  )
+if (NOT FLANG_RT_EXPERIMENTAL_O

[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-12-16 Thread Michael Kruse via llvm-branch-commits


@@ -0,0 +1,226 @@
+#===-- CMakeLists.txt 
--===#
+#
+# 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
+#
+#======#
+#
+# Build instructions for the flang-rt library. This is file is intended to be
+# included using the LLVM_ENABLE_RUNTIMES mechanism.
+#
+#======#
+
+set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
+set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(FLANG_RT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang")
+
+
+# CMake 3.24 is the first version of CMake that directly recognizes Flang.
+# LLVM's requirement is only CMake 3.20, teach CMake 3.20-3.23 how to use 
Flang.
+if (CMAKE_VERSION VERSION_LESS "3.24")
+  cmake_path(GET CMAKE_Fortran_COMPILER STEM _Fortran_COMPILER_STEM)
+  if (_Fortran_COMPILER_STEM STREQUAL "flang-new" OR _Fortran_COMPILER_STEM 
STREQUAL "flang")
+include(CMakeForceCompiler)
+CMAKE_FORCE_Fortran_COMPILER("${CMAKE_Fortran_COMPILER}" "LLVMFlang")
+
+set(CMAKE_Fortran_COMPILER_ID "LLVMFlang")
+set(CMAKE_Fortran_COMPILER_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
+
+set(CMAKE_Fortran_SUBMODULE_SEP "-")
+set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
+
+set(CMAKE_Fortran_PREPROCESS_SOURCE
+  " -cpp-E  
> ")
+
+set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
+set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")
+
+set(CMAKE_Fortran_MODDIR_FLAG "-module-dir")
+
+set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp")
+set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp")
+set(CMAKE_Fortran_POSTPROCESS_FLAG "-ffixed-line-length-72")
+
+set(CMAKE_Fortran_COMPILE_OPTIONS_TARGET "--target=")
+
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,")
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",")
+  endif ()
+endif ()
+enable_language(Fortran)
+
+
+list(APPEND CMAKE_MODULE_PATH
+"${FLANG_RT_SOURCE_DIR}/cmake/modules"
+"${FLANG_SOURCE_DIR}/cmake/modules"
+  )
+include(AddFlangRT)
+include(FlangCommon)
+
+
+
+# Build Mode Introspection #
+
+
+# Setting these variables from an LLVM build is sufficient that flang-rt can
+# construct the output paths, so it can behave as if it was in-tree here.
+set(LLVM_TREE_AVAILABLE OFF)
+if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND 
PACKAGE_VERSION)
+  # This is a bootstap build
+  set(LLVM_TREE_AVAILABLE ON)
+endif()
+
+# Path to LLVM development tools (FileCheck, llvm-lit, not, ...)
+set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin")
+
+if (LLVM_TREE_AVAILABLE)
+  # In a bootstrap build emit the libraries into a default search path in the
+  # build directory of the just-built compiler. This allows using the
+  # just-built compiler without specifying paths to runtime libraries.
+  #
+  # Despite Clang in the name, get_clang_resource_dir does not depend on Clang
+  # being added to the build. Flang uses the same resource dir as clang.
+  include(GetClangResourceDir)
+  get_clang_resource_dir(FLANG_RT_BUILD_LIB_DIR PREFIX 
"${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
+  get_clang_resource_dir(FLANG_RT_INSTALL_LIB_DIR SUBDIR 
"lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the 
install prefix itself
+else ()
+  # In a runtimes build never write into LLVM's build dir. It might be reused
+  # for mutliple Flang-RT builds (e.g. Debug/Release). Instead create our own
+  # library directory.
+  #
+  # TODO: Support multi-config generators
+  set(FLANG_RT_BUILD_LIB_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
+  set(FLANG_RT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
+endif ()
+
+if (DEFINED WIN32)
+  set(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_BUILD_LIB_DIR}/windows")
+  set(FLANG_RT_INSTALL_LIB_DIR "${FLANG_RT_INSTALL_LIB_DIR}/windows")

Meinersbur wrote:

Compler-RT (`libflang_rt.builtins.a`) does it by default 
(`LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` [defaults to 
False](https://github.com/llvm/llvm-project/blob/d866005f6928a2a97e67866bedb26139d8cc27d9/llvm/CMakeLists.txt#L949)
 on Windows): 
https://github.com/llvm/llvm-project/blob/main/compiler-rt/cmake/base-config-ix.cmake#L108-L109.

I could make this configurable as well, but atm I am avoiding introducing a 
even larger configuration space that I have to test; I know these defaults work.

https://github.com/llvm/llvm-project/pull/110217
___
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][Vector] Clean up `populateVectorToLLVMConversionPatterns` (PR #119975)

2024-12-16 Thread Petr Kurapov via llvm-branch-commits

https://github.com/kurapov-peter approved this pull request.

Looks OK to me

https://github.com/llvm/llvm-project/pull/119975
___
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] c9e72b3 - Bump version to 19.1.6

2024-12-16 Thread Tobias Hieta via llvm-branch-commits

Author: Tobias Hieta
Date: 2024-12-13T14:49:03+01:00
New Revision: c9e72b3945f1672f0507539ce903c9696b3479ba

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

LOG: Bump version to 19.1.6

Added: 


Modified: 
cmake/Modules/LLVMVersion.cmake
libcxx/include/__config
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/lit/lit/__init__.py
llvm/utils/mlgo-utils/mlgo/__init__.py

Removed: 




diff  --git a/cmake/Modules/LLVMVersion.cmake b/cmake/Modules/LLVMVersion.cmake
index 9b39550118c496..93d36736439b18 100644
--- a/cmake/Modules/LLVMVersion.cmake
+++ b/cmake/Modules/LLVMVersion.cmake
@@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 5)
+  set(LLVM_VERSION_PATCH 6)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 33e0043136fee7..e97669bca411e5 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -27,7 +27,7 @@
 // _LIBCPP_VERSION represents the version of libc++, which matches the version 
of LLVM.
 // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), 
_LIBCPP_VERSION is
 // defined to XXYYZZ.
-#  define _LIBCPP_VERSION 190105
+#  define _LIBCPP_VERSION 190106
 
 #  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
 #  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)

diff  --git a/llvm/utils/gn/secondary/llvm/version.gni 
b/llvm/utils/gn/secondary/llvm/version.gni
index c32a040dcba67a..c46d2abdb8ef2d 100644
--- a/llvm/utils/gn/secondary/llvm/version.gni
+++ b/llvm/utils/gn/secondary/llvm/version.gni
@@ -1,4 +1,4 @@
 llvm_version_major = 19
 llvm_version_minor = 1
-llvm_version_patch = 5
+llvm_version_patch = 6
 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch"

diff  --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index 8557e5a061d1d9..ee0a3b2240e1e9 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = "Daniel Dunbar"
 __email__ = "dan...@minormatter.com"
-__versioninfo__ = (19, 1, 5)
+__versioninfo__ = (19, 1, 6)
 __version__ = ".".join(str(v) for v in __versioninfo__) + "dev"
 
 __all__ = []

diff  --git a/llvm/utils/mlgo-utils/mlgo/__init__.py 
b/llvm/utils/mlgo-utils/mlgo/__init__.py
index e2f8ca88d91ec1..cec9ca8b2f648b 100644
--- a/llvm/utils/mlgo-utils/mlgo/__init__.py
+++ b/llvm/utils/mlgo-utils/mlgo/__init__.py
@@ -4,7 +4,7 @@
 
 from datetime import timezone, datetime
 
-__versioninfo__ = (19, 1, 5)
+__versioninfo__ = (19, 1, 6)
 __version__ = (
 ".".join(str(v) for v in __versioninfo__)
 + "dev"



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


[llvm-branch-commits] [libcxx] [llvm] Bump version to 19.1.6 (PR #120051)

2024-12-16 Thread Tobias Hieta via llvm-branch-commits

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


[llvm-branch-commits] [libcxx] [llvm] Bump version to 19.1.6 (PR #120051)

2024-12-16 Thread via llvm-branch-commits

github-actions[bot] wrote:

@tru (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/120051
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [llvm] Bump version to 19.1.6 (PR #120051)

2024-12-16 Thread via llvm-branch-commits

AreaZR wrote:

So we can merge whatever is currently 19.x milestone, approved, and then merge 
this finally, right?

https://github.com/llvm/llvm-project/pull/120051
___
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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-12-16 Thread via llvm-branch-commits

h-vetinari wrote:

This now builds fine on linux & windows for me, though I'm running into an 
issue when doing the following on windows (pieced together a bit to avoid 
distractions that are due to packaging):

```batch
set "FC=flang.exe"
set "LD=lld-link.exe"

:: following 
https://github.com/conda-forge/clang-win-activation-feedstock/blob/main/recipe/activate-clang_win-64.bat
set "FFLAGS=-D_CRT_SECURE_NO_WARNINGS -fms-runtime-lib=dll -fuse-ld=lld 
-I%LIBRARY_PREFIX%\Library\include"
set "LDFLAGS=%LDFLAGS% 
-Wl,-defaultlib:%LIBRARY_PREFIX:\=/%/lib/clang/20/lib/windows/clang_rt.builtins-x86_64.lib"

%FC% hello_world.f90 
```
where the file in question looks like:
```fortran
program hello
  print *, "Hello World!"
end program hello
```
this fails with
```
LINK : fatal error LNK1104: cannot open file 'flang_rt.static.lib'
flang: error: linker command failed with exit code 1104 (use -v to see 
invocation)
```
despite being in the same prefix as flang, under
```
%LIBRARY_PREFIX%/lib/windows/flang_rt.static.lib
```
which is the default location for `-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX%` as 
of this PR. 

Aside from trivial modifications (e.g. `flang-new` -> `flang`), this matches 
our flag and testing setup as it's currently working for v19, so I'm expecting 
this to stay functional 

PS. The explicit linkage to `clang_rt.builtins-x86_64.lib` might not be 
necessary anymore after this PR (see 
[here](https://github.com/llvm/llvm-project/pull/110217#discussion_r1838900052));
 it used to be necessary though, and I just haven't gotten around to removing 
it yet 

https://github.com/llvm/llvm-project/pull/110217
___
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] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)

2024-12-16 Thread Daniil Kovalev via llvm-branch-commits


@@ -1808,34 +1808,6 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
 
   AddUnalignedAccessWarning(CmdArgs);
 
-  Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_intrinsics,

kovdan01 wrote:

@MaskRay Applied your suggestion in 346d1ef9d0d638ddda2b48a9c629f24a4385df02

> I'm afraid that you missed the point. Keep the code in Clang.cpp but do the 
> following
> 
> ```
> // Clang.cpp
> if (Linux pauth abi or isDarwin) {
>   claim these pauth options
> }
> ```



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


[llvm-branch-commits] [libcxx] [llvm] Bump version to 19.1.6 (PR #120051)

2024-12-16 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru milestoned 
https://github.com/llvm/llvm-project/pull/120051
___
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] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)

2024-12-16 Thread Daniil Kovalev via llvm-branch-commits

kovdan01 wrote:

@MaskRay Previous comments should now be addressed, would be glad to see your 
feedback on the new version of the PR

https://github.com/llvm/llvm-project/pull/113152
___
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] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)

2024-12-16 Thread Daniil Kovalev via llvm-branch-commits

https://github.com/kovdan01 updated 
https://github.com/llvm/llvm-project/pull/113152

>From 1914833e15a81ee85aea3a6e1bed2b88a338d3e7 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Mon, 21 Oct 2024 12:18:56 +0300
Subject: [PATCH 1/5] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin

Most ptrauth flags are ABI-affecting, so they should not be exposed to
end users. Under certain conditions, some ptrauth driver flags are intended
to be used for ARM64 Darwin, so allow them in this case.

Leave `-faarch64-jump-table-hardening` available for all AArch64 targets
since it's not ABI-affecting.
---
 clang/lib/Driver/ToolChains/Clang.cpp  | 28 
 clang/lib/Driver/ToolChains/Darwin.cpp | 37 +++
 clang/lib/Driver/ToolChains/Linux.cpp  | 53 +++
 clang/test/Driver/aarch64-ptrauth.c| 91 +-
 4 files changed, 93 insertions(+), 116 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ad0a225d2bc604..914a96eaa5f853 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1808,34 +1808,6 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
 
   AddUnalignedAccessWarning(CmdArgs);
 
-  Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_intrinsics,
-options::OPT_fno_ptrauth_intrinsics);
-  Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_calls,
-options::OPT_fno_ptrauth_calls);
-  Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_returns,
-options::OPT_fno_ptrauth_returns);
-  Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_auth_traps,
-options::OPT_fno_ptrauth_auth_traps);
-  Args.addOptInFlag(
-  CmdArgs, options::OPT_fptrauth_vtable_pointer_address_discrimination,
-  options::OPT_fno_ptrauth_vtable_pointer_address_discrimination);
-  Args.addOptInFlag(
-  CmdArgs, options::OPT_fptrauth_vtable_pointer_type_discrimination,
-  options::OPT_fno_ptrauth_vtable_pointer_type_discrimination);
-  Args.addOptInFlag(
-  CmdArgs, options::OPT_fptrauth_type_info_vtable_pointer_discrimination,
-  options::OPT_fno_ptrauth_type_info_vtable_pointer_discrimination);
-  Args.addOptInFlag(
-  CmdArgs, options::OPT_fptrauth_function_pointer_type_discrimination,
-  options::OPT_fno_ptrauth_function_pointer_type_discrimination);
-
-  Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_indirect_gotos,
-options::OPT_fno_ptrauth_indirect_gotos);
-  Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_init_fini,
-options::OPT_fno_ptrauth_init_fini);
-  Args.addOptInFlag(CmdArgs,
-options::OPT_fptrauth_init_fini_address_discrimination,
-options::OPT_fno_ptrauth_init_fini_address_discrimination);
   Args.addOptInFlag(CmdArgs, options::OPT_faarch64_jump_table_hardening,
 options::OPT_fno_aarch64_jump_table_hardening);
 }
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index cdb6d21a0148b6..9e1e46a75e0be6 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3065,6 +3065,40 @@ bool Darwin::isSizedDeallocationUnavailable() const {
   return TargetVersion < sizedDeallocMinVersion(OS);
 }
 
+static void addPointerAuthFlags(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) {
+  DriverArgs.addOptInFlag(CC1Args, options::OPT_fptrauth_intrinsics,
+  options::OPT_fno_ptrauth_intrinsics);
+
+  DriverArgs.addOptInFlag(CC1Args, options::OPT_fptrauth_calls,
+  options::OPT_fno_ptrauth_calls);
+
+  DriverArgs.addOptInFlag(CC1Args, options::OPT_fptrauth_returns,
+  options::OPT_fno_ptrauth_returns);
+
+  DriverArgs.addOptInFlag(CC1Args, options::OPT_fptrauth_auth_traps,
+  options::OPT_fno_ptrauth_auth_traps);
+
+  DriverArgs.addOptInFlag(
+  CC1Args, options::OPT_fptrauth_vtable_pointer_address_discrimination,
+  options::OPT_fno_ptrauth_vtable_pointer_address_discrimination);
+
+  DriverArgs.addOptInFlag(
+  CC1Args, options::OPT_fptrauth_vtable_pointer_type_discrimination,
+  options::OPT_fno_ptrauth_vtable_pointer_type_discrimination);
+
+  DriverArgs.addOptInFlag(
+  CC1Args, options::OPT_fptrauth_type_info_vtable_pointer_discrimination,
+  options::OPT_fno_ptrauth_type_info_vtable_pointer_discrimination);
+
+  DriverArgs.addOptInFlag(
+  CC1Args, options::OPT_fptrauth_function_pointer_type_discrimination,
+  options::OPT_fno_ptrauth_function_pointer_type_discrimination);
+
+  DriverArgs.addOptInFlag(CC1Args, options::OPT_fptrauth_indirect_gotos,
+  options::OPT_fno_ptrauth_indirect_gotos);
+}
+
 void Darwin::addClangTargetOptions(
 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList 

[llvm-branch-commits] [clang] [PAC][clang] Handle pauthtest environment and ABI in Linux-specific code (PR #113151)

2024-12-16 Thread Daniil Kovalev via llvm-branch-commits

https://github.com/kovdan01 updated 
https://github.com/llvm/llvm-project/pull/113151

>From 491c4551aababde147705d1bea649cffded7d325 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Mon, 21 Oct 2024 12:00:19 +0300
Subject: [PATCH] [PAC][clang] Handle pauthtest environment and ABI in
 Linux-specific code

Since pauthtest is a Linux-specific ABI, it should not be handled in
common driver code.
---
 clang/lib/Basic/Targets/AArch64.cpp  |  9 +-
 clang/lib/Basic/Targets/AArch64.h| 11 +++
 clang/lib/Basic/Targets/OSTargets.cpp|  1 +
 clang/lib/Basic/Targets/OSTargets.h  |  6 ++
 clang/lib/CodeGen/CodeGenModule.cpp  |  2 -
 clang/lib/CodeGen/TargetInfo.h   |  1 -
 clang/lib/Driver/ToolChain.cpp   |  1 -
 clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 21 -
 clang/lib/Driver/ToolChains/Arch/AArch64.h   |  3 -
 clang/lib/Driver/ToolChains/Clang.cpp| 60 +---
 clang/lib/Driver/ToolChains/Linux.cpp| 96 
 clang/lib/Driver/ToolChains/Linux.h  |  7 ++
 clang/test/Driver/aarch64-ptrauth.c  | 34 +--
 13 files changed, 150 insertions(+), 102 deletions(-)

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 53e102bbe44687..c98b3a309248ef 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -206,8 +206,7 @@ AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple 
&Triple,
 StringRef AArch64TargetInfo::getABI() const { return ABI; }
 
 bool AArch64TargetInfo::setABI(const std::string &Name) {
-  if (Name != "aapcs" && Name != "aapcs-soft" && Name != "darwinpcs" &&
-  Name != "pauthtest")
+  if (Name != "aapcs" && Name != "aapcs-soft" && Name != "darwinpcs")
 return false;
 
   ABI = Name;
@@ -221,12 +220,6 @@ bool AArch64TargetInfo::validateTarget(DiagnosticsEngine 
&Diags) const {
 Diags.Report(diag::err_target_unsupported_abi_with_fpu) << ABI;
 return false;
   }
-  if (getTriple().getEnvironment() == llvm::Triple::PAuthTest &&
-  getTriple().getOS() != llvm::Triple::Linux) {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< getTriple().getEnvironmentName() << getTriple().getTriple();
-return false;
-  }
   return true;
 }
 
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 68a8b1ebad8cde..8be3061e7f34a4 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -121,6 +121,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
 
   const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
 
+protected:
   std::string ABI;
 
 public:
@@ -258,6 +259,16 @@ class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public 
AArch64TargetInfo {
   void setDataLayout() override;
 };
 
+template <>
+inline bool
+LinuxTargetInfo::setABI(const std::string &Name) {
+  if (Name == "pauthtest") {
+ABI = Name;
+return true;
+  }
+  return AArch64leTargetInfo::setABI(Name);
+}
+
 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
 : public WindowsTargetInfo {
   const llvm::Triple Triple;
diff --git a/clang/lib/Basic/Targets/OSTargets.cpp 
b/clang/lib/Basic/Targets/OSTargets.cpp
index 88c054150ab224..666e2561829dd3 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -10,6 +10,7 @@
 
//===--===//
 
 #include "OSTargets.h"
+#include "AArch64.h"
 #include "clang/Basic/MacroBuilder.h"
 #include "llvm/ADT/StringRef.h"
 
diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index cd9b3760ca5874..58a96697ccf19f 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -374,6 +374,12 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
   const char *getStaticInitSectionSpecifier() const override {
 return ".text.startup";
   }
+
+  // This allows template specializations, see
+  // LinuxTargetInfo::setABI
+  bool setABI(const std::string &Name) override {
+return OSTargetInfo::setABI(Name);
+  }
 };
 
 // NetBSD Target
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d3d5c0743a520b..e0257081b3a1e9 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -144,8 +144,6 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
   return createWindowsAArch64TargetCodeGenInfo(CGM, AArch64ABIKind::Win64);
 else if (Target.getABI() == "aapcs-soft")
   Kind = AArch64ABIKind::AAPCSSoft;
-else if (Target.getABI() == "pauthtest")
-  Kind = AArch64ABIKind::PAuthTest;
 
 return createAArch64TargetCodeGenInfo(CGM, Kind);
   }
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index ab3142bdea684e..fea303599bd76d 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+

[llvm-branch-commits] [clang] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,344 @@
+//===-- tysan.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of TypeSanitizer.
+//
+// TypeSanitizer runtime.
+//===--===//
+
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flag_parser.h"
+#include "sanitizer_common/sanitizer_flags.h"
+#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_report_decorator.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+#include "tysan/tysan.h"
+
+using namespace __sanitizer;
+using namespace __tysan;
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_set_type_unknown(const void *addr, uptr size) {
+  if (tysan_inited)
+internal_memset(shadow_for(addr), 0, size * sizeof(uptr));
+}
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_copy_types(const void *daddr, const void *saddr, uptr size) {
+  if (tysan_inited)
+internal_memmove(shadow_for(daddr), shadow_for(saddr), size * 
sizeof(uptr));
+}
+
+static const char *getDisplayName(const char *Name) {
+  if (Name[0] == '\0')
+return "";
+
+  // Clang generates tags for C++ types that demangle as typeinfo. Remove the
+  // prefix from the generated string.
+  const char TIPrefix[] = "typeinfo name for ";
+
+  const char *DName = Symbolizer::GetOrInit()->Demangle(Name);
+  if (!internal_strncmp(DName, TIPrefix, sizeof(TIPrefix) - 1))
+DName += sizeof(TIPrefix) - 1;

fmayer wrote:

strlen? the compiler should be able to optimize that.

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,344 @@
+//===-- tysan.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of TypeSanitizer.
+//
+// TypeSanitizer runtime.
+//===--===//
+
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flag_parser.h"
+#include "sanitizer_common/sanitizer_flags.h"
+#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_report_decorator.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+#include "tysan/tysan.h"
+
+using namespace __sanitizer;
+using namespace __tysan;
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_set_type_unknown(const void *addr, uptr size) {
+  if (tysan_inited)
+internal_memset(shadow_for(addr), 0, size * sizeof(uptr));
+}
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_copy_types(const void *daddr, const void *saddr, uptr size) {
+  if (tysan_inited)
+internal_memmove(shadow_for(daddr), shadow_for(saddr), size * 
sizeof(uptr));
+}
+
+static const char *getDisplayName(const char *Name) {
+  if (Name[0] == '\0')
+return "";
+
+  // Clang generates tags for C++ types that demangle as typeinfo. Remove the
+  // prefix from the generated string.
+  const char TIPrefix[] = "typeinfo name for ";
+
+  const char *DName = Symbolizer::GetOrInit()->Demangle(Name);
+  if (!internal_strncmp(DName, TIPrefix, sizeof(TIPrefix) - 1))
+DName += sizeof(TIPrefix) - 1;
+
+  return DName;
+}
+
+static void printTDName(tysan_type_descriptor *td) {
+  if (((sptr)td) <= 0) {
+Printf("");
+return;
+  }
+
+  switch (td->Tag) {
+  default:
+DCHECK(0);
+break;
+  case TYSAN_MEMBER_TD:
+printTDName(td->Member.Access);
+if (td->Member.Access != td->Member.Base) {
+  Printf(" (in ");
+  printTDName(td->Member.Base);
+  Printf(" at offset %zu)", td->Member.Offset);
+}
+break;
+  case TYSAN_STRUCT_TD:
+Printf("%s", getDisplayName(
+ (char *)(td->Struct.Members + td->Struct.MemberCount)));
+break;
+  }
+}
+
+static tysan_type_descriptor *getRootTD(tysan_type_descriptor *TD) {
+  tysan_type_descriptor *RootTD = TD;
+
+  do {
+RootTD = TD;
+
+if (TD->Tag == TYSAN_STRUCT_TD) {
+  if (TD->Struct.MemberCount > 0)
+TD = TD->Struct.Members[0].Type;
+  else
+TD = nullptr;
+} else if (TD->Tag == TYSAN_MEMBER_TD) {
+  TD = TD->Member.Access;
+} else {
+  DCHECK(0);

fmayer wrote:

`DCHECK(false && "invalid enum value")`?

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,35 @@
+# -*- Python -*-
+
+import os
+
+# Setup config name.
+config.name = 'TypeSanitizer' + getattr(config, 'name_suffix', 'default')
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# Setup default compiler flags used with -fsanitize=type option.
+clang_tysan_cflags = (["-fsanitize=type",
+  "-mno-omit-leaf-frame-pointer",
+  "-fno-omit-frame-pointer",
+  "-fno-optimize-sibling-calls"] +
+  [config.target_cflags] +

fmayer wrote:

This looks wrong, `target_cflags` sounds like a list

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,344 @@
+//===-- tysan.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of TypeSanitizer.
+//
+// TypeSanitizer runtime.
+//===--===//
+
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flag_parser.h"
+#include "sanitizer_common/sanitizer_flags.h"
+#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_report_decorator.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+#include "tysan/tysan.h"
+
+using namespace __sanitizer;
+using namespace __tysan;
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_set_type_unknown(const void *addr, uptr size) {
+  if (tysan_inited)
+internal_memset(shadow_for(addr), 0, size * sizeof(uptr));
+}
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_copy_types(const void *daddr, const void *saddr, uptr size) {
+  if (tysan_inited)
+internal_memmove(shadow_for(daddr), shadow_for(saddr), size * 
sizeof(uptr));
+}
+
+static const char *getDisplayName(const char *Name) {
+  if (Name[0] == '\0')
+return "";
+
+  // Clang generates tags for C++ types that demangle as typeinfo. Remove the
+  // prefix from the generated string.
+  const char TIPrefix[] = "typeinfo name for ";

fmayer wrote:

can't we make this a `const char*`?

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Hahn via llvm-branch-commits

https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/76261

>From 524eb555b0473bd93401297c5deba77f4dbd83fe Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Fri, 22 Nov 2024 15:01:41 +
Subject: [PATCH 1/7] [TySan] A Type Sanitizer (Runtime Library)

---
 clang/runtime/CMakeLists.txt  |   2 +-
 .../cmake/Modules/AllSupportedArchDefs.cmake  |   1 +
 compiler-rt/cmake/config-ix.cmake |  15 +-
 compiler-rt/lib/tysan/CMakeLists.txt  |  64 
 compiler-rt/lib/tysan/lit.cfg |  35 ++
 compiler-rt/lib/tysan/lit.site.cfg.in |  12 +
 compiler-rt/lib/tysan/tysan.cpp   | 344 ++
 compiler-rt/lib/tysan/tysan.h |  79 
 compiler-rt/lib/tysan/tysan.syms.extra|   2 +
 compiler-rt/lib/tysan/tysan_flags.inc |  17 +
 compiler-rt/lib/tysan/tysan_interceptors.cpp  | 250 +
 compiler-rt/lib/tysan/tysan_platform.h|  93 +
 compiler-rt/test/tysan/CMakeLists.txt |  32 ++
 compiler-rt/test/tysan/anon-ns.cpp|  41 +++
 compiler-rt/test/tysan/anon-same-struct.c |  26 ++
 compiler-rt/test/tysan/anon-struct.c  |  27 ++
 compiler-rt/test/tysan/basic.c|  65 
 compiler-rt/test/tysan/char-memcpy.c  |  45 +++
 .../test/tysan/constexpr-subobject.cpp|  25 ++
 compiler-rt/test/tysan/global.c   |  31 ++
 compiler-rt/test/tysan/int-long.c |  21 ++
 compiler-rt/test/tysan/lit.cfg.py | 139 +++
 compiler-rt/test/tysan/lit.site.cfg.py.in |  17 +
 compiler-rt/test/tysan/ptr-float.c|  19 +
 ...ruct-offset-multiple-compilation-units.cpp |  51 +++
 compiler-rt/test/tysan/struct-offset.c|  26 ++
 compiler-rt/test/tysan/struct.c   |  39 ++
 compiler-rt/test/tysan/union-wr-wr.c  |  18 +
 compiler-rt/test/tysan/violation-pr45282.c|  32 ++
 compiler-rt/test/tysan/violation-pr47137.c|  40 ++
 compiler-rt/test/tysan/violation-pr51837.c|  34 ++
 compiler-rt/test/tysan/violation-pr62544.c|  24 ++
 compiler-rt/test/tysan/violation-pr62828.cpp  |  44 +++
 compiler-rt/test/tysan/violation-pr68655.cpp  |  40 ++
 compiler-rt/test/tysan/violation-pr86685.c|  29 ++
 35 files changed, 1777 insertions(+), 2 deletions(-)
 create mode 100644 compiler-rt/lib/tysan/CMakeLists.txt
 create mode 100644 compiler-rt/lib/tysan/lit.cfg
 create mode 100644 compiler-rt/lib/tysan/lit.site.cfg.in
 create mode 100644 compiler-rt/lib/tysan/tysan.cpp
 create mode 100644 compiler-rt/lib/tysan/tysan.h
 create mode 100644 compiler-rt/lib/tysan/tysan.syms.extra
 create mode 100644 compiler-rt/lib/tysan/tysan_flags.inc
 create mode 100644 compiler-rt/lib/tysan/tysan_interceptors.cpp
 create mode 100644 compiler-rt/lib/tysan/tysan_platform.h
 create mode 100644 compiler-rt/test/tysan/CMakeLists.txt
 create mode 100644 compiler-rt/test/tysan/anon-ns.cpp
 create mode 100644 compiler-rt/test/tysan/anon-same-struct.c
 create mode 100644 compiler-rt/test/tysan/anon-struct.c
 create mode 100644 compiler-rt/test/tysan/basic.c
 create mode 100644 compiler-rt/test/tysan/char-memcpy.c
 create mode 100644 compiler-rt/test/tysan/constexpr-subobject.cpp
 create mode 100644 compiler-rt/test/tysan/global.c
 create mode 100644 compiler-rt/test/tysan/int-long.c
 create mode 100644 compiler-rt/test/tysan/lit.cfg.py
 create mode 100644 compiler-rt/test/tysan/lit.site.cfg.py.in
 create mode 100644 compiler-rt/test/tysan/ptr-float.c
 create mode 100644 
compiler-rt/test/tysan/struct-offset-multiple-compilation-units.cpp
 create mode 100644 compiler-rt/test/tysan/struct-offset.c
 create mode 100644 compiler-rt/test/tysan/struct.c
 create mode 100644 compiler-rt/test/tysan/union-wr-wr.c
 create mode 100644 compiler-rt/test/tysan/violation-pr45282.c
 create mode 100644 compiler-rt/test/tysan/violation-pr47137.c
 create mode 100644 compiler-rt/test/tysan/violation-pr51837.c
 create mode 100644 compiler-rt/test/tysan/violation-pr62544.c
 create mode 100644 compiler-rt/test/tysan/violation-pr62828.cpp
 create mode 100644 compiler-rt/test/tysan/violation-pr68655.cpp
 create mode 100644 compiler-rt/test/tysan/violation-pr86685.c

diff --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt
index 65fcdc2868f031..ff2605b23d25b0 100644
--- a/clang/runtime/CMakeLists.txt
+++ b/clang/runtime/CMakeLists.txt
@@ -122,7 +122,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS 
${COMPILER_RT_SRC_ROOT}/)
COMPONENT compiler-rt)
 
   # Add top-level targets that build specific compiler-rt runtimes.
-  set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan 
ubsan ubsan-minimal)
+  set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan 
tysan ubsan ubsan-minimal)
   foreach(runtime ${COMPILER_RT_RUNTIMES})
 get_ext_project_build_command(build_runtime_cmd ${runtime})
 add_custom_target(${runtime}
diff --git a/compil

[llvm-branch-commits] [clang] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Hahn via llvm-branch-commits


@@ -0,0 +1,344 @@
+//===-- tysan.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of TypeSanitizer.
+//
+// TypeSanitizer runtime.
+//===--===//
+
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flag_parser.h"
+#include "sanitizer_common/sanitizer_flags.h"
+#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_report_decorator.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+#include "tysan/tysan.h"
+
+using namespace __sanitizer;
+using namespace __tysan;
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_set_type_unknown(const void *addr, uptr size) {
+  if (tysan_inited)
+internal_memset(shadow_for(addr), 0, size * sizeof(uptr));
+}
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_copy_types(const void *daddr, const void *saddr, uptr size) {
+  if (tysan_inited)
+internal_memmove(shadow_for(daddr), shadow_for(saddr), size * 
sizeof(uptr));
+}
+
+static const char *getDisplayName(const char *Name) {
+  if (Name[0] == '\0')
+return "";
+
+  // Clang generates tags for C++ types that demangle as typeinfo. Remove the
+  // prefix from the generated string.
+  const char TIPrefix[] = "typeinfo name for ";

fhahn wrote:

Done together with using `strlen` thanks

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Hahn via llvm-branch-commits


@@ -0,0 +1,344 @@
+//===-- tysan.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of TypeSanitizer.
+//
+// TypeSanitizer runtime.
+//===--===//
+
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flag_parser.h"
+#include "sanitizer_common/sanitizer_flags.h"
+#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_report_decorator.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+#include "tysan/tysan.h"
+
+using namespace __sanitizer;
+using namespace __tysan;
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_set_type_unknown(const void *addr, uptr size) {
+  if (tysan_inited)
+internal_memset(shadow_for(addr), 0, size * sizeof(uptr));
+}
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_copy_types(const void *daddr, const void *saddr, uptr size) {
+  if (tysan_inited)
+internal_memmove(shadow_for(daddr), shadow_for(saddr), size * 
sizeof(uptr));
+}
+
+static const char *getDisplayName(const char *Name) {
+  if (Name[0] == '\0')
+return "";
+
+  // Clang generates tags for C++ types that demangle as typeinfo. Remove the
+  // prefix from the generated string.
+  const char TIPrefix[] = "typeinfo name for ";
+
+  const char *DName = Symbolizer::GetOrInit()->Demangle(Name);
+  if (!internal_strncmp(DName, TIPrefix, sizeof(TIPrefix) - 1))
+DName += sizeof(TIPrefix) - 1;
+
+  return DName;
+}
+
+static void printTDName(tysan_type_descriptor *td) {
+  if (((sptr)td) <= 0) {
+Printf("");
+return;
+  }
+
+  switch (td->Tag) {
+  default:
+DCHECK(0);
+break;
+  case TYSAN_MEMBER_TD:
+printTDName(td->Member.Access);
+if (td->Member.Access != td->Member.Base) {
+  Printf(" (in ");
+  printTDName(td->Member.Base);
+  Printf(" at offset %zu)", td->Member.Offset);
+}
+break;
+  case TYSAN_STRUCT_TD:
+Printf("%s", getDisplayName(
+ (char *)(td->Struct.Members + td->Struct.MemberCount)));
+break;
+  }
+}
+
+static tysan_type_descriptor *getRootTD(tysan_type_descriptor *TD) {
+  tysan_type_descriptor *RootTD = TD;
+
+  do {
+RootTD = TD;
+
+if (TD->Tag == TYSAN_STRUCT_TD) {
+  if (TD->Struct.MemberCount > 0)
+TD = TD->Struct.Members[0].Type;
+  else
+TD = nullptr;
+} else if (TD->Tag == TYSAN_MEMBER_TD) {
+  TD = TD->Member.Access;
+} else {
+  DCHECK(0);

fhahn wrote:

Done, thanks!

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Hahn via llvm-branch-commits


@@ -0,0 +1,344 @@
+//===-- tysan.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of TypeSanitizer.
+//
+// TypeSanitizer runtime.
+//===--===//
+
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flag_parser.h"
+#include "sanitizer_common/sanitizer_flags.h"
+#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_report_decorator.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+#include "tysan/tysan.h"
+
+using namespace __sanitizer;
+using namespace __tysan;
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_set_type_unknown(const void *addr, uptr size) {
+  if (tysan_inited)
+internal_memset(shadow_for(addr), 0, size * sizeof(uptr));
+}
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+tysan_copy_types(const void *daddr, const void *saddr, uptr size) {
+  if (tysan_inited)
+internal_memmove(shadow_for(daddr), shadow_for(saddr), size * 
sizeof(uptr));
+}
+
+static const char *getDisplayName(const char *Name) {
+  if (Name[0] == '\0')
+return "";
+
+  // Clang generates tags for C++ types that demangle as typeinfo. Remove the
+  // prefix from the generated string.
+  const char TIPrefix[] = "typeinfo name for ";
+
+  const char *DName = Symbolizer::GetOrInit()->Demangle(Name);
+  if (!internal_strncmp(DName, TIPrefix, sizeof(TIPrefix) - 1))
+DName += sizeof(TIPrefix) - 1;

fhahn wrote:

Updated, thanks

https://github.com/llvm/llvm-project/pull/76261
___
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] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-16 Thread Florian Hahn via llvm-branch-commits

fhahn wrote:

ping :) 

https://github.com/llvm/llvm-project/pull/76261
___
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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-12-16 Thread Michael Kruse via llvm-branch-commits

Meinersbur wrote:

@h-vetinari Is this using a bootstrap or default-only build? Is flang built 
in-tree or out-of-tree? Is `flang` in the build- or install-tree? Did you check 
whether the `flang_rt.static.lib` is present?

I am going to test more configurations under Windows trying to reproduce this. 
Narrowing it down would help.

@clementval I am pretty sure that bot intends to test build Flang using shared 
libraries (`libFortranSemantics.so`, ...), not the runtime. That those have 
been linked was unfortunate. That builder is going to continue to work with a 
static `libflang_rt.a`.

https://github.com/llvm/llvm-project/pull/110217
___
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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-12-16 Thread Michael Kruse via llvm-branch-commits

Meinersbur wrote:

> I feel that in the short term (this patch) loosing the ability to build 
> shared libs is a bit of a regression, and that it would be nice to have an 
> option to do shared library instead of static (or just let 
> `BUILD_SHARED_LIBS` drives that as it currently does until the options are 
> ready).

Using shared libs was undocumented so far and CUDA/OpenMP builds are even 
erroring out on them. It didn't seem being considered by anyone when I started, 
similar to other CMake features like cross-compiling or multi-configuration 
build systems.

The new machanism will be different from `BUILD_SHARED_LIBS` so not reusing any 
of its code. On the other side it would be a significant burden now since it 
doubles the number of configurations I have to get working and testing now 
while it will be replaced in the short term anyway. I hope you are not planning 
a release that requires to contain a `.so` for compatibility reasons?

https://github.com/llvm/llvm-project/pull/110217
___
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] [DirectX] Create symbols for resource handles (PR #119775)

2024-12-16 Thread Justin Bogner via llvm-branch-commits


@@ -0,0 +1,48 @@
+; RUN: opt -S -passes=dxil-translate-metadata %s | FileCheck %s
+
+target triple = "dxil-pc-shadermodel6.6-compute"
+
+%struct.S = type { <4 x float>, <4 x i32> }
+
+define void @test() {
+  ; Buffer
+  %float4 = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
+  @llvm.dx.handle.fromBinding(i32 0, i32 0, i32 1, i32 0, i1 false)
+  ; CHECK: %TypedBuffer = type { <4 x float> }
+
+  ; Buffer
+  %int = call target("dx.TypedBuffer", i32, 0, 0, 1)
+  @llvm.dx.handle.fromBinding(i32 0, i32 1, i32 1, i32 0, i1 false)
+  ; CHECK: %TypedBuffer.0 = type { i32 }
+
+  ; Buffer
+  %uint3 = call target("dx.TypedBuffer", <3 x i32>, 0, 0, 0)
+  @llvm.dx.handle.fromBinding(i32 0, i32 2, i32 1, i32 0, i1 false)
+  ; CHECK: %TypedBuffer.1 = type { <3 x i32> }
+
+  ; StructuredBuffer
+  %struct0 = call target("dx.RawBuffer", %struct.S, 0, 0)
+  @llvm.dx.handle.fromBinding(i32 0, i32 10, i32 1, i32 0, i1 true)
+  ; CHECK: %StructuredBuffer = type { %struct.S }
+
+  ; ByteAddressBuffer
+  %byteaddr = call target("dx.RawBuffer", i8, 0, 0)
+  @llvm.dx.handle.fromBinding(i32 0, i32 20, i32 1, i32 0, i1 false)
+  ; CHECK: %ByteAddressBuffer = type { i32 }
+
+  ret void
+}
+
+; CHECK:  @[[T0:.*]] = external constant %TypedBuffer
+; CHECK-NEXT: @[[T1:.*]] = external constant %TypedBuffer.0
+; CHECK-NEXT: @[[T2:.*]] = external constant %TypedBuffer.1
+; CHECK-NEXT: @[[S0:.*]] = external constant %StructuredBuffer
+; CHECK-NEXT: @[[B0:.*]] = external constant %ByteAddressBuffer
+
+; CHECK: !{i32 0, ptr @[[T0]], !""

bogner wrote:

Yes. The logic in TranslateMetadata isn't (yet?) providing a name. The change 
as is does not fix #105059 - I can add a comment to that effect

https://github.com/llvm/llvm-project/pull/119775
___
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] [DirectX] Create symbols for resource handles (PR #119775)

2024-12-16 Thread Justin Bogner via llvm-branch-commits

bogner wrote:

> If there already is a global variable for the resource in the module, 
> shouldn't we be using that instead of creating a new symbol?

The only global variables in the module before this point are the globals for 
the resource handles. These are (1) the wrong type (they're the handle object 
itself) and (2) it isn't clear what's happening with them long term. The 
mechanism here creates a global of the type that DXIL wants in the final output.

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


[llvm-branch-commits] [lld] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)

2024-12-16 Thread Derek Schuff via llvm-branch-commits

https://github.com/dschuff updated 
https://github.com/llvm/llvm-project/pull/119723

>From 3baa93367c6b0862279decc5d2400bc59fa1c485 Mon Sep 17 00:00:00 2001
From: Sam Clegg 
Date: Mon, 9 Sep 2024 09:28:08 -0700
Subject: [PATCH] [lld][WebAssembly] Fix use of uninitialized stack data with
 --wasm64 (#107780)

In the case of `--wasm64` we were setting the type of the init expression
to be 64-bit but were only setting the low 32-bits of the value (by
assigning to Int32).

Fixes: https://github.com/emscripten-core/emscripten/issues/22538
(cherry picked from commit 5c8fd1eece8fff69871cef57a2363dc0f734a7d1)
---
 lld/wasm/SyntheticSections.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index f02f55519a2512..72d08b849d8e86 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -587,8 +587,7 @@ void ElemSection::writeBody() {
 initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex();
   } else {
 bool is64 = config->is64.value_or(false);
-initExpr.Inst.Opcode = is64 ? WASM_OPCODE_I64_CONST : 
WASM_OPCODE_I32_CONST;
-initExpr.Inst.Value.Int32 = config->tableBase;
+initExpr = intConst(config->tableBase, is64);
   }
   writeInitExpr(os, initExpr);
 

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


[llvm-branch-commits] [lld] [PAC][lld][AArch64][ELF] Support signed TLSDESC (PR #113817)

2024-12-16 Thread Daniil Kovalev via llvm-branch-commits

https://github.com/kovdan01 updated 
https://github.com/llvm/llvm-project/pull/113817

>From bddd8de9f922790a63237cc581df37c6f7fc4464 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Fri, 25 Oct 2024 12:32:27 +0300
Subject: [PATCH 01/11] [PAC][lld][AArch64][ELF] Support signed TLSDESC

Support `R_AARCH64_AUTH_TLSDESC_ADR_PAGE21`, `R_AARCH64_AUTH_TLSDESC_LD64_LO12`
and `R_AARCH64_AUTH_TLSDESC_LD64_LO12` static TLSDESC relocations.
---
 lld/ELF/Arch/AArch64.cpp |   8 ++
 lld/ELF/InputSection.cpp |   2 +
 lld/ELF/Relocations.cpp  |  38 +++-
 lld/ELF/Relocations.h|   2 +
 lld/ELF/Symbols.h|   1 +
 lld/ELF/SyntheticSections.cpp|   5 +
 lld/test/ELF/aarch64-tlsdesc-pauth.s | 134 +++
 7 files changed, 188 insertions(+), 2 deletions(-)
 create mode 100644 lld/test/ELF/aarch64-tlsdesc-pauth.s

diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 9571e0e9566fc3..68c9c5e20e0f94 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -157,9 +157,14 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s,
 return RE_AARCH64_AUTH;
   case R_AARCH64_TLSDESC_ADR_PAGE21:
 return RE_AARCH64_TLSDESC_PAGE;
+  case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21:
+return RE_AARCH64_AUTH_TLSDESC_PAGE;
   case R_AARCH64_TLSDESC_LD64_LO12:
   case R_AARCH64_TLSDESC_ADD_LO12:
 return R_TLSDESC;
+  case R_AARCH64_AUTH_TLSDESC_LD64_LO12:
+  case R_AARCH64_AUTH_TLSDESC_ADD_LO12:
+return RE_AARCH64_AUTH_TLSDESC;
   case R_AARCH64_TLSDESC_CALL:
 return R_TLSDESC_CALL;
   case R_AARCH64_TLSLE_ADD_TPREL_HI12:
@@ -542,6 +547,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel,
   case R_AARCH64_ADR_PREL_PG_HI21:
   case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
   case R_AARCH64_TLSDESC_ADR_PAGE21:
+  case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21:
 checkInt(ctx, loc, val, 33, rel);
 [[fallthrough]];
   case R_AARCH64_ADR_PREL_PG_HI21_NC:
@@ -592,6 +598,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel,
   case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
   case R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC:
   case R_AARCH64_TLSDESC_LD64_LO12:
+  case R_AARCH64_AUTH_TLSDESC_LD64_LO12:
 checkAlignment(ctx, loc, val, 8, rel);
 write32Imm12(loc, getBits(val, 3, 11));
 break;
@@ -666,6 +673,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel,
 break;
   case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
   case R_AARCH64_TLSDESC_ADD_LO12:
+  case R_AARCH64_AUTH_TLSDESC_ADD_LO12:
 write32Imm12(loc, val);
 break;
   case R_AARCH64_TLSDESC:
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 26dc5c606f57f9..8b9f687b34f308 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -965,12 +965,14 @@ uint64_t InputSectionBase::getRelocTargetVA(Ctx &ctx, 
const Relocation &r,
   case R_SIZE:
 return r.sym->getSize() + a;
   case R_TLSDESC:
+  case RelExpr::R_AARCH64_AUTH_TLSDESC:
 return ctx.in.got->getTlsDescAddr(*r.sym) + a;
   case R_TLSDESC_PC:
 return ctx.in.got->getTlsDescAddr(*r.sym) + a - p;
   case R_TLSDESC_GOTPLT:
 return ctx.in.got->getTlsDescAddr(*r.sym) + a - ctx.in.gotPlt->getVA();
   case RE_AARCH64_TLSDESC_PAGE:
+  case RE_AARCH64_AUTH_TLSDESC_PAGE:
 return getAArch64Page(ctx.in.got->getTlsDescAddr(*r.sym) + a) -
getAArch64Page(p);
   case RE_LOONGARCH_TLSDESC_PAGE_PC:
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 07cbdb7806fde1..088f2e2298d1fa 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1326,6 +1326,36 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr 
expr, RelType type,
 return 1;
   }
 
+  auto fatalBothAuthAndNonAuth = [&sym]() {
+fatal("both AUTH and non-AUTH TLSDESC entries for '" + sym.getName() +
+  "' requested, but only one type of TLSDESC entry per symbol is "
+  "supported");
+  };
+
+  // Do not optimize signed TLSDESC as described in pauthabielf64 to LE/IE.
+  // 
https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#general-restrictions
+  // > PAUTHELF64 only supports the descriptor based TLS (TLSDESC).
+  if (oneof(
+  expr)) {
+assert(ctx.arg.emachine == EM_AARCH64);
+if (!sym.hasFlag(NEEDS_TLSDESC))
+  sym.setFlags(NEEDS_TLSDESC | NEEDS_TLSDESC_AUTH);
+else if (!sym.hasFlag(NEEDS_TLSDESC_AUTH))
+  fatalBothAuthAndNonAuth();
+sec->addReloc({expr, type, offset, addend, &sym});
+return 1;
+  }
+
+  if (sym.hasFlag(NEEDS_TLSDESC_AUTH)) {
+assert(ctx.arg.emachine == EM_AARCH64);
+// TLSDESC_CALL hint relocation probably should not be emitted by compiler
+// with signed TLSDESC enabled since it does not give any value, but leave 
a
+// check against that just in case someone uses it.
+if (expr != R_TLSDESC_CALL)
+  fatalBothAuthAndNonAuth();
+return 1;
+  }
+
   bool isRISCV = ctx.arg.emachine

[llvm-branch-commits] [lld] [PAC][lld][AArch64][ELF] Support signed GOT with tiny code model (PR #113816)

2024-12-16 Thread Daniil Kovalev via llvm-branch-commits

https://github.com/kovdan01 updated 
https://github.com/llvm/llvm-project/pull/113816

>From 67683bb9c119d98ba8e57c2a51a3df113a5fe562 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Fri, 25 Oct 2024 21:28:18 +0300
Subject: [PATCH 01/10] [PAC][lld][AArch64][ELF] Support signed GOT with tiny
 code model

Support `R_AARCH64_AUTH_GOT_ADR_PREL_LO21` and `R_AARCH64_AUTH_GOT_LD_PREL19`
GOT-generating relocations.
---
 lld/ELF/Arch/AArch64.cpp |  5 ++
 lld/ELF/InputSection.cpp |  1 +
 lld/ELF/Relocations.cpp  | 11 +--
 lld/ELF/Relocations.h|  1 +
 lld/test/ELF/aarch64-got-relocations-pauth.s | 73 
 5 files changed, 87 insertions(+), 4 deletions(-)

diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 9571e0e9566fc3..b63551d0f682e5 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -205,6 +205,9 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s,
   case R_AARCH64_AUTH_LD64_GOT_LO12_NC:
   case R_AARCH64_AUTH_GOT_ADD_LO12_NC:
 return RE_AARCH64_AUTH_GOT;
+  case R_AARCH64_AUTH_GOT_LD_PREL19:
+  case R_AARCH64_AUTH_GOT_ADR_PREL_LO21:
+return RE_AARCH64_AUTH_GOT_PC;
   case R_AARCH64_LD64_GOTPAGE_LO15:
 return RE_AARCH64_GOT_PAGE;
   case R_AARCH64_ADR_GOT_PAGE:
@@ -548,6 +551,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel,
 write32AArch64Addr(loc, val >> 12);
 break;
   case R_AARCH64_ADR_PREL_LO21:
+  case R_AARCH64_AUTH_GOT_ADR_PREL_LO21:
 checkInt(ctx, loc, val, 21, rel);
 write32AArch64Addr(loc, val);
 break;
@@ -568,6 +572,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel,
   case R_AARCH64_CONDBR19:
   case R_AARCH64_LD_PREL_LO19:
   case R_AARCH64_GOT_LD_PREL19:
+  case R_AARCH64_AUTH_GOT_LD_PREL19:
 checkAlignment(ctx, loc, val, 4, rel);
 checkInt(ctx, loc, val, 21, rel);
 writeMaskedBits32le(loc, (val & 0x1C) << 3, 0x1C << 3);
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 26dc5c606f57f9..76af4ec4193a4f 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -817,6 +817,7 @@ uint64_t InputSectionBase::getRelocTargetVA(Ctx &ctx, const 
Relocation &r,
   case RE_AARCH64_GOT_PAGE:
 return r.sym->getGotVA(ctx) + a - getAArch64Page(ctx.in.got->getVA());
   case R_GOT_PC:
+  case R_AARCH64_AUTH_GOT_PC:
   case R_RELAX_TLS_GD_TO_IE:
 return r.sym->getGotVA(ctx) + a - p;
   case R_GOTPLT_GOTREL:
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 07cbdb7806fde1..690b4933bb809e 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -197,8 +197,9 @@ static bool needsPlt(RelExpr expr) {
 }
 
 bool lld::elf::needsGot(RelExpr expr) {
-  return oneof(
   expr);
@@ -981,7 +982,8 @@ bool RelocationScanner::isStaticLinkTimeConstant(RelExpr e, 
RelType type,
 R_GOTPLTONLY_PC, R_PLT_PC, R_PLT_GOTREL, R_PLT_GOTPLT,
 R_GOTPLT_GOTREL, R_GOTPLT_PC, RE_PPC32_PLTREL, RE_PPC64_CALL_PLT,
 RE_PPC64_RELAX_TOC, RE_RISCV_ADD, RE_AARCH64_GOT_PAGE,
-RE_AARCH64_AUTH_GOT, RE_LOONGARCH_PLT_PAGE_PC, RE_LOONGARCH_GOT,
+RE_AARCH64_AUTH_GOT, RE_AARCH64_AUTH_GOT_PC,
+RE_LOONGARCH_PLT_PAGE_PC, RE_LOONGARCH_GOT,
 RE_LOONGARCH_GOT_PAGE_PC>(e))
 return true;
 
@@ -1096,7 +1098,8 @@ void RelocationScanner::processAux(RelExpr expr, RelType 
type, uint64_t offset,
 } else if (!sym.isTls() || ctx.arg.emachine != EM_LOONGARCH) {
   // Many LoongArch TLS relocs reuse the RE_LOONGARCH_GOT type, in which
   // case the NEEDS_GOT flag shouldn't get set.
-  if (expr == RE_AARCH64_AUTH_GOT || expr == RE_AARCH64_AUTH_GOT_PAGE_PC)
+  if (expr == RE_AARCH64_AUTH_GOT || expr == RE_AARCH64_AUTH_GOT_PAGE_PC ||
+  expr == RE_AARCH64_AUTH_GOT_PAGE_PC)
 sym.setFlags(NEEDS_GOT | NEEDS_GOT_AUTH);
   else
 sym.setFlags(NEEDS_GOT | NEEDS_GOT_NONAUTH);
diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h
index d993ab77adc3cc..fde25a230b72e6 100644
--- a/lld/ELF/Relocations.h
+++ b/lld/ELF/Relocations.h
@@ -95,6 +95,7 @@ enum RelExpr {
   RE_AARCH64_AUTH_GOT_PAGE_PC,
   RE_AARCH64_GOT_PAGE,
   RE_AARCH64_AUTH_GOT,
+  RE_AARCH64_AUTH_GOT_PC,
   RE_AARCH64_PAGE_PC,
   RE_AARCH64_RELAX_TLS_GD_TO_IE_PAGE_PC,
   RE_AARCH64_TLSDESC_PAGE,
diff --git a/lld/test/ELF/aarch64-got-relocations-pauth.s 
b/lld/test/ELF/aarch64-got-relocations-pauth.s
index 4456fe3ad7714b..147996fae2254a 100644
--- a/lld/test/ELF/aarch64-got-relocations-pauth.s
+++ b/lld/test/ELF/aarch64-got-relocations-pauth.s
@@ -77,6 +77,79 @@ _start:
   adrp x1, :got_auth:zed
   add  x1, x1, :got_auth_lo12:zed
 
+#--- ok-tiny.s
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux ok-tiny.s -o ok-tiny.o
+
+# RUN: ld.lld ok-tiny.o a.so -pie -o external-tiny
+# RUN: llvm-readelf -r -S -x .got external-tiny | FileCheck %s 
--check-prefix=EXTERNAL-TINY
+
+# RUN:

[llvm-branch-commits] [llvm] RegAlloc: Fix verifier error after failed allocation (PR #119690)

2024-12-16 Thread Matt Arsenault via llvm-branch-commits


@@ -161,6 +163,40 @@ void RegAllocBase::postOptimization() {
   DeadRemats.clear();
 }
 
+void RegAllocBase::cleanupFailedVRegs() {
+  SmallSet JunkRegs;
+
+  for (Register FailedReg : FailedVRegs) {
+JunkRegs.insert(FailedReg);
+
+MCRegister PhysReg = VRM->getPhys(FailedReg);
+LiveInterval &FailedInterval = LIS->getInterval(FailedReg);
+
+// The liveness information for the failed register and anything 
interfering
+// with the physical register we arbitrarily chose is junk and needs to be
+// deleted.
+for (MCRegUnitIterator Units(PhysReg, TRI); Units.isValid(); ++Units) {
+  LiveIntervalUnion::Query &Q = Matrix->query(FailedInterval, *Units);
+  for (const LiveInterval *InterferingReg : Q.interferingVRegs())
+JunkRegs.insert(InterferingReg->reg());
+}
+  }
+
+  // TODO: Probably need to set undef on any physreg uses not associated with
+  // a virtual register.

arsenm wrote:

It depends. There are some that use reserved physical registers, and some that 
don't. The verifier rules are different. Reserved registers get very little 
checking but you're not allowed to set most of these operand flags when using 
them 

https://github.com/llvm/llvm-project/pull/119690
___
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: Delete spills of undef values (PR #119684)

2024-12-16 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Dec 17, 12:51 AM EST**: A user started a stack merge that includes this 
pull request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/119684).


https://github.com/llvm/llvm-project/pull/119684
___
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] [DirectX] Lower ops after translating metadata (PR #120157)

2024-12-16 Thread Chris B via llvm-branch-commits

https://github.com/llvm-beanz approved this pull request.


https://github.com/llvm/llvm-project/pull/120157
___
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] Add predicates to tablegen-defined properties (PR #120176)

2024-12-16 Thread Krzysztof Drewniak via llvm-branch-commits

https://github.com/krzysz00 created 
https://github.com/llvm/llvm-project/pull/120176

Give the properties from tablegen a `predicate` field that holds the predicate 
that the property needs to satisfy, if one exists, and hook that field up to 
verifier generation.

>From e8b571f614adbc68ad551798c8e4b6b7df09c315 Mon Sep 17 00:00:00 2001
From: Krzysztof Drewniak 
Date: Wed, 27 Nov 2024 18:54:40 -0800
Subject: [PATCH] [mlir] Add predicates to tablegen-defined properties

Give the properties from tablegen a `predicate` field that holds the
predicate that the property needs to satisfy, if one exists, and hook
that field up to verifier generation.
---
 mlir/include/mlir/IR/Properties.td| 129 +++
 mlir/include/mlir/TableGen/Property.h |   5 +
 mlir/lib/TableGen/Property.cpp|  14 +-
 mlir/test/IR/test-op-property-predicates.mlir | 148 ++
 mlir/test/lib/Dialect/Test/TestOps.td |  32 +++-
 .../mlir-tblgen/op-properties-predicates.td   |  72 +
 mlir/test/mlir-tblgen/op-properties.td|   2 +-
 mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp   |  55 +++
 8 files changed, 417 insertions(+), 40 deletions(-)
 create mode 100644 mlir/test/IR/test-op-property-predicates.mlir
 create mode 100644 mlir/test/mlir-tblgen/op-properties-predicates.td

diff --git a/mlir/include/mlir/IR/Properties.td 
b/mlir/include/mlir/IR/Properties.td
index 0becf7d0098356..63ba0fda2ac979 100644
--- a/mlir/include/mlir/IR/Properties.td
+++ b/mlir/include/mlir/IR/Properties.td
@@ -13,6 +13,8 @@
 #ifndef PROPERTIES
 #define PROPERTIES
 
+include "mlir/IR/Constraints.td"
+
 // Base class for defining properties.
 class Property {
   // User-readable one line summary used in error reporting messages. If empty,
@@ -63,6 +65,12 @@ class Property {
 return convertFromAttribute($_storage, $_attr, $_diag);
   }];
 
+  // The verification predicate for this property. Defaults to And<[]>,
+  // which is trivially true, since properties are always their expected type.
+  // Within the predicate, `$_self` is an instance of the **interface**
+  // type of the property.
+  Pred predicate = ?;
+
   // The call expression to hash the property.
   //
   // Format:
@@ -150,8 +158,8 @@ class Property {
   return ::mlir::failure();
   }];
 
-  // Base definition for the property. (Will be) used for `OptionalProperty` 
and
-  // such cases, analogously to `baseAttr`.
+  // Base definition for the property. Used to look through `OptionalProperty`
+  // for some format generation, as with the `baseAttr` field on attributes.
   Property baseProperty = ?;
 
   // Default value for the property within its storage. This should be an 
expression
@@ -224,8 +232,7 @@ def I64Property : IntProperty<"int64_t">;
 
 class EnumProperty :
 Property {
-  // TODO: take advantage of EnumAttrInfo and the like to make this share nice
-  // parsing code with EnumAttr.
+  // TODO:  implement predicate for enum validity.
   let writeToMlirBytecode = [{
 $_writer.writeVarInt(static_cast($_storage));
   }];
@@ -330,6 +337,56 @@ def UnitProperty : Property<"bool", "unit property"> {
   }];
 }
 
+//===--===//
+// Property field overwrites
+
+/// Class for giving a property a default value.
+/// This doesn't change anything about the property other than giving it a 
default
+/// which can be used by ODS to elide printing.
+class DefaultValuedProperty : Property {
+  let defaultValue = default;
+  let storageTypeValueOverride = storageDefault;
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let summary = p.summary;
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let predicate = p.predicate;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.writeToMlirBytecode;
+}
+
+class ConfinedProperty
+: Property {
+  let predicate = !if(!initialized(p.predicate), And<[p.predicate, pred]>, 
pred);
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.wr

[llvm-branch-commits] [mlir] [mlir] Add predicates to tablegen-defined properties (PR #120176)

2024-12-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-ods

Author: Krzysztof Drewniak (krzysz00)


Changes

Give the properties from tablegen a `predicate` field that holds the predicate 
that the property needs to satisfy, if one exists, and hook that field up to 
verifier generation.

---

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


8 Files Affected:

- (modified) mlir/include/mlir/IR/Properties.td (+96-33) 
- (modified) mlir/include/mlir/TableGen/Property.h (+5) 
- (modified) mlir/lib/TableGen/Property.cpp (+12-2) 
- (added) mlir/test/IR/test-op-property-predicates.mlir (+148) 
- (modified) mlir/test/lib/Dialect/Test/TestOps.td (+28-4) 
- (added) mlir/test/mlir-tblgen/op-properties-predicates.td (+72) 
- (modified) mlir/test/mlir-tblgen/op-properties.td (+1-1) 
- (modified) mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp (+55) 


``diff
diff --git a/mlir/include/mlir/IR/Properties.td 
b/mlir/include/mlir/IR/Properties.td
index 0becf7d0098356..63ba0fda2ac979 100644
--- a/mlir/include/mlir/IR/Properties.td
+++ b/mlir/include/mlir/IR/Properties.td
@@ -13,6 +13,8 @@
 #ifndef PROPERTIES
 #define PROPERTIES
 
+include "mlir/IR/Constraints.td"
+
 // Base class for defining properties.
 class Property {
   // User-readable one line summary used in error reporting messages. If empty,
@@ -63,6 +65,12 @@ class Property {
 return convertFromAttribute($_storage, $_attr, $_diag);
   }];
 
+  // The verification predicate for this property. Defaults to And<[]>,
+  // which is trivially true, since properties are always their expected type.
+  // Within the predicate, `$_self` is an instance of the **interface**
+  // type of the property.
+  Pred predicate = ?;
+
   // The call expression to hash the property.
   //
   // Format:
@@ -150,8 +158,8 @@ class Property {
   return ::mlir::failure();
   }];
 
-  // Base definition for the property. (Will be) used for `OptionalProperty` 
and
-  // such cases, analogously to `baseAttr`.
+  // Base definition for the property. Used to look through `OptionalProperty`
+  // for some format generation, as with the `baseAttr` field on attributes.
   Property baseProperty = ?;
 
   // Default value for the property within its storage. This should be an 
expression
@@ -224,8 +232,7 @@ def I64Property : IntProperty<"int64_t">;
 
 class EnumProperty :
 Property {
-  // TODO: take advantage of EnumAttrInfo and the like to make this share nice
-  // parsing code with EnumAttr.
+  // TODO:  implement predicate for enum validity.
   let writeToMlirBytecode = [{
 $_writer.writeVarInt(static_cast($_storage));
   }];
@@ -330,6 +337,56 @@ def UnitProperty : Property<"bool", "unit property"> {
   }];
 }
 
+//===--===//
+// Property field overwrites
+
+/// Class for giving a property a default value.
+/// This doesn't change anything about the property other than giving it a 
default
+/// which can be used by ODS to elide printing.
+class DefaultValuedProperty : Property {
+  let defaultValue = default;
+  let storageTypeValueOverride = storageDefault;
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let summary = p.summary;
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let predicate = p.predicate;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.writeToMlirBytecode;
+}
+
+class ConfinedProperty
+: Property {
+  let predicate = !if(!initialized(p.predicate), And<[p.predicate, pred]>, 
pred);
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.writeToMlirBytecode;
+  let defaultValue = p.defaultValue;
+  let storageTypeValueOverride = p.storageTypeValueOverride;
+}
+
 
//===--===//
 // Primitive property combinators
 
@@ -342,14 +399,37 @@ class _makePropStorage {
 true : "") # ";";
 }
 
+/// Construct a `Pred`icate `ret` that wraps the predicate of the underlying
+/// prope

[llvm-branch-commits] [mlir] [mlir] Add predicates to tablegen-defined properties (PR #120176)

2024-12-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-core

Author: Krzysztof Drewniak (krzysz00)


Changes

Give the properties from tablegen a `predicate` field that holds the predicate 
that the property needs to satisfy, if one exists, and hook that field up to 
verifier generation.

---

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


8 Files Affected:

- (modified) mlir/include/mlir/IR/Properties.td (+96-33) 
- (modified) mlir/include/mlir/TableGen/Property.h (+5) 
- (modified) mlir/lib/TableGen/Property.cpp (+12-2) 
- (added) mlir/test/IR/test-op-property-predicates.mlir (+148) 
- (modified) mlir/test/lib/Dialect/Test/TestOps.td (+28-4) 
- (added) mlir/test/mlir-tblgen/op-properties-predicates.td (+72) 
- (modified) mlir/test/mlir-tblgen/op-properties.td (+1-1) 
- (modified) mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp (+55) 


``diff
diff --git a/mlir/include/mlir/IR/Properties.td 
b/mlir/include/mlir/IR/Properties.td
index 0becf7d0098356..63ba0fda2ac979 100644
--- a/mlir/include/mlir/IR/Properties.td
+++ b/mlir/include/mlir/IR/Properties.td
@@ -13,6 +13,8 @@
 #ifndef PROPERTIES
 #define PROPERTIES
 
+include "mlir/IR/Constraints.td"
+
 // Base class for defining properties.
 class Property {
   // User-readable one line summary used in error reporting messages. If empty,
@@ -63,6 +65,12 @@ class Property {
 return convertFromAttribute($_storage, $_attr, $_diag);
   }];
 
+  // The verification predicate for this property. Defaults to And<[]>,
+  // which is trivially true, since properties are always their expected type.
+  // Within the predicate, `$_self` is an instance of the **interface**
+  // type of the property.
+  Pred predicate = ?;
+
   // The call expression to hash the property.
   //
   // Format:
@@ -150,8 +158,8 @@ class Property {
   return ::mlir::failure();
   }];
 
-  // Base definition for the property. (Will be) used for `OptionalProperty` 
and
-  // such cases, analogously to `baseAttr`.
+  // Base definition for the property. Used to look through `OptionalProperty`
+  // for some format generation, as with the `baseAttr` field on attributes.
   Property baseProperty = ?;
 
   // Default value for the property within its storage. This should be an 
expression
@@ -224,8 +232,7 @@ def I64Property : IntProperty<"int64_t">;
 
 class EnumProperty :
 Property {
-  // TODO: take advantage of EnumAttrInfo and the like to make this share nice
-  // parsing code with EnumAttr.
+  // TODO:  implement predicate for enum validity.
   let writeToMlirBytecode = [{
 $_writer.writeVarInt(static_cast($_storage));
   }];
@@ -330,6 +337,56 @@ def UnitProperty : Property<"bool", "unit property"> {
   }];
 }
 
+//===--===//
+// Property field overwrites
+
+/// Class for giving a property a default value.
+/// This doesn't change anything about the property other than giving it a 
default
+/// which can be used by ODS to elide printing.
+class DefaultValuedProperty : Property {
+  let defaultValue = default;
+  let storageTypeValueOverride = storageDefault;
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let summary = p.summary;
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let predicate = p.predicate;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.writeToMlirBytecode;
+}
+
+class ConfinedProperty
+: Property {
+  let predicate = !if(!initialized(p.predicate), And<[p.predicate, pred]>, 
pred);
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.writeToMlirBytecode;
+  let defaultValue = p.defaultValue;
+  let storageTypeValueOverride = p.storageTypeValueOverride;
+}
+
 
//===--===//
 // Primitive property combinators
 
@@ -342,14 +399,37 @@ class _makePropStorage {
 true : "") # ";";
 }
 
+/// Construct a `Pred`icate `ret` that wraps the predicate of the underlying
+/// prop

[llvm-branch-commits] [mlir] [mlir] Add predicates to tablegen-defined properties (PR #120176)

2024-12-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: Krzysztof Drewniak (krzysz00)


Changes

Give the properties from tablegen a `predicate` field that holds the predicate 
that the property needs to satisfy, if one exists, and hook that field up to 
verifier generation.

---

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


8 Files Affected:

- (modified) mlir/include/mlir/IR/Properties.td (+96-33) 
- (modified) mlir/include/mlir/TableGen/Property.h (+5) 
- (modified) mlir/lib/TableGen/Property.cpp (+12-2) 
- (added) mlir/test/IR/test-op-property-predicates.mlir (+148) 
- (modified) mlir/test/lib/Dialect/Test/TestOps.td (+28-4) 
- (added) mlir/test/mlir-tblgen/op-properties-predicates.td (+72) 
- (modified) mlir/test/mlir-tblgen/op-properties.td (+1-1) 
- (modified) mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp (+55) 


``diff
diff --git a/mlir/include/mlir/IR/Properties.td 
b/mlir/include/mlir/IR/Properties.td
index 0becf7d0098356..63ba0fda2ac979 100644
--- a/mlir/include/mlir/IR/Properties.td
+++ b/mlir/include/mlir/IR/Properties.td
@@ -13,6 +13,8 @@
 #ifndef PROPERTIES
 #define PROPERTIES
 
+include "mlir/IR/Constraints.td"
+
 // Base class for defining properties.
 class Property {
   // User-readable one line summary used in error reporting messages. If empty,
@@ -63,6 +65,12 @@ class Property {
 return convertFromAttribute($_storage, $_attr, $_diag);
   }];
 
+  // The verification predicate for this property. Defaults to And<[]>,
+  // which is trivially true, since properties are always their expected type.
+  // Within the predicate, `$_self` is an instance of the **interface**
+  // type of the property.
+  Pred predicate = ?;
+
   // The call expression to hash the property.
   //
   // Format:
@@ -150,8 +158,8 @@ class Property {
   return ::mlir::failure();
   }];
 
-  // Base definition for the property. (Will be) used for `OptionalProperty` 
and
-  // such cases, analogously to `baseAttr`.
+  // Base definition for the property. Used to look through `OptionalProperty`
+  // for some format generation, as with the `baseAttr` field on attributes.
   Property baseProperty = ?;
 
   // Default value for the property within its storage. This should be an 
expression
@@ -224,8 +232,7 @@ def I64Property : IntProperty<"int64_t">;
 
 class EnumProperty :
 Property {
-  // TODO: take advantage of EnumAttrInfo and the like to make this share nice
-  // parsing code with EnumAttr.
+  // TODO:  implement predicate for enum validity.
   let writeToMlirBytecode = [{
 $_writer.writeVarInt(static_cast($_storage));
   }];
@@ -330,6 +337,56 @@ def UnitProperty : Property<"bool", "unit property"> {
   }];
 }
 
+//===--===//
+// Property field overwrites
+
+/// Class for giving a property a default value.
+/// This doesn't change anything about the property other than giving it a 
default
+/// which can be used by ODS to elide printing.
+class DefaultValuedProperty : Property {
+  let defaultValue = default;
+  let storageTypeValueOverride = storageDefault;
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let summary = p.summary;
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let predicate = p.predicate;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.writeToMlirBytecode;
+}
+
+class ConfinedProperty
+: Property {
+  let predicate = !if(!initialized(p.predicate), And<[p.predicate, pred]>, 
pred);
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.writeToMlirBytecode;
+  let defaultValue = p.defaultValue;
+  let storageTypeValueOverride = p.storageTypeValueOverride;
+}
+
 
//===--===//
 // Primitive property combinators
 
@@ -342,14 +399,37 @@ class _makePropStorage {
 true : "") # ";";
 }
 
+/// Construct a `Pred`icate `ret` that wraps the predicate of the underlying
+/// property 

[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-12-16 Thread via llvm-branch-commits

h-vetinari wrote:

> @h-vetinari Is this using a bootstrap or default-only build? Is flang built 
> in-tree or out-of-tree? Is `flang` in the build- or install-tree? Did you 
> check whether the `flang_rt.static.lib` is present?
> 
> I am going to test more configurations under Windows trying to reproduce 
> this. Narrowing it down would help.

On a basis of already-compiled & installed `llvm` (the subproject), clang, 
mlir, compiler-rt, we first build flang, and then flang-rt using the just-built 
flang. Both get installed (ultimately) into the same install tree where the 
other LLVM bits are already present*, so in the end it should be pretty 
standard -- all in one place. I did check that `flang_rt.static.lib` is present 
(under the path I described, i.e. `/lib/windows/flang_rt.static.lib`, relative 
to `CMAKE_INSTALL_PREFIX`).


* details
 
this is actually the mechanism that defines what the "installation" of a given 
package X means from the POV of conda-build; i.e. populate the the install-tree 
with whatever needs to be there, take a snapshot before and after installation, 
then the (positive) delta between the before/after snapshots defines the 
content of X _as installed_.

For testing, there's a further level of isolation from the build environment, 
in that everything gets torn down and then recreated based on what has been 
determined to be the package content (plus all specified dependencies), and 
_then_ run the tests. This is to avoid spuriously relying on stuff from the 
build tree, and forcing the installation to be explicit about what it needs to 
put into the installation-`$PREFIX`. It also ends up testing/enforcing 
relocatability (which needs some more magic on linux, but it's possible).



In sequence, we do:
* set up install-tree with the (LLVM) bits required to build flang
* build 
[flang](https://github.com/h-vetinari/flang-feedstock/blob/dev/recipe/bld.bat)
* build 
[flang-rt](https://github.com/h-vetinari/flang-feedstock/blob/dev/recipe/install_flang-rt.bat)
* [build some wrappers that just add metadata]
* run tests

Everything is held together by a 
[recipe](https://github.com/h-vetinari/flang-feedstock/blob/dev/recipe/meta.yaml),
 but I don't expect that to be immediately self-evident (happy to explain 
what's happening though!).

So for the final test, we create an environment that looks like
```
TEST START: C:\bld\win-64\flang_win-64-20.0.0.dev3-h0d486fc_0.conda
[...]

## Package Plan ##

  environment location: C:\bld\flang-split_1734298984217\_test_env


The following NEW packages will be INSTALLED:

clang:  20.0.0.dev3-default_h00e4eaa_0 
conda-forge/label/llvm_dev
clang-20:   20.0.0.dev3-default_h00e4eaa_0 
conda-forge/label/llvm_dev
compiler-rt:20.0.0.dev3-h85af4db_0 
conda-forge/label/llvm_dev
compiler-rt_win-64: 20.0.0.dev3-h85af4db_0 
conda-forge/label/llvm_dev
flang:  20.0.0.dev3-hb33b443_0 local
 
flang-rt:   20.0.0.dev3-h963887e_0 local
 
flang_impl_win-64:  20.0.0.dev3-h0d486fc_0 local
 
flang_win-64:   20.0.0.dev3-h0d486fc_0 local
 
libiconv:   1.17-hcfcfb64_2conda-forge  
 
libllvm20:  20.0.0.dev3-h7de1732_0 
conda-forge/label/llvm_dev
libxml2:2.13.5-he286e8c_1  conda-forge  
 
libzlib:1.3.1-h2466b09_2   conda-forge  
 
lld:20.0.0.dev3-h4ef2093_0 
conda-forge/label/llvm_dev
llvm-tools: 20.0.0.dev3-h6f9bbfe_0 
conda-forge/label/llvm_dev
ucrt:   10.0.22621.0-h57928b3_1conda-forge  
 
vc: 14.3-ha32ba9b_23   conda-forge  
 
vc14_runtime:   14.42.34433-he29a5d6_23conda-forge  
 
zstd:   1.5.6-h0ea2cb4_0   conda-forge 
```
The `local` packages are the ones that have just been built (not yet 
published); the ones from the `llvm_dev` label have been built & published 
previously (but from the same commit). `flang{,_impl}_win-64` are the 
metapackages I mentioned that don't change anything.

The testing order follows the DAG of dependencies, IOW, since `flang_win-64` 
(the final compiler) depends on `flang-rt`, the tests for `flang-rt` have 
already run before, and I've explicitly 
[tested](https://github.com/h-vetinari/flang-feedstock/blob/e86a0e2a0ab30056f6d924dcd4668ec975328767/recipe/meta.yaml#L60)
 the presence of `flang_rt.static.lib` _as installed_. In particular, this 
guarantees that this library is in the expected location when we end up testing 
`flang_win-64`.

Here are the full 
[logs](https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=1110855&view=results)
 if you're interested (note that azure pipelines de

[llvm-branch-commits] [lld] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)

2024-12-16 Thread Linwei Shang via llvm-branch-commits

lwshang wrote:

> Merging is blocked
> The base branch does not allow updates.

Can this PR be merged?
Will this backport be able to catch the v19.1.6 train tomorrow (if it happens)?

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


[llvm-branch-commits] [lld] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)

2024-12-16 Thread via llvm-branch-commits

DianQK wrote:

> > Merging is blocked
> > The base branch does not allow updates.
> 
> Can this PR be merged? Will this backport be able to catch the v19.1.6 train 
> tomorrow (if it happens)?

Yes. I don't see any concerns not merging. Note that merging of the release 
branch is handled by the release manager, which is different from the main 
branch.

https://github.com/llvm/llvm-project/pull/119723
___
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][Vector] Clean up `populateVectorToLLVMConversionPatterns` (PR #119975)

2024-12-16 Thread via llvm-branch-commits


@@ -522,6 +524,16 @@ 
DECLARE_CONVERT_OP_TO_GPU_RUNTIME_CALL_PATTERN(SetCsrPointersOp)
 
 void GpuToLLVMConversionPass::runOnOperation() {
   MLIRContext *context = &getContext();
+
+  // Perform progressive lowering of vector transfer operations.
+  {
+RewritePatternSet patterns(&getContext());
+// Vector transfer ops with rank > 1 should be lowered with VectorToSCF.
+vector::populateVectorTransferLoweringPatterns(patterns,
+   /*maxTransferRank=*/1);
+(void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));

MaheshRavishankar wrote:

Maybe this should return a `signalPassFailure` instead of just ignoring the 
result

https://github.com/llvm/llvm-project/pull/119975
___
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] b2b261c - Revert "[Static analysis] Encodes a filename before inserting it into a URL. …"

2024-12-16 Thread via llvm-branch-commits

Author: Ryosuke Niwa
Date: 2024-12-16T23:35:54-08:00
New Revision: b2b261c406108390117e1b6c3fdbe5e9d53a7111

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

LOG: Revert "[Static analysis] Encodes a filename before inserting it into a 
URL. …"

This reverts commit f515d7aa720142dfbb72f52e9d0106ba33e1fe69.

Added: 


Modified: 
clang/tools/scan-build/bin/scan-build

Removed: 




diff  --git a/clang/tools/scan-build/bin/scan-build 
b/clang/tools/scan-build/bin/scan-build
index 1df043ef8b72bd..37241c6d85c5b2 100755
--- a/clang/tools/scan-build/bin/scan-build
+++ b/clang/tools/scan-build/bin/scan-build
@@ -23,7 +23,6 @@ use Term::ANSIColor qw(:constants);
 use Cwd qw/ getcwd abs_path /;
 use Sys::Hostname;
 use Hash::Util qw(lock_keys);
-use URI::Escape;
 
 my $Prog = "scan-build";
 my $BuildName;
@@ -821,8 +820,7 @@ ENDTEXT
   }
 
   # Emit the "View" link.
-  my $EncodedReport = uri_escape($ReportFile, "^A-Za-z0-9\-\._~\/");
-  print OUT "View Report";
+  print OUT "View Report";
 
   # Emit REPORTBUG markers.
   print OUT "\n\n";



___
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/19.x: [Clang][perf-training] Fix clean command in perf-helper.py (#118978) (PR #119051)

2024-12-16 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/119051
___
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/19.x: [Clang][perf-training] Fix clean command in perf-helper.py (#118978) (PR #119051)

2024-12-16 Thread Tobias Hieta via llvm-branch-commits

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

>From 3d21a9a8e4ecd4a88acfa80700cebfdcd35dde6c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 6 Dec 2024 18:34:59 -0800
Subject: [PATCH] [Clang][perf-training] Fix clean command in perf-helper.py
 (#118978)

The first path argument was always being ignored, and since most calls
to this command only passed one path, it wasn't actually doing anything
in most cases.

This bug was introduced by dd0356d741aefa25ece973d6cc4b55dcb73b84b4.

(cherry picked from commit 18af3fc1bf8855e1e166e64a9210ed07d610aa54)
---
 clang/utils/perf-training/perf-helper.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/utils/perf-training/perf-helper.py 
b/clang/utils/perf-training/perf-helper.py
index 3ed42a187fd803..d76c6ede3fe5a2 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -36,7 +36,7 @@ def clean(args):
 + "\tRemoves all files with extension from ."
 )
 return 1
-for path in args[1:-1]:
+for path in args[0:-1]:
 for filename in findFilesWithExtension(path, args[-1]):
 os.remove(filename)
 return 0

___
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] 3d21a9a - [Clang][perf-training] Fix clean command in perf-helper.py (#118978)

2024-12-16 Thread Tobias Hieta via llvm-branch-commits

Author: Tom Stellard
Date: 2024-12-17T08:48:13+01:00
New Revision: 3d21a9a8e4ecd4a88acfa80700cebfdcd35dde6c

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

LOG: [Clang][perf-training] Fix clean command in perf-helper.py (#118978)

The first path argument was always being ignored, and since most calls
to this command only passed one path, it wasn't actually doing anything
in most cases.

This bug was introduced by dd0356d741aefa25ece973d6cc4b55dcb73b84b4.

(cherry picked from commit 18af3fc1bf8855e1e166e64a9210ed07d610aa54)

Added: 


Modified: 
clang/utils/perf-training/perf-helper.py

Removed: 




diff  --git a/clang/utils/perf-training/perf-helper.py 
b/clang/utils/perf-training/perf-helper.py
index 3ed42a187fd803..d76c6ede3fe5a2 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -36,7 +36,7 @@ def clean(args):
 + "\tRemoves all files with extension from ."
 )
 return 1
-for path in args[1:-1]:
+for path in args[0:-1]:
 for filename in findFilesWithExtension(path, args[-1]):
 os.remove(filename)
 return 0



___
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/19.x: [Clang][perf-training] Fix clean command in perf-helper.py (#118978) (PR #119051)

2024-12-16 Thread via llvm-branch-commits

github-actions[bot] wrote:

@tstellar (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/119051
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits