[llvm-branch-commits] [llvm] llvm-reduce: Fix asserting on TargetExtTypes that do not support zeroinit (PR #132733)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/132733

>From 7a64f7f65eccb4c69f3a07a4df0aed7bb5c6676c Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Mon, 24 Mar 2025 19:52:11 +0700
Subject: [PATCH] llvm-reduce: Fix asserting on TargetExtTypes that do not
 support zeroinit

So far I've been unsuccessful in finding an example where the used constant
value is directly observed in the output. This avoids an assert in an 
intermediate
step of value replacement.
---
 .../operands-to-args-target-ext-type.ll   | 32 +++
 .../llvm-reduce/reduce-args-target-ext-ty.ll  | 13 
 llvm/tools/llvm-reduce/deltas/Utils.cpp   | 11 ++-
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 
llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
 create mode 100644 llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll

diff --git a/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll 
b/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
new file mode 100644
index 0..cafd460f14ab3
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
@@ -0,0 +1,32 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction 
--delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg 
--check-prefixes=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefixes=RESULT
+
+; Make sure there's no assert from trying to create a
+; not-zeroinitializable target ext type
+
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+declare target("sometarget.sometype") @produces_ext_ty()
+
+; INTERESTING: define void @not_zero_foldable(
+
+; RESULT: define void @not_zero_foldable(target("sometarget.sometype") %call) {
+; RESULT-NEXT: %call1 = call target("sometarget.sometype") @produces_ext_ty()
+; RESULT-NEXT: call void @uses_ext_ty(target("sometarget.sometype") %call)
+define void @not_zero_foldable() {
+  %call = call target("sometarget.sometype") @produces_ext_ty()
+  call void @uses_ext_ty(target("sometarget.sometype") %call)
+  ret void
+}
+
+declare void @uses_zeroinit_ext_ty(target("spirv.zeroinit"))
+declare target("sometarget.sometype") @produces_zeroinit_ext_ty()
+
+; INTERESTING: define void @foldable_to_zero(
+; RESULT: define void @foldable_to_zero(target("spirv.zeroinit") %call) {
+define void @foldable_to_zero() {
+  %call = call target("spirv.zeroinit") @produces_zeroinit_ext_ty()
+  call void @uses_zeroinit_ext_ty(target("spirv.zeroinit") %call)
+  ret void
+}
+
diff --git a/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll 
b/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll
new file mode 100644
index 0..e3a7e80f5e4ef
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction 
--delta-passes=arguments --test FileCheck --test-arg %s --test-arg 
--check-prefixes=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefixes=RESULT
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+declare target("sometarget.sometype") @produces_ext_ty()
+
+; INTERESTING: @interesting(
+; RESULT: @interesting(
+; RESULT: void @uses_ext_ty()
+define void @interesting(target("sometarget.sometype") %arg) {
+  call void @uses_ext_ty(target("sometarget.sometype") %arg)
+  ret void
+}
diff --git a/llvm/tools/llvm-reduce/deltas/Utils.cpp 
b/llvm/tools/llvm-reduce/deltas/Utils.cpp
index 669b9db8a825a..92a44921a7cfb 100644
--- a/llvm/tools/llvm-reduce/deltas/Utils.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Utils.cpp
@@ -24,7 +24,16 @@ cl::opt llvm::Verbose("verbose",
 cl::init(false), cl::cat(LLVMReduceOptions));
 
 Value *llvm::getDefaultValue(Type *T) {
-  return T->isVoidTy() ? PoisonValue::get(T) : Constant::getNullValue(T);
+  if (T->isVoidTy())
+return PoisonValue::get(T);
+
+  if (auto *TET = dyn_cast(T)) {
+if (TET->hasProperty(TargetExtType::HasZeroInit))
+  return ConstantTargetNone::get(TET);
+return PoisonValue::get(TET);
+  }
+
+  return Constant::getNullValue(T);
 }
 
 bool llvm::hasAliasUse(Function &F) {

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


[llvm-branch-commits] [clang] [clang] Track final substitution for Subst* AST nodes (PR #132748)

2025-03-24 Thread Matheus Izvekov via llvm-branch-commits

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

>From c5e50089af34acdb807680cf80576ca03ff1715f Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Sat, 22 Mar 2025 16:03:04 -0300
Subject: [PATCH 1/4] [clang] Track final substitution for
 SubstTemplateTemplateParm nodes

---
 clang/include/clang/AST/ASTContext.h   |  9 +
 clang/include/clang/AST/PropertiesBase.td  |  3 ++-
 clang/include/clang/AST/TemplateName.h | 17 -
 clang/include/clang/AST/Type.h |  3 ++-
 clang/lib/AST/ASTContext.cpp   |  6 +++---
 clang/lib/AST/ASTImporter.cpp  |  2 +-
 clang/lib/AST/TemplateName.cpp |  6 --
 clang/lib/AST/TextNodeDumper.cpp   |  2 ++
 clang/lib/Sema/SemaTemplateInstantiate.cpp |  8 ++--
 9 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1f7c75559e1e9..14a097189ca86 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2396,10 +2396,11 @@ class ASTContext : public RefCountedBase {
 const IdentifierInfo *Name) const;
   TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
 OverloadedOperatorKind Operator) const;
-  TemplateName
-  getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
-   unsigned Index,
-   std::optional PackIndex) const;
+  TemplateName getSubstTemplateTemplateParm(TemplateName replacement,
+Decl *AssociatedDecl,
+unsigned Index,
+std::optional PackIndex,
+bool Final) const;
   TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument 
&ArgPack,
 Decl *AssociatedDecl,
 unsigned Index,
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 5f3a885832e2e..416914db2f7c8 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -729,8 +729,9 @@ let Class = PropertyTypeCase in {
   def : Property<"packIndex", Optional> {
 let Read = [{ parm->getPackIndex() }];
   }
+  def : Property<"final", Bool> { let Read = [{ parm->getFinal() }]; }
   def : Creator<[{
-return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, 
index, packIndex);
+return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, 
index, packIndex, final);
   }]>;
 }
 let Class = PropertyTypeCase in 
{
diff --git a/clang/include/clang/AST/TemplateName.h 
b/clang/include/clang/AST/TemplateName.h
index ce97f834bfc1d..313802502f818 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -413,9 +413,11 @@ class SubstTemplateTemplateParmStorage
 
   SubstTemplateTemplateParmStorage(TemplateName Replacement,
Decl *AssociatedDecl, unsigned Index,
-   std::optional PackIndex)
+   std::optional PackIndex,
+   bool Final)
   : UncommonTemplateNameStorage(SubstTemplateTemplateParm, Index,
-PackIndex ? *PackIndex + 1 : 0),
+((PackIndex ? *PackIndex + 1 : 0) << 1) |
+Final),
 Replacement(Replacement), AssociatedDecl(AssociatedDecl) {
 assert(AssociatedDecl != nullptr);
   }
@@ -429,10 +431,15 @@ class SubstTemplateTemplateParmStorage
   /// This should match the result of `getParameter()->getIndex()`.
   unsigned getIndex() const { return Bits.Index; }
 
+  // This substitution is Final, which means the substitution is fully
+  // sugared: it doesn't need to be resugared later.
+  bool getFinal() const { return Bits.Data & 1; }
+
   std::optional getPackIndex() const {
-if (Bits.Data == 0)
+auto Data = Bits.Data >> 1;
+if (Data == 0)
   return std::nullopt;
-return Bits.Data - 1;
+return Data - 1;
   }
 
   TemplateTemplateParmDecl *getParameter() const;
@@ -442,7 +449,7 @@ class SubstTemplateTemplateParmStorage
 
   static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Replacement,
   Decl *AssociatedDecl, unsigned Index,
-  std::optional PackIndex);
+  std::optional PackIndex, bool Final);
 };
 
 class DeducedTemplateStorage : public UncommonTemplateNameStorage,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 3b80f962a3bc6..950e4f4cc7780 100644
--- a/clang/include/clang/AST/Type.h
+++ b

[llvm-branch-commits] [compiler-rt] release/20.x: [compiler-rt][Darwin][x86] Fix instrprof-darwin-exports test (#131425) (PR #132506)

2025-03-24 Thread John Hui via llvm-branch-commits

j-hui wrote:

@dtellenbach I'm unable to add you as a reviewer/merge this myself; could you 
please take a look at this PR? Thank you!

https://github.com/llvm/llvm-project/pull/132506
___
llvm-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] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt edited 
https://github.com/llvm/llvm-project/pull/132808
___
llvm-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] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt created 
https://github.com/llvm/llvm-project/pull/132808

RISCVToolChain object passes `--sysroot` option from clang to gnuld. Adding
the supprt for the same in BareMetal toolchain object.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 5th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ie830bf6d126fea46dc225e5ef97e14349765ba07

>From 7ed2c8d8e13d552ad5a2f18d4743b6101b1c9fbf Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 07:04:59 -0700
Subject: [PATCH] [Driver] Forward sysroot from Driver to linker in BareMetal
 ToolChain Object

RISCVToolChain object passes `--sysroot` option from clang to gnuld. Adding
the supprt for the same in BareMetal toolchain object.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 5th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ie830bf6d126fea46dc225e5ef97e14349765ba07
---
 clang/lib/Driver/ToolChains/BareMetal.cpp |  3 ++
 clang/test/Driver/aarch64-toolchain.c |  6 +--
 clang/test/Driver/arm-toolchain.c |  6 +--
 clang/test/Driver/baremetal.cpp   | 48 +++
 4 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index edf9ecc728282..508c2bbb2339e 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -529,6 +529,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
+  if (!D.SysRoot.empty())
+CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
+
   CmdArgs.push_back("-Bstatic");
 
   if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
diff --git a/clang/test/Driver/aarch64-toolchain.c 
b/clang/test/Driver/aarch64-toolchain.c
index d45be9a6ee649..e299591305a0a 100644
--- a/clang/test/Driver/aarch64-toolchain.c
+++ b/clang/test/Driver/aarch64-toolchain.c
@@ -16,7 +16,7 @@
 // C-AARCH64-BAREMETAL: "-cc1" "-triple" "aarch64-unknown-none-elf"
 // C-AARCH64-BAREMETAL: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
 "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-Bstatic" "-EL"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
@@ -52,7 +52,7 @@
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/backward"
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1"
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
  "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL: "-Bstatic" "-EL"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
@@ -89,7 +89,7 @@
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/v1"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld
+// CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
 "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aar

[llvm-branch-commits] [clang] [Driver] Fix link order of BareMetal toolchain object (PR #132806)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt created 
https://github.com/llvm/llvm-project/pull/132806

The linker job in BareMetal toolchain object will be used by gnuld and lld both.
However, gnuld process the arguments in the order in which they appear on 
command
line, whereas there is no such restriction with lld.

The previous order was:
LibraryPaths -> Libraries -> LTOOptions -> LinkerInputs
The new iorder is:
LibraryPaths -> LTOOptions -> LinkerInputs -> Libraries

LTO options need to be added before adding any linker inputs because file format
after compile stage during LTO is bitcode which gnuld natively cannot process.
Hence iwill need to pass appropriate plugins before adding any bitcode file on 
the
command line.

Object files that are getting linked need to be passed before processing any
libraries so that gnuld can appropriately do symbol resolution for the symbols
for which no definition is provided through user code.

Similar link order is also followed by other linker jobs for gnuld such as in
gnutools::Linker in Gnu.cpp

This is the 3rd patch in the series of patches of merging RISCVToolchain into
BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: I0e68e403c08b5687cc3346e833981f7b9f3819c4

>From 2d1b254b792ce5c1cee9922d63f3a4f5e90838b1 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 06:17:42 -0700
Subject: [PATCH] [Driver] Fix link order of BareMetal toolchain object

The linker job in BareMetal toolchain object will be used by gnuld and lld both.
However, gnuld process the arguments in the order in which they appear on 
command
line, whereas there is no such restriction with lld.

The previous order was:
LibraryPaths -> Libraries -> LTOOptions -> LinkerInputs
The new iorder is:
LibraryPaths -> LTOOptions -> LinkerInputs -> Libraries

LTO options need to be added before adding any linker inputs because file format
after compile stage during LTO is bitcode which gnuld natively cannot process.
Hence iwill need to pass appropriate plugins before adding any bitcode file on 
the
command line.

Object files that are getting linked need to be passed before processing any
libraries so that gnuld can appropriately do symbol resolution for the symbols
for which no definition is provided through user code.

Similar link order is also followed by other linker jobs for gnuld such as in
gnutools::Linker in Gnu.cpp

This is the 3rd patch in the series of patches of merging RISCVToolchain into
BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: I0e68e403c08b5687cc3346e833981f7b9f3819c4
---
 clang/lib/Driver/ToolChains/BareMetal.cpp   | 32 
 clang/test/Driver/aarch64-toolchain-extra.c |  2 +-
 clang/test/Driver/aarch64-toolchain.c   | 24 +++---
 clang/test/Driver/arm-toolchain-extra.c |  2 +-
 clang/test/Driver/arm-toolchain.c   | 24 +++---
 clang/test/Driver/baremetal-multilib.yaml   |  3 +-
 clang/test/Driver/baremetal-sysroot.cpp |  8 +-
 clang/test/Driver/baremetal.cpp | 82 +
 8 files changed, 100 insertions(+), 77 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 7ec6d86d998a4..919fc6fe71178 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -529,8 +529,6 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
-  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
-
   CmdArgs.push_back("-Bstatic");
 
   if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
@@ -576,6 +574,22 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   for (const auto &LibPath : TC.getLibraryPaths())
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-L", LibPath)));
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+// Find the first filename InputInfo object.
+auto Input = llvm::find_if(
+Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
+if (Input == Inputs.end())
+  // For a very rare case, all of the inputs to the linker are
+  // InputArg. If that happens, just use the first InputInfo.
+  Input = Inputs.begin();
+
+addLTOOptions(TC, Args, CmdArgs, Output, *Input,
+  D.getLTOMode() == LTOK_Thin);
+  }
+
+  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
+
   if (TC.ShouldLinkCXXStdlib(Args)) {
 bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
!Args.hasArg(options::OPT_static);
@@ -596,20 +610,6 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("--end-group");
   }
 
-  if

[llvm-branch-commits] [clang] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)

2025-03-24 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Garvit Gupta (quic-garvgupt)


Changes

RISCVToolChain object passes `--sysroot` option from clang to gnuld. Adding
the supprt for the same in BareMetal toolchain object.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 5th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

---

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


4 Files Affected:

- (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+3) 
- (modified) clang/test/Driver/aarch64-toolchain.c (+3-3) 
- (modified) clang/test/Driver/arm-toolchain.c (+3-3) 
- (modified) clang/test/Driver/baremetal.cpp (+24-24) 


``diff
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index edf9ecc728282..508c2bbb2339e 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -529,6 +529,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
+  if (!D.SysRoot.empty())
+CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
+
   CmdArgs.push_back("-Bstatic");
 
   if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
diff --git a/clang/test/Driver/aarch64-toolchain.c 
b/clang/test/Driver/aarch64-toolchain.c
index d45be9a6ee649..e299591305a0a 100644
--- a/clang/test/Driver/aarch64-toolchain.c
+++ b/clang/test/Driver/aarch64-toolchain.c
@@ -16,7 +16,7 @@
 // C-AARCH64-BAREMETAL: "-cc1" "-triple" "aarch64-unknown-none-elf"
 // C-AARCH64-BAREMETAL: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
 "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-Bstatic" "-EL"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
@@ -52,7 +52,7 @@
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/backward"
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1"
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
  "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL: "-Bstatic" "-EL"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
@@ -89,7 +89,7 @@
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/v1"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld
+// CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
 "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-Bstatic" "-EL"
 // CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
diff --git a/clang/test/Driver/arm-toolchain.c 
b/clang/test/Driver/arm-toolchain.c
index d89f77b86c23b..7869a35842630 100644
--- a/clang/test/Driver/arm-toolchain.c
+++ b/clang/test/Driver/arm-toolchain.c
@@ -16,7 +16,7 @@
 // C-ARM-BAREMETAL: "-cc1" "-triple" "thumbv6m-unknown-none-eabi"
 // C-ARM-BAREMETAL: "-isysroot" 
"{{.*}}Inputs/bas

[llvm-branch-commits] [clang] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt ready_for_review 
https://github.com/llvm/llvm-project/pull/132807
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -540,19 +577,54 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_r)) {
-CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  bool WantCRTs =
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+  const char *crtbegin, *crtend;
+  if (WantCRTs) {
+if (!Args.hasArg(options::OPT_r))
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (TC.isUsingLD()) {
+  auto RuntimeLib = TC.GetRuntimeLibType(Args);
+  if (RuntimeLib == ToolChain::RLT_Libgcc) {
+crtbegin = "crtbegin.o";
+crtend = "crtend.o";
+  } else {
+assert(RuntimeLib == ToolChain::RLT_CompilerRT);
+crtbegin =
+TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+crtend =
+TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+  }
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtbegin)));
+}
   }
 
-  Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
-options::OPT_s, options::OPT_t, options::OPT_r});
+  Args.addAllArgs(CmdArgs,
+  {options::OPT_L, options::OPT_u, options::OPT_T_Group,
+   options::OPT_s, options::OPT_t, options::OPT_r});

quic-garvgupt wrote:

Done
[Driver] Add option to force undefined symbols during linking in BareMetal 
toolchain object. https://github.com/llvm/llvm-project/pull/132807

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Fix link order of BareMetal toolchain object (PR #132806)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt ready_for_review 
https://github.com/llvm/llvm-project/pull/132806
___
llvm-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] [Driver] Add option to force udnefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt created 
https://github.com/llvm/llvm-project/pull/132807

toolchain object.

Add support for `-u` option to force defined symbols. This option is supported
by both lld and gnuld.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 4th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ia6597c756923a77fd9c7cb9a6ae8e52a56f5457d

>From 09f0151e2a4f06fa86e9f79901ab6e787f7b8446 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 06:49:09 -0700
Subject: [PATCH] [Driver] Add option to force udnefined symbols during linking
 in BareMetal toolchain object.

Add support for `-u` option to force defined symbols. This option is supported
by both lld and gnuld.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 4th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ia6597c756923a77fd9c7cb9a6ae8e52a56f5457d
---
 clang/lib/Driver/ToolChains/BareMetal.cpp |  5 +++--
 clang/test/Driver/riscv-args.c|  6 --
 clang/test/Driver/undefined-symbols.c | 15 +++
 3 files changed, 18 insertions(+), 8 deletions(-)
 delete mode 100644 clang/test/Driver/riscv-args.c
 create mode 100644 clang/test/Driver/undefined-symbols.c

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 919fc6fe71178..edf9ecc728282 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -566,8 +566,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
-options::OPT_s, options::OPT_t, options::OPT_r});
+  Args.addAllArgs(CmdArgs,
+  {options::OPT_L, options::OPT_u, options::OPT_T_Group,
+   options::OPT_s, options::OPT_t, options::OPT_r});
 
   TC.AddFilePathLibArgs(Args, CmdArgs);
 
diff --git a/clang/test/Driver/riscv-args.c b/clang/test/Driver/riscv-args.c
deleted file mode 100644
index cab08e5b0f811..0
--- a/clang/test/Driver/riscv-args.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// Check the arguments are correctly passed
-
-// Make sure -T is the last with gcc-toolchain option
-// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 
-T a.lds -u foo %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LD %s
-// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
diff --git a/clang/test/Driver/undefined-symbols.c 
b/clang/test/Driver/undefined-symbols.c
new file mode 100644
index 0..0ce0db43bccad
--- /dev/null
+++ b/clang/test/Driver/undefined-symbols.c
@@ -0,0 +1,15 @@
+// Check the arguments are correctly passed
+
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 
-T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD %s
+// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
+
+// TODO: Merge this test with the above in the last patch when finally 
integrating riscv
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### --target=aarch64-none-elf --gcc-toolchain= -Xlinker 
--defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-LD %s
+// RUN: %clang -### --target=armv6m-none-eabi --gcc-toolchain= -Xlinker 
--defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-LD %s
+// CHECK-ARM-LD: {{.*}} "-T" "a.lds" "-u" "foo" {{.*}} "--defsym=FOO=10"
+

___
llvm-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] [Driver] Fix link order of BareMetal toolchain object (PR #132806)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

quic-garvgupt wrote:

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

* **#132807** https://app.graphite.dev/github/pr/llvm/llvm-project/132807?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#132806** https://app.graphite.dev/github/pr/llvm/llvm-project/132806?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/132806?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#121830** https://app.graphite.dev/github/pr/llvm/llvm-project/121830?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>: 1 other dependent PR 
([#121831](https://github.com/llvm/llvm-project/pull/121831) https://app.graphite.dev/github/pr/llvm/llvm-project/121831?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>)
* **#121829** https://app.graphite.dev/github/pr/llvm/llvm-project/121829?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




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


https://github.com/llvm/llvm-project/pull/132806
___
llvm-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] [Driver] Add option to force udnefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

quic-garvgupt wrote:

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

* **#132807** https://app.graphite.dev/github/pr/llvm/llvm-project/132807?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/132807?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#132806** https://app.graphite.dev/github/pr/llvm/llvm-project/132806?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#121830** https://app.graphite.dev/github/pr/llvm/llvm-project/121830?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>: 1 other dependent PR 
([#121831](https://github.com/llvm/llvm-project/pull/121831) https://app.graphite.dev/github/pr/llvm/llvm-project/121831?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>)
* **#121829** https://app.graphite.dev/github/pr/llvm/llvm-project/121829?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




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


https://github.com/llvm/llvm-project/pull/132807
___
llvm-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] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/132807

>From 2c160d5d94b20733d17249d715bbe2d71ec2c091 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 06:49:09 -0700
Subject: [PATCH] [Driver] Add option to force udnefined symbols during linking
 in BareMetal toolchain object.

Add support for `-u` option to force defined symbols. This option is supported
by both lld and gnuld.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 4th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ia6597c756923a77fd9c7cb9a6ae8e52a56f5457d
---
 clang/lib/Driver/ToolChains/BareMetal.cpp |  5 +++--
 clang/test/Driver/riscv-args.c|  6 --
 clang/test/Driver/undefined-symbols.c | 15 +++
 3 files changed, 18 insertions(+), 8 deletions(-)
 delete mode 100644 clang/test/Driver/riscv-args.c
 create mode 100644 clang/test/Driver/undefined-symbols.c

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 919fc6fe71178..edf9ecc728282 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -566,8 +566,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
-options::OPT_s, options::OPT_t, options::OPT_r});
+  Args.addAllArgs(CmdArgs,
+  {options::OPT_L, options::OPT_u, options::OPT_T_Group,
+   options::OPT_s, options::OPT_t, options::OPT_r});
 
   TC.AddFilePathLibArgs(Args, CmdArgs);
 
diff --git a/clang/test/Driver/riscv-args.c b/clang/test/Driver/riscv-args.c
deleted file mode 100644
index cab08e5b0f811..0
--- a/clang/test/Driver/riscv-args.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// Check the arguments are correctly passed
-
-// Make sure -T is the last with gcc-toolchain option
-// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 
-T a.lds -u foo %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LD %s
-// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
diff --git a/clang/test/Driver/undefined-symbols.c 
b/clang/test/Driver/undefined-symbols.c
new file mode 100644
index 0..0ce0db43bccad
--- /dev/null
+++ b/clang/test/Driver/undefined-symbols.c
@@ -0,0 +1,15 @@
+// Check the arguments are correctly passed
+
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 
-T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD %s
+// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
+
+// TODO: Merge this test with the above in the last patch when finally 
integrating riscv
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### --target=aarch64-none-elf --gcc-toolchain= -Xlinker 
--defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-LD %s
+// RUN: %clang -### --target=armv6m-none-eabi --gcc-toolchain= -Xlinker 
--defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-LD %s
+// CHECK-ARM-LD: {{.*}} "-T" "a.lds" "-u" "foo" {{.*}} "--defsym=FOO=10"
+

___
llvm-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] [Driver] Fix link order of BareMetal toolchain object (PR #132806)

2025-03-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Garvit Gupta (quic-garvgupt)


Changes

The linker job in BareMetal toolchain object will be used by gnuld and lld both.
However, gnuld process the arguments in the order in which they appear on 
command
line, whereas there is no such restriction with lld.

The previous order was:
LibraryPaths -> Libraries -> LTOOptions -> LinkerInputs
The new iorder is:
LibraryPaths -> LTOOptions -> LinkerInputs -> Libraries

LTO options need to be added before adding any linker inputs because file format
after compile stage during LTO is bitcode which gnuld natively cannot process.
Hence iwill need to pass appropriate plugins before adding any bitcode file on 
the
command line.

Object files that are getting linked need to be passed before processing any
libraries so that gnuld can appropriately do symbol resolution for the symbols
for which no definition is provided through user code.

Similar link order is also followed by other linker jobs for gnuld such as in
gnutools::Linker in Gnu.cpp

This is the 3rd patch in the series of patches of merging RISCVToolchain into
BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

---

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


8 Files Affected:

- (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+16-16) 
- (modified) clang/test/Driver/aarch64-toolchain-extra.c (+1-1) 
- (modified) clang/test/Driver/aarch64-toolchain.c (+12-12) 
- (modified) clang/test/Driver/arm-toolchain-extra.c (+1-1) 
- (modified) clang/test/Driver/arm-toolchain.c (+12-12) 
- (modified) clang/test/Driver/baremetal-multilib.yaml (+2-1) 
- (modified) clang/test/Driver/baremetal-sysroot.cpp (+5-3) 
- (modified) clang/test/Driver/baremetal.cpp (+51-31) 


``diff
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 7ec6d86d998a4..919fc6fe71178 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -529,8 +529,6 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
-  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
-
   CmdArgs.push_back("-Bstatic");
 
   if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
@@ -576,6 +574,22 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   for (const auto &LibPath : TC.getLibraryPaths())
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-L", LibPath)));
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+// Find the first filename InputInfo object.
+auto Input = llvm::find_if(
+Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
+if (Input == Inputs.end())
+  // For a very rare case, all of the inputs to the linker are
+  // InputArg. If that happens, just use the first InputInfo.
+  Input = Inputs.begin();
+
+addLTOOptions(TC, Args, CmdArgs, Output, *Input,
+  D.getLTOMode() == LTOK_Thin);
+  }
+
+  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
+
   if (TC.ShouldLinkCXXStdlib(Args)) {
 bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
!Args.hasArg(options::OPT_static);
@@ -596,20 +610,6 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("--end-group");
   }
 
-  if (D.isUsingLTO()) {
-assert(!Inputs.empty() && "Must have at least one input.");
-// Find the first filename InputInfo object.
-auto Input = llvm::find_if(
-Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
-if (Input == Inputs.end())
-  // For a very rare case, all of the inputs to the linker are
-  // InputArg. If that happens, just use the first InputInfo.
-  Input = Inputs.begin();
-
-addLTOOptions(TC, Args, CmdArgs, Output, *Input,
-  D.getLTOMode() == LTOK_Thin);
-  }
-
   if ((TC.hasValidGCCInstallation() || hasGCCToolChainAlongSideClang(D)) &&
   WantCRTs)
 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtend)));
diff --git a/clang/test/Driver/aarch64-toolchain-extra.c 
b/clang/test/Driver/aarch64-toolchain-extra.c
index 2a930e35acd45..a0b5f2902962f 100644
--- a/clang/test/Driver/aarch64-toolchain-extra.c
+++ b/clang/test/Driver/aarch64-toolchain-extra.c
@@ -31,5 +31,5 @@
 // C-AARCH64-BAREMETAL-NOGCC: 
"{{.*}}/aarch64-nogcc/bin/../aarch64-none-elf/lib/crt0.o"
 // C-AARCH64-BAREMETAL-NOGCC: 
"{{.*}}/aarch64-nogcc/{{.*}}/aarch64-none-elf/lib/crtbegin.o"
 // C-AARCH64-BAREMETAL-NOGCC: 
"{{.*}}/aarch64-nogcc/bin/../aarch64-none-elf/lib"
-// C-AARCH64-BAREMETAL-NOGCC: "--start-group" "-lgcc" "--as-needed" 

[llvm-branch-commits] [llvm] llvm-reduce: Fix asserting on TargetExtTypes that do not support zeroinit (PR #132733)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/132733

>From 7a64f7f65eccb4c69f3a07a4df0aed7bb5c6676c Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Mon, 24 Mar 2025 19:52:11 +0700
Subject: [PATCH] llvm-reduce: Fix asserting on TargetExtTypes that do not
 support zeroinit

So far I've been unsuccessful in finding an example where the used constant
value is directly observed in the output. This avoids an assert in an 
intermediate
step of value replacement.
---
 .../operands-to-args-target-ext-type.ll   | 32 +++
 .../llvm-reduce/reduce-args-target-ext-ty.ll  | 13 
 llvm/tools/llvm-reduce/deltas/Utils.cpp   | 11 ++-
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 
llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
 create mode 100644 llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll

diff --git a/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll 
b/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
new file mode 100644
index 0..cafd460f14ab3
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
@@ -0,0 +1,32 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction 
--delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg 
--check-prefixes=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefixes=RESULT
+
+; Make sure there's no assert from trying to create a
+; not-zeroinitializable target ext type
+
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+declare target("sometarget.sometype") @produces_ext_ty()
+
+; INTERESTING: define void @not_zero_foldable(
+
+; RESULT: define void @not_zero_foldable(target("sometarget.sometype") %call) {
+; RESULT-NEXT: %call1 = call target("sometarget.sometype") @produces_ext_ty()
+; RESULT-NEXT: call void @uses_ext_ty(target("sometarget.sometype") %call)
+define void @not_zero_foldable() {
+  %call = call target("sometarget.sometype") @produces_ext_ty()
+  call void @uses_ext_ty(target("sometarget.sometype") %call)
+  ret void
+}
+
+declare void @uses_zeroinit_ext_ty(target("spirv.zeroinit"))
+declare target("sometarget.sometype") @produces_zeroinit_ext_ty()
+
+; INTERESTING: define void @foldable_to_zero(
+; RESULT: define void @foldable_to_zero(target("spirv.zeroinit") %call) {
+define void @foldable_to_zero() {
+  %call = call target("spirv.zeroinit") @produces_zeroinit_ext_ty()
+  call void @uses_zeroinit_ext_ty(target("spirv.zeroinit") %call)
+  ret void
+}
+
diff --git a/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll 
b/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll
new file mode 100644
index 0..e3a7e80f5e4ef
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction 
--delta-passes=arguments --test FileCheck --test-arg %s --test-arg 
--check-prefixes=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefixes=RESULT
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+declare target("sometarget.sometype") @produces_ext_ty()
+
+; INTERESTING: @interesting(
+; RESULT: @interesting(
+; RESULT: void @uses_ext_ty()
+define void @interesting(target("sometarget.sometype") %arg) {
+  call void @uses_ext_ty(target("sometarget.sometype") %arg)
+  ret void
+}
diff --git a/llvm/tools/llvm-reduce/deltas/Utils.cpp 
b/llvm/tools/llvm-reduce/deltas/Utils.cpp
index 669b9db8a825a..92a44921a7cfb 100644
--- a/llvm/tools/llvm-reduce/deltas/Utils.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Utils.cpp
@@ -24,7 +24,16 @@ cl::opt llvm::Verbose("verbose",
 cl::init(false), cl::cat(LLVMReduceOptions));
 
 Value *llvm::getDefaultValue(Type *T) {
-  return T->isVoidTy() ? PoisonValue::get(T) : Constant::getNullValue(T);
+  if (T->isVoidTy())
+return PoisonValue::get(T);
+
+  if (auto *TET = dyn_cast(T)) {
+if (TET->hasProperty(TargetExtType::HasZeroInit))
+  return ConstantTargetNone::get(TET);
+return PoisonValue::get(TET);
+  }
+
+  return Constant::getNullValue(T);
 }
 
 bool llvm::hasAliasUse(Function &F) {

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


[llvm-branch-commits] [llvm] llvm-reduce: Fix asserting on TargetExtTypes that do not support zeroinit (PR #132733)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

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

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




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


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


[llvm-branch-commits] [CI] Move CI over to new project computation script (PR #132642)

2025-03-24 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/132642


___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/121830

>From f84242edcb47b10c1f7f9c4d831ad66395d37bdd Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 04:58:57 -0700
Subject: [PATCH] [Driver] Add support for crtbegin.o, crtend.o and libgloss
 lib to BareMetal toolchain object

This patch conditionalise the addition of crt{begin,end}.o object files along
with addition of -lgloss lib based on whether libc selected is newlib or llvm
libc. Since there is no way a user can specify which libc it wants to link
against, currently passing valid GCCInstallation to driver will select newlib
otherwise it will default to llvm libc.

Moreover, this patch makes gnuld the default linker for baremetal toolchain
object. User need to pass `-fuse-ld=lld` explicitly to driver to select lld

This is the 2nd patch in the series of patches of merging RISCVToolchain into
BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ie06dc976c306cf04ec2733bbb2d271c57d201f86
---
 clang/lib/Driver/ToolChains/BareMetal.cpp   | 34 +++-
 clang/lib/Driver/ToolChains/BareMetal.h |  3 +-
 clang/test/Driver/aarch64-toolchain-extra.c | 13 ++-
 clang/test/Driver/aarch64-toolchain.c   | 83 +++
 clang/test/Driver/arm-toolchain-extra.c |  7 ++
 clang/test/Driver/arm-toolchain.c   | 88 -
 clang/test/Driver/sanitizer-ld.c|  2 +-
 7 files changed, 218 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index b2e62e3d254af..7ec6d86d998a4 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -545,9 +545,27 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_r)) {
-CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  bool WantCRTs =
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+  const char *crtbegin, *crtend;
+  if (WantCRTs) {
+if (!Args.hasArg(options::OPT_r))
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (TC.hasValidGCCInstallation() || hasGCCToolChainAlongSideClang(D)) {
+  auto RuntimeLib = TC.GetRuntimeLibType(Args);
+  if (RuntimeLib == ToolChain::RLT_Libgcc) {
+crtbegin = "crtbegin.o";
+crtend = "crtend.o";
+  } else {
+assert(RuntimeLib == ToolChain::RLT_CompilerRT);
+crtbegin =
+TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+crtend =
+TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+  }
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtbegin)));
+}
   }
 
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
@@ -570,9 +588,12 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+CmdArgs.push_back("--start-group");
 AddRunTimeLibs(TC, D, CmdArgs, Args);
-
 CmdArgs.push_back("-lc");
+if (TC.hasValidGCCInstallation() || hasGCCToolChainAlongSideClang(D))
+  CmdArgs.push_back("-lgloss");
+CmdArgs.push_back("--end-group");
   }
 
   if (D.isUsingLTO()) {
@@ -588,6 +609,11 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 addLTOOptions(TC, Args, CmdArgs, Output, *Input,
   D.getLTOMode() == LTOK_Thin);
   }
+
+  if ((TC.hasValidGCCInstallation() || hasGCCToolChainAlongSideClang(D)) &&
+  WantCRTs)
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtend)));
+
   if (TC.getTriple().isRISCV())
 CmdArgs.push_back("-X");
 
diff --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index 2a791e7672e5e..87f173342def2 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -36,6 +36,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
   Tool *buildStaticLibTool() const override;
 
 public:
+  bool hasValidGCCInstallation() const { return GCCInstallation.isValid(); }
   bool isBareMetal() const override { return true; }
   bool isCrossCompiling() const override { return true; }
   bool HasNativeLLVMSupport() const override { return true; }
@@ -60,8 +61,6 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
 return ToolChain::CST_Libcxx;
   }
 
-  const char *getDefaultLinker() const override { return "ld.lld"; }
-
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
diff --git a/clang/test/Driver

[llvm-branch-commits] [clang] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/132808

>From 91298e97a772f173be23e3a8a1b0bf563644d784 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 07:04:59 -0700
Subject: [PATCH] [Driver] Forward sysroot from Driver to linker in BareMetal
 ToolChain Object

RISCVToolChain object passes `--sysroot` option from clang to gnuld. Adding
the supprt for the same in BareMetal toolchain object.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 5th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ie830bf6d126fea46dc225e5ef97e14349765ba07
---
 clang/lib/Driver/ToolChains/BareMetal.cpp |  3 ++
 clang/test/Driver/aarch64-toolchain.c |  6 +--
 clang/test/Driver/arm-toolchain.c |  6 +--
 clang/test/Driver/baremetal.cpp   | 48 +++
 4 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index edf9ecc728282..508c2bbb2339e 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -529,6 +529,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
+  if (!D.SysRoot.empty())
+CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
+
   CmdArgs.push_back("-Bstatic");
 
   if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
diff --git a/clang/test/Driver/aarch64-toolchain.c 
b/clang/test/Driver/aarch64-toolchain.c
index 121e335466dce..62b54670e54ac 100644
--- a/clang/test/Driver/aarch64-toolchain.c
+++ b/clang/test/Driver/aarch64-toolchain.c
@@ -16,7 +16,7 @@
 // C-AARCH64-BAREMETAL: "-cc1" "-triple" "aarch64-unknown-none-elf"
 // C-AARCH64-BAREMETAL: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
 "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-Bstatic" "-EL"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
@@ -52,7 +52,7 @@
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/backward"
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1"
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
  "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL: "-Bstatic" "-EL"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
@@ -89,7 +89,7 @@
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/v1"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld
+// CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
 "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-Bstatic" "-EL"
 // CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
diff --git a/clang/test/Driver/arm-toolchain.c 
b/clang/test/Driver/arm-toolchain.c
index d89f77b86c23b..7869a35842630 100644
--- a/clang/test/Driver/arm-toolchain.c
+++ b/clang/test/Driver/arm-toolchain.c
@@

[llvm-branch-commits] [llvm] llvm-reduce: Fix asserting on TargetExtTypes that do not support zeroinit (PR #132733)

2025-03-24 Thread Arthur Eubanks via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/132733
___
llvm-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] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

quic-garvgupt wrote:

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

* **#132808** https://app.graphite.dev/github/pr/llvm/llvm-project/132808?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/132808?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#132807** https://app.graphite.dev/github/pr/llvm/llvm-project/132807?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#132806** https://app.graphite.dev/github/pr/llvm/llvm-project/132806?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#121830** https://app.graphite.dev/github/pr/llvm/llvm-project/121830?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>: 1 other dependent PR 
([#121831](https://github.com/llvm/llvm-project/pull/121831) https://app.graphite.dev/github/pr/llvm/llvm-project/121831?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>)
* **#121829** https://app.graphite.dev/github/pr/llvm/llvm-project/121829?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




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


https://github.com/llvm/llvm-project/pull/132808
___
llvm-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] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt edited 
https://github.com/llvm/llvm-project/pull/132807
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -524,12 +552,21 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
-  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
+  if (!D.SysRoot.empty())
+CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));

quic-garvgupt wrote:

Done
[Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object 
https://github.com/llvm/llvm-project/pull/132808

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -540,19 +577,54 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_r)) {
-CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  bool WantCRTs =
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+  const char *crtbegin, *crtend;
+  if (WantCRTs) {
+if (!Args.hasArg(options::OPT_r))
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (TC.isUsingLD()) {
+  auto RuntimeLib = TC.GetRuntimeLibType(Args);
+  if (RuntimeLib == ToolChain::RLT_Libgcc) {
+crtbegin = "crtbegin.o";
+crtend = "crtend.o";
+  } else {
+assert(RuntimeLib == ToolChain::RLT_CompilerRT);
+crtbegin =
+TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+crtend =
+TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+  }
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtbegin)));
+}

quic-garvgupt wrote:

Fixed

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -154,6 +154,8 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple 
&Triple,
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
   SysRoot = computeSysRoot();
+  UseLD =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_insensitive("ld");

quic-garvgupt wrote:

Removed the assignment statement itself since it became redundant

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

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


[llvm-branch-commits] [llvm] llvm-reduce: Do not reduce alloca array sizes to 0 (PR #132864)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

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

Fixes #64340

>From e06807edae0421d47567d98995d87429914bbad3 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Tue, 25 Mar 2025 09:39:18 +0700
Subject: [PATCH] llvm-reduce: Do not reduce alloca array sizes to 0

Fixes #64340
---
 .../llvm-reduce/reduce-operands-alloca.ll | 69 +++
 .../llvm-reduce/deltas/ReduceOperands.cpp |  5 ++
 2 files changed, 74 insertions(+)
 create mode 100644 llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll

diff --git a/llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll 
b/llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll
new file mode 100644
index 0..61c46185b3378
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll
@@ -0,0 +1,69 @@
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=operands-zero 
--test FileCheck --test-arg --check-prefix=CHECK --test-arg %s --test-arg 
--input-file %s -o %t
+; RUN: FileCheck %s --check-prefixes=CHECK,ZERO < %t
+
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=operands-one 
--test FileCheck --test-arg --check-prefix=CHECK --test-arg %s --test-arg 
--input-file %s -o %t
+; RUN: FileCheck %s --check-prefixes=CHECK,ONE < %t
+
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=operands-poison 
--test FileCheck --test-arg --check-prefix=CHECK --test-arg %s --test-arg 
--input-file %s -o %t
+; RUN: FileCheck %s --check-prefixes=CHECK,POISON < %t
+
+
+; CHECK-LABEL: @dyn_alloca(
+; ZERO: %alloca = alloca i32, i32 %size, align 4
+; ONE: %alloca = alloca i32, align 4
+; POISON: %alloca = alloca i32, i32 %size, align 4
+define void @dyn_alloca(i32 %size) {
+ %alloca = alloca i32, i32 %size
+ store i32 0, ptr %alloca
+ ret void
+}
+
+; CHECK-LABEL: @alloca_0_elt(
+; ZERO: %alloca = alloca i32, i32 0, align 4
+; ONE: %alloca = alloca i32, i32 0, align 4
+; POISON:  %alloca = alloca i32, i32 0, align 4
+define void @alloca_0_elt() {
+ %alloca = alloca i32, i32 0
+ store i32 0, ptr %alloca
+ ret void
+}
+
+; CHECK-LABEL: @alloca_1_elt(
+; ZERO: %alloca = alloca i32, align 4
+; ONE: %alloca = alloca i32, align 4
+; POISON: %alloca = alloca i32, align 4
+define void @alloca_1_elt() {
+ %alloca = alloca i32, i32 1
+ store i32 0, ptr %alloca
+ ret void
+}
+
+; CHECK-LABEL: @alloca_1024_elt(
+; ZERO: %alloca = alloca i32, i32 1024, align 4
+; ONE: %alloca = alloca i32, align 4
+; POISON: %alloca = alloca i32, i32 1024, align 4
+define void @alloca_1024_elt() {
+ %alloca = alloca i32, i32 1024
+ store i32 0, ptr %alloca
+ ret void
+}
+
+; CHECK-LABEL: @alloca_poison_elt(
+; ZERO: %alloca = alloca i32, i32 poison, align 4
+; ONE: %alloca = alloca i32, align 4
+; POISON: %alloca = alloca i32, i32 poison, align 4
+define void @alloca_poison_elt() {
+ %alloca = alloca i32, i32 poison
+ store i32 0, ptr %alloca
+ ret void
+}
+
+; CHECK-LABEL: @alloca_constexpr_elt(
+; ZERO: %alloca = alloca i32, i32 ptrtoint (ptr @alloca_constexpr_elt to i32)
+; ONE: %alloca = alloca i32, align 4
+; POISON: %alloca = alloca i32, i32 ptrtoint (ptr @alloca_constexpr_elt to i32)
+define void @alloca_constexpr_elt() {
+ %alloca = alloca i32, i32 ptrtoint (ptr @alloca_constexpr_elt to i32)
+ store i32 0, ptr %alloca
+ ret void
+}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp 
b/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
index 1c0dd70666cb9..8c69b1cc202eb 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
@@ -130,6 +130,11 @@ void llvm::reduceOperandsZeroDeltaPass(TestRunner &Test) {
   auto ReduceValue = [](Use &Op) -> Value * {
 if (!shouldReduceOperand(Op))
   return nullptr;
+
+// Avoid introducing 0-sized allocations.
+if (isa(Op.getUser()))
+  return nullptr;
+
 // Don't duplicate an existing switch case.
 if (auto *IntTy = dyn_cast(Op->getType()))
   if (switchCaseExists(Op, ConstantInt::get(IntTy, 0)))

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


[llvm-branch-commits] [clang] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt edited 
https://github.com/llvm/llvm-project/pull/121831
___
llvm-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] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/121831

>From 0f5818919b0cf053fd0deef4e321a25266c6039a Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 6 Jan 2025 10:05:08 -0800
Subject: [PATCH] [RISCV] Integrate RISCV target in baremetal toolchain object
 and deprecate RISCVToolchain object

This patch:
- Adds CXXStdlib, runtimelib and unwindlib defaults for riscv target to
  BareMetal toolchain object.
- Add riscv 32 and 64-bit emulation flags to linker job of BareMetal
  toolchain.
- Removes call to RISCVToolChain object from llvm.

This PR is last patch in the series of patches of merging RISCVToolchain
object into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: I2877ac328f55a7638cc185d6034866cbd2ac4203
---
 clang/lib/Driver/CMakeLists.txt   |   1 -
 clang/lib/Driver/Driver.cpp   |  10 +-
 clang/lib/Driver/ToolChains/BareMetal.cpp |  33 ++-
 clang/lib/Driver/ToolChains/BareMetal.h   |  11 +-
 .../lib/Driver/ToolChains/RISCVToolchain.cpp  | 232 --
 clang/lib/Driver/ToolChains/RISCVToolchain.h  |  67 -
 clang/test/Driver/baremetal.cpp   |  44 ++--
 clang/test/Driver/riscv32-toolchain-extra.c   |   7 +-
 clang/test/Driver/riscv32-toolchain.c |  26 +-
 clang/test/Driver/riscv64-toolchain-extra.c   |   7 +-
 clang/test/Driver/riscv64-toolchain.c |  20 +-
 clang/test/Driver/undefined-symbols.c |   8 +
 12 files changed, 94 insertions(+), 372 deletions(-)
 delete mode 100644 clang/lib/Driver/ToolChains/RISCVToolchain.cpp
 delete mode 100644 clang/lib/Driver/ToolChains/RISCVToolchain.h

diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 5bdb6614389cf..eee29af5d181a 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -74,7 +74,6 @@ add_clang_library(clangDriver
   ToolChains/OHOS.cpp
   ToolChains/OpenBSD.cpp
   ToolChains/PS4CPU.cpp
-  ToolChains/RISCVToolchain.cpp
   ToolChains/Solaris.cpp
   ToolChains/SPIRV.cpp
   ToolChains/SPIRVOpenMP.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 056bfcf1b739a..82b49da928a79 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -41,7 +41,6 @@
 #include "ToolChains/PPCFreeBSD.h"
 #include "ToolChains/PPCLinux.h"
 #include "ToolChains/PS4CPU.h"
-#include "ToolChains/RISCVToolchain.h"
 #include "ToolChains/SPIRV.h"
 #include "ToolChains/SPIRVOpenMP.h"
 #include "ToolChains/SYCL.h"
@@ -6886,16 +6885,11 @@ const ToolChain &Driver::getToolChain(const ArgList 
&Args,
 TC = std::make_unique(*this, Target, Args);
 break;
   case llvm::Triple::msp430:
-TC =
-std::make_unique(*this, Target, Args);
+TC = std::make_unique(*this, Target, 
Args);
 break;
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
-if (toolchains::RISCVToolChain::hasGCCToolchain(*this, Args))
-  TC =
-  std::make_unique(*this, Target, 
Args);
-else
-  TC = std::make_unique(*this, Target, Args);
+TC = std::make_unique(*this, Target, Args);
 break;
   case llvm::Triple::ve:
 TC = std::make_unique(*this, Target, Args);
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 508c2bbb2339e..8e721aa72d9c5 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -336,6 +336,26 @@ BareMetal::OrderedMultilibs 
BareMetal::getOrderedMultilibs() const {
   return llvm::reverse(Default);
 }
 
+ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const {
+  if (getTriple().isRISCV() && GCCInstallation.isValid())
+return ToolChain::CST_Libstdcxx;
+  return ToolChain::CST_Libcxx;
+}
+
+ToolChain::RuntimeLibType BareMetal::GetDefaultRuntimeLibType() const {
+  if (getTriple().isRISCV() && GCCInstallation.isValid())
+return ToolChain::RLT_Libgcc;
+  return ToolChain::RLT_CompilerRT;
+}
+
+ToolChain::UnwindLibType
+BareMetal::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
+  if (getTriple().isRISCV())
+return ToolChain::UNW_None;
+
+  return ToolChain::GetUnwindLibType(Args);
+}
+
 void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdinc))
@@ -534,8 +554,14 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   CmdArgs.push_back("-Bstatic");
 
-  if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
-CmdArgs.push_back("--no-relax");
+  if (Triple.isRISCV()) {
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("--no-relax");
+CmdArgs.push_back("-m");
+CmdArgs.push_back(Arch == llvm::Triple::riscv64 ? "elf64lriscv"
+   

[llvm-branch-commits] [clang] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)

2025-03-24 Thread Petr Hosek via llvm-branch-commits


@@ -16,7 +16,7 @@
 // C-AARCH64-BAREMETAL: "-cc1" "-triple" "aarch64-unknown-none-elf"
 // C-AARCH64-BAREMETAL: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
 "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"

petrhosek wrote:

Can you move the `--sysroot=` flags onto the newline to make this more 
readable? Same for all other cases in this PR.
```suggestion
// C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
// C-AARCH64-BAREMETAL: 
"--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
```

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


[llvm-branch-commits] AArch64: Relax x16/x17 constraint on AUT in certain cases. (PR #132857)

2025-03-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Peter Collingbourne (pcc)


Changes

On most operating systems, the x16 and x17 registers are not special,
so there is no benefit, and only a code size cost, to constraining AUT
to only using them. Therefore, adjust the backend to only use the AUT
pseudo (renamed AUTx16x17 for clarity) on Darwin platforms, or if traps
are requested. All other platforms use the unconstrained variant of the
instruction for selection.


---

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


10 Files Affected:

- (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+1-10) 
- (modified) llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp (+6-4) 
- (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+18-7) 
- (modified) llvm/lib/Target/AArch64/AArch64Subtarget.cpp (+23) 
- (modified) llvm/lib/Target/AArch64/AArch64Subtarget.h (+8) 
- (modified) llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
(+1-1) 
- (modified) llvm/test/CodeGen/AArch64/ptrauth-call.ll (+37-16) 
- (modified) llvm/test/CodeGen/AArch64/ptrauth-fpac.ll (+47-34) 
- (modified) 
llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll (+27-21) 
- (modified) llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll 
(+138-118) 


``diff
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 79b190388eb75..73d3fb575897e 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -69,15 +69,6 @@
 
 using namespace llvm;
 
-enum PtrauthCheckMode { Default, Unchecked, Poison, Trap };
-static cl::opt PtrauthAuthChecks(
-"aarch64-ptrauth-auth-checks", cl::Hidden,
-cl::values(clEnumValN(Unchecked, "none", "don't test for failure"),
-   clEnumValN(Poison, "poison", "poison on failure"),
-   clEnumValN(Trap, "trap", "trap on failure")),
-cl::desc("Check pointer authentication auth/resign failures"),
-cl::init(Default));
-
 #define DEBUG_TYPE "asm-printer"
 
 namespace {
@@ -2868,7 +2859,7 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
 return;
   }
 
-  case AArch64::AUT:
+  case AArch64::AUTx16x17:
   case AArch64::AUTPAC:
 emitPtrauthAuthResign(MI);
 return;
diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
index 22083460b400a..2eafb8eae2082 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
@@ -361,7 +361,7 @@ class AArch64DAGToDAGISel : public SelectionDAGISel {
 
   bool tryIndexedLoad(SDNode *N);
 
-  void SelectPtrauthAuth(SDNode *N);
+  void SelectPtrauthAuthX16X17(SDNode *N);
   void SelectPtrauthResign(SDNode *N);
 
   bool trySelectStackSlotTagP(SDNode *N);
@@ -1521,7 +1521,7 @@ extractPtrauthBlendDiscriminators(SDValue Disc, 
SelectionDAG *DAG) {
   AddrDisc);
 }
 
-void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) {
+void AArch64DAGToDAGISel::SelectPtrauthAuthX16X17(SDNode *N) {
   SDLoc DL(N);
   // IntrinsicID is operand #0
   SDValue Val = N->getOperand(1);
@@ -1539,7 +1539,7 @@ void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) {
  AArch64::X16, Val, SDValue());
   SDValue Ops[] = {AUTKey, AUTConstDisc, AUTAddrDisc, X16Copy.getValue(1)};
 
-  SDNode *AUT = CurDAG->getMachineNode(AArch64::AUT, DL, MVT::i64, Ops);
+  SDNode *AUT = CurDAG->getMachineNode(AArch64::AUTx16x17, DL, MVT::i64, Ops);
   ReplaceNode(N, AUT);
 }
 
@@ -5613,7 +5613,9 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) {
   return;
 
 case Intrinsic::ptrauth_auth:
-  SelectPtrauthAuth(Node);
+  if (!Subtarget->isX16X17Safer(CurDAG->getMachineFunction()))
+break;
+  SelectPtrauthAuthX16X17(Node);
   return;
 
 case Intrinsic::ptrauth_resign:
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 6c61e3a613f6f..98a35b3840771 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -66,6 +66,14 @@ def HasLOR   : Predicate<"Subtarget->hasLOR()">,
 def HasPAuth : Predicate<"Subtarget->hasPAuth()">,
AssemblerPredicateWithAll<(all_of FeaturePAuth), 
"pauth">;
 
+// On most operating systems, the x16 and x17 registers are not special, so
+// there is no benefit, and only a code size cost, to constraining PAC
+// instructions to only using them. This predicate may be used to guard 
patterns
+// that allow PAC instructions to be used with any register.
+let RecomputePerFunction = 1 in {
+  def X16X17NotSafer   : Predicate<"!Subtarget->isX16X17Safer(*MF)">;
+}
+
 def HasPAuthLR   : Predicate<"Subtarget->hasPAuthLR()">,
AssemblerPredicateWithAll<(all_of FeatureP

[llvm-branch-commits] [llvm] llvm-reduce: Fix asserting on TargetExtTypes that do not support zeroinit (PR #132733)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/132733

>From 42c74dd8ab2e5246b8664a29bc4d9db3ac9c75eb Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Mon, 24 Mar 2025 19:52:11 +0700
Subject: [PATCH] llvm-reduce: Fix asserting on TargetExtTypes that do not
 support zeroinit

So far I've been unsuccessful in finding an example where the used constant
value is directly observed in the output. This avoids an assert in an 
intermediate
step of value replacement.
---
 .../operands-to-args-target-ext-type.ll   | 32 +++
 .../llvm-reduce/reduce-args-target-ext-ty.ll  | 13 
 llvm/tools/llvm-reduce/deltas/Utils.cpp   | 11 ++-
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 
llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
 create mode 100644 llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll

diff --git a/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll 
b/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
new file mode 100644
index 0..cafd460f14ab3
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
@@ -0,0 +1,32 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction 
--delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg 
--check-prefixes=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefixes=RESULT
+
+; Make sure there's no assert from trying to create a
+; not-zeroinitializable target ext type
+
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+declare target("sometarget.sometype") @produces_ext_ty()
+
+; INTERESTING: define void @not_zero_foldable(
+
+; RESULT: define void @not_zero_foldable(target("sometarget.sometype") %call) {
+; RESULT-NEXT: %call1 = call target("sometarget.sometype") @produces_ext_ty()
+; RESULT-NEXT: call void @uses_ext_ty(target("sometarget.sometype") %call)
+define void @not_zero_foldable() {
+  %call = call target("sometarget.sometype") @produces_ext_ty()
+  call void @uses_ext_ty(target("sometarget.sometype") %call)
+  ret void
+}
+
+declare void @uses_zeroinit_ext_ty(target("spirv.zeroinit"))
+declare target("sometarget.sometype") @produces_zeroinit_ext_ty()
+
+; INTERESTING: define void @foldable_to_zero(
+; RESULT: define void @foldable_to_zero(target("spirv.zeroinit") %call) {
+define void @foldable_to_zero() {
+  %call = call target("spirv.zeroinit") @produces_zeroinit_ext_ty()
+  call void @uses_zeroinit_ext_ty(target("spirv.zeroinit") %call)
+  ret void
+}
+
diff --git a/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll 
b/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll
new file mode 100644
index 0..e3a7e80f5e4ef
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction 
--delta-passes=arguments --test FileCheck --test-arg %s --test-arg 
--check-prefixes=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefixes=RESULT
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+declare target("sometarget.sometype") @produces_ext_ty()
+
+; INTERESTING: @interesting(
+; RESULT: @interesting(
+; RESULT: void @uses_ext_ty()
+define void @interesting(target("sometarget.sometype") %arg) {
+  call void @uses_ext_ty(target("sometarget.sometype") %arg)
+  ret void
+}
diff --git a/llvm/tools/llvm-reduce/deltas/Utils.cpp 
b/llvm/tools/llvm-reduce/deltas/Utils.cpp
index 669b9db8a825a..92a44921a7cfb 100644
--- a/llvm/tools/llvm-reduce/deltas/Utils.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Utils.cpp
@@ -24,7 +24,16 @@ cl::opt llvm::Verbose("verbose",
 cl::init(false), cl::cat(LLVMReduceOptions));
 
 Value *llvm::getDefaultValue(Type *T) {
-  return T->isVoidTy() ? PoisonValue::get(T) : Constant::getNullValue(T);
+  if (T->isVoidTy())
+return PoisonValue::get(T);
+
+  if (auto *TET = dyn_cast(T)) {
+if (TET->hasProperty(TargetExtType::HasZeroInit))
+  return ConstantTargetNone::get(TET);
+return PoisonValue::get(TET);
+  }
+
+  return Constant::getNullValue(T);
 }
 
 bool llvm::hasAliasUse(Function &F) {

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


[llvm-branch-commits] [CI] Move CI over to new project computation script (PR #132642)

2025-03-24 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/132642


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


[llvm-branch-commits] [CI] Move CI over to new project computation script (PR #132642)

2025-03-24 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/132642


___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -565,26 +637,16 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+CmdArgs.push_back("--start-group");
 AddRunTimeLibs(TC, D, CmdArgs, Args);
-
 CmdArgs.push_back("-lc");
+if (TC.isUsingLD())
+  CmdArgs.push_back("-lgloss");

quic-garvgupt wrote:

Fixed

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread Petr Hosek via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/132807
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -331,6 +333,32 @@ BareMetal::OrderedMultilibs 
BareMetal::getOrderedMultilibs() const {
   return llvm::reverse(Default);
 }
 
+ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const {
+  if (getTriple().isRISCV() && GCCInstallation.isValid())
+return ToolChain::CST_Libstdcxx;
+  return ToolChain::CST_Libcxx;
+}
+
+ToolChain::RuntimeLibType BareMetal::GetDefaultRuntimeLibType() const {
+  if (getTriple().isRISCV() && GCCInstallation.isValid())
+return ToolChain::RLT_Libgcc;
+  return ToolChain::RLT_CompilerRT;
+}
+
+ToolChain::UnwindLibType
+BareMetal::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
+  if (getTriple().isRISCV())
+return ToolChain::UNW_None;
+
+  return ToolChain::GetUnwindLibType(Args);
+}
+
+const char *BareMetal::getDefaultLinker() const {
+  if (isUsingLD())

quic-garvgupt wrote:

Fixed. ld will be the default Linker

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

quic-garvgupt wrote:

> I asked for various parts of the linker setup to be moved into a separate PR. 
> I understand that each of those changes would cause some churn in tests, but 
> I think that's desirable so we understand the effect of each of those changes 
> in isolation.

I have split the PR as requested. However, this PR was pushed a little over two 
months ago, and such requests would have been greatly appreciated earlier in 
the review process. Implementing significant changes at later stages can be 
challenging. I hope that the pace of the reviews will now be more consistent. 
Thank you very much for all your feedback and comments.

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


[llvm-branch-commits] [clang] [llvm] [AMDGPU][Attributor] Rework update of `AAAMDWavesPerEU` (PR #123995)

2025-03-24 Thread Shilei Tian via llvm-branch-commits


@@ -1425,8 +1453,14 @@ static bool runImpl(Module &M, AnalysisGetter &AG, 
TargetMachine &TM,
 }
   }
 
-  ChangeStatus Change = A.run();
-  return Change == ChangeStatus::CHANGED;
+  bool Changed = A.run() == ChangeStatus::CHANGED;
+
+  if (Changed && (LTOPhase == ThinOrFullLTOPhase::None ||
+  LTOPhase == ThinOrFullLTOPhase::FullLTOPostLink ||
+  LTOPhase == ThinOrFullLTOPhase::ThinLTOPostLink))
+checkWavesPerEU(M, TM);

shiltian wrote:

> This isn't running as part of the attribute run? Why isn't this part of 
> manifest?

So first, the manifest of the two AAs might not run. Second, there is a 
dependency between the two AAs and the order of the manifest call is 
undetermined.

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


[llvm-branch-commits] AArch64: Relax x16/x17 constraint on AUT in certain cases. (PR #132857)

2025-03-24 Thread Peter Collingbourne via llvm-branch-commits

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

On most operating systems, the x16 and x17 registers are not special,
so there is no benefit, and only a code size cost, to constraining AUT
to only using them. Therefore, adjust the backend to only use the AUT
pseudo (renamed AUTx16x17 for clarity) on Darwin platforms, or if traps
are requested. All other platforms use the unconstrained variant of the
instruction for selection.



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


[llvm-branch-commits] AArch64: Relax x16/x17 constraint on AUT in certain cases. (PR #132857)

2025-03-24 Thread via llvm-branch-commits

Amir429206 wrote:

> 
> 
> 
> @llvm/pr-subscribers-backend-aarch64
> 
> Author: Peter Collingbourne (pcc)
> 
> 
> Changes
> 
> On most operating systems, the x16 and x17 registers are not special,
> so there is no benefit, and only a code size cost, to constraining AUT
> to only using them. Therefore, adjust the backend to only use the AUT
> pseudo (renamed AUTx16x17 for clarity) on Darwin platforms, or if traps
> are requested. All other platforms use the unconstrained variant of the
> instruction for selection.
> 
> 
> ---
> 
> Patch is 35.18 KiB, truncated to 20.00 KiB below, full version: 
> https://github.com/llvm/llvm-project/pull/132857.diff
> 
> 
> 10 Files Affected:
> 
> - (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+1-10) 
> - (modified) llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp (+6-4) 
> - (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+18-7) 
> - (modified) llvm/lib/Target/AArch64/AArch64Subtarget.cpp (+23) 
> - (modified) llvm/lib/Target/AArch64/AArch64Subtarget.h (+8) 
> - (modified) llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
> (+1-1) 
> - (modified) llvm/test/CodeGen/AArch64/ptrauth-call.ll (+37-16) 
> - (modified) llvm/test/CodeGen/AArch64/ptrauth-fpac.ll (+47-34) 
> - (modified) 
> llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll 
> (+27-21) 
> - (modified) llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll 
> (+138-118) 
> 
> 
> ``diff
> diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
> b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
> index 79b190388eb75..73d3fb575897e 100644
> --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
> +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
> @@ -69,15 +69,6 @@
>  
>  using namespace llvm;
>  
> -enum PtrauthCheckMode { Default, Unchecked, Poison, Trap };
> -static cl::opt PtrauthAuthChecks(
> -"aarch64-ptrauth-auth-checks", cl::Hidden,
> -cl::values(clEnumValN(Unchecked, "none", "don't test for failure"),
> -   clEnumValN(Poison, "poison", "poison on failure"),
> -   clEnumValN(Trap, "trap", "trap on failure")),
> -cl::desc("Check pointer authentication auth/resign failures"),
> -cl::init(Default));
> -
>  #define DEBUG_TYPE "asm-printer"
>  
>  namespace {
> @@ -2868,7 +2859,7 @@ void AArch64AsmPrinter::emitInstruction(const 
> MachineInstr *MI) {
>  return;
>}
>  
> -  case AArch64::AUT:
> +  case AArch64::AUTx16x17:
>case AArch64::AUTPAC:
>  emitPtrauthAuthResign(MI);
>  return;
> diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp 
> b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
> index 22083460b400a..2eafb8eae2082 100644
> --- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
> +++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
> @@ -361,7 +361,7 @@ class AArch64DAGToDAGISel : public SelectionDAGISel {
>  
>bool tryIndexedLoad(SDNode *N);
>  
> -  void SelectPtrauthAuth(SDNode *N);
> +  void SelectPtrauthAuthX16X17(SDNode *N);
>void SelectPtrauthResign(SDNode *N);
>  
>bool trySelectStackSlotTagP(SDNode *N);
> @@ -1521,7 +1521,7 @@ extractPtrauthBlendDiscriminators(SDValue Disc, 
> SelectionDAG *DAG) {
>AddrDisc);
>  }
>  
> -void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) {
> +void AArch64DAGToDAGISel::SelectPtrauthAuthX16X17(SDNode *N) {
>SDLoc DL(N);
>// IntrinsicID is operand #0
>SDValue Val = N->getOperand(1);
> @@ -1539,7 +1539,7 @@ void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) {
>   AArch64::X16, Val, SDValue());
>SDValue Ops[] = {AUTKey, AUTConstDisc, AUTAddrDisc, X16Copy.getValue(1)};
>  
> -  SDNode *AUT = CurDAG->getMachineNode(AArch64::AUT, DL, MVT::i64, Ops);
> +  SDNode *AUT = CurDAG->getMachineNode(AArch64::AUTx16x17, DL, MVT::i64, 
> Ops);
>ReplaceNode(N, AUT);
>  }
>  
> @@ -5613,7 +5613,9 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) {
>return;
>  
>  case Intrinsic::ptrauth_auth:
> -  SelectPtrauthAuth(Node);
> +  if (!Subtarget->isX16X17Safer(CurDAG->getMachineFunction()))
> +break;
> +  SelectPtrauthAuthX16X17(Node);
>return;
>  
>  case Intrinsic::ptrauth_resign:
> diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
> b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
> index 6c61e3a613f6f..98a35b3840771 100644
> --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
> +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
> @@ -66,6 +66,14 @@ def HasLOR   : Predicate<"Subtarget->hasLOR()">,
>  def HasPAuth : Predicate<"Subtarget->hasPAuth()">,
> AssemblerPredicateWithAll<(all_of FeaturePAuth), 
> "pauth">;
>  
> +// On most operating systems, the x16 and x17 registers are not special, so
> +// there is no benefit, and only a code size cost, to constraining PAC
> +// instructions to only using them. This predicate may be used to guard 
> patterns
> +// that allow PAC instructi

[llvm-branch-commits] [llvm] llvm-reduce: Do not reduce alloca array sizes to 0 (PR #132864)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

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


[llvm-branch-commits] AArch64: Relax x16/x17 constraint on AUT in certain cases. (PR #132857)

2025-03-24 Thread via llvm-branch-commits

Amir429206 wrote:

9a7delection

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


[llvm-branch-commits] [llvm] llvm-reduce: Do not reduce alloca array sizes to 0 (PR #132864)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

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

* **#132864** https://app.graphite.dev/github/pr/llvm/llvm-project/132864?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/132864?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#132862** https://app.graphite.dev/github/pr/llvm/llvm-project/132862?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#132732** https://app.graphite.dev/github/pr/llvm/llvm-project/132732?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>: 1 other dependent PR 
([#132733](https://github.com/llvm/llvm-project/pull/132733) https://app.graphite.dev/github/pr/llvm/llvm-project/132733?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>)
* `main`




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


https://github.com/llvm/llvm-project/pull/132864
___
llvm-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] [YAML] fix output incorrect format for block scalar string (PR #131694)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

can you rebase to retrigger tests 

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


[llvm-branch-commits] [clang] [clang] Track final substitution for Subst* AST nodes (PR #132748)

2025-03-24 Thread Shafik Yaghmour via llvm-branch-commits


@@ -80,7 +80,7 @@ void test2() {
 // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from 
argument type to parameter type for 1st argument
 // CHECK-ELIDE-TREE:   I2<
 // CHECK-ELIDE-TREE: [double != int],
-// CHECK-ELIDE-TREE: [...], 

shafik wrote:

There are a lot of merely formatting changes here, it is already a large PR and 
it feels distracting, I would have preferred this was a separate NFC commit to 
fix the formatting.

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


[llvm-branch-commits] [clang] [clang] Track final substitution for Subst* AST nodes (PR #132748)

2025-03-24 Thread Matheus Izvekov via llvm-branch-commits


@@ -265,14 +265,14 @@ int k9 = f9(V9());
 // CHECK-ELIDE-TREE:   S9<
 // CHECK-ELIDE-TREE: [2 * ...],
 // CHECK-ELIDE-TREE: U9<
-// CHECK-ELIDE-TREE:   [(no qualifiers) != const] double>>

mizvekov wrote:

Yeah, with the Subst type node, you get difference when printing  if the node 
is top-level qualified, versus when it is bottom-qualified. So you can get 
harmless differences in the order const appears, and in this case here 
differences in the order you see qualifiers as you single step desugar the 
types.

The tree-differ could be improved to remove these inconsistencies, but given 
the harmless nature of the effect we don't need to do it now.

https://github.com/llvm/llvm-project/pull/132748
___
llvm-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] [YAML] fix output incorrect format for block scalar string (PR #131694)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/131694
___
llvm-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/20.x: [llvm-dlltool] Implement the --identify option (PR #132483)

2025-03-24 Thread Martin Storsjö via llvm-branch-commits

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


[llvm-branch-commits] [llvm] llvm-reduce: Fix asserting on TargetExtTypes that do not support zeroinit (PR #132733)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits

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

So far I've been unsuccessful in finding an example where the used constant
value is directly observed in the output. This avoids an assert in an 
intermediate
step of value replacement.

>From caedfd891a14f679e1f5f3d5f00f0e63d8599676 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Mon, 24 Mar 2025 19:52:11 +0700
Subject: [PATCH] llvm-reduce: Fix asserting on TargetExtTypes that do not
 support zeroinit

So far I've been unsuccessful in finding an example where the used constant
value is directly observed in the output. This avoids an assert in an 
intermediate
step of value replacement.
---
 .../operands-to-args-target-ext-type.ll   | 32 +++
 .../llvm-reduce/reduce-args-target-ext-ty.ll  | 13 
 llvm/tools/llvm-reduce/deltas/Utils.cpp   | 11 ++-
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 
llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
 create mode 100644 llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll

diff --git a/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll 
b/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
new file mode 100644
index 0..cafd460f14ab3
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/operands-to-args-target-ext-type.ll
@@ -0,0 +1,32 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction 
--delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg 
--check-prefixes=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefixes=RESULT
+
+; Make sure there's no assert from trying to create a
+; not-zeroinitializable target ext type
+
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+declare target("sometarget.sometype") @produces_ext_ty()
+
+; INTERESTING: define void @not_zero_foldable(
+
+; RESULT: define void @not_zero_foldable(target("sometarget.sometype") %call) {
+; RESULT-NEXT: %call1 = call target("sometarget.sometype") @produces_ext_ty()
+; RESULT-NEXT: call void @uses_ext_ty(target("sometarget.sometype") %call)
+define void @not_zero_foldable() {
+  %call = call target("sometarget.sometype") @produces_ext_ty()
+  call void @uses_ext_ty(target("sometarget.sometype") %call)
+  ret void
+}
+
+declare void @uses_zeroinit_ext_ty(target("spirv.zeroinit"))
+declare target("sometarget.sometype") @produces_zeroinit_ext_ty()
+
+; INTERESTING: define void @foldable_to_zero(
+; RESULT: define void @foldable_to_zero(target("spirv.zeroinit") %call) {
+define void @foldable_to_zero() {
+  %call = call target("spirv.zeroinit") @produces_zeroinit_ext_ty()
+  call void @uses_zeroinit_ext_ty(target("spirv.zeroinit") %call)
+  ret void
+}
+
diff --git a/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll 
b/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll
new file mode 100644
index 0..e3a7e80f5e4ef
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/reduce-args-target-ext-ty.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction 
--delta-passes=arguments --test FileCheck --test-arg %s --test-arg 
--check-prefixes=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefixes=RESULT
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+declare target("sometarget.sometype") @produces_ext_ty()
+
+; INTERESTING: @interesting(
+; RESULT: @interesting(
+; RESULT: void @uses_ext_ty()
+define void @interesting(target("sometarget.sometype") %arg) {
+  call void @uses_ext_ty(target("sometarget.sometype") %arg)
+  ret void
+}
diff --git a/llvm/tools/llvm-reduce/deltas/Utils.cpp 
b/llvm/tools/llvm-reduce/deltas/Utils.cpp
index 669b9db8a825a..92a44921a7cfb 100644
--- a/llvm/tools/llvm-reduce/deltas/Utils.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Utils.cpp
@@ -24,7 +24,16 @@ cl::opt llvm::Verbose("verbose",
 cl::init(false), cl::cat(LLVMReduceOptions));
 
 Value *llvm::getDefaultValue(Type *T) {
-  return T->isVoidTy() ? PoisonValue::get(T) : Constant::getNullValue(T);
+  if (T->isVoidTy())
+return PoisonValue::get(T);
+
+  if (auto *TET = dyn_cast(T)) {
+if (TET->hasProperty(TargetExtType::HasZeroInit))
+  return ConstantTargetNone::get(TET);
+return PoisonValue::get(TET);
+  }
+
+  return Constant::getNullValue(T);
 }
 
 bool llvm::hasAliasUse(Function &F) {

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


[llvm-branch-commits] [clang] [llvm] [AMDGPU][Attributor] Rework update of `AAAMDWavesPerEU` (PR #123995)

2025-03-24 Thread Shilei Tian via llvm-branch-commits


@@ -899,4 +899,5 @@ void test_set_fpenv(unsigned long env) {
 
 // CHECK-DAG: [[$GRID_RANGE]] = !{i32 1, i32 0}
 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
-// CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { convergent mustprogress 
nocallback nofree nounwind willreturn memory(none) }
+// CHECK-SPIRV-DAG: attributes #[[$NOUNWIND_READONLY]] = { convergent 
mustprogress nocallback nofree nounwind willreturn memory(none) }
+// CHECK-AMDGCN-DAG: attributes #[[$NOUNWIND_READONLY]] = { convergent 
mustprogress nocallback nofree nounwind willreturn memory(none) 
"amdgpu-waves-per-eu"="4,10" }

shiltian wrote:

`clang -cc1` seems to run optimization by default.

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


[llvm-branch-commits] [clang] [llvm] [AMDGPU][Attributor] Rework update of `AAAMDWavesPerEU` (PR #123995)

2025-03-24 Thread Shilei Tian via llvm-branch-commits


@@ -1336,6 +1311,59 @@ static void addPreloadKernArgHint(Function &F, 
TargetMachine &TM) {
   }
 }
 
+static void checkWavesPerEU(Module &M, TargetMachine &TM) {
+  for (Function &F : M) {
+const GCNSubtarget &ST = TM.getSubtarget(F);
+
+auto FlatWgrpSizeAttr =
+AMDGPU::getIntegerPairAttribute(F, "amdgpu-flat-work-group-size");
+auto WavesPerEUAttr = AMDGPU::getIntegerPairAttribute(
+F, "amdgpu-waves-per-eu", /*OnlyFirstRequired=*/true);
+
+unsigned MinWavesPerEU = ST.getMinWavesPerEU();
+unsigned MaxWavesPerEU = ST.getMaxWavesPerEU();
+
+unsigned MinFlatWgrpSize = 1U;
+unsigned MaxFlatWgrpSize = 1024U;
+if (FlatWgrpSizeAttr.has_value()) {
+  MinFlatWgrpSize = FlatWgrpSizeAttr->first;
+  MaxFlatWgrpSize = *(FlatWgrpSizeAttr->second);
+}

shiltian wrote:

`FlatWgrpSizeAttr->second` is `std::optional`.

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


[llvm-branch-commits] [clang] [clang-tools-extra] [clang][HeuristicResolver] Apply default argument heuristic in resolveDeclRefExpr as well (PR #132576)

2025-03-24 Thread Shafik Yaghmour via llvm-branch-commits


@@ -315,9 +315,9 @@ std::vector 
HeuristicResolverImpl::resolveMemberExpr(
 
 std::vector
 HeuristicResolverImpl::resolveDeclRefExpr(const DependentScopeDeclRefExpr *RE) 
{
-  return resolveDependentMember(
-  resolveNestedNameSpecifierToType(RE->getQualifier()), RE->getDeclName(),
-  StaticFilter);
+  QualType Qualifier = resolveNestedNameSpecifierToType(RE->getQualifier());
+  Qualifier = simplifyType(Qualifier, nullptr, /*UnwrapPointer=*/false);

shafik wrote:

```suggestion
  Qualifier = simplifyType(Qualifier, /*E=*/nullptr, /*UnwrapPointer=*/false);
```

The name is not the most descriptive.

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


[llvm-branch-commits] [clang] [llvm] [AMDGPU][Attributor] Rework update of `AAAMDWavesPerEU` (PR #123995)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits


@@ -1336,6 +1311,59 @@ static void addPreloadKernArgHint(Function &F, 
TargetMachine &TM) {
   }
 }
 
+static void checkWavesPerEU(Module &M, TargetMachine &TM) {

arsenm wrote:

Missing comment, and "check"? This modifies attributes 

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


[llvm-branch-commits] [clang] [clang] Track final substitution for Subst* AST nodes (PR #132748)

2025-03-24 Thread Matheus Izvekov via llvm-branch-commits

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

This patch re-adds Subst* nodes for 'Final' substitutions, adding a bit to 
these nodes to differentiate them from non-Final ones, which for example helps 
track forward progress in resugaring.

This was originally changed when we added support for sugared substitutions in 
the template instantiator 
(https://github.com/llvm/llvm-project/commit/326feaafb0913ec6b21d1d89d09cbdbb40db7503),
 and later applied to NTTP and default argument substitution 
(https://github.com/llvm/llvm-project/commit/ab1140874fc6ab8ceb55a470489b80d953e1c6a6)
 and type alias templates (7f78f99fe5af82361d37adcbd2daa4d04afba13d).

This kind of instantiation is favored for entities which we don't track 
specializations, like the aforementioned cases because:
* Without tracking specializations, its not possible to (correctly) resugar 
these later.
* A change to track specialization and adding resugar pass would have been more 
expensive.

While the node could have been still useful, its removal helped offset the 
extra costs of the sugared instantiation.

Otherwise, adding them would also necessitate tracking which nodes don't need 
to be resugared later, which this patch does.

Adding the node back does add a little bit of performance penalty on itself:
![image](https://github.com/user-attachments/assets/f0863092-1dea-42f1-91a1-e163a6d7b2e1)

0.25% on stage2-clang.

And this will make resugaring a little bit more expensive later when that's 
upstreamed, since there are more AST nodes to walk, and more AST nodes to 
produce.

Before:
![image](https://github.com/user-attachments/assets/2d8824ed-ce5e-424b-90f3-bf1afc6cfe15)

After:
![image](https://github.com/user-attachments/assets/3c48b9fb-9566-4428-ba20-83d5e68c1668)

Which on the current implementation and applications of resugaring transform, 
is an extra 0.24% on stage2-clang.

Some upstream users reported desirability of keeping these Subst* nodes in all 
cases, and we had added a special frontend flag to control its removal, which 
this patch now also removes.

>From 617eb6d28d686aeda3b3880618092ee2d456de51 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Sat, 22 Mar 2025 16:03:04 -0300
Subject: [PATCH 1/4] [clang] Track final substitution for
 SubstTemplateTemplateParm nodes

---
 clang/include/clang/AST/ASTContext.h   |  9 +
 clang/include/clang/AST/PropertiesBase.td  |  3 ++-
 clang/include/clang/AST/TemplateName.h | 17 -
 clang/include/clang/AST/Type.h |  3 ++-
 clang/lib/AST/ASTContext.cpp   |  6 +++---
 clang/lib/AST/ASTImporter.cpp  |  2 +-
 clang/lib/AST/TemplateName.cpp |  6 --
 clang/lib/AST/TextNodeDumper.cpp   |  2 ++
 clang/lib/Sema/SemaTemplateInstantiate.cpp |  8 ++--
 9 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1f7c75559e1e9..14a097189ca86 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2396,10 +2396,11 @@ class ASTContext : public RefCountedBase {
 const IdentifierInfo *Name) const;
   TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
 OverloadedOperatorKind Operator) const;
-  TemplateName
-  getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
-   unsigned Index,
-   std::optional PackIndex) const;
+  TemplateName getSubstTemplateTemplateParm(TemplateName replacement,
+Decl *AssociatedDecl,
+unsigned Index,
+std::optional PackIndex,
+bool Final) const;
   TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument 
&ArgPack,
 Decl *AssociatedDecl,
 unsigned Index,
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 5f3a885832e2e..416914db2f7c8 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -729,8 +729,9 @@ let Class = PropertyTypeCase in {
   def : Property<"packIndex", Optional> {
 let Read = [{ parm->getPackIndex() }];
   }
+  def : Property<"final", Bool> { let Read = [{ parm->getFinal() }]; }
   def : Creator<[{
-return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, 
index, packIndex);
+return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, 
index, packIndex, final);
   }]>;
 }
 let Class = PropertyTypeCase in 
{
diff --git a/clang/include/clang/AST/TemplateName.h 
b/clang/include/clang/AST/TemplateName.h
index ce97f834bfc1d.

[llvm-branch-commits] [clang] [clang] Track final substitution for Subst* AST nodes (PR #132748)

2025-03-24 Thread Matheus Izvekov via llvm-branch-commits

mizvekov wrote:

FYI @ymand @jvoung 

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


[llvm-branch-commits] [clang] [clang] Track final substitution for Subst* AST nodes (PR #132748)

2025-03-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

This patch re-adds Subst* nodes for 'Final' substitutions, adding a bit to 
these nodes to differentiate them from non-Final ones, which for example helps 
track forward progress in resugaring.

This was originally changed when we added support for sugared substitutions in 
the template instantiator 
(https://github.com/llvm/llvm-project/commit/326feaafb0913ec6b21d1d89d09cbdbb40db7503),
 and later applied to NTTP and default argument substitution 
(https://github.com/llvm/llvm-project/commit/ab1140874fc6ab8ceb55a470489b80d953e1c6a6)
 and type alias templates (7f78f99fe5af82361d37adcbd2daa4d04afba13d).

This kind of instantiation is favored for entities which we don't track 
specializations, like the aforementioned cases because:
* Without tracking specializations, its not possible to (correctly) resugar 
these later.
* A change to track specialization and adding resugar pass would have been more 
expensive.

While the node could have been still useful, its removal helped offset the 
extra costs of the sugared instantiation.

Otherwise, adding them would also necessitate tracking which nodes don't need 
to be resugared later, which this patch does.

Adding the node back does add a little bit of performance penalty on itself:
![image](https://github.com/user-attachments/assets/f0863092-1dea-42f1-91a1-e163a6d7b2e1)

0.25% on stage2-clang.

And this will make resugaring a little bit more expensive later when that's 
upstreamed, since there are more AST nodes to walk, and more AST nodes to 
produce.

Before:
![image](https://github.com/user-attachments/assets/2d8824ed-ce5e-424b-90f3-bf1afc6cfe15)

After:
![image](https://github.com/user-attachments/assets/3c48b9fb-9566-4428-ba20-83d5e68c1668)

Which on the current implementation and applications of resugaring transform, 
is an extra 0.24% on stage2-clang.

Some upstream users reported desirability of keeping these Subst* nodes in all 
cases, and we had added a special frontend flag to control its removal, which 
this patch now also removes.

---

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


21 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+9-8) 
- (modified) clang/include/clang/AST/ExprCXX.h (+20-5) 
- (modified) clang/include/clang/AST/PropertiesBase.td (+2-1) 
- (modified) clang/include/clang/AST/TemplateName.h (+12-5) 
- (modified) clang/include/clang/AST/Type.h (+14-10) 
- (modified) clang/include/clang/AST/TypeProperties.td (+2-2) 
- (modified) clang/include/clang/Basic/LangOptions.def (-1) 
- (modified) clang/include/clang/Driver/Options.td (-6) 
- (modified) clang/lib/AST/ASTContext.cpp (+8-7) 
- (modified) clang/lib/AST/ASTImporter.cpp (+5-4) 
- (modified) clang/lib/AST/ExprCXX.cpp (+4-2) 
- (modified) clang/lib/AST/TemplateName.cpp (+4-2) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+4) 
- (modified) clang/lib/AST/Type.cpp (+18-4) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+4-10) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+18-30) 
- (modified) clang/lib/Sema/TreeTransform.h (+2-1) 
- (removed) 
clang/test/AST/ast-dump-retain-subst-template-type-parm-type-ast-nodes.cpp 
(-18) 
- (modified) clang/test/AST/ast-dump-template-decls.cpp (+12-6) 
- (modified) clang/test/Misc/diag-template-diffing-cxx11.cpp (+37-37) 
- (modified) clang/test/SemaTemplate/make_integer_seq.cpp (+6-2) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1f7c75559e1e9..2ef8112225767 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1795,10 +1795,10 @@ class ASTContext : public RefCountedBase {
   QualType Wrapped, QualType Contained,
   const HLSLAttributedResourceType::Attributes &Attrs);
 
-  QualType
-  getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
-   unsigned Index,
-   std::optional PackIndex) const;
+  QualType getSubstTemplateTypeParmType(QualType Replacement,
+Decl *AssociatedDecl, unsigned Index,
+std::optional PackIndex,
+bool Final) const;
   QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
 unsigned Index, bool Final,
 const TemplateArgument &ArgPack);
@@ -2396,10 +2396,11 @@ class ASTContext : public RefCountedBase {
 const IdentifierInfo *Name) const;
   TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
 OverloadedOperatorKind Operator) const;
-  TemplateName
-  getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
-

[llvm-branch-commits] [clang] [llvm] [AMDGPU][Attributor] Rework update of `AAAMDWavesPerEU` (PR #123995)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits


@@ -1425,8 +1453,14 @@ static bool runImpl(Module &M, AnalysisGetter &AG, 
TargetMachine &TM,
 }
   }
 
-  ChangeStatus Change = A.run();
-  return Change == ChangeStatus::CHANGED;
+  bool Changed = A.run() == ChangeStatus::CHANGED;
+
+  if (Changed && (LTOPhase == ThinOrFullLTOPhase::None ||
+  LTOPhase == ThinOrFullLTOPhase::FullLTOPostLink ||
+  LTOPhase == ThinOrFullLTOPhase::ThinLTOPostLink))
+checkWavesPerEU(M, TM);

arsenm wrote:

This isn't running as part of the attribute run? Why isn't this part of 
manifest? 

Changed is also really course, you only can care about specific attributes 
changing 

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


[llvm-branch-commits] [clang] [llvm] [AMDGPU][Attributor] Rework update of `AAAMDWavesPerEU` (PR #123995)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits


@@ -1336,6 +1311,59 @@ static void addPreloadKernArgHint(Function &F, 
TargetMachine &TM) {
   }
 }
 
+static void checkWavesPerEU(Module &M, TargetMachine &TM) {
+  for (Function &F : M) {
+const GCNSubtarget &ST = TM.getSubtarget(F);
+
+auto FlatWgrpSizeAttr =
+AMDGPU::getIntegerPairAttribute(F, "amdgpu-flat-work-group-size");
+auto WavesPerEUAttr = AMDGPU::getIntegerPairAttribute(
+F, "amdgpu-waves-per-eu", /*OnlyFirstRequired=*/true);
+
+unsigned MinWavesPerEU = ST.getMinWavesPerEU();
+unsigned MaxWavesPerEU = ST.getMaxWavesPerEU();
+
+unsigned MinFlatWgrpSize = 1U;
+unsigned MaxFlatWgrpSize = 1024U;
+if (FlatWgrpSizeAttr.has_value()) {
+  MinFlatWgrpSize = FlatWgrpSizeAttr->first;
+  MaxFlatWgrpSize = *(FlatWgrpSizeAttr->second);
+}
+
+// Start with the max range.
+unsigned Min = MinWavesPerEU;
+unsigned Max = MaxWavesPerEU;
+
+// If the attribute exists, set them to the value from the attribute.
+if (WavesPerEUAttr.has_value()) {
+  Min = WavesPerEUAttr->first;
+  if (WavesPerEUAttr->second.has_value())
+Max = *(WavesPerEUAttr->second);
+}

arsenm wrote:

Does this really need another variant of the parsing logic in GCNSubtarget? 

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


[llvm-branch-commits] [clang] [llvm] [AMDGPU][Attributor] Rework update of `AAAMDWavesPerEU` (PR #123995)

2025-03-24 Thread Matt Arsenault via llvm-branch-commits


@@ -1160,24 +1138,21 @@ struct AAAMDWavesPerEU : public AAAMDSizeRangeAttribute 
{
   LLVM_DEBUG(dbgs() << '[' << getName() << "] Call " << Caller->getName()
 << "->" << Func->getName() << '\n');
 
-  const auto *CallerInfo = A.getAAFor(
+  const auto *CallerAA = A.getAAFor(
   *this, IRPosition::function(*Caller), DepClassTy::REQUIRED);
-  const auto *AssumedGroupSize = A.getAAFor(
-  *this, IRPosition::function(*Func), DepClassTy::REQUIRED);
-  if (!CallerInfo || !AssumedGroupSize || !CallerInfo->isValidState() ||
-  !AssumedGroupSize->isValidState())
+  if (!CallerAA || !CallerAA->isValidState())
 return false;
 
-  unsigned Min, Max;
-  std::tie(Min, Max) = InfoCache.getEffectiveWavesPerEU(
-  *Caller,
-  {CallerInfo->getAssumed().getLower().getZExtValue(),
-   CallerInfo->getAssumed().getUpper().getZExtValue() - 1},
-  {AssumedGroupSize->getAssumed().getLower().getZExtValue(),
-   AssumedGroupSize->getAssumed().getUpper().getZExtValue() - 1});
-  ConstantRange CallerRange(APInt(32, Min), APInt(32, Max + 1));
-  IntegerRangeState CallerRangeState(CallerRange);
-  Change |= clampStateAndIndicateChange(this->getState(), 
CallerRangeState);
+  auto Assumed = this->getAssumed();

arsenm wrote:

No auto 

https://github.com/llvm/llvm-project/pull/123995
___
llvm-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] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Garvit Gupta (quic-garvgupt)


Changes

Add support for `-u` option to force defined symbols. This option is supported
by both lld and gnuld.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 4th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

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


3 Files Affected:

- (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+3-2) 
- (removed) clang/test/Driver/riscv-args.c (-6) 
- (added) clang/test/Driver/undefined-symbols.c (+15) 


``diff
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 919fc6fe71178..edf9ecc728282 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -566,8 +566,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
-options::OPT_s, options::OPT_t, options::OPT_r});
+  Args.addAllArgs(CmdArgs,
+  {options::OPT_L, options::OPT_u, options::OPT_T_Group,
+   options::OPT_s, options::OPT_t, options::OPT_r});
 
   TC.AddFilePathLibArgs(Args, CmdArgs);
 
diff --git a/clang/test/Driver/riscv-args.c b/clang/test/Driver/riscv-args.c
deleted file mode 100644
index cab08e5b0f811..0
--- a/clang/test/Driver/riscv-args.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// Check the arguments are correctly passed
-
-// Make sure -T is the last with gcc-toolchain option
-// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 
-T a.lds -u foo %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LD %s
-// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
diff --git a/clang/test/Driver/undefined-symbols.c 
b/clang/test/Driver/undefined-symbols.c
new file mode 100644
index 0..0ce0db43bccad
--- /dev/null
+++ b/clang/test/Driver/undefined-symbols.c
@@ -0,0 +1,15 @@
+// Check the arguments are correctly passed
+
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 
-T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD %s
+// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
+
+// TODO: Merge this test with the above in the last patch when finally 
integrating riscv
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### --target=aarch64-none-elf --gcc-toolchain= -Xlinker 
--defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-LD %s
+// RUN: %clang -### --target=armv6m-none-eabi --gcc-toolchain= -Xlinker 
--defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-LD %s
+// CHECK-ARM-LD: {{.*}} "-T" "a.lds" "-u" "foo" {{.*}} "--defsym=FOO=10"
+

``




https://github.com/llvm/llvm-project/pull/132807
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -524,12 +552,21 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
-  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
+  if (!D.SysRoot.empty())
+CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
   CmdArgs.push_back("-Bstatic");
 
-  if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
-CmdArgs.push_back("--no-relax");
+  if (Triple.isRISCV()) {
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("--no-relax");
+if (TC.isUsingLD()) {
+  CmdArgs.push_back("-m");
+  CmdArgs.push_back(Arch == llvm::Triple::riscv64 ? "elf64lriscv"
+  : "elf32lriscv");
+}

quic-garvgupt wrote:

Fixed

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -524,12 +552,21 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
-  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
+  if (!D.SysRoot.empty())
+CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
   CmdArgs.push_back("-Bstatic");
 
-  if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
-CmdArgs.push_back("--no-relax");
+  if (Triple.isRISCV()) {
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("--no-relax");
+if (TC.isUsingLD()) {
+  CmdArgs.push_back("-m");
+  CmdArgs.push_back(Arch == llvm::Triple::riscv64 ? "elf64lriscv"
+  : "elf32lriscv");
+}
+CmdArgs.push_back("-X");
+  }

quic-garvgupt wrote:

Done
[RISCV] Integrate RISCV target in baremetal toolchain object and deprecate 
RISCVToolchain object https://github.com/llvm/llvm-project/pull/121831

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits


@@ -540,19 +577,54 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_r)) {
-CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  bool WantCRTs =
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+  const char *crtbegin, *crtend;
+  if (WantCRTs) {
+if (!Args.hasArg(options::OPT_r))
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (TC.isUsingLD()) {
+  auto RuntimeLib = TC.GetRuntimeLibType(Args);
+  if (RuntimeLib == ToolChain::RLT_Libgcc) {
+crtbegin = "crtbegin.o";
+crtend = "crtend.o";
+  } else {
+assert(RuntimeLib == ToolChain::RLT_CompilerRT);
+crtbegin =
+TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+crtend =
+TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+  }
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtbegin)));
+}
   }
 
-  Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
-options::OPT_s, options::OPT_t, options::OPT_r});
+  Args.addAllArgs(CmdArgs,
+  {options::OPT_L, options::OPT_u, options::OPT_T_Group,
+   options::OPT_s, options::OPT_t, options::OPT_r});
 
   TC.AddFilePathLibArgs(Args, CmdArgs);
 
   for (const auto &LibPath : TC.getLibraryPaths())
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-L", LibPath)));
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+// Find the first filename InputInfo object.
+auto Input = llvm::find_if(
+Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
+if (Input == Inputs.end())
+  // For a very rare case, all of the inputs to the linker are
+  // InputArg. If that happens, just use the first InputInfo.
+  Input = Inputs.begin();
+
+addLTOOptions(TC, Args, CmdArgs, Output, *Input,
+  D.getLTOMode() == LTOK_Thin);
+  }

quic-garvgupt wrote:

Done
[Driver] Fix link order of BareMetal toolchain object 
https://github.com/llvm/llvm-project/pull/132806

https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt edited 
https://github.com/llvm/llvm-project/pull/132807
___
llvm-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] [Driver] Fix link order of BareMetal toolchain object (PR #132806)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt edited 
https://github.com/llvm/llvm-project/pull/132806
___
llvm-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] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt edited 
https://github.com/llvm/llvm-project/pull/121830
___
llvm-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] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

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


[llvm-branch-commits] [CI] Move CI over to new project computation script (PR #132642)

2025-03-24 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/132642


___
llvm-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] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)

2025-03-24 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt ready_for_review 
https://github.com/llvm/llvm-project/pull/132808
___
llvm-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] [HLSL] DO NOT MERGE - Resource constructors prototype (PR #132453)

2025-03-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Helena Kotas (hekota)


Changes



---

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


14 Files Affected:

- (modified) clang/include/clang/Basic/Builtins.td (+12) 
- (modified) clang/include/clang/Sema/SemaHLSL.h (+4) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+18) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+1-1) 
- (modified) clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp (+113-67) 
- (modified) clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.h (+1) 
- (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+2-1) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+2-4) 
- (modified) clang/lib/Sema/SemaHLSL.cpp (+87) 
- (modified) 
clang/test/CodeGenHLSL/builtins/ByteAddressBuffers-constructors.hlsl (+75-22) 
- (modified) clang/test/CodeGenHLSL/builtins/RWBuffer-constructor-opt.hlsl 
(+1-1) 
- (modified) clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl (+71-7) 
- (modified) 
clang/test/CodeGenHLSL/builtins/StructuredBuffers-constructors.hlsl (+68-37) 
- (modified) clang/test/CodeGenHLSL/resource-bindings.hlsl (+31-19) 


``diff
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 2fbdfaea57ccd..8e3828e4a4771 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4783,6 +4783,18 @@ def HLSLResourceGetPointer : LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
+def HLSLResourceCreatePoisonHandle : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_resource_createpoisonhandle"];
+  let Attributes = [NoThrow];
+  let Prototype = "void(...)";
+}
+
+def HLSLResourceCreateHandleFromBinding : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_resource_createhandlefrombinding"];
+  let Attributes = [NoThrow];
+  let Prototype = "void(...)";
+}
+
 def HLSLAll : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_all"];
   let Attributes = [NoThrow, Const];
diff --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
index f333fe30e8da0..4ad00b210cccf 100644
--- a/clang/include/clang/Sema/SemaHLSL.h
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -105,6 +105,7 @@ class SemaHLSL : public SemaBase {
  HLSLParamModifierAttr::Spelling Spelling);
   void ActOnTopLevelFunction(FunctionDecl *FD);
   void ActOnVariableDeclarator(VarDecl *VD);
+  bool ActOnUninitializedVarDecl(VarDecl *D);
   void ActOnEndOfTranslationUnit(TranslationUnitDecl *TU);
   void CheckEntryPoint(FunctionDecl *FD);
   void CheckSemanticAnnotation(FunctionDecl *EntryPoint, const Decl *Param,
@@ -179,6 +180,9 @@ class SemaHLSL : public SemaBase {
   void processExplicitBindingsOnDecl(VarDecl *D);
 
   void diagnoseAvailabilityViolations(TranslationUnitDecl *TU);
+  bool initResourceVarFromBinding(VarDecl *VD, unsigned SpaceNo,
+  unsigned RegisterNo, int32_t Range,
+  unsigned Index);
 };
 
 } // namespace clang
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a5ed2595bad4d..5e364b5913a13 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19579,6 +19579,24 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 RetTy, CGM.getHLSLRuntime().getCreateResourceGetPointerIntrinsic(),
 ArrayRef{HandleOp, IndexOp});
   }
+  case Builtin::BI__builtin_hlsl_resource_createpoisonhandle: {
+llvm::Type *HandleTy = CGM.getTypes().ConvertType(E->getType());
+return llvm::PoisonValue::get(HandleTy);
+  }
+  case Builtin::BI__builtin_hlsl_resource_createhandlefrombinding: {
+llvm::Type *HandleTy = CGM.getTypes().ConvertType(E->getType());
+Value *SpaceNoOp = EmitScalarExpr(E->getArg(1));
+Value *RegisterNoOp = EmitScalarExpr(E->getArg(2));
+Value *RangeOp = EmitScalarExpr(E->getArg(3));
+Value *IndexOp = EmitScalarExpr(E->getArg(4));
+// FIXME: NonUniformResourceIndex bit is not yet implemented
+Value *NonUniform =
+llvm::ConstantInt::get(llvm::Type::getInt1Ty(getLLVMContext()), false);
+return Builder.CreateIntrinsic(
+HandleTy, CGM.getHLSLRuntime().getCreateHandleFromBindingIntrinsic(),
+ArrayRef{SpaceNoOp, RegisterNoOp, RangeOp, IndexOp,
+  NonUniform});
+  }
   case Builtin::BI__builtin_hlsl_all: {
 Value *Op0 = EmitScalarExpr(E->getArg(0));
 return Builder.CreateIntrinsic(
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index dc34653e8f497..b4e693dbe85f2 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -659,7 +659,7 @@ void CGHLSLRuntime::handleGlobalVarDefinition(const VarDecl 
*VD,
 // not implemented yet.
 return;
 
-  createResourceInitFn(CGM, GV, RBA->getSlotNumber(), RBA->getSpaceNumber());

[llvm-branch-commits] [clang] release/20.x: [Clang] Fix various bugs in alias CTAD transform (PR #132697)

2025-03-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

This patch cherry-picks 032ad590d6, 868c89ff0 and 38d71c9bd onto the 20 release 
branch.

The first patch addresses recently surfaced CTAD problems, which we believe it 
would be nice to roll out the fix quickly, given the release window is not 
closed yet.

The second patch is a follow-up to the first and fixed a test failure on the 
arm32 platform.

The third patch follows-up on the previous patch that I cherry-picked to the 20 
release branch, which removes a unnecessary assertion.

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


6 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+20-8) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+34-12) 
- (modified) clang/lib/Sema/TreeTransform.h (+48-36) 
- (modified) clang/test/SemaCXX/ctad.cpp (+131-1) 
- (modified) clang/test/SemaTemplate/deduction-guide.cpp (+48) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 03b68271b7864..955325026f369 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1060,6 +1060,8 @@ Bug Fixes to C++ Support
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Fixed an integer overflow bug in computing template parameter depths when 
synthesizing CTAD guides. (#GH128691)
 - Fixed an incorrect pointer access when checking access-control on concepts. 
(#GH131530)
+- Fixed various alias CTAD bugs involving variadic template arguments. 
(#GH123591), (#GH127539), (#GH129077),
+  (#GH129620), and (#GH129998).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index b424de9c8a945..6728857edc6d8 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -377,12 +377,10 @@ struct ConvertConstructorToDeductionGuideTransform {
 if (NestedPattern)
   Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
 auto [Depth, Index] = getDepthAndIndex(Param);
-// Depth can still be 0 if FTD belongs to an explicit class template
-// specialization with an empty template parameter list. In that case,
-// we don't want the NewDepth to overflow, and it should remain 0.
-assert(Depth ||
-   cast(FTD->getDeclContext())
-   ->isExplicitSpecialization());
+// Depth can be 0 if FTD belongs to a non-template class/a class
+// template specialization with an empty template parameter list. In
+// that case, we don't want the NewDepth to overflow, and it should
+// remain 0.
 NamedDecl *NewParam = transformTemplateParameter(
 SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment,
 Depth ? Depth - 1 : 0);
@@ -989,6 +987,19 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, 
TypeAliasTemplateDecl *AliasTemplate) {
   return {Template, AliasRhsTemplateArgs};
 }
 
+bool IsNonDeducedArgument(const TemplateArgument &TA) {
+  // The following cases indicate the template argument is non-deducible:
+  //   1. The result is null. E.g. When it comes from a default template
+  //   argument that doesn't appear in the alias declaration.
+  //   2. The template parameter is a pack and that cannot be deduced from
+  //   the arguments within the alias declaration.
+  // Non-deducible template parameters will persist in the transformed
+  // deduction guide.
+  return TA.isNull() ||
+ (TA.getKind() == TemplateArgument::Pack &&
+  llvm::any_of(TA.pack_elements(), IsNonDeducedArgument));
+}
+
 // Build deduction guides for a type alias template from the given underlying
 // deduction guide F.
 FunctionTemplateDecl *
@@ -1057,7 +1068,8 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   // !!NOTE: DeduceResults respects the sequence of template parameters of
   // the deduction guide f.
   for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
-if (const auto &D = DeduceResults[Index]; !D.isNull()) // Deduced
+const auto &D = DeduceResults[Index];
+if (!IsNonDeducedArgument(D))
   DeducedArgs.push_back(D);
 else
   NonDeducedTemplateParamsInFIndex.push_back(Index);
@@ -1121,7 +1133,7 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   Args.addOuterTemplateArguments(TransformedDeducedAliasArgs);
   for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
 const auto &D = DeduceResults[Index];
-if (D.isNull()) {
+if (IsNonDeducedArgument(D)) {
   // 2): Non-deduced template parameters would be substituted later.
   continue;
 }
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index cf29d8a101b43..73567f3be814d 100644
--- a/

[llvm-branch-commits] [clang] release/20.x: [Clang] Fix various bugs in alias CTAD transform (PR #132697)

2025-03-24 Thread Younan Zhang via llvm-branch-commits

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


[llvm-branch-commits] [clang] release/20.x: [Clang] Fix various bugs in alias CTAD transform (PR #132697)

2025-03-24 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/132697

This patch cherry-picks 032ad590d6, 868c89ff0 and 38d71c9bd onto the 20 release 
branch.

The first patch addresses recently surfaced CTAD problems, which we believe it 
would be nice to roll out the fix quickly, given the release window is not 
closed yet.

The second patch is a follow-up to the first and fixed a test failure on the 
arm32 platform.

The third patch follows-up on the previous patch that I cherry-picked to the 20 
release branch, which removes a unnecessary assertion.

>From 9dedad6dc2cd447f4f919b7c6dc25e1b392a5316 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 22 Mar 2025 22:55:58 +0800
Subject: [PATCH] release/20.x: [Clang] Fix various bugs in alias CTAD
 transform

This patch cherry-picks 032ad590d6, 868c89ff0 and 38d71c9bd onto the 20
release branch.

The first patch addresses recently surfaced CTAD problems, which we
believe it would be nice to roll out the fix quickly, given the release
window is not closed yet.

The second patch is a follow-up to the first and fixed a test failure
on the arm32 platform.

The third patch follows-up on the previous patch that I cherry-picked to
the 20 release branch, which removes a unnecessary assertion.
---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/lib/Sema/SemaTemplateDeductionGuide.cpp |  28 ++--
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  46 --
 clang/lib/Sema/TreeTransform.h|  84 ++-
 clang/test/SemaCXX/ctad.cpp   | 132 +-
 clang/test/SemaTemplate/deduction-guide.cpp   |  48 +++
 6 files changed, 283 insertions(+), 57 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 03b68271b7864..955325026f369 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1060,6 +1060,8 @@ Bug Fixes to C++ Support
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Fixed an integer overflow bug in computing template parameter depths when 
synthesizing CTAD guides. (#GH128691)
 - Fixed an incorrect pointer access when checking access-control on concepts. 
(#GH131530)
+- Fixed various alias CTAD bugs involving variadic template arguments. 
(#GH123591), (#GH127539), (#GH129077),
+  (#GH129620), and (#GH129998).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index b424de9c8a945..6728857edc6d8 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -377,12 +377,10 @@ struct ConvertConstructorToDeductionGuideTransform {
 if (NestedPattern)
   Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
 auto [Depth, Index] = getDepthAndIndex(Param);
-// Depth can still be 0 if FTD belongs to an explicit class template
-// specialization with an empty template parameter list. In that case,
-// we don't want the NewDepth to overflow, and it should remain 0.
-assert(Depth ||
-   cast(FTD->getDeclContext())
-   ->isExplicitSpecialization());
+// Depth can be 0 if FTD belongs to a non-template class/a class
+// template specialization with an empty template parameter list. In
+// that case, we don't want the NewDepth to overflow, and it should
+// remain 0.
 NamedDecl *NewParam = transformTemplateParameter(
 SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment,
 Depth ? Depth - 1 : 0);
@@ -989,6 +987,19 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, 
TypeAliasTemplateDecl *AliasTemplate) {
   return {Template, AliasRhsTemplateArgs};
 }
 
+bool IsNonDeducedArgument(const TemplateArgument &TA) {
+  // The following cases indicate the template argument is non-deducible:
+  //   1. The result is null. E.g. When it comes from a default template
+  //   argument that doesn't appear in the alias declaration.
+  //   2. The template parameter is a pack and that cannot be deduced from
+  //   the arguments within the alias declaration.
+  // Non-deducible template parameters will persist in the transformed
+  // deduction guide.
+  return TA.isNull() ||
+ (TA.getKind() == TemplateArgument::Pack &&
+  llvm::any_of(TA.pack_elements(), IsNonDeducedArgument));
+}
+
 // Build deduction guides for a type alias template from the given underlying
 // deduction guide F.
 FunctionTemplateDecl *
@@ -1057,7 +1068,8 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   // !!NOTE: DeduceResults respects the sequence of template parameters of
   // the deduction guide f.
   for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
-if (const auto &D = DeduceResults[Index]; !D.isNull()) // Deduced
+const auto &D = DeduceResults[Index];
+if (!IsNonDeduced

[llvm-branch-commits] [lld] [lld][LoongArch] Convert TLS IE to LE in the normal or medium code model (PR #123680)

2025-03-24 Thread Lu Weining via llvm-branch-commits

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


[llvm-branch-commits] [llvm] AMDGPU/GlobalISel: add RegBankLegalize rules for extends and trunc (PR #132383)

2025-03-24 Thread Petar Avramovic via llvm-branch-commits

https://github.com/petar-avramovic ready_for_review 
https://github.com/llvm/llvm-project/pull/132383
___
llvm-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] [GlobalISel] Combine redundant sext_inreg (PR #131624)

2025-03-24 Thread Pierre van Houtryve via llvm-branch-commits

https://github.com/Pierre-vh updated 
https://github.com/llvm/llvm-project/pull/131624

>From d85d13bb1824c716d19179a1fbeca48f4ed37368 Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Mon, 17 Mar 2025 13:54:59 +0100
Subject: [PATCH 1/3] [GlobalISel] Combine redundant sext_inreg

---
 .../llvm/CodeGen/GlobalISel/CombinerHelper.h  |   3 +
 .../include/llvm/Target/GlobalISel/Combine.td |   9 +-
 .../GlobalISel/CombinerHelperCasts.cpp|  27 +++
 .../combine-redundant-sext-inreg.mir  | 164 ++
 .../combine-sext-trunc-sextinreg.mir  |  87 ++
 .../CodeGen/AMDGPU/GlobalISel/llvm.abs.ll |   5 -
 6 files changed, 289 insertions(+), 6 deletions(-)
 create mode 100644 
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
 create mode 100644 
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-sext-trunc-sextinreg.mir

diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h 
b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index 9b78342c8fc39..5778377d125a8 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -994,6 +994,9 @@ class CombinerHelper {
   // overflow sub
   bool matchSuboCarryOut(const MachineInstr &MI, BuildFnTy &MatchInfo) const;
 
+  // (sext_inreg (sext_inreg x, K0), K1)
+  void applyRedundantSextInReg(MachineInstr &Root, MachineInstr &Other) const;
+
 private:
   /// Checks for legality of an indexed variant of \p LdSt.
   bool isIndexedLoadStoreLegal(GLoadStore &LdSt) const;
diff --git a/llvm/include/llvm/Target/GlobalISel/Combine.td 
b/llvm/include/llvm/Target/GlobalISel/Combine.td
index 660b03080f92e..6a0ff683a4647 100644
--- a/llvm/include/llvm/Target/GlobalISel/Combine.td
+++ b/llvm/include/llvm/Target/GlobalISel/Combine.td
@@ -1849,6 +1849,12 @@ def anyext_of_anyext : ext_of_ext_opcodes;
 def anyext_of_zext : ext_of_ext_opcodes;
 def anyext_of_sext : ext_of_ext_opcodes;
 
+def sext_inreg_of_sext_inreg : GICombineRule<
+   (defs root:$dst),
+   (match (G_SEXT_INREG $x, $src, $a):$other,
+  (G_SEXT_INREG $dst, $x, $b):$root),
+   (apply [{ Helper.applyRedundantSextInReg(*${root}, *${other}); }])>;
+
 // Push cast through build vector.
 class buildvector_of_opcode : GICombineRule <
   (defs root:$root, build_fn_matchinfo:$matchinfo),
@@ -1896,7 +1902,8 @@ def cast_of_cast_combines: GICombineGroup<[
   sext_of_anyext,
   anyext_of_anyext,
   anyext_of_zext,
-  anyext_of_sext
+  anyext_of_sext,
+  sext_inreg_of_sext_inreg,
 ]>;
 
 def cast_combines: GICombineGroup<[
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp 
b/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
index 576fd5fd81703..883a62c308232 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
@@ -378,3 +378,30 @@ bool CombinerHelper::matchCastOfInteger(const MachineInstr 
&CastMI,
 return false;
   }
 }
+
+void CombinerHelper::applyRedundantSextInReg(MachineInstr &Root,
+ MachineInstr &Other) const {
+  assert(Root.getOpcode() == TargetOpcode::G_SEXT_INREG &&
+ Other.getOpcode() == TargetOpcode::G_SEXT_INREG);
+
+  unsigned RootWidth = Root.getOperand(2).getImm();
+  unsigned OtherWidth = Other.getOperand(2).getImm();
+
+  Register Dst = Root.getOperand(0).getReg();
+  Register OtherDst = Other.getOperand(0).getReg();
+  Register Src = Other.getOperand(1).getReg();
+
+  if (RootWidth >= OtherWidth) {
+// The root sext_inreg is entirely redundant because the other one
+// is narrower.
+Observer.changingAllUsesOfReg(MRI, Dst);
+MRI.replaceRegWith(Dst, OtherDst);
+Observer.finishedChangingAllUsesOfReg();
+  } else {
+// RootWidth < OtherWidth, rewrite this G_SEXT_INREG with the source of the
+// other G_SEXT_INREG.
+Builder.buildSExtInReg(Dst, Src, RootWidth);
+  }
+
+  Root.eraseFromParent();
+}
diff --git 
a/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir 
b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
new file mode 100644
index 0..566ee8e6c338d
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
@@ -0,0 +1,164 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030 
-run-pass=amdgpu-regbank-combiner -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: inreg8_inreg16
+tracksRegLiveness: true
+body: |
+  bb.0:
+liveins: $vgpr0
+; CHECK-LABEL: name: inreg8_inreg16
+; CHECK: liveins: $vgpr0
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: %copy:_(s32) = COPY $vgpr0
+; CHECK-NEXT: %inreg:_(s32) = G_SEXT_INREG %copy, 8
+; CHECK-NEXT: $vgpr0 = COPY %inreg(s32)
+%copy:_(s32) = COPY $vgpr0
+%inreg:_(s32) = G_SEXT_INREG %copy, 8
+%inreg1:_(s32) = G_SEXT_INREG %inreg, 16
+$vgpr0 = COPY %inreg1
+...
+
+

[llvm-branch-commits] [llvm] [AMDGPU] Precommit si-fold-bitmask.mir (PR #131310)

2025-03-24 Thread Pierre van Houtryve via llvm-branch-commits

Pierre-vh wrote:

> Then isUnneededShiftMask should probably recognize more forms of the pattern

Yes, but with a cast operation it gets tricky. If I add `(zext node:$src0)` to 
the PatFrag, it doesn't work because the PatFrag is always used like this: 
`(cshl_32 (i32 $src0))`. As `$src0` is inferred to i32, it proceeds to infer 
the zext as a zext to i64 and then we get a type mismatch error.
I'm not sure how to proceed with this one, I need someone to help me figure out 
the right syntax

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


[llvm-branch-commits] [llvm] AMDGPU/GlobalISel: add RegBankLegalize rules for extends and trunc (PR #132383)

2025-03-24 Thread Petar Avramovic via llvm-branch-commits


@@ -489,22 +489,61 @@ RegBankLegalizeRules::RegBankLegalizeRules(const 
GCNSubtarget &_ST,
   .Uni(B32, {{SgprB32}, {Sgpr32AExtBoolInReg, SgprB32, SgprB32}});
 
   addRulesForGOpcs({G_ANYEXT})
+  .Any({{UniS16, S1}, {{None}, {None}}}) // should be combined away
   .Any({{UniS32, S1}, {{None}, {None}}}) // should be combined away
-  .Any({{UniS32, S16}, {{Sgpr32}, {Sgpr16}}});
+  .Any({{UniS64, S1}, {{None}, {None}}}) // should be combined away
+  .Any({{{DivS16, S1}}, {{Vgpr16}, {Vcc}, VccExtToSel}})
+  .Any({{{DivS32, S1}}, {{Vgpr32}, {Vcc}, VccExtToSel}})
+  .Any({{{DivS64, S1}}, {{Vgpr64}, {Vcc}, VccExtToSel}})
+  .Any({{UniS64, S32}, {{Sgpr64}, {Sgpr32}, Ext32To64}})

petar-avramovic wrote:

Probably could improve this one a bit. Originally I wanted to keep rules as 
oneliners. There are Uni and Div that are specialized and have fewer braces and 
think that almost all remaining opcodes are using them.

https://github.com/llvm/llvm-project/pull/132383
___
llvm-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] [GlobalISel] Combine redundant sext_inreg (PR #131624)

2025-03-24 Thread Pierre van Houtryve via llvm-branch-commits

https://github.com/Pierre-vh updated 
https://github.com/llvm/llvm-project/pull/131624

>From f4c801437460aef9b9c2e5f49d1e98ec90fadb16 Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Mon, 17 Mar 2025 13:54:59 +0100
Subject: [PATCH 1/3] [GlobalISel] Combine redundant sext_inreg

---
 .../llvm/CodeGen/GlobalISel/CombinerHelper.h  |   3 +
 .../include/llvm/Target/GlobalISel/Combine.td |   9 +-
 .../GlobalISel/CombinerHelperCasts.cpp|  27 +++
 .../combine-redundant-sext-inreg.mir  | 164 ++
 .../combine-sext-trunc-sextinreg.mir  |  87 ++
 .../CodeGen/AMDGPU/GlobalISel/llvm.abs.ll |   5 -
 6 files changed, 289 insertions(+), 6 deletions(-)
 create mode 100644 
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
 create mode 100644 
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-sext-trunc-sextinreg.mir

diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h 
b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index 9b78342c8fc39..5778377d125a8 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -994,6 +994,9 @@ class CombinerHelper {
   // overflow sub
   bool matchSuboCarryOut(const MachineInstr &MI, BuildFnTy &MatchInfo) const;
 
+  // (sext_inreg (sext_inreg x, K0), K1)
+  void applyRedundantSextInReg(MachineInstr &Root, MachineInstr &Other) const;
+
 private:
   /// Checks for legality of an indexed variant of \p LdSt.
   bool isIndexedLoadStoreLegal(GLoadStore &LdSt) const;
diff --git a/llvm/include/llvm/Target/GlobalISel/Combine.td 
b/llvm/include/llvm/Target/GlobalISel/Combine.td
index 660b03080f92e..6a0ff683a4647 100644
--- a/llvm/include/llvm/Target/GlobalISel/Combine.td
+++ b/llvm/include/llvm/Target/GlobalISel/Combine.td
@@ -1849,6 +1849,12 @@ def anyext_of_anyext : ext_of_ext_opcodes;
 def anyext_of_zext : ext_of_ext_opcodes;
 def anyext_of_sext : ext_of_ext_opcodes;
 
+def sext_inreg_of_sext_inreg : GICombineRule<
+   (defs root:$dst),
+   (match (G_SEXT_INREG $x, $src, $a):$other,
+  (G_SEXT_INREG $dst, $x, $b):$root),
+   (apply [{ Helper.applyRedundantSextInReg(*${root}, *${other}); }])>;
+
 // Push cast through build vector.
 class buildvector_of_opcode : GICombineRule <
   (defs root:$root, build_fn_matchinfo:$matchinfo),
@@ -1896,7 +1902,8 @@ def cast_of_cast_combines: GICombineGroup<[
   sext_of_anyext,
   anyext_of_anyext,
   anyext_of_zext,
-  anyext_of_sext
+  anyext_of_sext,
+  sext_inreg_of_sext_inreg,
 ]>;
 
 def cast_combines: GICombineGroup<[
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp 
b/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
index 576fd5fd81703..883a62c308232 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
@@ -378,3 +378,30 @@ bool CombinerHelper::matchCastOfInteger(const MachineInstr 
&CastMI,
 return false;
   }
 }
+
+void CombinerHelper::applyRedundantSextInReg(MachineInstr &Root,
+ MachineInstr &Other) const {
+  assert(Root.getOpcode() == TargetOpcode::G_SEXT_INREG &&
+ Other.getOpcode() == TargetOpcode::G_SEXT_INREG);
+
+  unsigned RootWidth = Root.getOperand(2).getImm();
+  unsigned OtherWidth = Other.getOperand(2).getImm();
+
+  Register Dst = Root.getOperand(0).getReg();
+  Register OtherDst = Other.getOperand(0).getReg();
+  Register Src = Other.getOperand(1).getReg();
+
+  if (RootWidth >= OtherWidth) {
+// The root sext_inreg is entirely redundant because the other one
+// is narrower.
+Observer.changingAllUsesOfReg(MRI, Dst);
+MRI.replaceRegWith(Dst, OtherDst);
+Observer.finishedChangingAllUsesOfReg();
+  } else {
+// RootWidth < OtherWidth, rewrite this G_SEXT_INREG with the source of the
+// other G_SEXT_INREG.
+Builder.buildSExtInReg(Dst, Src, RootWidth);
+  }
+
+  Root.eraseFromParent();
+}
diff --git 
a/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir 
b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
new file mode 100644
index 0..566ee8e6c338d
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
@@ -0,0 +1,164 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030 
-run-pass=amdgpu-regbank-combiner -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: inreg8_inreg16
+tracksRegLiveness: true
+body: |
+  bb.0:
+liveins: $vgpr0
+; CHECK-LABEL: name: inreg8_inreg16
+; CHECK: liveins: $vgpr0
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: %copy:_(s32) = COPY $vgpr0
+; CHECK-NEXT: %inreg:_(s32) = G_SEXT_INREG %copy, 8
+; CHECK-NEXT: $vgpr0 = COPY %inreg(s32)
+%copy:_(s32) = COPY $vgpr0
+%inreg:_(s32) = G_SEXT_INREG %copy, 8
+%inreg1:_(s32) = G_SEXT_INREG %inreg, 16
+$vgpr0 = COPY %inreg1
+...
+
+

[llvm-branch-commits] [llvm] [GlobalISel] Combine redundant sext_inreg (PR #131624)

2025-03-24 Thread Pierre van Houtryve via llvm-branch-commits

https://github.com/Pierre-vh updated 
https://github.com/llvm/llvm-project/pull/131624

>From f4c801437460aef9b9c2e5f49d1e98ec90fadb16 Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Mon, 17 Mar 2025 13:54:59 +0100
Subject: [PATCH 1/3] [GlobalISel] Combine redundant sext_inreg

---
 .../llvm/CodeGen/GlobalISel/CombinerHelper.h  |   3 +
 .../include/llvm/Target/GlobalISel/Combine.td |   9 +-
 .../GlobalISel/CombinerHelperCasts.cpp|  27 +++
 .../combine-redundant-sext-inreg.mir  | 164 ++
 .../combine-sext-trunc-sextinreg.mir  |  87 ++
 .../CodeGen/AMDGPU/GlobalISel/llvm.abs.ll |   5 -
 6 files changed, 289 insertions(+), 6 deletions(-)
 create mode 100644 
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
 create mode 100644 
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-sext-trunc-sextinreg.mir

diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h 
b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index 9b78342c8fc39..5778377d125a8 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -994,6 +994,9 @@ class CombinerHelper {
   // overflow sub
   bool matchSuboCarryOut(const MachineInstr &MI, BuildFnTy &MatchInfo) const;
 
+  // (sext_inreg (sext_inreg x, K0), K1)
+  void applyRedundantSextInReg(MachineInstr &Root, MachineInstr &Other) const;
+
 private:
   /// Checks for legality of an indexed variant of \p LdSt.
   bool isIndexedLoadStoreLegal(GLoadStore &LdSt) const;
diff --git a/llvm/include/llvm/Target/GlobalISel/Combine.td 
b/llvm/include/llvm/Target/GlobalISel/Combine.td
index 660b03080f92e..6a0ff683a4647 100644
--- a/llvm/include/llvm/Target/GlobalISel/Combine.td
+++ b/llvm/include/llvm/Target/GlobalISel/Combine.td
@@ -1849,6 +1849,12 @@ def anyext_of_anyext : ext_of_ext_opcodes;
 def anyext_of_zext : ext_of_ext_opcodes;
 def anyext_of_sext : ext_of_ext_opcodes;
 
+def sext_inreg_of_sext_inreg : GICombineRule<
+   (defs root:$dst),
+   (match (G_SEXT_INREG $x, $src, $a):$other,
+  (G_SEXT_INREG $dst, $x, $b):$root),
+   (apply [{ Helper.applyRedundantSextInReg(*${root}, *${other}); }])>;
+
 // Push cast through build vector.
 class buildvector_of_opcode : GICombineRule <
   (defs root:$root, build_fn_matchinfo:$matchinfo),
@@ -1896,7 +1902,8 @@ def cast_of_cast_combines: GICombineGroup<[
   sext_of_anyext,
   anyext_of_anyext,
   anyext_of_zext,
-  anyext_of_sext
+  anyext_of_sext,
+  sext_inreg_of_sext_inreg,
 ]>;
 
 def cast_combines: GICombineGroup<[
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp 
b/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
index 576fd5fd81703..883a62c308232 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
@@ -378,3 +378,30 @@ bool CombinerHelper::matchCastOfInteger(const MachineInstr 
&CastMI,
 return false;
   }
 }
+
+void CombinerHelper::applyRedundantSextInReg(MachineInstr &Root,
+ MachineInstr &Other) const {
+  assert(Root.getOpcode() == TargetOpcode::G_SEXT_INREG &&
+ Other.getOpcode() == TargetOpcode::G_SEXT_INREG);
+
+  unsigned RootWidth = Root.getOperand(2).getImm();
+  unsigned OtherWidth = Other.getOperand(2).getImm();
+
+  Register Dst = Root.getOperand(0).getReg();
+  Register OtherDst = Other.getOperand(0).getReg();
+  Register Src = Other.getOperand(1).getReg();
+
+  if (RootWidth >= OtherWidth) {
+// The root sext_inreg is entirely redundant because the other one
+// is narrower.
+Observer.changingAllUsesOfReg(MRI, Dst);
+MRI.replaceRegWith(Dst, OtherDst);
+Observer.finishedChangingAllUsesOfReg();
+  } else {
+// RootWidth < OtherWidth, rewrite this G_SEXT_INREG with the source of the
+// other G_SEXT_INREG.
+Builder.buildSExtInReg(Dst, Src, RootWidth);
+  }
+
+  Root.eraseFromParent();
+}
diff --git 
a/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir 
b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
new file mode 100644
index 0..566ee8e6c338d
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-redundant-sext-inreg.mir
@@ -0,0 +1,164 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030 
-run-pass=amdgpu-regbank-combiner -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: inreg8_inreg16
+tracksRegLiveness: true
+body: |
+  bb.0:
+liveins: $vgpr0
+; CHECK-LABEL: name: inreg8_inreg16
+; CHECK: liveins: $vgpr0
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: %copy:_(s32) = COPY $vgpr0
+; CHECK-NEXT: %inreg:_(s32) = G_SEXT_INREG %copy, 8
+; CHECK-NEXT: $vgpr0 = COPY %inreg(s32)
+%copy:_(s32) = COPY $vgpr0
+%inreg:_(s32) = G_SEXT_INREG %copy, 8
+%inreg1:_(s32) = G_SEXT_INREG %inreg, 16
+$vgpr0 = COPY %inreg1
+...
+
+

[llvm-branch-commits] [llvm] [CodeGen][StaticDataSplitter]Support constant pool partitioning (PR #129781)

2025-03-24 Thread Mingming Liu via llvm-branch-commits


@@ -112,21 +117,52 @@ bool 
StaticDataSplitter::runOnMachineFunction(MachineFunction &MF) {
   return Changed;
 }
 
+const Constant *
+StaticDataSplitter::getConstant(const MachineOperand &Op,
+const TargetMachine &TM,
+const MachineConstantPool *MCP) {
+  if (!Op.isGlobal() && !Op.isCPI())
+return nullptr;
+
+  if (Op.isGlobal()) {
+// Find global variables with local linkage.
+const GlobalVariable *GV = getLocalLinkageGlobalVariable(Op.getGlobal());
+// Skip 'special' global variables conservatively because they are
+// often handled specially, and skip those not in static data
+// sections.
+if (!GV || GV->getName().starts_with("llvm.") ||
+!inStaticDataSection(GV, TM))
+  return nullptr;
+return GV;

mingmingl-llvm wrote:

The global variable handling should be a part of 
https://github.com/llvm/llvm-project/pull/125756, so did it in 
https://github.com/llvm/llvm-project/pull/125756/commits/9302b2b708cdce89add071fa584c12ddb4f9d71d

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


[llvm-branch-commits] [compiler-rt] release/20.x: [compiler-rt][Darwin][x86] Fix instrprof-darwin-exports test (#131425) (PR #132506)

2025-03-24 Thread David Tellenbach via llvm-branch-commits

dtellenbach wrote:

> @dtellenbach I'm unable to add you as a reviewer/merge this myself; could you 
> please take a look at this PR? Thank you!

@j-hui, the LLVM release managers will take it from here and merge this once 
they get around to it.

https://github.com/llvm/llvm-project/pull/132506
___
llvm-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][NFC] Remove unnecessary directory cleanup (PR #132101)

2025-03-24 Thread Paul Kirth via llvm-branch-commits

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

The tests all remove the directory at test start, and it only prevents
inspecting the test artifacts to remove them at the end of the test run.

>From dfc4eaed7e1ae54774a53afcf67d50b074d0eaa7 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Wed, 19 Mar 2025 20:58:15 +
Subject: [PATCH] [clang-doc][NFC] Remove unnecessary directory cleanup

The tests all remove the directory at test start, and it only prevents
inspecting the test artifacts to remove them at the end of the test run.
---
 clang-tools-extra/test/clang-doc/single-file-public.cpp | 4 +---
 clang-tools-extra/test/clang-doc/single-file.cpp| 4 +---
 clang-tools-extra/test/clang-doc/test-path-abs.cpp  | 6 +++---
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/single-file-public.cpp 
b/clang-tools-extra/test/clang-doc/single-file-public.cpp
index 82e81749a1c52..d22ccb6698403 100644
--- a/clang-tools-extra/test/clang-doc/single-file-public.cpp
+++ b/clang-tools-extra/test/clang-doc/single-file-public.cpp
@@ -1,5 +1,4 @@
-// RUN: rm -rf %t
-// RUN: mkdir %t
+// RUN: rm -rf %t && mkdir -p %t
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --public --executor=standalone -p %t %t/test.cpp 
-output=%t/docs
@@ -7,7 +6,6 @@
 //   (which we don't know in advance). This checks the record file by searching
 //   for a name with a 40-char USR name.
 // RUN: find %t/docs -regex ".*/[0-9A-F]*.yaml" -exec cat {} ";" | FileCheck 
%s --check-prefix=CHECK
-// RUN: rm -rf %t
 
 class Record {
 private:
diff --git a/clang-tools-extra/test/clang-doc/single-file.cpp 
b/clang-tools-extra/test/clang-doc/single-file.cpp
index 211afb3b45e52..6fde13c7f510d 100644
--- a/clang-tools-extra/test/clang-doc/single-file.cpp
+++ b/clang-tools-extra/test/clang-doc/single-file.cpp
@@ -1,10 +1,8 @@
-// RUN: rm -rf %t
-// RUN: mkdir %t
+// RUN: rm -rf %t && mkdir -p %t
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp 
-output=%t/docs
 // RUN: cat %t/docs/index.yaml | FileCheck %s --check-prefix=CHECK
-// RUN: rm -rf %t
 
 void function(int x);
 
diff --git a/clang-tools-extra/test/clang-doc/test-path-abs.cpp 
b/clang-tools-extra/test/clang-doc/test-path-abs.cpp
index f6cce95bbea0c..292a2a3b5474d 100644
--- a/clang-tools-extra/test/clang-doc/test-path-abs.cpp
+++ b/clang-tools-extra/test/clang-doc/test-path-abs.cpp
@@ -1,6 +1,6 @@
-// RUN: rm -rf %t && mkdir %t
+// RUN: rm -rf %t && mkdir -p %t
 // RUN: clang-doc --format=html --executor=standalone %s --output=%t
 // RUN: FileCheck %s -input-file=%t/index_json.js  -check-prefix=JSON-INDEX
-// RUN: rm -rf %t
 
-// JSON-INDEX: var RootPath = "{{.*}}test-path-abs.cpp.tmp";
\ No newline at end of file
+// JSON-INDEX: var RootPath = "{{.*}}test-path-abs.cpp.tmp";
+

___
llvm-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][memref] Remove runtime verification for `memref.reinterpret_cast` (PR #132547)

2025-03-24 Thread via llvm-branch-commits

https://github.com/MaheshRavishankar commented:

I think this is OK, but when we create a new memref, dont we want to verify 
that the strides specified dont make it such that accessing using strides goes 
out of bounds?

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