[llvm-branch-commits] [clang] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)

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

https://github.com/kovdan01 edited 
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] [llvm] [Analysis] Add DebugInfoCache analysis (PR #118629)

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

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

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

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

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

>From a49247fe8ccde67b26fada91d865a01f704ff05c 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] [Coro] Use DebugInfoCache to speed up cloning in CoroSplitPass (PR #118630)

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

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

>From daedf07d8ca50dde9974f5d59a5cb55d4056c15b 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] release/19.x: [clang-format] Fix idempotent format of hash in macro body (#118513) (PR #119503)

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

tru wrote:

can we get a review on this?

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


[llvm-branch-commits] [llvm] release/19.x: [SimpleLoopUnswitch] Fix LCSSA phi node invalidation (PR #118870)

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

tru wrote:

@nikic is this fine to merge?

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


[llvm-branch-commits] [llvm] release/19.x: [RISCV] Add hasPostISelHook to sf.vfnrclip pseudo instructions. (#114274) (PR #117948)

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

tru wrote:

Can we get a review of this?

https://github.com/llvm/llvm-project/pull/117948
___
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] hexagon: fix link order for libc/builtins (#117057) (PR #117968)

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

tru wrote:

Can we get a review of this?

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


[llvm-branch-commits] [llvm] release/19.x: [Matrix] Skip already fused instructions before trying to fuse multiply. (PR #118020)

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

tru wrote:

Who can review this?

https://github.com/llvm/llvm-project/pull/118020
___
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-17 Thread Tobias Hieta via llvm-branch-commits

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

>From d2953ab0a79f9f2d2877703dbc235b92541faec9 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] d2953ab - [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780)

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

Author: Sam Clegg
Date: 2024-12-17T10:06:24+01:00
New Revision: d2953ab0a79f9f2d2877703dbc235b92541faec9

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

LOG: [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)

Added: 


Modified: 
lld/wasm/SyntheticSections.cpp

Removed: 




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] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)

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

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

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

Meinersbur wrote:

> 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.

Without knowing what configurations FLANG_RT_EXPERIMENTAL_DISABLE_STATIC will 
be used with, there will either be an endless back-and-forth of new things that 
still do not work with any reviewer that tries that option or me having to test 
all (reasonably common) configurations anyway.

Rather than investing time on a temporary solution, I prefer working an the 
proper approach right away: #120213. If it is important to you, I can push all 
three with a single `git push` so at no point it is not there is not a 
possibility to build a shared library.

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] Add predicates to tablegen-defined properties (PR #120176)

2024-12-17 Thread Mehdi Amini via llvm-branch-commits


@@ -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

joker-eph wrote:

Please add a short doc for the class

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


[llvm-branch-commits] [llvm] release/19.x: [AggressiveInstCombine] Use APInt and avoid truncation when folding loads (PR #118866)

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

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

>From 657e03f8625c9e7326f241aea584ff5c43b30ba3 Mon Sep 17 00:00:00 2001
From: Antonio Frighetto 
Date: Wed, 4 Dec 2024 10:15:11 +0100
Subject: [PATCH] [AggressiveInstCombine] Use APInt and avoid truncation when
 folding loads

A miscompilation issue has been addressed with improved handling.

Fixes: https://github.com/llvm/llvm-project/issues/118467.
(cherry picked from commit f68b0e36997322eeda8fd199ea80deb1b49c5410)
---
 .../AggressiveInstCombine.cpp |  3 +-
 .../AggressiveInstCombine/AArch64/or-load.ll  | 20 +++
 .../AggressiveInstCombine/X86/or-load.ll  | 52 +++
 3 files changed, 53 insertions(+), 22 deletions(-)

diff --git 
a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp 
b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
index d5a38ec17a2a84..1d23ec8ced204f 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -811,8 +811,7 @@ static bool foldConsecutiveLoads(Instruction &I, const 
DataLayout &DL,
 APInt Offset1(DL.getIndexTypeSizeInBits(Load1Ptr->getType()), 0);
 Load1Ptr = Load1Ptr->stripAndAccumulateConstantOffsets(
 DL, Offset1, /* AllowNonInbounds */ true);
-Load1Ptr = Builder.CreatePtrAdd(Load1Ptr,
-Builder.getInt32(Offset1.getZExtValue()));
+Load1Ptr = Builder.CreatePtrAdd(Load1Ptr, Builder.getInt(Offset1));
   }
   // Generate wider load.
   NewLoad = Builder.CreateAlignedLoad(WiderType, Load1Ptr, LI1->getAlign(),
diff --git a/llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll 
b/llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll
index 1400ee7f703cab..10c4c9b0ca4c99 100644
--- a/llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll
+++ b/llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll
@@ -1121,19 +1121,19 @@ entry:
 
 define i32 @loadCombine_4consecutive_metadata(ptr %p, ptr %pstr) {
 ; LE-LABEL: @loadCombine_4consecutive_metadata(
-; LE-NEXT:[[L1:%.*]] = load i32, ptr [[P:%.*]], align 1, !alias.scope !0
-; LE-NEXT:store i32 25, ptr [[PSTR:%.*]], align 4, !noalias !0
+; LE-NEXT:[[L1:%.*]] = load i32, ptr [[P:%.*]], align 1, !alias.scope 
[[META0:![0-9]+]]
+; LE-NEXT:store i32 25, ptr [[PSTR:%.*]], align 4, !noalias [[META0]]
 ; LE-NEXT:ret i32 [[L1]]
 ;
 ; BE-LABEL: @loadCombine_4consecutive_metadata(
 ; BE-NEXT:[[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
 ; BE-NEXT:[[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
 ; BE-NEXT:[[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
-; BE-NEXT:[[L1:%.*]] = load i8, ptr [[P]], align 1, !alias.scope !0
-; BE-NEXT:[[L2:%.*]] = load i8, ptr [[P1]], align 1, !alias.scope !0
-; BE-NEXT:[[L3:%.*]] = load i8, ptr [[P2]], align 1, !alias.scope !0
-; BE-NEXT:[[L4:%.*]] = load i8, ptr [[P3]], align 1, !alias.scope !0
-; BE-NEXT:store i32 25, ptr [[PSTR:%.*]], align 4, !noalias !0
+; BE-NEXT:[[L1:%.*]] = load i8, ptr [[P]], align 1, !alias.scope 
[[META0:![0-9]+]]
+; BE-NEXT:[[L2:%.*]] = load i8, ptr [[P1]], align 1, !alias.scope [[META0]]
+; BE-NEXT:[[L3:%.*]] = load i8, ptr [[P2]], align 1, !alias.scope [[META0]]
+; BE-NEXT:[[L4:%.*]] = load i8, ptr [[P3]], align 1, !alias.scope [[META0]]
+; BE-NEXT:store i32 25, ptr [[PSTR:%.*]], align 4, !noalias [[META0]]
 ; BE-NEXT:[[E1:%.*]] = zext i8 [[L1]] to i32
 ; BE-NEXT:[[E2:%.*]] = zext i8 [[L2]] to i32
 ; BE-NEXT:[[E3:%.*]] = zext i8 [[L3]] to i32
@@ -1869,7 +1869,7 @@ define i32 @loadCombine_4consecutive_badinsert2(ptr %p) {
 
 define i32 @loadCombine_4consecutive_badinsert3(ptr %p) {
 ; LE-LABEL: @loadCombine_4consecutive_badinsert3(
-; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
+; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 1
 ; LE-NEXT:[[L1:%.*]] = load i32, ptr [[TMP1]], align 1
 ; LE-NEXT:ret i32 [[L1]]
 ;
@@ -2088,7 +2088,7 @@ define i32 @loadCombine_4consecutive_badinsert6(ptr %p) {
 
 define void @nested_gep(ptr %p, ptr %dest) {
 ; LE-LABEL: @nested_gep(
-; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 68
+; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 68
 ; LE-NEXT:[[LD2:%.*]] = load i64, ptr [[TMP1]], align 4
 ; LE-NEXT:[[TRUNC:%.*]] = trunc i64 [[LD2]] to i32
 ; LE-NEXT:store i32 [[TRUNC]], ptr [[DEST:%.*]], align 4
@@ -2128,7 +2128,7 @@ define void @nested_gep(ptr %p, ptr %dest) {
 
 define void @bitcast_gep(ptr %p, ptr %dest) {
 ; LE-LABEL: @bitcast_gep(
-; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 68
+; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 68
 ; LE-NEXT:[[LD2:%.*]] = load i64, ptr [[TMP1]], align 4
 ; LE-NEXT:[[TRUNC:%.*]] = trunc i64 [[LD2]] to i32
 ; LE-NEXT:store i32 [[TRUNC]], ptr [[DES

[llvm-branch-commits] [llvm] 657e03f - [AggressiveInstCombine] Use APInt and avoid truncation when folding loads

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

Author: Antonio Frighetto
Date: 2024-12-17T10:19:28+01:00
New Revision: 657e03f8625c9e7326f241aea584ff5c43b30ba3

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

LOG: [AggressiveInstCombine] Use APInt and avoid truncation when folding loads

A miscompilation issue has been addressed with improved handling.

Fixes: https://github.com/llvm/llvm-project/issues/118467.
(cherry picked from commit f68b0e36997322eeda8fd199ea80deb1b49c5410)

Added: 


Modified: 
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll
llvm/test/Transforms/AggressiveInstCombine/X86/or-load.ll

Removed: 




diff  --git 
a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp 
b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
index d5a38ec17a2a84..1d23ec8ced204f 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -811,8 +811,7 @@ static bool foldConsecutiveLoads(Instruction &I, const 
DataLayout &DL,
 APInt Offset1(DL.getIndexTypeSizeInBits(Load1Ptr->getType()), 0);
 Load1Ptr = Load1Ptr->stripAndAccumulateConstantOffsets(
 DL, Offset1, /* AllowNonInbounds */ true);
-Load1Ptr = Builder.CreatePtrAdd(Load1Ptr,
-Builder.getInt32(Offset1.getZExtValue()));
+Load1Ptr = Builder.CreatePtrAdd(Load1Ptr, Builder.getInt(Offset1));
   }
   // Generate wider load.
   NewLoad = Builder.CreateAlignedLoad(WiderType, Load1Ptr, LI1->getAlign(),

diff  --git a/llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll 
b/llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll
index 1400ee7f703cab..10c4c9b0ca4c99 100644
--- a/llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll
+++ b/llvm/test/Transforms/AggressiveInstCombine/AArch64/or-load.ll
@@ -1121,19 +1121,19 @@ entry:
 
 define i32 @loadCombine_4consecutive_metadata(ptr %p, ptr %pstr) {
 ; LE-LABEL: @loadCombine_4consecutive_metadata(
-; LE-NEXT:[[L1:%.*]] = load i32, ptr [[P:%.*]], align 1, !alias.scope !0
-; LE-NEXT:store i32 25, ptr [[PSTR:%.*]], align 4, !noalias !0
+; LE-NEXT:[[L1:%.*]] = load i32, ptr [[P:%.*]], align 1, !alias.scope 
[[META0:![0-9]+]]
+; LE-NEXT:store i32 25, ptr [[PSTR:%.*]], align 4, !noalias [[META0]]
 ; LE-NEXT:ret i32 [[L1]]
 ;
 ; BE-LABEL: @loadCombine_4consecutive_metadata(
 ; BE-NEXT:[[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
 ; BE-NEXT:[[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
 ; BE-NEXT:[[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
-; BE-NEXT:[[L1:%.*]] = load i8, ptr [[P]], align 1, !alias.scope !0
-; BE-NEXT:[[L2:%.*]] = load i8, ptr [[P1]], align 1, !alias.scope !0
-; BE-NEXT:[[L3:%.*]] = load i8, ptr [[P2]], align 1, !alias.scope !0
-; BE-NEXT:[[L4:%.*]] = load i8, ptr [[P3]], align 1, !alias.scope !0
-; BE-NEXT:store i32 25, ptr [[PSTR:%.*]], align 4, !noalias !0
+; BE-NEXT:[[L1:%.*]] = load i8, ptr [[P]], align 1, !alias.scope 
[[META0:![0-9]+]]
+; BE-NEXT:[[L2:%.*]] = load i8, ptr [[P1]], align 1, !alias.scope [[META0]]
+; BE-NEXT:[[L3:%.*]] = load i8, ptr [[P2]], align 1, !alias.scope [[META0]]
+; BE-NEXT:[[L4:%.*]] = load i8, ptr [[P3]], align 1, !alias.scope [[META0]]
+; BE-NEXT:store i32 25, ptr [[PSTR:%.*]], align 4, !noalias [[META0]]
 ; BE-NEXT:[[E1:%.*]] = zext i8 [[L1]] to i32
 ; BE-NEXT:[[E2:%.*]] = zext i8 [[L2]] to i32
 ; BE-NEXT:[[E3:%.*]] = zext i8 [[L3]] to i32
@@ -1869,7 +1869,7 @@ define i32 @loadCombine_4consecutive_badinsert2(ptr %p) {
 
 define i32 @loadCombine_4consecutive_badinsert3(ptr %p) {
 ; LE-LABEL: @loadCombine_4consecutive_badinsert3(
-; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
+; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 1
 ; LE-NEXT:[[L1:%.*]] = load i32, ptr [[TMP1]], align 1
 ; LE-NEXT:ret i32 [[L1]]
 ;
@@ -2088,7 +2088,7 @@ define i32 @loadCombine_4consecutive_badinsert6(ptr %p) {
 
 define void @nested_gep(ptr %p, ptr %dest) {
 ; LE-LABEL: @nested_gep(
-; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 68
+; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 68
 ; LE-NEXT:[[LD2:%.*]] = load i64, ptr [[TMP1]], align 4
 ; LE-NEXT:[[TRUNC:%.*]] = trunc i64 [[LD2]] to i32
 ; LE-NEXT:store i32 [[TRUNC]], ptr [[DEST:%.*]], align 4
@@ -2128,7 +2128,7 @@ define void @nested_gep(ptr %p, ptr %dest) {
 
 define void @bitcast_gep(ptr %p, ptr %dest) {
 ; LE-LABEL: @bitcast_gep(
-; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 68
+; LE-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 68
 ; 

[llvm-branch-commits] [llvm] release/19.x: [WebAssembly] Handle symbols in `.init_array` sections (#119127) (PR #119533)

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

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

>From 8069ce6ab1766a166b956192ad72c143be3b860e Mon Sep 17 00:00:00 2001
From: George Stagg 
Date: Wed, 4 Dec 2024 21:12:15 +
Subject: [PATCH 1/2] [WebAssembly] Support multiple `.init_array` fragments
 when writing Wasm objects (#111008)

(cherry picked from commit ac5dd455caaf286625f61b604291f2eaed9702f0)
---
 llvm/lib/MC/WasmObjectWriter.cpp  | 89 ++-
 llvm/test/MC/WebAssembly/init-array.s | 49 +++
 2 files changed, 96 insertions(+), 42 deletions(-)
 create mode 100644 llvm/test/MC/WebAssembly/init-array.s

diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index f25dc92fa235a2..a66c5713ff8a6e 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1853,49 +1853,54 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler 
&Asm,
 if (EmptyFrag.getKind() != MCFragment::FT_Data)
   report_fatal_error(".init_array section should be aligned");
 
-const MCFragment &AlignFrag = *EmptyFrag.getNext();
-if (AlignFrag.getKind() != MCFragment::FT_Align)
-  report_fatal_error(".init_array section should be aligned");
-if (cast(AlignFrag).getAlignment() !=
-Align(is64Bit() ? 8 : 4))
-  report_fatal_error(".init_array section should be aligned for pointers");
-
-const MCFragment &Frag = *AlignFrag.getNext();
-if (Frag.hasInstructions() || Frag.getKind() != MCFragment::FT_Data)
-  report_fatal_error("only data supported in .init_array section");
-
-uint16_t Priority = UINT16_MAX;
-unsigned PrefixLength = strlen(".init_array");
-if (WS.getName().size() > PrefixLength) {
-  if (WS.getName()[PrefixLength] != '.')
+const MCFragment *nextFrag = EmptyFrag.getNext();
+while (nextFrag != nullptr) {
+  const MCFragment &AlignFrag = *nextFrag;
+  if (AlignFrag.getKind() != MCFragment::FT_Align)
+report_fatal_error(".init_array section should be aligned");
+  if (cast(AlignFrag).getAlignment() !=
+  Align(is64Bit() ? 8 : 4))
 report_fatal_error(
-".init_array section priority should start with '.'");
-  if (WS.getName().substr(PrefixLength + 1).getAsInteger(10, Priority))
-report_fatal_error("invalid .init_array section priority");
-}
-const auto &DataFrag = cast(Frag);
-const SmallVectorImpl &Contents = DataFrag.getContents();
-for (const uint8_t *
- P = (const uint8_t *)Contents.data(),
-*End = (const uint8_t *)Contents.data() + Contents.size();
- P != End; ++P) {
-  if (*P != 0)
-report_fatal_error("non-symbolic data in .init_array section");
-}
-for (const MCFixup &Fixup : DataFrag.getFixups()) {
-  assert(Fixup.getKind() ==
- MCFixup::getKindForSize(is64Bit() ? 8 : 4, false));
-  const MCExpr *Expr = Fixup.getValue();
-  auto *SymRef = dyn_cast(Expr);
-  if (!SymRef)
-report_fatal_error("fixups in .init_array should be symbol 
references");
-  const auto &TargetSym = cast(SymRef->getSymbol());
-  if (TargetSym.getIndex() == InvalidIndex)
-report_fatal_error("symbols in .init_array should exist in symtab");
-  if (!TargetSym.isFunction())
-report_fatal_error("symbols in .init_array should be for functions");
-  InitFuncs.push_back(
-  std::make_pair(Priority, TargetSym.getIndex()));
+".init_array section should be aligned for pointers");
+
+  const MCFragment &Frag = *AlignFrag.getNext();
+  nextFrag = Frag.getNext();
+  if (Frag.hasInstructions() || Frag.getKind() != MCFragment::FT_Data)
+report_fatal_error("only data supported in .init_array section");
+
+  uint16_t Priority = UINT16_MAX;
+  unsigned PrefixLength = strlen(".init_array");
+  if (WS.getName().size() > PrefixLength) {
+if (WS.getName()[PrefixLength] != '.')
+  report_fatal_error(
+  ".init_array section priority should start with '.'");
+if (WS.getName().substr(PrefixLength + 1).getAsInteger(10, Priority))
+  report_fatal_error("invalid .init_array section priority");
+  }
+  const auto &DataFrag = cast(Frag);
+  const SmallVectorImpl &Contents = DataFrag.getContents();
+  for (const uint8_t *
+   P = (const uint8_t *)Contents.data(),
+  *End = (const uint8_t *)Contents.data() + Contents.size();
+   P != End; ++P) {
+if (*P != 0)
+  report_fatal_error("non-symbolic data in .init_array section");
+  }
+  for (const MCFixup &Fixup : DataFrag.getFixups()) {
+assert(Fixup.getKind() ==
+   MCFixup::getKindForSize(is64Bit() ? 8 : 4, false));
+const MCExpr *Expr = Fixup.getValue();
+auto *SymRef = dyn_cast(Expr);
+if (!SymRef)
+  report_fatal_error(
+  "fixups in .init_array should be symbol 

[llvm-branch-commits] [llvm] release/19.x: [SimpleLoopUnswitch] Fix LCSSA phi node invalidation (PR #118870)

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

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


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


[llvm-branch-commits] [llvm] release/19.x: [SimpleLoopUnswitch] Fix LCSSA phi node invalidation (PR #118870)

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

github-actions[bot] wrote:

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


[llvm-branch-commits] [llvm] release/19.x: [SimpleLoopUnswitch] Fix LCSSA phi node invalidation (PR #118870)

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

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

>From e21dc4bd5474d04b8e62d7331362edcc5648d7e5 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 27 Nov 2024 11:47:22 +0100
Subject: [PATCH] [SimpleLoopUnswitch] Fix LCSSA phi node invalidation

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

(cherry picked from commit fc5c89900f2a4b50e0f3a88ef7c89115d93684f4)
---
 .../Transforms/Scalar/SimpleLoopUnswitch.cpp  |  5 +-
 .../Transforms/SimpleLoopUnswitch/pr117537.ll | 92 +++
 2 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll

diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp 
b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index c235d2fb2a5bd4..f99f4487c5540e 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -1249,8 +1249,9 @@ static BasicBlock *buildClonedLoopBlocks(
   assert(VMap.lookup(&I) == &ClonedI && "Mismatch in the value map!");
 
   // Forget SCEVs based on exit phis in case SCEV looked through the phi.
-  if (SE && isa(I))
-SE->forgetValue(&I);
+  if (SE)
+if (auto *PN = dyn_cast(&I))
+  SE->forgetLcssaPhiWithNewPredecessor(&L, PN);
 
   BasicBlock::iterator InsertPt = MergeBB->getFirstInsertionPt();
 
diff --git a/llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll 
b/llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll
new file mode 100644
index 00..fd61cfab164d3b
--- /dev/null
+++ b/llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll
@@ -0,0 +1,92 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt -S 
-passes='print,simple-loop-unswitch,print'
 -verify-scev < %s 2>/dev/null | FileCheck %s
+
+; Make sure we don't assert due to insufficient SCEV invalidation.
+
+define void @test(ptr %p) {
+; CHECK-LABEL: define void @test(
+; CHECK-SAME: ptr [[P:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:[[CHECK:%.*]] = icmp eq ptr [[P]], null
+; CHECK-NEXT:br i1 [[CHECK]], label %[[ENTRY_SPLIT_US:.*]], label 
%[[ENTRY_SPLIT:.*]]
+; CHECK:   [[ENTRY_SPLIT_US]]:
+; CHECK-NEXT:br label %[[BB0_US:.*]]
+; CHECK:   [[BB0_US]]:
+; CHECK-NEXT:br label %[[LOOP0_US:.*]]
+; CHECK:   [[LOOP0_US]]:
+; CHECK-NEXT:[[V_US:%.*]] = load atomic i32, ptr [[P]] unordered, align 8
+; CHECK-NEXT:[[ADD_US:%.*]] = add i32 [[V_US]], 3
+; CHECK-NEXT:br i1 true, label %[[PREHEADER_SPLIT_US:.*]], label 
%[[BB0_US]]
+; CHECK:   [[PREHEADER_SPLIT_US]]:
+; CHECK-NEXT:[[ADD_LCSSA_US:%.*]] = phi i32 [ [[ADD_US]], %[[LOOP0_US]] ]
+; CHECK-NEXT:br label %[[PREHEADER:.*]]
+; CHECK:   [[ENTRY_SPLIT]]:
+; CHECK-NEXT:br label %[[BB0:.*]]
+; CHECK:   [[BB0]]:
+; CHECK-NEXT:br label %[[LATCH:.*]]
+; CHECK:   [[LATCH]]:
+; CHECK-NEXT:br i1 false, label %[[EXIT0:.*]], label %[[LOOP0:.*]]
+; CHECK:   [[EXIT0]]:
+; CHECK-NEXT:ret void
+; CHECK:   [[LOOP0]]:
+; CHECK-NEXT:[[V:%.*]] = load atomic i32, ptr [[P]] unordered, align 8
+; CHECK-NEXT:[[ADD:%.*]] = add i32 [[V]], 3
+; CHECK-NEXT:br i1 true, label %[[PREHEADER_SPLIT:.*]], label %[[BB0]]
+; CHECK:   [[PREHEADER_SPLIT]]:
+; CHECK-NEXT:[[ADD_LCSSA:%.*]] = phi i32 [ [[ADD]], %[[LOOP0]] ]
+; CHECK-NEXT:br label %[[PREHEADER]]
+; CHECK:   [[PREHEADER]]:
+; CHECK-NEXT:[[DOTUS_PHI:%.*]] = phi i32 [ [[ADD_LCSSA]], 
%[[PREHEADER_SPLIT]] ], [ [[ADD_LCSSA_US]], %[[PREHEADER_SPLIT_US]] ]
+; CHECK-NEXT:br label %[[LOOP1:.*]]
+; CHECK:   [[LOOP1]]:
+; CHECK-NEXT:[[IV1:%.*]] = phi i32 [ [[DOTUS_PHI]], %[[PREHEADER]] ], [ 
[[IV1_NEXT:%.*]], %[[BACKEDGE:.*]] ]
+; CHECK-NEXT:[[IV1_NEXT]] = add i32 [[IV1]], -33
+; CHECK-NEXT:br label %[[LOOP2:.*]]
+; CHECK:   [[BACKEDGE]]:
+; CHECK-NEXT:br i1 true, label %[[EXIT1:.*]], label %[[LOOP1]]
+; CHECK:   [[LOOP2]]:
+; CHECK-NEXT:[[IV0:%.*]] = phi i32 [ [[IV1]], %[[LOOP1]] ], [ 
[[IV0_NEXT:%.*]], %[[LOOP2]] ]
+; CHECK-NEXT:[[IV0_NEXT]] = add nsw i32 [[IV0]], 1
+; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[IV0_NEXT]], 0
+; CHECK-NEXT:br i1 [[CMP]], label %[[BACKEDGE]], label %[[LOOP2]]
+; CHECK:   [[EXIT1]]:
+; CHECK-NEXT:ret void
+;
+entry:
+  %check = icmp eq ptr %p, null
+  br label %bb0
+
+bb0:  ; preds = %loop0, %entry
+  br i1 %check, label %loop0, label %latch
+
+latch:; preds = %bb0
+  br i1 %check, label %exit0, label %loop0
+
+exit0:; preds = %latch
+  ret void
+
+loop0:; preds = %latch, %bb0
+  %v = load atomic i32, ptr %p unordered, align 8
+  %add = add i32 %v, 3
+  br i1 true, label %preheader, label %bb0
+
+preheader:; preds = %loop0
+ 

[llvm-branch-commits] [llvm] release/19.x: [SimpleLoopUnswitch] Fix LCSSA phi node invalidation (PR #118870)

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

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/118870
___
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] e21dc4b - [SimpleLoopUnswitch] Fix LCSSA phi node invalidation

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

Author: Nikita Popov
Date: 2024-12-17T12:04:04+01:00
New Revision: e21dc4bd5474d04b8e62d7331362edcc5648d7e5

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

LOG: [SimpleLoopUnswitch] Fix LCSSA phi node invalidation

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

(cherry picked from commit fc5c89900f2a4b50e0f3a88ef7c89115d93684f4)

Added: 
llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll

Modified: 
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp 
b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index c235d2fb2a5bd4..f99f4487c5540e 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -1249,8 +1249,9 @@ static BasicBlock *buildClonedLoopBlocks(
   assert(VMap.lookup(&I) == &ClonedI && "Mismatch in the value map!");
 
   // Forget SCEVs based on exit phis in case SCEV looked through the phi.
-  if (SE && isa(I))
-SE->forgetValue(&I);
+  if (SE)
+if (auto *PN = dyn_cast(&I))
+  SE->forgetLcssaPhiWithNewPredecessor(&L, PN);
 
   BasicBlock::iterator InsertPt = MergeBB->getFirstInsertionPt();
 

diff  --git a/llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll 
b/llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll
new file mode 100644
index 00..fd61cfab164d3b
--- /dev/null
+++ b/llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll
@@ -0,0 +1,92 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt -S 
-passes='print,simple-loop-unswitch,print'
 -verify-scev < %s 2>/dev/null | FileCheck %s
+
+; Make sure we don't assert due to insufficient SCEV invalidation.
+
+define void @test(ptr %p) {
+; CHECK-LABEL: define void @test(
+; CHECK-SAME: ptr [[P:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:[[CHECK:%.*]] = icmp eq ptr [[P]], null
+; CHECK-NEXT:br i1 [[CHECK]], label %[[ENTRY_SPLIT_US:.*]], label 
%[[ENTRY_SPLIT:.*]]
+; CHECK:   [[ENTRY_SPLIT_US]]:
+; CHECK-NEXT:br label %[[BB0_US:.*]]
+; CHECK:   [[BB0_US]]:
+; CHECK-NEXT:br label %[[LOOP0_US:.*]]
+; CHECK:   [[LOOP0_US]]:
+; CHECK-NEXT:[[V_US:%.*]] = load atomic i32, ptr [[P]] unordered, align 8
+; CHECK-NEXT:[[ADD_US:%.*]] = add i32 [[V_US]], 3
+; CHECK-NEXT:br i1 true, label %[[PREHEADER_SPLIT_US:.*]], label 
%[[BB0_US]]
+; CHECK:   [[PREHEADER_SPLIT_US]]:
+; CHECK-NEXT:[[ADD_LCSSA_US:%.*]] = phi i32 [ [[ADD_US]], %[[LOOP0_US]] ]
+; CHECK-NEXT:br label %[[PREHEADER:.*]]
+; CHECK:   [[ENTRY_SPLIT]]:
+; CHECK-NEXT:br label %[[BB0:.*]]
+; CHECK:   [[BB0]]:
+; CHECK-NEXT:br label %[[LATCH:.*]]
+; CHECK:   [[LATCH]]:
+; CHECK-NEXT:br i1 false, label %[[EXIT0:.*]], label %[[LOOP0:.*]]
+; CHECK:   [[EXIT0]]:
+; CHECK-NEXT:ret void
+; CHECK:   [[LOOP0]]:
+; CHECK-NEXT:[[V:%.*]] = load atomic i32, ptr [[P]] unordered, align 8
+; CHECK-NEXT:[[ADD:%.*]] = add i32 [[V]], 3
+; CHECK-NEXT:br i1 true, label %[[PREHEADER_SPLIT:.*]], label %[[BB0]]
+; CHECK:   [[PREHEADER_SPLIT]]:
+; CHECK-NEXT:[[ADD_LCSSA:%.*]] = phi i32 [ [[ADD]], %[[LOOP0]] ]
+; CHECK-NEXT:br label %[[PREHEADER]]
+; CHECK:   [[PREHEADER]]:
+; CHECK-NEXT:[[DOTUS_PHI:%.*]] = phi i32 [ [[ADD_LCSSA]], 
%[[PREHEADER_SPLIT]] ], [ [[ADD_LCSSA_US]], %[[PREHEADER_SPLIT_US]] ]
+; CHECK-NEXT:br label %[[LOOP1:.*]]
+; CHECK:   [[LOOP1]]:
+; CHECK-NEXT:[[IV1:%.*]] = phi i32 [ [[DOTUS_PHI]], %[[PREHEADER]] ], [ 
[[IV1_NEXT:%.*]], %[[BACKEDGE:.*]] ]
+; CHECK-NEXT:[[IV1_NEXT]] = add i32 [[IV1]], -33
+; CHECK-NEXT:br label %[[LOOP2:.*]]
+; CHECK:   [[BACKEDGE]]:
+; CHECK-NEXT:br i1 true, label %[[EXIT1:.*]], label %[[LOOP1]]
+; CHECK:   [[LOOP2]]:
+; CHECK-NEXT:[[IV0:%.*]] = phi i32 [ [[IV1]], %[[LOOP1]] ], [ 
[[IV0_NEXT:%.*]], %[[LOOP2]] ]
+; CHECK-NEXT:[[IV0_NEXT]] = add nsw i32 [[IV0]], 1
+; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[IV0_NEXT]], 0
+; CHECK-NEXT:br i1 [[CMP]], label %[[BACKEDGE]], label %[[LOOP2]]
+; CHECK:   [[EXIT1]]:
+; CHECK-NEXT:ret void
+;
+entry:
+  %check = icmp eq ptr %p, null
+  br label %bb0
+
+bb0:  ; preds = %loop0, %entry
+  br i1 %check, label %loop0, label %latch
+
+latch:; preds = %bb0
+  br i1 %check, label %exit0, label %loop0
+
+exit0:; preds = %latch
+  ret void
+
+loop0:; preds = %latch, %bb0
+  %v = load atomic i32, ptr %p unordered, align 8
+  %add = add i32 %v, 3
+  br i1 true, label %preheader, label %bb0
+
+preheader:  

[llvm-branch-commits] [llvm] [Flang-RT] Build libflang_rt.so (PR #120213)

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

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/120213

Under non-Windows platforms, also create a dynamic library version of the 
runtime. Build of either version of the library can be switched off using 
FLANG_RT_ENABLE_STATIC=OFF respectively FLANG_RT_ENABLE_SHARED=OFF. Default is 
to build both.

PR on top of #110217.

EXPERIMENTAL DRAFT. CHANGES AND CLEANUPS IN PROGRESS.

>From 7e252f1a64e12ac04706175cabc303076d9e973f Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 17 Dec 2024 12:00:38 +0100
Subject: [PATCH] Add FLANG_RT_ENABLE_STATIC and _SHARED

---
 flang-rt/CMakeLists.txt |  14 +++
 flang-rt/cmake/modules/AddFlangRT.cmake | 123 
 2 files changed, 117 insertions(+), 20 deletions(-)

diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 1d7b241adea89c..48169673ad772f 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -115,6 +115,20 @@ endif ()
 option(FLANG_RT_INCLUDE_TESTS "Generate build targets for the flang-rt unit 
and regression-tests." "${LLVM_INCLUDE_TESTS}")
 
 
+option(FLANG_RT_ENABLE_STATIC "Build Flang-RT as a static library." ON)
+if (WIN32)
+  # Windows DLL currently not implemented.
+  set(FLANG_RT_ENABLE_SHARED OFF)
+else ()
+  option(FLANG_RT_ENABLE_SHARED "Build Flang-RT as a shared library." ON)
+endif ()
+if (NOT FLANG_RT_ENABLE_STATIC AND NOT FLANG_RT_ENABLE_SHARED)
+  message(FATAL_ERROR "Must build at least one type of library
+  (FLANG_RT_ENABLE_STATIC=ON, FLANG_RT_ENABLE_SHARED=ON, or both)
+")
+endif ()
+
+
 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
 ""
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake 
b/flang-rt/cmake/modules/AddFlangRT.cmake
index 6e55a0d115713d..e20622b7039785 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -38,42 +38,124 @@ function (add_flangrt_library name)
 ${ARGN})
 
   if (ARG_INSTALL_WITH_TOOLCHAIN AND ARG_EXCLUDE_FROM_ALL)
- message(SEND_ERROR "add_flangrt_library(${name} ...):
+message(SEND_ERROR "add_flangrt_library(${name} ...):
INSTALL_WITH_TOOLCHAIN and EXCLUDE_FROM_ALL are in conflict. When
installing an artifact it must have been built first in the 'all' 
target.
- ")
+  ")
+return ()
   endif ()
 
-  # Also add header files to IDEs to list as part of the library
-  set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES 
HEADER_FILE_ONLY ON)
+  #if (ARG_CMAKE_CONFIGURABLE AND (ARG_STATIC OR ARG_SHARED))
+  #  message(SEND_ERROR "add_flangrt_library(${name} ...):
+  # CMAKE_CONFIGURABLE cannot be used together with STATIC or SHARED.
+  #")
+  #  return ()
+  #endif ()
+
+  #if (NOT ARG_STATIC AND NOT ARG_SHARED AND NOT ARG_CMAKE_CONFIGURABLE AND 
NOT ARG_OBJECT)
+  #  message(SEND_ERROR "add_flangrt_library(${name} ...):
+  # Must specifiy library type.
+  #")
+  #  return ()
+  #endif () 
+
+  set(build_static OFF)
+  set(build_shared OFF)
+  if (ARG_STATIC AND FLANG_RT_ENABLE_STATIC)
+set(build_static ON)
+  endif ()
+  if (ARG_SHARED AND FLANG_RT_ENABLE_SHARED)
+set(build_shared ON)
+  endif ()
+  if (NOT ARG_STATIC AND NOT ARG_SHARED AND NOT ARG_OBJECT)
+if (BUILD_SHARED_LIBS)
+  set(build_shared ON)
+else ()
+  set(build_static ON)
+endif ()
+  endif ()
 
-  # Forward libtype to add_library
-  set(extra_args "")
-  if (ARG_SHARED)
-list(APPEND extra_args SHARED)
+  # Name of targets must only depend on function arguments to be predictable 
for callers.
+  if (ARG_STATIC AND ARG_SHARED)
+set(name_static "${name}.static")
+set(name_shared "${name}.shared")
+  else ()
+set(name_static "${name}")
+set(name_shared "${name}")
   endif ()
-  if (ARG_STATIC)
-list(APPEND extra_args STATIC)
+  if (ARG_OBJECT AND NOT ARG_STATIC AND NOT ARG_SHARED)
+set(name_object "${name}")
+  else ()
+set(name_object "obj.${name}")
   endif ()
-  if (ARG_OBJECT)
-list(APPEND extra_args OBJECT)
+
+
+  if (ARG_OBJECT AND NOT build_static AND NOT build_shared)
+set(build_only_objectlib ON)
+  else ()
+set(build_only_objectlib OFF)
   endif ()
+  if (build_only_objectlib OR (build_static AND build_shared))
+set(need_objectlib ON)
+  else ()
+set(need_objectlib OFF)
+  endif ()
+
+  if (NOT build_static AND NOT build_shared AND NOT need_objectlib)
+# Nothing to build
+return ()
+  endif ()
+
+  # Also add header files to IDEs to list as part of the library
+  set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES 
HEADER_FILE_ONLY ON)
+
+  set(extra_args "")
   if (ARG_EXCLUDE_FROM_ALL)
 list(APPEND extra_args EXCLUDE_FROM_ALL)
   endif ()
 
-  add_library(${name} ${extra_args} ${ARG_ADDITIONAL_HEADERS} 
${ARG_UNPARSED_ARGUMENTS})
 
-  if (ARG_INSTALL_WITH_TOOLCHAIN)
-s

[llvm-branch-commits] [llvm] release/19.x: [AggressiveInstCombine] Use APInt and avoid truncation when folding loads (PR #118866)

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

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/118866
___
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] [19.x] Backport standalone build fixes for offload (PR #118643)

2024-12-17 Thread Michał Górny via llvm-branch-commits

mgorny wrote:

Thanks! Since it's a nice setup, and pretty much was broken before, I don't 
think there's a point in a release note.

https://github.com/llvm/llvm-project/pull/118643
___
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-17 Thread Markus Böck via llvm-branch-commits

https://github.com/zero9178 commented:

Looks great to me, thank you! I added a few comments but they're all 
implementation details, no conceptual complaints from my side.

Also adding Jeff as a reviewer given the disucssion at 
https://github.com/llvm/llvm-project/pull/94732

https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits


@@ -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 = ?;

zero9178 wrote:

Since this semantically defaults to `And<[]>`, can we use this default value 
here?
`?` is difficult to deal with in my exeperience as it basically requires 
special casing everywhere.


https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits


@@ -1033,6 +1033,60 @@ while (true) {{
   emitVerifier(namedAttr.attr, namedAttr.name, getVarName(namedAttr.name));
 }
 
+static void genPropertyVerifier(const OpOrAdaptorHelper &emitHelper,
+FmtContext &ctx, MethodBody &body) {
+
+  // Code to get a reference to a property into a variable to avoid multiple
+  // evaluations while verifying a property.
+  // {0}: Property variable name.
+  // {1}: Property name, with the first letter capitalized, to find the getter.
+  // {2}: Property interface type.
+  const char *const fetchProperty = R"(
+  {2} {0} = this->get{1}(); (void){0};
+)";
+
+  // Code to verify that the predicate of a property holds. Embeds the
+  // condition inline.
+  // {0}: Property condition code, pre-tgfmt()'d.
+  // {1}: Emit error prefix.
+  // {2}: Property name.
+  // {3}: Property description.
+  const char *const verifyProperty = R"(
+  if (!({0}))
+return {1}"property '{2}' failed to satiisfy constraint: {3}");

zero9178 wrote:

```suggestion
return {1}"property '{2}' failed to satisfy constraint: {3}");
```

https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits


@@ -1033,6 +1033,60 @@ while (true) {{
   emitVerifier(namedAttr.attr, namedAttr.name, getVarName(namedAttr.name));
 }
 
+static void genPropertyVerifier(const OpOrAdaptorHelper &emitHelper,
+FmtContext &ctx, MethodBody &body) {
+
+  // Code to get a reference to a property into a variable to avoid multiple
+  // evaluations while verifying a property.
+  // {0}: Property variable name.
+  // {1}: Property name, with the first letter capitalized, to find the getter.
+  // {2}: Property interface type.
+  const char *const fetchProperty = R"(
+  {2} {0} = this->get{1}(); (void){0};
+)";
+
+  // Code to verify that the predicate of a property holds. Embeds the
+  // condition inline.
+  // {0}: Property condition code, pre-tgfmt()'d.
+  // {1}: Emit error prefix.
+  // {2}: Property name.
+  // {3}: Property description.
+  const char *const verifyProperty = R"(
+  if (!({0}))
+return {1}"property '{2}' failed to satiisfy constraint: {3}");
+)";
+
+  // Prefix variables with `tblgen_` to avoid hiding the attribute accessor.
+  const auto getVarName = [&](const NamedProperty &prop) {
+std::string varName =
+convertToCamelFromSnakeCase(prop.name, /*capitalizeFirst=*/false);
+return (tblgenNamePrefix + Twine(varName)).str();
+  };
+
+  body.indent();

zero9178 wrote:

The code here does nothing but indent the property verifier although no 
construct is output that would necessitate such indentation.

Did you mean to use `auto scope = body.scope("{", "}", /*indent=*/true)` 
instead?

https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits


@@ -1033,6 +1033,60 @@ while (true) {{
   emitVerifier(namedAttr.attr, namedAttr.name, getVarName(namedAttr.name));
 }
 
+static void genPropertyVerifier(const OpOrAdaptorHelper &emitHelper,
+FmtContext &ctx, MethodBody &body) {
+
+  // Code to get a reference to a property into a variable to avoid multiple
+  // evaluations while verifying a property.
+  // {0}: Property variable name.
+  // {1}: Property name, with the first letter capitalized, to find the getter.
+  // {2}: Property interface type.
+  const char *const fetchProperty = R"(
+  {2} {0} = this->get{1}(); (void){0};

zero9178 wrote:

```suggestion
  [[maybe_unused]] {2} {0} = this->get{1}();
```

https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits


@@ -1033,6 +1033,60 @@ while (true) {{
   emitVerifier(namedAttr.attr, namedAttr.name, getVarName(namedAttr.name));
 }
 
+static void genPropertyVerifier(const OpOrAdaptorHelper &emitHelper,
+FmtContext &ctx, MethodBody &body) {
+
+  // Code to get a reference to a property into a variable to avoid multiple
+  // evaluations while verifying a property.
+  // {0}: Property variable name.
+  // {1}: Property name, with the first letter capitalized, to find the getter.
+  // {2}: Property interface type.
+  const char *const fetchProperty = R"(
+  {2} {0} = this->get{1}(); (void){0};
+)";
+
+  // Code to verify that the predicate of a property holds. Embeds the
+  // condition inline.
+  // {0}: Property condition code, pre-tgfmt()'d.

zero9178 wrote:

```suggestion
  // {0}: Property condition code, post-tgfmt()'d.
```


https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits


@@ -342,14 +399,37 @@ class _makePropStorage {
 true : "") # ";";
 }
 
+/// Construct a `Pred`icate `ret` that wraps the predicate of the underlying
+/// property `childProp` with:
+///
+///   [](childProp.storageType& s) {
+/// return [](childProp.interfaceType i) {
+///   return leafSubst(childProp.predicate, "$_self" to "i");
+/// }(childProp.convertFromStorage(s))
+///   }
+///
+/// and then appends `prefix` and `suffix`.
+class _makeChildWrapperPred {

zero9178 wrote:

```suggestion
class _makeStorageWrapperPred {
```
Not 100% sure about the current name or the suggested name, but feel this 
explains the implementation a bit more precisely (effectively allowing us to 
use this predicate with the storage type instead)

Are `prefix` and `suffix` also strictly needed or could they be added by caller 
code using `Conat`? I feel this might make the code slightly easier to digest

https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits

https://github.com/zero9178 edited 
https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits

https://github.com/zero9178 edited 
https://github.com/llvm/llvm-project/pull/120176
___
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] MachineUniformityAnalysis: Improve isConstantOrUndefValuePhi (PR #112866)

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

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

>From 991bdf1a6de2e91732a3b9c443786243aaa58e91 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] AMDGPU/GlobalISel: RegBankLegalize rules for load (PR #112882)

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

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

>From 78ffc92ec65935c16caedc8ac3f9943e544c7dcd 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 5b32e96de12cb4..fec4ac1a15b5a9 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] [clang] [compiler-rt] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

2024-12-17 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/8] [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-17 Thread Florian Hahn 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(

fhahn wrote:

ditto

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-17 Thread Florian Hahn 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(

fhahn wrote:

This joins together paths for used in an environment variable, IIUC e.g. 
`os.path.join` will use `/` on macOS to join parts of a single path and 
`pathsep` will be `:` used to join together multiple multiple separate paths

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-17 Thread Florian Hahn 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:

fhahn wrote:

Removed, 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-17 Thread Florian Hahn 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

fhahn wrote:

Removed the conditional import, as we currently require Python >= 3.8 
https://llvm.org/docs/GettingStarted.html#software

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-17 Thread Florian Hahn 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);

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-17 Thread Florian Hahn 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(

fhahn wrote:

ditto

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-17 Thread Florian Hahn 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:

fhahn wrote:

Changed to check `if attr_value` and return value early.

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-17 Thread Florian Hahn 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

fhahn wrote:

Removed, 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-17 Thread Florian Mayer via llvm-branch-commits

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


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-17 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:

just confirming it is expected that empty string, or false, or something like 
that will now fail

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] [llvm] [19.x] Backport standalone build fixes for offload (PR #118643)

2024-12-17 Thread Tobias Hieta via llvm-branch-commits
=?utf-8?q?Michał_Górny?= ,
=?utf-8?q?Michał_Górny?= ,
=?utf-8?q?Michał_Górny?= ,
=?utf-8?q?Michał_Górny?= ,
=?utf-8?q?Michał_Górny?= 
Message-ID:
In-Reply-To: 


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

>From be6e2e72cb51f95c852e6d6567c8b2d066dfd19e Mon Sep 17 00:00:00 2001
From: estewart08 
Date: Mon, 19 Aug 2024 17:59:21 -0500
Subject: [PATCH 1/6] [offload] - Fix issue with standalone debug offload build
 (#104647)

Error: CommandLine Error: Option 'attributor-manifest-internal'
registered more than once

During the standalone debug build of offload the above error is seen at
app runtime when using a prebuilt llvm with LLVM_LINK_LLVM_DYLIB=ON.
This is caused by linking both libLLVM.so and various archives that are
found via llvm_map_components_to_libnames for jit support.
---
 offload/plugins-nextgen/common/CMakeLists.txt | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/offload/plugins-nextgen/common/CMakeLists.txt 
b/offload/plugins-nextgen/common/CMakeLists.txt
index 284f98875170cd..aea20c6ec31435 100644
--- a/offload/plugins-nextgen/common/CMakeLists.txt
+++ b/offload/plugins-nextgen/common/CMakeLists.txt
@@ -11,13 +11,15 @@ add_dependencies(PluginCommon intrinsics_gen)
 
 # Only enable JIT for those targets that LLVM can support.
 set(supported_jit_targets AMDGPU NVPTX)
-foreach(target IN LISTS supported_jit_targets)
-  if("${target}" IN_LIST LLVM_TARGETS_TO_BUILD)
- target_compile_definitions(PluginCommon PRIVATE 
"LIBOMPTARGET_JIT_${target}")
-llvm_map_components_to_libnames(llvm_libs ${target})
-target_link_libraries(PluginCommon PRIVATE ${llvm_libs})
-  endif()
-endforeach()
+if (NOT LLVM_LINK_LLVM_DYLIB)
+  foreach(target IN LISTS supported_jit_targets)
+if("${target}" IN_LIST LLVM_TARGETS_TO_BUILD)
+  target_compile_definitions(PluginCommon PRIVATE 
"LIBOMPTARGET_JIT_${target}")
+  llvm_map_components_to_libnames(llvm_libs ${target})
+  target_link_libraries(PluginCommon PRIVATE ${llvm_libs})
+endif()
+  endforeach()
+endif()
 
 # Include the RPC server from the `libc` project if availible.
 if(TARGET llvmlibc_rpc_server AND ${LIBOMPTARGET_GPU_LIBC_SUPPORT})

>From e3b2d0149ffadef53fe8165f55e648466c025416 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= 
Date: Sat, 30 Nov 2024 12:32:57 +0100
Subject: [PATCH 2/6] [offload] Include CheckCXXCompilerFlag in CMake

Include CheckCXXCompilerFlag before it is used in the top-level CMake
file.  This fixes standalone builds, but it is also cleaner than
assuming that some previous CMake file will include it for us.
---
 offload/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 4cd97a6a5ff63d..3ba892c76c8b8e 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -127,6 +127,7 @@ include(LibomptargetGetDependencies)
 # Set up testing infrastructure.
 include(OpenMPTesting)
 
+include(CheckCXXCompilerFlag)
 check_cxx_compiler_flag(-Werror=global-constructors OFFLOAD_HAVE_WERROR_CTOR)
 
 # LLVM source tree is required at build time for libomptarget

>From 5ce79b5045ae2e362fbd7b28351b10634d05b0f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= 
Date: Sat, 30 Nov 2024 15:32:39 +0100
Subject: [PATCH 3/6] [offload] [test] Add "omp" test dependency only when
 present

Add the `omp` target dependency to tests only when the respective target
is present, i.e. when not building standalone against system libomp.
---
 offload/test/CMakeLists.txt | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/offload/test/CMakeLists.txt b/offload/test/CMakeLists.txt
index 3ac5d7907e2cc2..c90ed26389faf6 100644
--- a/offload/test/CMakeLists.txt
+++ b/offload/test/CMakeLists.txt
@@ -22,6 +22,11 @@ if(CUDAToolkit_FOUND)
   get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
 endif()
 
+set(OMP_DEPEND)
+if(TARGET omp)
+  set(OMP_DEPEND omp)
+endif()
+
 string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS 
"${LIBOMPTARGET_SYSTEM_TARGETS}")
 foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
   string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)
@@ -29,7 +34,7 @@ foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
   add_offload_testsuite(check-libomptarget-${CURRENT_TARGET}
 "Running libomptarget tests"
 ${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET}
-DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS}
+DEPENDS omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
 ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
   list(APPEND LIBOMPTARGET_LIT_TESTSUITES 
${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET})
 
@@ -43,12 +48,12 @@ add_offload_testsuite(check-libomptarget
   "Running libomptarget tests"
   ${LIBOMPTARGET_LIT_TESTSUITES}
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS}
+  DEPENDS omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
   ARGS ${LIBOMPTARGET_LIT_AR

[llvm-branch-commits] [llvm] [19.x] Backport standalone build fixes for offload (PR #118643)

2024-12-17 Thread Tobias Hieta via llvm-branch-commits
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= ,
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= ,
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= ,
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= ,
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= 
Message-ID:
In-Reply-To: 


https://github.com/tru closed https://github.com/llvm/llvm-project/pull/118643
___
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] [19.x] Backport standalone build fixes for offload (PR #118643)

2024-12-17 Thread via llvm-branch-commits
=?utf-8?q?Michał_Górny?= ,
=?utf-8?q?Michał_Górny?= ,
=?utf-8?q?Michał_Górny?= ,
=?utf-8?q?Michał_Górny?= ,
=?utf-8?q?Michał_Górny?= 
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:

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


[llvm-branch-commits] [llvm] release/19.x: [Matrix] Skip already fused instructions before trying to fuse multiply. (PR #118020)

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

fhahn wrote:

@anemet or @francisvm , but at this point it may not be worth trying to pick 
this

https://github.com/llvm/llvm-project/pull/118020
___
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-17 Thread via llvm-branch-commits

github-actions[bot] wrote:

@nikic (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/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] 8069ce6 - [WebAssembly] Support multiple `.init_array` fragments when writing Wasm objects (#111008)

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

Author: George Stagg
Date: 2024-12-17T10:12:46+01:00
New Revision: 8069ce6ab1766a166b956192ad72c143be3b860e

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

LOG: [WebAssembly] Support multiple `.init_array` fragments when writing Wasm 
objects (#111008)

(cherry picked from commit ac5dd455caaf286625f61b604291f2eaed9702f0)

Added: 
llvm/test/MC/WebAssembly/init-array.s

Modified: 
llvm/lib/MC/WasmObjectWriter.cpp

Removed: 




diff  --git a/llvm/lib/MC/WasmObjectWriter.cpp 
b/llvm/lib/MC/WasmObjectWriter.cpp
index f25dc92fa235a2..a66c5713ff8a6e 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1853,49 +1853,54 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler 
&Asm,
 if (EmptyFrag.getKind() != MCFragment::FT_Data)
   report_fatal_error(".init_array section should be aligned");
 
-const MCFragment &AlignFrag = *EmptyFrag.getNext();
-if (AlignFrag.getKind() != MCFragment::FT_Align)
-  report_fatal_error(".init_array section should be aligned");
-if (cast(AlignFrag).getAlignment() !=
-Align(is64Bit() ? 8 : 4))
-  report_fatal_error(".init_array section should be aligned for pointers");
-
-const MCFragment &Frag = *AlignFrag.getNext();
-if (Frag.hasInstructions() || Frag.getKind() != MCFragment::FT_Data)
-  report_fatal_error("only data supported in .init_array section");
-
-uint16_t Priority = UINT16_MAX;
-unsigned PrefixLength = strlen(".init_array");
-if (WS.getName().size() > PrefixLength) {
-  if (WS.getName()[PrefixLength] != '.')
+const MCFragment *nextFrag = EmptyFrag.getNext();
+while (nextFrag != nullptr) {
+  const MCFragment &AlignFrag = *nextFrag;
+  if (AlignFrag.getKind() != MCFragment::FT_Align)
+report_fatal_error(".init_array section should be aligned");
+  if (cast(AlignFrag).getAlignment() !=
+  Align(is64Bit() ? 8 : 4))
 report_fatal_error(
-".init_array section priority should start with '.'");
-  if (WS.getName().substr(PrefixLength + 1).getAsInteger(10, Priority))
-report_fatal_error("invalid .init_array section priority");
-}
-const auto &DataFrag = cast(Frag);
-const SmallVectorImpl &Contents = DataFrag.getContents();
-for (const uint8_t *
- P = (const uint8_t *)Contents.data(),
-*End = (const uint8_t *)Contents.data() + Contents.size();
- P != End; ++P) {
-  if (*P != 0)
-report_fatal_error("non-symbolic data in .init_array section");
-}
-for (const MCFixup &Fixup : DataFrag.getFixups()) {
-  assert(Fixup.getKind() ==
- MCFixup::getKindForSize(is64Bit() ? 8 : 4, false));
-  const MCExpr *Expr = Fixup.getValue();
-  auto *SymRef = dyn_cast(Expr);
-  if (!SymRef)
-report_fatal_error("fixups in .init_array should be symbol 
references");
-  const auto &TargetSym = cast(SymRef->getSymbol());
-  if (TargetSym.getIndex() == InvalidIndex)
-report_fatal_error("symbols in .init_array should exist in symtab");
-  if (!TargetSym.isFunction())
-report_fatal_error("symbols in .init_array should be for functions");
-  InitFuncs.push_back(
-  std::make_pair(Priority, TargetSym.getIndex()));
+".init_array section should be aligned for pointers");
+
+  const MCFragment &Frag = *AlignFrag.getNext();
+  nextFrag = Frag.getNext();
+  if (Frag.hasInstructions() || Frag.getKind() != MCFragment::FT_Data)
+report_fatal_error("only data supported in .init_array section");
+
+  uint16_t Priority = UINT16_MAX;
+  unsigned PrefixLength = strlen(".init_array");
+  if (WS.getName().size() > PrefixLength) {
+if (WS.getName()[PrefixLength] != '.')
+  report_fatal_error(
+  ".init_array section priority should start with '.'");
+if (WS.getName().substr(PrefixLength + 1).getAsInteger(10, Priority))
+  report_fatal_error("invalid .init_array section priority");
+  }
+  const auto &DataFrag = cast(Frag);
+  const SmallVectorImpl &Contents = DataFrag.getContents();
+  for (const uint8_t *
+   P = (const uint8_t *)Contents.data(),
+  *End = (const uint8_t *)Contents.data() + Contents.size();
+   P != End; ++P) {
+if (*P != 0)
+  report_fatal_error("non-symbolic data in .init_array section");
+  }
+  for (const MCFixup &Fixup : DataFrag.getFixups()) {
+assert(Fixup.getKind() ==
+   MCFixup::getKindForSize(is64Bit() ? 8 : 4, false));
+const MCExpr *Expr = Fixup.getValue();
+auto *SymRef = dyn_cast(Expr);
+if (!SymRef)
+  report_fatal_error(
+  "fixups in .in

[llvm-branch-commits] [llvm] 8e9465b - [WebAssembly] Handle symbols in `.init_array` sections (#119127)

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

Author: George Stagg
Date: 2024-12-17T10:12:46+01:00
New Revision: 8e9465bd150bcbe2d200efc7c0e31abf8ddebe58

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

LOG: [WebAssembly] Handle symbols in `.init_array` sections (#119127)

Follow on from #111008.

(cherry picked from commit ed91843d435d0cd2c39ebb1a50f2907c621f07ed)

Added: 
llvm/test/MC/WebAssembly/init-array-label.s

Modified: 
llvm/lib/MC/WasmObjectWriter.cpp

Removed: 




diff  --git a/llvm/lib/MC/WasmObjectWriter.cpp 
b/llvm/lib/MC/WasmObjectWriter.cpp
index a66c5713ff8a6e..85264692456767 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1326,6 +1326,22 @@ static bool isInSymtab(const MCSymbolWasm &Sym) {
   return true;
 }
 
+static bool isSectionReferenced(MCAssembler &Asm, MCSectionWasm &Section) {
+  StringRef SectionName = Section.getName();
+
+  for (const MCSymbol &S : Asm.symbols()) {
+const auto &WS = static_cast(S);
+if (WS.isData() && WS.isInSection()) {
+  auto &RefSection = static_cast(WS.getSection());
+  if (RefSection.getName() == SectionName) {
+return true;
+  }
+}
+  }
+
+  return false;
+}
+
 void WasmObjectWriter::prepareImports(
 SmallVectorImpl &Imports, MCAssembler &Asm) {
   // For now, always emit the memory import, since loads and stores are not
@@ -1482,8 +1498,10 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler 
&Asm,
 LLVM_DEBUG(dbgs() << "Processing Section " << SectionName << "  group "
   << Section.getGroup() << "\n";);
 
-// .init_array sections are handled specially elsewhere.
-if (SectionName.starts_with(".init_array"))
+// .init_array sections are handled specially elsewhere, include them in
+// data segments if and only if referenced by a symbol.
+if (SectionName.starts_with(".init_array") &&
+!isSectionReferenced(Asm, Section))
   continue;
 
 // Code is handled separately

diff  --git a/llvm/test/MC/WebAssembly/init-array-label.s 
b/llvm/test/MC/WebAssembly/init-array-label.s
new file mode 100644
index 00..0b4a5ea2da0b59
--- /dev/null
+++ b/llvm/test/MC/WebAssembly/init-array-label.s
@@ -0,0 +1,91 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | obj2yaml | 
FileCheck %s
+
+init1:
+   .functype   init1 () -> ()
+   end_function
+
+init2:
+   .functype   init2 () -> ()
+   end_function
+
+   .section.init_array.42,"",@
+   .p2align2, 0x0
+   .int32  init1
+
+   .section.init_array,"",@
+   .globl  p_init1
+   .p2align2, 0x0
+p_init1:
+   .int32  init1
+   .size   p_init1, 4
+
+   .section.init_array,"",@
+   .globl  p_init2
+   .p2align2, 0x0
+p_init2:
+   .int32  init1
+   .int32  init2
+   .size   p_init2, 8
+
+# CHECK:- Type:FUNCTION
+# CHECK-NEXT: FunctionTypes:   [ 0, 0 ]
+# CHECK-NEXT:   - Type:DATACOUNT
+# CHECK-NEXT: Count:   1
+# CHECK-NEXT:   - Type:CODE
+# CHECK-NEXT: Functions:
+# CHECK-NEXT:   - Index:   0
+# CHECK-NEXT: Locals:  []
+# CHECK-NEXT: Body:0B
+# CHECK-NEXT:   - Index:   1
+# CHECK-NEXT: Locals:  []
+# CHECK-NEXT: Body:0B
+# CHECK-NEXT:   - Type:DATA
+# CHECK-NEXT: Segments:
+# CHECK-NEXT:   - SectionOffset:   6
+# CHECK-NEXT: InitFlags:   0
+# CHECK-NEXT: Offset:
+# CHECK-NEXT:   Opcode:  I32_CONST
+# CHECK-NEXT:   Value:   0
+# CHECK-NEXT: Content: ''
+# CHECK-NEXT:   - Type:CUSTOM
+# CHECK-NEXT: Name:linking
+# CHECK-NEXT: Version: 2
+# CHECK-NEXT: SymbolTable:
+# CHECK-NEXT:   - Index:   0
+# CHECK-NEXT: Kind:FUNCTION
+# CHECK-NEXT: Name:init1
+# CHECK-NEXT: Flags:   [ BINDING_LOCAL ]
+# CHECK-NEXT: Function:0
+# CHECK-NEXT:   - Index:   1
+# CHECK-NEXT: Kind:FUNCTION
+# CHECK-NEXT: Name:init2
+# CHECK-NEXT: Flags:   [ BINDING_LOCAL ]
+# CHECK-NEXT: Function:1
+# CHECK-NEXT:   - Index:   2
+# CHECK-NEXT: Kind:DATA
+# CHECK-NEXT: Name:p_init1
+# CHECK-NEXT: Flags:   [  ]
+# CHECK-NEXT: Segment: 0
+# CHECK-NEXT: Size:4
+# CHECK-NEXT:   - Index:   3
+# CHECK-NEXT: Kind:DATA
+# CHECK-NEXT: Name:p_init2
+# CHECK-NEXT: Fl

[llvm-branch-commits] [llvm] release/19.x: [WebAssembly] Handle symbols in `.init_array` sections (#119127) (PR #119533)

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

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


[llvm-branch-commits] [llvm] release/19.x: [WebAssembly] Handle symbols in `.init_array` sections (#119127) (PR #119533)

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

github-actions[bot] wrote:

@nikic (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/119533
___
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-17 Thread Daniil Kovalev via llvm-branch-commits

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

>From 0caff13d6748f8c2d14608412db80eb5bba5fe71 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Mon, 21 Oct 2024 12:18:56 +0300
Subject: [PATCH 1/6] [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 4105d38d15d7d8..71f98704e334c4 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3067,6 +3067,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] [llvm] release/19.x: [RISCV] Fix typo in CV_SH_rr_inc pattern (#120246) (PR #120296)

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

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v

Author: None (llvmbot)


Changes

Backport e8ce6c4

Requested by: @topperc

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


1 Files Affected:

- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td (+1-1) 


``diff
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
index 3bd6da28682863..99485981701479 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
@@ -694,7 +694,7 @@ let Predicates = [HasVendorXCVmem, IsRV32], AddedComplexity 
= 1 in {
   def : CVStriPat;
 
   def : CVStrriPat;
-  def : CVStrriPat;
+  def : CVStrriPat;
   def : CVStrriPat;
 
   def : CVStrrPat;

``




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


[llvm-branch-commits] [llvm] release/19.x: [RISCV] Fix typo in CV_SH_rr_inc pattern (#120246) (PR #120296)

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

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


[llvm-branch-commits] [llvm] release/19.x: [RISCV] Fix typo in CV_SH_rr_inc pattern (#120246) (PR #120296)

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

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

Backport e8ce6c4

Requested by: @topperc

>From 032b352c2ba61eab447d08fd7cd86fbaee36be10 Mon Sep 17 00:00:00 2001
From: Philipp van Kempen 
Date: Tue, 17 Dec 2024 21:20:17 +0100
Subject: [PATCH] [RISCV] Fix typo in CV_SH_rr_inc pattern (#120246)

This typo in
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td#L701:L701
caused a compiler crash in 'RISC-V Assembly Printer' because
CV_SH_ri_inc was selected, leading to `getImmOpValue` being called for a
register operand.

This bug did not affect the Assembler output and therefore does not
trigger any existing unit tests, but is visible by examining the final
MIR function.

(cherry picked from commit e8ce6c4e69745b1b2cd6f7479c48fbae44622cb3)
---
 llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
index 3bd6da28682863..99485981701479 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
@@ -694,7 +694,7 @@ let Predicates = [HasVendorXCVmem, IsRV32], AddedComplexity 
= 1 in {
   def : CVStriPat;
 
   def : CVStrriPat;
-  def : CVStrriPat;
+  def : CVStrriPat;
   def : CVStrriPat;
 
   def : CVStrrPat;

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


[llvm-branch-commits] [llvm] release/19.x: [RISCV] Fix typo in CV_SH_rr_inc pattern (#120246) (PR #120296)

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

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/120296
___
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][clang] Handle pauthtest environment and ABI in Linux-specific code (PR #113151)

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

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

>From 74c5de129cd4a1e90463aa9ad05b1b90bd3ff981 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 5ac3eefbd6c518..e0f3eca8b12258 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] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)

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

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

>From 0caff13d6748f8c2d14608412db80eb5bba5fe71 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Mon, 21 Oct 2024 12:18:56 +0300
Subject: [PATCH 1/7] [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 4105d38d15d7d8..71f98704e334c4 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3067,6 +3067,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][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)

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


@@ -15,50 +16,85 @@
 // RUN:   -fno-ptrauth-indirect-gotos -fptrauth-indirect-gotos \
 // RUN:   -fno-ptrauth-init-fini -fptrauth-init-fini \
 // RUN:   -fno-ptrauth-init-fini-address-discrimination 
-fptrauth-init-fini-address-discrimination \
+// RUN:   -fno-ptrauth-elf-got -fptrauth-elf-got \
 // RUN:   -fno-aarch64-jump-table-hardening -faarch64-jump-table-hardening \
-// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL
-// ALL: "-cc1"{{.*}} "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" 
"-fptrauth-type-info-vtable-pointer-discrimination" "-fptrauth-indirect-gotos" 
"-fptrauth-init-fini" "-fptrauth-init-fini-address-discrimination" 
"-faarch64-jump-table-hardening"
+// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL-LINUX-PAUTHTEST
+// RUN: %clang -### -c --target=aarch64-linux-pauthtest \
+// RUN:   -fno-ptrauth-intrinsics -fptrauth-intrinsics \
+// RUN:   -fno-ptrauth-calls -fptrauth-calls \
+// RUN:   -fno-ptrauth-returns -fptrauth-returns \
+// RUN:   -fno-ptrauth-auth-traps -fptrauth-auth-traps \
+// RUN:   -fno-ptrauth-vtable-pointer-address-discrimination 
-fptrauth-vtable-pointer-address-discrimination \
+// RUN:   -fno-ptrauth-vtable-pointer-type-discrimination 
-fptrauth-vtable-pointer-type-discrimination \
+// RUN:   -fno-ptrauth-type-info-vtable-pointer-discrimination 
-fptrauth-type-info-vtable-pointer-discrimination \
+// RUN:   -fno-ptrauth-indirect-gotos -fptrauth-indirect-gotos \
+// RUN:   -fno-ptrauth-init-fini -fptrauth-init-fini \
+// RUN:   -fno-ptrauth-init-fini-address-discrimination 
-fptrauth-init-fini-address-discrimination \
+// RUN:   -fno-ptrauth-elf-got -fptrauth-elf-got \
+// RUN:   -fno-aarch64-jump-table-hardening -faarch64-jump-table-hardening \
+// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL-LINUX-PAUTHTEST
+// ALL-LINUX-PAUTHTEST: "-cc1"{{.*}} "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" 
"-fptrauth-type-info-vtable-pointer-discrimination" "-fptrauth-indirect-gotos" 
"-fptrauth-init-fini" "-fptrauth-init-fini-address-discrimination" 
"-fptrauth-elf-got"{{.*}} "-faarch64-jump-table-hardening"
 
-// RUN: %clang -### -c --target=aarch64-linux -mabi=pauthtest %s 2>&1 | 
FileCheck %s --check-prefix=PAUTHABI1
-// RUN: %clang -### -c --target=aarch64-linux-pauthtest %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHABI1
-// PAUTHABI1:  "-cc1"{{.*}} "-triple" "aarch64-unknown-linux-pauthtest"
-// PAUTHABI1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" 
"-fptrauth-type-info-vtable-pointer-discrimination" "-fptrauth-indirect-gotos" 
"-fptrauth-init-fini" "-fptrauth-init-fini-address-discrimination" 
"-faarch64-jump-table-hardening"
-// PAUTHABI1-SAME: "-target-abi" "pauthtest"
-// PAUTHABI1-NOT: "-fptrauth-function-pointer-type-discrimination"
+// RUN: %clang -### -c --target=aarch64-linux \
+// RUN:   -fno-aarch64-jump-table-hardening -faarch64-jump-table-hardening \
+// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL-LINUX
+// ALL-LINUX: "-cc1"{{.*}} "-faarch64-jump-table-hardening"
+
+ Some -fptrauth-* flags are supported for ARM64 Darwin.
+// RUN: %clang -### -c --target=arm64-darwin \
+// RUN:   -fno-ptrauth-intrinsics -fptrauth-intrinsics \
+// RUN:   -fno-ptrauth-calls -fptrauth-calls \
+// RUN:   -fno-ptrauth-returns -fptrauth-returns \
+// RUN:   -fno-ptrauth-auth-traps -fptrauth-auth-traps \
+// RUN:   -fno-ptrauth-vtable-pointer-address-discrimination 
-fptrauth-vtable-pointer-address-discrimination \
+// RUN:   -fno-ptrauth-vtable-pointer-type-discrimination 
-fptrauth-vtable-pointer-type-discrimination \
+// RUN:   -fno-ptrauth-type-info-vtable-pointer-discrimination 
-fptrauth-type-info-vtable-pointer-discrimination \
+// RUN:   -fno-ptrauth-indirect-gotos -fptrauth-indirect-gotos \
+// RUN:   -fno-aarch64-jump-table-hardening -faarch64-jump-table-hardening \
+// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL-DARWIN
+// ALL-DARWIN: "-cc1"{{.*}} "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" 
"-fptrauth-type-info-vtable-pointer-discrimination" 
"-fptrauth-indirect-gotos"{{.*}} "-faarch64-jump-table-hardening"
+
+// RUN: %clang -### -c --target=aarch64-linux -mabi=pauthtest %s 2>&1 | 
FileCheck %s --check-prefix=PAUTHTEST1
+// RUN: %clang -### -c --target=aarch64-linux-pauthtest %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHTEST1
+// PAUTHTEST1:  "-cc1"{{.*}} "-triple" "aarch64-unknown-linux-pauthtest"
+// PAUTHTEST1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-

[llvm-branch-commits] [llvm] release/19.x: [RISCV] Fix typo in CV_SH_rr_inc pattern (#120246) (PR #120296)

2024-12-17 Thread Sam Elliott via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/120296
___
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-17 Thread Sarah Spall via llvm-branch-commits

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

LGTM

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] [clang-tools-extra] [clang-doc] Use LangOpts when printing types (PR #120308)

2024-12-17 Thread Petr Hosek via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/120308
___
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] [NFC][BoundsChecking] Add TrapBB local variable (PR #119983)

2024-12-17 Thread Kirill Stoimenov via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/119983
___
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] [TRI] Remove reserved registers in getRegPressureSetLimit (PR #118787)

2024-12-17 Thread Craig Topper via llvm-branch-commits

topperc wrote:

Should we just rename the TRI function to discourage use and encourage everyone 
to use RegClassInfo?

https://github.com/llvm/llvm-project/pull/118787
___
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-17 Thread Krzysztof Drewniak via llvm-branch-commits


@@ -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 = ?;

krzysz00 wrote:

The trouble with `And<[]>` is that it's hard to detect and I'd like to say "if 
X doesn't have a predicate, then OptionalProperty doesn't either"

I was considering going an adding explicit True and False cases to the 
predicate combiner kind but that sameed invasive

... Also, I don't think the And<[]> detector works 

https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Fangrui Song via llvm-branch-commits


@@ -15,50 +16,85 @@
 // RUN:   -fno-ptrauth-indirect-gotos -fptrauth-indirect-gotos \
 // RUN:   -fno-ptrauth-init-fini -fptrauth-init-fini \
 // RUN:   -fno-ptrauth-init-fini-address-discrimination 
-fptrauth-init-fini-address-discrimination \
+// RUN:   -fno-ptrauth-elf-got -fptrauth-elf-got \
 // RUN:   -fno-aarch64-jump-table-hardening -faarch64-jump-table-hardening \
-// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL
-// ALL: "-cc1"{{.*}} "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" 
"-fptrauth-type-info-vtable-pointer-discrimination" "-fptrauth-indirect-gotos" 
"-fptrauth-init-fini" "-fptrauth-init-fini-address-discrimination" 
"-faarch64-jump-table-hardening"
+// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL-LINUX-PAUTHTEST
+// RUN: %clang -### -c --target=aarch64-linux-pauthtest \
+// RUN:   -fno-ptrauth-intrinsics -fptrauth-intrinsics \
+// RUN:   -fno-ptrauth-calls -fptrauth-calls \
+// RUN:   -fno-ptrauth-returns -fptrauth-returns \
+// RUN:   -fno-ptrauth-auth-traps -fptrauth-auth-traps \
+// RUN:   -fno-ptrauth-vtable-pointer-address-discrimination 
-fptrauth-vtable-pointer-address-discrimination \
+// RUN:   -fno-ptrauth-vtable-pointer-type-discrimination 
-fptrauth-vtable-pointer-type-discrimination \
+// RUN:   -fno-ptrauth-type-info-vtable-pointer-discrimination 
-fptrauth-type-info-vtable-pointer-discrimination \
+// RUN:   -fno-ptrauth-indirect-gotos -fptrauth-indirect-gotos \
+// RUN:   -fno-ptrauth-init-fini -fptrauth-init-fini \
+// RUN:   -fno-ptrauth-init-fini-address-discrimination 
-fptrauth-init-fini-address-discrimination \
+// RUN:   -fno-ptrauth-elf-got -fptrauth-elf-got \
+// RUN:   -fno-aarch64-jump-table-hardening -faarch64-jump-table-hardening \
+// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL-LINUX-PAUTHTEST
+// ALL-LINUX-PAUTHTEST: "-cc1"{{.*}} "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" 
"-fptrauth-type-info-vtable-pointer-discrimination" "-fptrauth-indirect-gotos" 
"-fptrauth-init-fini" "-fptrauth-init-fini-address-discrimination" 
"-fptrauth-elf-got"{{.*}} "-faarch64-jump-table-hardening"
 
-// RUN: %clang -### -c --target=aarch64-linux -mabi=pauthtest %s 2>&1 | 
FileCheck %s --check-prefix=PAUTHABI1
-// RUN: %clang -### -c --target=aarch64-linux-pauthtest %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHABI1
-// PAUTHABI1:  "-cc1"{{.*}} "-triple" "aarch64-unknown-linux-pauthtest"
-// PAUTHABI1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" 
"-fptrauth-type-info-vtable-pointer-discrimination" "-fptrauth-indirect-gotos" 
"-fptrauth-init-fini" "-fptrauth-init-fini-address-discrimination" 
"-faarch64-jump-table-hardening"
-// PAUTHABI1-SAME: "-target-abi" "pauthtest"
-// PAUTHABI1-NOT: "-fptrauth-function-pointer-type-discrimination"
+// RUN: %clang -### -c --target=aarch64-linux \
+// RUN:   -fno-aarch64-jump-table-hardening -faarch64-jump-table-hardening \
+// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL-LINUX
+// ALL-LINUX: "-cc1"{{.*}} "-faarch64-jump-table-hardening"
+
+ Some -fptrauth-* flags are supported for ARM64 Darwin.
+// RUN: %clang -### -c --target=arm64-darwin \
+// RUN:   -fno-ptrauth-intrinsics -fptrauth-intrinsics \
+// RUN:   -fno-ptrauth-calls -fptrauth-calls \
+// RUN:   -fno-ptrauth-returns -fptrauth-returns \
+// RUN:   -fno-ptrauth-auth-traps -fptrauth-auth-traps \
+// RUN:   -fno-ptrauth-vtable-pointer-address-discrimination 
-fptrauth-vtable-pointer-address-discrimination \
+// RUN:   -fno-ptrauth-vtable-pointer-type-discrimination 
-fptrauth-vtable-pointer-type-discrimination \
+// RUN:   -fno-ptrauth-type-info-vtable-pointer-discrimination 
-fptrauth-type-info-vtable-pointer-discrimination \
+// RUN:   -fno-ptrauth-indirect-gotos -fptrauth-indirect-gotos \
+// RUN:   -fno-aarch64-jump-table-hardening -faarch64-jump-table-hardening \
+// RUN:   %s 2>&1 | FileCheck %s --check-prefix=ALL-DARWIN
+// ALL-DARWIN: "-cc1"{{.*}} "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" 
"-fptrauth-type-info-vtable-pointer-discrimination" 
"-fptrauth-indirect-gotos"{{.*}} "-faarch64-jump-table-hardening"
+
+// RUN: %clang -### -c --target=aarch64-linux -mabi=pauthtest %s 2>&1 | 
FileCheck %s --check-prefix=PAUTHTEST1
+// RUN: %clang -### -c --target=aarch64-linux-pauthtest %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHTEST1
+// PAUTHTEST1:  "-cc1"{{.*}} "-triple" "aarch64-unknown-linux-pauthtest"
+// PAUTHTEST1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-

[llvm-branch-commits] [clang] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)

2024-12-17 Thread Fangrui Song via llvm-branch-commits

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


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] [compiler-rt] [llvm] [TySan] Improved compatability for tests (PR #96507)

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

https://github.com/fhahn closed https://github.com/llvm/llvm-project/pull/96507
___
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] [llvm] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

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

https://github.com/fhahn closed https://github.com/llvm/llvm-project/pull/95387
___
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] [llvm] [TySan] Fix struct access with different bases (PR #108385)

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

https://github.com/fhahn closed https://github.com/llvm/llvm-project/pull/108385
___
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] TypedUAVLoadAdditionalFormats shader flag (PR #120280)

2024-12-17 Thread Helena Kotas via llvm-branch-commits

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

LGTM!

https://github.com/llvm/llvm-project/pull/120280
___
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-format] Fix idempotent format of hash in macro body (#118513) (PR #119503)

2024-12-17 Thread Owen Pan via llvm-branch-commits

owenca wrote:

> can we get a review on this?

I already approved it.

https://github.com/llvm/llvm-project/pull/119503
___
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-17 Thread Markus Böck via llvm-branch-commits


@@ -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 = ?;

zero9178 wrote:

I thought about it some more and pros- and cons in my head are:
* If you want to optimize the TableGen code such that the code is less (using 
the various `!if` constructs seen here), both `?` and `And<[]>` semantically 
are just as capable as they can both be checked for (`!initialized` and `!eq`) 
and special cased. Admittedly, I think that choosing `And<[]>` as the canonical 
"true" representation is more arbitrary, but both are to an extent and it is 
only for "readability of the outputted C++" optimization anyways. It could also 
be mitigated by defining `defvar True = And<[]>`, making it more readable.
* The con of `?` is that it **requires** classes such as `Optional` to special 
case `?`, while the `And<[]>` representation would not, making it purely an 
opt-in optimization, and not a semantic requirement for composing properties. 

Due to the last point I am therefore still leaning towards `And<[]>` as 
default. I also think in an ideal world it is the backend emitter that would 
optimize this but that is besides the point.
Would also love to hear other's opinion as I could live with the `?` default if 
others feel more strongly about it.

https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits

https://github.com/zero9178 edited 
https://github.com/llvm/llvm-project/pull/120176
___
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-17 Thread Markus Böck via llvm-branch-commits


@@ -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 = ?;

zero9178 wrote:

What is the use case for detecting this/propagating this to `OptionalProperty`? 
Is this purely as an optimization for the generated code (for e.g. debug 
builds) or do we need this semantics accessible from within TableGen? I'd 
rather have this optimization implemented in C++ and not have the public API 
suffer because of it.

https://github.com/llvm/llvm-project/pull/120176
___
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-doc][NFC] Use isa over dyn_cast (PR #120309)

2024-12-17 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi created 
https://github.com/llvm/llvm-project/pull/120309

These call sites don't need the cast, as they don't use the value.



___
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-doc] Use LangOpts when printing types (PR #120308)

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

llvmbot wrote:




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

Author: Paul Kirth (ilovepi)


Changes

The implementation in the clang-doc serializer failed to take in the
LangOpts from the declaration. Asa result, we'd do things like print
`_Bool` instead of `bool`, even in C++ code.

Fixes #62970


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


4 Files Affected:

- (modified) clang-tools-extra/clang-doc/Serialize.cpp (+13-8) 
- (modified) clang-tools-extra/test/clang-doc/basic.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-doc/templates.cpp (+6-6) 
- (modified) clang-tools-extra/unittests/clang-doc/SerializeTest.cpp (+4-2) 


``diff
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp 
b/clang-tools-extra/clang-doc/Serialize.cpp
index b9db78cf7d688f..ddac5399b966d4 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -236,10 +236,10 @@ static RecordDecl *getRecordDeclForType(const QualType 
&T) {
   return nullptr;
 }
 
-TypeInfo getTypeInfoForType(const QualType &T) {
+TypeInfo getTypeInfoForType(const QualType &T, const PrintingPolicy& Policy) {
   const TagDecl *TD = getTagDeclForType(T);
   if (!TD)
-return TypeInfo(Reference(SymbolID(), T.getAsString()));
+return TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
 
   InfoType IT;
   if (dyn_cast(TD)) {
@@ -250,7 +250,7 @@ TypeInfo getTypeInfoForType(const QualType &T) {
 IT = InfoType::IT_default;
   }
   return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
-T.getAsString(), getInfoRelativePath(TD)));
+T.getAsString(Policy), getInfoRelativePath(TD)));
 }
 
 static bool isPublic(const clang::AccessSpecifier AS,
@@ -379,10 +379,11 @@ static void parseFields(RecordInfo &I, const RecordDecl 
*D, bool PublicOnly,
 if (!shouldSerializeInfo(PublicOnly, /*IsInAnonymousNamespace=*/false, F))
   continue;
 
+auto &LO = F->getLangOpts();
 // Use getAccessUnsafe so that we just get the default AS_none if it's not
 // valid, as opposed to an assert.
 MemberTypeInfo &NewMember = I.Members.emplace_back(
-getTypeInfoForType(F->getTypeSourceInfo()->getType()),
+getTypeInfoForType(F->getTypeSourceInfo()->getType(), LO),
 F->getNameAsString(),
 getFinalAccessSpecifier(Access, F->getAccessUnsafe()));
 populateMemberTypeInfo(NewMember, F);
@@ -412,9 +413,10 @@ static void parseEnumerators(EnumInfo &I, const EnumDecl 
*D) {
 }
 
 static void parseParameters(FunctionInfo &I, const FunctionDecl *D) {
+auto &LO = D->getLangOpts();
   for (const ParmVarDecl *P : D->parameters()) {
 FieldTypeInfo &FieldInfo = I.Params.emplace_back(
-getTypeInfoForType(P->getOriginalType()), P->getNameAsString());
+getTypeInfoForType(P->getOriginalType(), LO), P->getNameAsString());
 FieldInfo.DefaultValue = getSourceCode(D, P->getDefaultArgRange());
   }
 }
@@ -541,7 +543,8 @@ static void populateFunctionInfo(FunctionInfo &I, const 
FunctionDecl *D,
  bool &IsInAnonymousNamespace) {
   populateSymbolInfo(I, D, FC, LineNumber, Filename, IsFileInRootDir,
  IsInAnonymousNamespace);
-  I.ReturnType = getTypeInfoForType(D->getReturnType());
+auto &LO = D->getLangOpts();
+  I.ReturnType = getTypeInfoForType(D->getReturnType(), LO);
   parseParameters(I, D);
 
   PopulateTemplateParameters(I.Template, D);
@@ -783,7 +786,8 @@ emitInfo(const TypedefDecl *D, const FullComment *FC, int 
LineNumber,
 return {};
 
   Info.DefLoc.emplace(LineNumber, File, IsFileInRootDir);
-  Info.Underlying = getTypeInfoForType(D->getUnderlyingType());
+  auto &LO = D->getLangOpts();
+  Info.Underlying = getTypeInfoForType(D->getUnderlyingType(), LO);
   if (Info.Underlying.Type.Name.empty()) {
 // Typedef for an unnamed type. This is like "typedef struct { } Foo;"
 // The record serializer explicitly checks for this syntax and constructs
@@ -809,7 +813,8 @@ emitInfo(const TypeAliasDecl *D, const FullComment *FC, int 
LineNumber,
 return {};
 
   Info.DefLoc.emplace(LineNumber, File, IsFileInRootDir);
-  Info.Underlying = getTypeInfoForType(D->getUnderlyingType());
+  auto &LO = D->getLangOpts();
+  Info.Underlying = getTypeInfoForType(D->getUnderlyingType(), LO);
   Info.IsUsing = true;
 
   // Info is wrapped in its parent scope so is returned in the second position.
diff --git a/clang-tools-extra/test/clang-doc/basic.cpp 
b/clang-tools-extra/test/clang-doc/basic.cpp
index 318a271a9af04e..539ce8190ebbed 100644
--- a/clang-tools-extra/test/clang-doc/basic.cpp
+++ b/clang-tools-extra/test/clang-doc/basic.cpp
@@ -23,11 +23,11 @@ extern bool b();
 // YAML-NEXT: Filename:'{{.*}}'
 // YAML-NEXT: ReturnType:
 // YAML-NEXT:   Type:
-// YAML-NEXT: Name:'_Bool'
-// YAML-NEXT: QualName:'_Bool'
+// YAML-NEXT: Name:'

[llvm-branch-commits] [clang-doc] Use LangOpts when printing types (PR #120308)

2024-12-17 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi created 
https://github.com/llvm/llvm-project/pull/120308

The implementation in the clang-doc serializer failed to take in the
LangOpts from the declaration. Asa result, we'd do things like print
`_Bool` instead of `bool`, even in C++ code.

Fixes #62970



___
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-doc][NFC] Use isa over dyn_cast (PR #120309)

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

llvmbot wrote:




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

Author: Paul Kirth (ilovepi)


Changes

These call sites don't need the cast, as they don't use the value.


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


1 Files Affected:

- (modified) clang-tools-extra/clang-doc/Serialize.cpp (+2-2) 


``diff
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp 
b/clang-tools-extra/clang-doc/Serialize.cpp
index b9db78cf7d688f..34b9121d3154ed 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -242,9 +242,9 @@ TypeInfo getTypeInfoForType(const QualType &T) {
 return TypeInfo(Reference(SymbolID(), T.getAsString()));
 
   InfoType IT;
-  if (dyn_cast(TD)) {
+  if (isa(TD)) {
 IT = InfoType::IT_enum;
-  } else if (dyn_cast(TD)) {
+  } else if (isa(TD)) {
 IT = InfoType::IT_record;
   } else {
 IT = InfoType::IT_default;

``




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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] Use LangOpts when printing types (PR #120308)

2024-12-17 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/120308

>From ac3ce2e8bacdf6b2e7f7d812b16b2854d5ca34f2 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 17 Dec 2024 13:58:09 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?=
 =?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1

[skip ci]
---
 clang-tools-extra/test/clang-doc/basic.cpp | 136 +
 1 file changed, 136 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/basic.cpp

diff --git a/clang-tools-extra/test/clang-doc/basic.cpp 
b/clang-tools-extra/test/clang-doc/basic.cpp
new file mode 100644
index 00..318a271a9af04e
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/basic.cpp
@@ -0,0 +1,136 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs
+// RUN: cat %t/docs/index.yaml | FileCheck %s --check-prefix=YAML
+
+// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs 
--format=md
+// RUN: cat %t/docs/GlobalNamespace/index.md | FileCheck %s --check-prefix=MD
+
+//  YAML: ---
+// YAML-NEXT: USR: ''
+// YAML-NEXT: ChildFunctions:
+
+// MD: # Global Namespace
+// MD: ## Functions
+
+extern bool b();
+
+// YAML-NEXT:   - USR: '88A104C263241E354ECF5B55B04AE8CEAD625B71'
+// YAML-NEXT: Name:'b'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'_Bool'
+// YAML-NEXT: QualName:'_Bool'
+
+// MD: ### b
+// MD: *_Bool b()*
+
+char c();
+
+// YAML-NEXT:   - USR: 'EA3287837B3F175C8DB154406B4DAD2924F479B5'
+// YAML-NEXT: Name:'c'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'char'
+// YAML-NEXT: QualName:'char'
+
+// MD: ### c
+// MD: *char c()*
+
+double d();
+
+// YAML-NEXT:   - USR: '60A47E4696CEFC411AB2E1EEFA2DD914E2A7E450'
+// YAML-NEXT: Name:'d'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'double'
+// YAML-NEXT: QualName:'double'
+
+// MD: ### d
+// MD: *double d()*
+
+float f();
+
+// YAML-NEXT:   - USR: 'B3A9EC6BECD5869CF3ACDFB25153CFE6BBDD5EAB'
+// YAML-NEXT: Name:'f'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'float'
+// YAML-NEXT: QualName:'float'
+
+// MD: ### f
+// MD: *float f()*
+
+int i();
+
+// YAML-NEXT:   - USR: '307041280A81EB46F949A94AD52587C659FD801C'
+// YAML-NEXT: Name:'i'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'int'
+// YAML-NEXT: QualName:'int'
+
+// MD: ### i
+// MD: *int i()*
+
+long l();
+
+// YAML-NEXT:   - USR: 'A1CE9AB0064C412F857592E01332C641C1A06F37'
+// YAML-NEXT: Name:'l'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'long'
+// YAML-NEXT: QualName:'long'
+
+// MD: ### l
+// MD: *long l()*
+
+long long ll();
+
+// YAML-NEXT:   - USR: '5C2C44ED4825C066EF6ED796863586F343C8BCA9'
+// YAML-NEXT: Name:'ll'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'long long'
+// YAML-NEXT: QualName:'long long'
+
+// MD: ### ll
+// MD: *long long ll()*
+
+short s();
+
+// YAML-NEXT:   - USR: '412341570FD3AD2C3A1E9A1DE7B3C01C07BEACFE'
+// YAML-NEXT: Name:'s'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'s

[llvm-branch-commits] [clang-tools-extra] [clang-doc] Use LangOpts when printing types (PR #120308)

2024-12-17 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi edited 
https://github.com/llvm/llvm-project/pull/120308
___
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-doc][NFC] Use isa over dyn_cast (PR #120309)

2024-12-17 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi closed 
https://github.com/llvm/llvm-project/pull/120309
___
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] [llvm] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

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

fhahn wrote:

Sorry I didn't mean to close this PR, looks like it happened automatically once 
I deleted the `users/fhahn/tysan-a-type-sanitizer-runtime-library` branch :( 

https://github.com/llvm/llvm-project/pull/95387
___
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] [llvm] [TySan] Improved compatability for tests (PR #96507)

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

fhahn wrote:

Sorry I didn't mean to close this PR, looks like it happened automatically once 
I deleted the `users/fhahn/tysan-a-type-sanitizer-runtime-library` branch :( 

https://github.com/llvm/llvm-project/pull/96507
___
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] [llvm] [TySan] Fix struct access with different bases (PR #108385)

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

fhahn wrote:

Sorry I didn't mean to close this PR, looks like it happened automatically once 
I deleted the `users/fhahn/tysan-a-type-sanitizer-runtime-library` branch :( 

https://github.com/llvm/llvm-project/pull/108385
___
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-doc][NFC] Use isa over dyn_cast (PR #120309)

2024-12-17 Thread Petr Hosek via llvm-branch-commits

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


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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] Use LangOpts when printing types (PR #120308)

2024-12-17 Thread Paul Kirth via llvm-branch-commits

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] Use LangOpts when printing types (PR #120308)

2024-12-17 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/120308

>From ac3ce2e8bacdf6b2e7f7d812b16b2854d5ca34f2 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 17 Dec 2024 13:58:09 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1

[skip ci]
---
 clang-tools-extra/test/clang-doc/basic.cpp | 136 +
 1 file changed, 136 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/basic.cpp

diff --git a/clang-tools-extra/test/clang-doc/basic.cpp 
b/clang-tools-extra/test/clang-doc/basic.cpp
new file mode 100644
index 00..318a271a9af04e
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/basic.cpp
@@ -0,0 +1,136 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs
+// RUN: cat %t/docs/index.yaml | FileCheck %s --check-prefix=YAML
+
+// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs 
--format=md
+// RUN: cat %t/docs/GlobalNamespace/index.md | FileCheck %s --check-prefix=MD
+
+//  YAML: ---
+// YAML-NEXT: USR: ''
+// YAML-NEXT: ChildFunctions:
+
+// MD: # Global Namespace
+// MD: ## Functions
+
+extern bool b();
+
+// YAML-NEXT:   - USR: '88A104C263241E354ECF5B55B04AE8CEAD625B71'
+// YAML-NEXT: Name:'b'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'_Bool'
+// YAML-NEXT: QualName:'_Bool'
+
+// MD: ### b
+// MD: *_Bool b()*
+
+char c();
+
+// YAML-NEXT:   - USR: 'EA3287837B3F175C8DB154406B4DAD2924F479B5'
+// YAML-NEXT: Name:'c'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'char'
+// YAML-NEXT: QualName:'char'
+
+// MD: ### c
+// MD: *char c()*
+
+double d();
+
+// YAML-NEXT:   - USR: '60A47E4696CEFC411AB2E1EEFA2DD914E2A7E450'
+// YAML-NEXT: Name:'d'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'double'
+// YAML-NEXT: QualName:'double'
+
+// MD: ### d
+// MD: *double d()*
+
+float f();
+
+// YAML-NEXT:   - USR: 'B3A9EC6BECD5869CF3ACDFB25153CFE6BBDD5EAB'
+// YAML-NEXT: Name:'f'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'float'
+// YAML-NEXT: QualName:'float'
+
+// MD: ### f
+// MD: *float f()*
+
+int i();
+
+// YAML-NEXT:   - USR: '307041280A81EB46F949A94AD52587C659FD801C'
+// YAML-NEXT: Name:'i'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'int'
+// YAML-NEXT: QualName:'int'
+
+// MD: ### i
+// MD: *int i()*
+
+long l();
+
+// YAML-NEXT:   - USR: 'A1CE9AB0064C412F857592E01332C641C1A06F37'
+// YAML-NEXT: Name:'l'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'long'
+// YAML-NEXT: QualName:'long'
+
+// MD: ### l
+// MD: *long l()*
+
+long long ll();
+
+// YAML-NEXT:   - USR: '5C2C44ED4825C066EF6ED796863586F343C8BCA9'
+// YAML-NEXT: Name:'ll'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:'long long'
+// YAML-NEXT: QualName:'long long'
+
+// MD: ### ll
+// MD: *long long ll()*
+
+short s();
+
+// YAML-NEXT:   - USR: '412341570FD3AD2C3A1E9A1DE7B3C01C07BEACFE'
+// YAML-NEXT: Name:'s'
+// YAML-NEXT: Location:
+// YAML-NEXT:   - LineNumber:  [[# @LINE-5]]
+// YAML-NEXT: Filename:'{{.*}}'
+// YAML-NEXT: ReturnType:
+// YAML-NEXT:   Type:
+// YAML-NEXT: Name:  

[llvm-branch-commits] [llvm] release/19.x: [RISCV] Add hasPostISelHook to sf.vfnrclip pseudo instructions. (#114274) (PR #117948)

2024-12-17 Thread Luke Lau via llvm-branch-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/117948
___
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][WebAssembly] Replace config-> with ctx.arg. (PR #119835)

2024-12-17 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/119835


___
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][WebAssembly] Replace config-> with ctx.arg. (PR #119835)

2024-12-17 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

Updated the description. This consolidates global variables. 

https://github.com/llvm/llvm-project/pull/119835
___
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][WebAssembly] Replace config-> with ctx.arg. (PR #119835)

2024-12-17 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/119835
___
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][WebAssembly] Replace config-> with ctx.arg. (PR #119835)

2024-12-17 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/119835


___
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] 4b79faf - Revert "[AArch64] Lower alias mask to a whilewr (#100769)"

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

Author: Sam Tebbs
Date: 2024-12-17T16:23:26Z
New Revision: 4b79faf786d77e5c5b1271f1efab6967e43f6a17

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

LOG: Revert "[AArch64] Lower alias mask to a whilewr (#100769)"

This reverts commit e7f9d8e5c3e49e729c69aaa9be3322f7902370b8.

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Removed: 
llvm/test/CodeGen/AArch64/whilewr.ll



diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 28f304100326c6..abc00fc86ee455 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1539,7 +1539,6 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine &TM,
   setOperationAction(ISD::VECREDUCE_AND, VT, Custom);
   setOperationAction(ISD::VECREDUCE_OR, VT, Custom);
   setOperationAction(ISD::VECREDUCE_XOR, VT, Custom);
-  setOperationAction(ISD::OR, VT, Custom);
 
   setOperationAction(ISD::SELECT_CC, VT, Expand);
   setOperationAction(ISD::INSERT_VECTOR_ELT, VT, Custom);
@@ -14329,128 +14328,8 @@ static SDValue tryLowerToSLI(SDNode *N, SelectionDAG 
&DAG) {
   return ResultSLI;
 }
 
-/// Try to lower the construction of a pointer alias mask to a WHILEWR.
-/// The mask's enabled lanes represent the elements that will not overlap 
across
-/// one loop iteration. This tries to match:
-/// or (splat (setcc_lt (sub ptrA, ptrB), -(element_size - 1))),
-///(get_active_lane_mask 0, (div (sub ptrA, ptrB), element_size))
-SDValue tryWhileWRFromOR(SDValue Op, SelectionDAG &DAG,
- const AArch64Subtarget &Subtarget) {
-  if (!Subtarget.hasSVE2())
-return SDValue();
-  SDValue LaneMask = Op.getOperand(0);
-  SDValue Splat = Op.getOperand(1);
-
-  if (Splat.getOpcode() != ISD::SPLAT_VECTOR)
-std::swap(LaneMask, Splat);
-
-  if (LaneMask.getOpcode() != ISD::INTRINSIC_WO_CHAIN ||
-  LaneMask.getConstantOperandVal(0) != Intrinsic::get_active_lane_mask ||
-  Splat.getOpcode() != ISD::SPLAT_VECTOR)
-return SDValue();
-
-  SDValue Cmp = Splat.getOperand(0);
-  if (Cmp.getOpcode() != ISD::SETCC)
-return SDValue();
-
-  CondCodeSDNode *Cond = cast(Cmp.getOperand(2));
-
-  auto ComparatorConst = dyn_cast(Cmp.getOperand(1));
-  if (!ComparatorConst || ComparatorConst->getSExtValue() > 0 ||
-  Cond->get() != ISD::CondCode::SETLT)
-return SDValue();
-  unsigned CompValue = std::abs(ComparatorConst->getSExtValue());
-  unsigned EltSize = CompValue + 1;
-  if (!isPowerOf2_64(EltSize) || EltSize > 8)
-return SDValue();
-
-  SDValue Diff = Cmp.getOperand(0);
-  if (Diff.getOpcode() != ISD::SUB || Diff.getValueType() != MVT::i64)
-return SDValue();
-
-  if (!isNullConstant(LaneMask.getOperand(1)) ||
-  (EltSize != 1 && LaneMask.getOperand(2).getOpcode() != ISD::SRA))
-return SDValue();
-
-  // The number of elements that alias is calculated by dividing the positive
-  // 
diff erence between the pointers by the element size. An alias mask for i8
-  // elements omits the division because it would just divide by 1
-  if (EltSize > 1) {
-SDValue DiffDiv = LaneMask.getOperand(2);
-auto DiffDivConst = dyn_cast(DiffDiv.getOperand(1));
-if (!DiffDivConst || DiffDivConst->getZExtValue() != Log2_64(EltSize))
-  return SDValue();
-if (EltSize > 2) {
-  // When masking i32 or i64 elements, the positive value of the
-  // possibly-negative 
diff erence comes from a select of the 
diff erence if
-  // it's positive, otherwise the 
diff erence plus the element size if it's
-  // negative: pos_
diff  = 
diff  < 0 ? (
diff  + 7) : 
diff 
-  SDValue Select = DiffDiv.getOperand(0);
-  // Make sure the 
diff erence is being compared by the select
-  if (Select.getOpcode() != ISD::SELECT_CC || Select.getOperand(3) != Diff)
-return SDValue();
-  // Make sure it's checking if the 
diff erence is less than 0
-  if (!isNullConstant(Select.getOperand(1)) ||
-  cast(Select.getOperand(4))->get() !=
-  ISD::CondCode::SETLT)
-return SDValue();
-  // An add creates a positive value from the negative 
diff erence
-  SDValue Add = Select.getOperand(2);
-  if (Add.getOpcode() != ISD::ADD || Add.getOperand(0) != Diff)
-return SDValue();
-  if (auto *AddConst = dyn_cast(Add.getOperand(1));
-  !AddConst || AddConst->getZExtValue() != EltSize - 1)
-return SDValue();
-} else {
-  // When masking i16 elements, this positive value comes from adding the
-  // 
diff erence's sign bit to the 
diff erence itself. This is equivalent to
-  // the 32 bit and 64 bit case: pos_
diff  = 
diff  + sign_bit (
diff )
-  SDValu

[llvm-branch-commits] [mlir] [mlir][Properties] Shorten "Property" to "Prop" in most places (PR #120368)

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

krzysz00 wrote:

So as to note upcoming plans:
- EnumProp probably wants to move to `EnumAttr` and grow a real predicate.
- `IndexProp` and `APIntProp` (name subject to debate) should exist
- Once the infrastructure feels like it's in a solid shape, I intend to go on a 
rampage through the upstream dialects where things that could reasonably be 
properties (ex. integer scalars) get turned into properties

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


  1   2   >