[arch-commits] Commit in (19 files)

Evangelos Foutras foutrelis at gemini.archlinux.org
Tue Jun 21 23:38:56 UTC 2022


    Date: Tuesday, June 21, 2022 @ 23:38:56
  Author: foutrelis
Revision: 449269

Add LLVM 13 packages for Zig

Added:
  clang13/
  clang13/repos/
  clang13/trunk/
  clang13/trunk/PKGBUILD
  clang13/trunk/enable-SSP-and-PIE-by-default.patch
  clang13/trunk/strip-exception-specifications-in-CFI-type-names.patch
  lld13/
  lld13/repos/
  lld13/trunk/
  lld13/trunk/PKGBUILD
  llvm13/
  llvm13/repos/
  llvm13/trunk/
  llvm13/trunk/PKGBUILD
  llvm13/trunk/disable-A-B-A-B-and-BSWAP-in-InstCombine.patch
  llvm13/trunk/disable-DIArgList-in-SPIR-V.patch
  llvm13/trunk/don-t-accept-nullptr-as-GEP-element-type.patch
  llvm13/trunk/don-t-move-DBG_VALUE-instructions.patch
  llvm13/trunk/don-t-override-__attribute__-no_stack_protector.patch

----------------------------------------------------------------------+
 clang13/trunk/PKGBUILD                                               |   94 +
 clang13/trunk/enable-SSP-and-PIE-by-default.patch                    |  374 ++++++
 clang13/trunk/strip-exception-specifications-in-CFI-type-names.patch |   59 +
 lld13/trunk/PKGBUILD                                                 |   67 +
 llvm13/trunk/PKGBUILD                                                |  110 ++
 llvm13/trunk/disable-A-B-A-B-and-BSWAP-in-InstCombine.patch          |   52 
 llvm13/trunk/disable-DIArgList-in-SPIR-V.patch                       |   23 
 llvm13/trunk/don-t-accept-nullptr-as-GEP-element-type.patch          |   63 +
 llvm13/trunk/don-t-move-DBG_VALUE-instructions.patch                 |   91 +
 llvm13/trunk/don-t-override-__attribute__-no_stack_protector.patch   |  540 ++++++++++
 10 files changed, 1473 insertions(+)

Added: clang13/trunk/PKGBUILD
===================================================================
--- clang13/trunk/PKGBUILD	                        (rev 0)
+++ clang13/trunk/PKGBUILD	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,94 @@
+# Maintainer: Evangelos Foutras <evangelos at foutrelis.com>
+# Contributor: Jan "heftig" Steffens <jan.steffens at gmail.com>
+
+pkgname=clang13
+pkgver=13.0.1
+pkgrel=1
+pkgdesc="C language family frontend for LLVM 13"
+arch=('x86_64')
+url="https://clang.llvm.org/"
+license=('custom:Apache 2.0 with LLVM Exception')
+depends=('llvm13-libs' 'gcc')
+makedepends=('llvm13' 'cmake' 'ninja' 'python')
+optdepends=('openmp: OpenMP support in clang with -fopenmp'
+            'llvm13: referenced by some clang headers')
+checkdepends=('llvm')
+_source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
+source=($_source_base/clang-$pkgver.src.tar.xz{,.sig}
+        $_source_base/llvm-$pkgver.src.tar.xz{,.sig}
+        strip-exception-specifications-in-CFI-type-names.patch
+        enable-SSP-and-PIE-by-default.patch)
+sha256sums=('787a9e2d99f5c8720aa1773e4be009461cd30d3bd40fdd24591e473467c917c9'
+            'SKIP'
+            'ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834'
+            'SKIP'
+            '3f4a2784a4c2b2df13e03beb0b66d5805c520f2b9f16ff76e0557daeb284c8fa'
+            '67706047fc93a2e79185d344bdac48219ce042c55ddb9b9397bc98db2153ba58')
+validpgpkeys+=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <hans at chromium.org>
+validpgpkeys+=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar at redhat.com>
+
+# Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
+# installing static libraries; inspired by Gentoo
+_get_distribution_components() {
+  local target
+  ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
+    case $target in
+      clang-libraries|distribution)
+        continue
+        ;;
+      clang|clang-*)
+        ;;
+      clang*|findAllSymbols)
+        continue
+        ;;
+    esac
+    echo $target
+  done
+}
+
+prepare() {
+  cd clang-$pkgver.src
+  mkdir build
+  patch -Np2 -i ../enable-SSP-and-PIE-by-default.patch
+  patch -Np2 -i ../strip-exception-specifications-in-CFI-type-names.patch
+}
+
+build() {
+  cd clang-$pkgver.src/build
+
+  local cmake_args=(
+    -G Ninja
+    -DCMAKE_BUILD_TYPE=Release
+    -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm13
+    -DCMAKE_SKIP_RPATH=ON
+    -DCLANG_LINK_CLANG_DYLIB=ON
+    -DLLVM_BUILD_TESTS=ON
+    -DLLVM_CONFIG=/usr/lib/llvm13/bin/llvm-config
+    -DLLVM_ENABLE_RTTI=ON
+    -DLLVM_EXTERNAL_LIT=/usr/bin/lit
+    -DLLVM_LINK_LLVM_DYLIB=ON
+    -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
+  )
+
+  cmake .. "${cmake_args[@]}"
+  local distribution_components=$(_get_distribution_components | paste -sd\;)
+  test -n "$distribution_components"
+  cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
+
+  cmake .. "${cmake_args[@]}"
+  ninja
+}
+
+check() {
+  cd clang-$pkgver.src/build
+  LD_LIBRARY_PATH=$PWD/lib ninja check-clang
+}
+
+package() {
+  cd clang-$pkgver.src/build
+
+  DESTDIR="$pkgdir" ninja install-distribution
+  install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
+
+# vim:set ts=2 sw=2 et:

Added: clang13/trunk/enable-SSP-and-PIE-by-default.patch
===================================================================
--- clang13/trunk/enable-SSP-and-PIE-by-default.patch	                        (rev 0)
+++ clang13/trunk/enable-SSP-and-PIE-by-default.patch	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,374 @@
+From 683787b5c5c075f53a95f4d85f76302111c89914 Mon Sep 17 00:00:00 2001
+From: Evangelos Foutras <evangelos at foutrelis.com>
+Date: Sat, 23 Oct 2021 05:08:48 +0300
+Subject: [PATCH] Enable SSP and PIE by default
+
+This is a minimal set of changes needed to make clang use SSP and PIE by
+default on Arch Linux. Tests that were easy to adjust have been changed
+accordingly; only test/Driver/linux-ld.c has been marked as "expected
+failure" due to the number of changes it would require (mostly replacing
+crtbegin.o with crtbeginS.o).
+
+Doing so is needed in order to align clang with the new default GCC
+behavior in Arch which generates PIE executables by default and also
+defaults to -fstack-protector-strong. It is not meant to be a long term
+solution, but a simple temporary fix.
+
+Hopefully these changes will be obsoleted by the introduction upstream
+of a compile-time option (https://bugs.llvm.org/show_bug.cgi?id=13410)
+---
+ clang/lib/Driver/ToolChains/Linux.cpp     | 10 ++++++++--
+ clang/lib/Driver/ToolChains/Linux.h       |  5 +++++
+ clang/test/Driver/cross-linux.c           | 16 ++++++++--------
+ clang/test/Driver/env.c                   |  2 +-
+ clang/test/Driver/fsanitize.c             | 14 +++++++-------
+ clang/test/Driver/gcc-toolchain.cpp       |  6 +++---
+ clang/test/Driver/hexagon-toolchain-elf.c |  2 +-
+ clang/test/Driver/hip-fpie-option.hip     |  4 ++--
+ clang/test/Driver/linux-as.c              |  4 ++--
+ clang/test/Driver/linux-ld.c              |  2 ++
+ clang/test/Driver/ppc-abi.c               | 18 +++++++++++-------
+ clang/test/Driver/riscv32-toolchain.c     |  4 ++--
+ clang/test/Driver/riscv64-toolchain.c     |  4 ++--
+ clang/test/Driver/stack-protector.c       |  4 ++--
+ 14 files changed, 56 insertions(+), 39 deletions(-)
+
+diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
+index c9360fc67165..2b60460e6604 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -652,8 +652,14 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
+ }
+ 
+ bool Linux::isPIEDefault() const {
+-  return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
+-          getTriple().isMusl() || getSanitizerArgs().requiresPIE();
++  const bool IsMips = getTriple().isMIPS();
++  const bool IsAndroid = getTriple().isAndroid();
++
++  if (IsMips || IsAndroid)
++    return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
++            getTriple().isMusl() || getSanitizerArgs().requiresPIE();
++
++  return true;
+ }
+ 
+ bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {
+diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
+index 169a37c44072..a6458092462e 100644
+--- a/clang/lib/Driver/ToolChains/Linux.h
++++ b/clang/lib/Driver/ToolChains/Linux.h
+@@ -10,6 +10,7 @@
+ #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LINUX_H
+ 
+ #include "Gnu.h"
++#include "clang/Basic/LangOptions.h"
+ #include "clang/Driver/ToolChain.h"
+ 
+ namespace clang {
+@@ -46,6 +47,10 @@ public:
+   bool isPIEDefault() const override;
+   bool isNoExecStackDefault() const override;
+   bool IsMathErrnoDefault() const override;
++  LangOptions::StackProtectorMode
++  GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
++    return LangOptions::SSPStrong;
++  }
+   SanitizerMask getSupportedSanitizers() const override;
+   void addProfileRTLibs(const llvm::opt::ArgList &Args,
+                         llvm::opt::ArgStringList &CmdArgs) const override;
+diff --git a/clang/test/Driver/cross-linux.c b/clang/test/Driver/cross-linux.c
+index 59f5a97d2d9d..8d0e9e724aa0 100644
+--- a/clang/test/Driver/cross-linux.c
++++ b/clang/test/Driver/cross-linux.c
+@@ -43,8 +43,8 @@
+ // CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
+ // CHECK-MULTI32-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
+ // CHECK-MULTI32-I386: "-m" "elf_i386"
+-// CHECK-MULTI32-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0]]{{/|\\\\}}crtbegin.o"
+-// CHECK-MULTI32-I386: "-L[[gcc_install]]"
++// CHECK-MULTI32-I386: "crti.o" "crtbeginS.o"
++// CHECK-MULTI32-I386: "-L[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0]]"
+ // CHECK-MULTI32-I386: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib32"
+ // CHECK-MULTI32-I386: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
+ // CHECK-MULTI32-I386: "-L[[sysroot]]/lib"
+@@ -61,8 +61,8 @@
+ // CHECK-MULTI32-X86-64: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
+ // CHECK-MULTI32-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
+ // CHECK-MULTI32-X86-64: "-m" "elf_x86_64"
+-// CHECK-MULTI32-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0]]/64{{/|\\\\}}crtbegin.o"
+-// CHECK-MULTI32-X86-64: "-L[[gcc_install]]/64"
++// CHECK-MULTI32-X86-64: "crti.o" "crtbeginS.o"
++// CHECK-MULTI32-X86-64: "-L[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0]]/64"
+ // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib64"
+ // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
+ // CHECK-MULTI32-X86-64: "-L[[sysroot]]/lib"
+@@ -79,8 +79,8 @@
+ // CHECK-MULTI64-I386: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
+ // CHECK-MULTI64-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
+ // CHECK-MULTI64-I386: "-m" "elf_i386"
+-// CHECK-MULTI64-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0]]/32{{/|\\\\}}crtbegin.o"
+-// CHECK-MULTI64-I386: "-L[[gcc_install]]/32"
++// CHECK-MULTI64-I386: "crti.o" "crtbeginS.o"
++// CHECK-MULTI64-I386: "-L[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0]]/32"
+ // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib32"
+ // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
+ // CHECK-MULTI64-I386: "-L[[sysroot]]/lib"
+@@ -97,8 +97,8 @@
+ // CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
+ // CHECK-MULTI64-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
+ // CHECK-MULTI64-X86-64: "-m" "elf_x86_64"
+-// CHECK-MULTI64-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0]]{{/|\\\\}}crtbegin.o"
+-// CHECK-MULTI64-X86-64: "-L[[gcc_install]]"
++// CHECK-MULTI64-X86-64: "crti.o" "crtbeginS.o"
++// CHECK-MULTI64-X86-64: "-L[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0]]"
+ // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib64"
+ // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
+ // CHECK-MULTI64-X86-64: "-L[[sysroot]]/lib"
+diff --git a/clang/test/Driver/env.c b/clang/test/Driver/env.c
+index e9b86cbcf428..47f304c0420d 100644
+--- a/clang/test/Driver/env.c
++++ b/clang/test/Driver/env.c
+@@ -22,7 +22,7 @@
+ //
+ // CHECK-LD-32-NOT: warning:
+ // CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+-// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/10.2.0{{/|\\\\}}crtbegin.o"
++// CHECK-LD-32: "crtbeginS.o"
+ // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/10.2.0"
+ // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/10.2.0/../../../../i386-unknown-linux/lib"
+ // CHECK-LD-32: "-L[[SYSROOT]]/lib"
+diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
+index b7d61abe7ec5..461b69b0ac15 100644
+--- a/clang/test/Driver/fsanitize.c
++++ b/clang/test/Driver/fsanitize.c
+@@ -344,15 +344,15 @@
+ // RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-sanitize=vptr -fsanitize=undefined,address %s -### 2>&1
+ // OK
+ 
+-// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
+-// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
++// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
++// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ // RUN: %clang -target x86_64-unknown-freebsd -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ // RUN: %clang -target aarch64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ // RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIC-NO-PIE
+ // RUN: %clang -target arm-linux-androideabi24 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ // RUN: %clang -target aarch64-linux-android -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
+-// RUN: %clang -target i386-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
++// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
++// RUN: %clang -target i386-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
+ 
+ // CHECK-NO-PIE-NOT: "-pie"
+ // CHECK-NO-PIE: "-mrelocation-model" "static"
+@@ -687,12 +687,12 @@
+ // RUN: %clang -fno-sanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NOSP
+ // NOSP-NOT: "-fsanitize=safe-stack"
+ 
+-// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
++// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
+ // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP-ASAN
+ // RUN: %clang -target x86_64-linux-gnu -fstack-protector -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
+ // RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SP
+-// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
+-// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
++// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
++// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
+ // RUN: %clang -target i386-contiki-unknown -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
+ // NO-SP-NOT: stack-protector
+ // NO-SP: "-fsanitize=safe-stack"
+diff --git a/clang/test/Driver/gcc-toolchain.cpp b/clang/test/Driver/gcc-toolchain.cpp
+index 7cdba0841b8c..655457d62bf8 100644
+--- a/clang/test/Driver/gcc-toolchain.cpp
++++ b/clang/test/Driver/gcc-toolchain.cpp
+@@ -23,7 +23,7 @@
+ // the same precise formatting of the path as the '-internal-system' flags
+ // above, so we just blanket wildcard match the 'crtbegin.o'.
+ // CHECK: "{{[^"]*}}ld{{(.exe)?}}"
+-// CHECK-SAME: "{{[^"]*}}/usr/lib/gcc/x86_64-linux-gnu/4.8{{/|\\\\}}crtbegin.o"
++// CHECK-SAME: "crtbeginS.o"
+ // CHECK-SAME: "-L[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8"
+ /// On x86_64, there is an extra usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu but we should not test it.
+ 
+@@ -35,5 +35,5 @@
+ // RUN:   --target=aarch64-suse-linux -B%S/Inputs/opensuse_42.2_aarch64_tree/usr | \
+ // RUN:   FileCheck %s --check-prefix=NO_AARCH64
+ 
+-// AARCH64:        Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crt1.o"
+-// NO_AARCH64-NOT: Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crt1.o"
++// AARCH64:        Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crti.o"
++// NO_AARCH64-NOT: Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crti.o"
+diff --git a/clang/test/Driver/hexagon-toolchain-elf.c b/clang/test/Driver/hexagon-toolchain-elf.c
+index cc11f9fcba9e..1fe8b5db587b 100644
+--- a/clang/test/Driver/hexagon-toolchain-elf.c
++++ b/clang/test/Driver/hexagon-toolchain-elf.c
+@@ -487,7 +487,7 @@
+ // RUN:   %s 2>&1 \
+ // RUN:   | FileCheck -check-prefix=CHECK042 %s
+ // CHECK042:      "-cc1"
+-// CHECK042:      "-mrelocation-model" "static"
++// CHECK042:      "-mrelocation-model" "pic"
+ // CHECK042:      "-mllvm" "-hexagon-small-data-threshold=8"
+ // CHECK042-NEXT: llvm-mc
+ // CHECK042:      "-gpsize=8"
+diff --git a/clang/test/Driver/hip-fpie-option.hip b/clang/test/Driver/hip-fpie-option.hip
+index 2e296a099dea..86915f1c8c25 100644
+--- a/clang/test/Driver/hip-fpie-option.hip
++++ b/clang/test/Driver/hip-fpie-option.hip
+@@ -5,11 +5,11 @@
+ 
+ // RUN: %clang -### -target x86_64-unknown-linux-gnu \
+ // RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+-// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
++// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
+ 
+ // RUN: %clang -### -target x86_64-unknown-linux-gnu \
+ // RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+-// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
++// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
+ 
+ // RUN: %clang -### -target x86_64-unknown-linux-gnu \
+ // RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+diff --git a/clang/test/Driver/linux-as.c b/clang/test/Driver/linux-as.c
+index 0959bd7ba0a1..4056a672b6f9 100644
+--- a/clang/test/Driver/linux-as.c
++++ b/clang/test/Driver/linux-as.c
+@@ -164,7 +164,7 @@
+ // CHECK-PPC-NO-MCPU-NOT: as{{.*}} "-mcpu=invalid-cpu"
+ //
+ // RUN: %clang -target sparc64-linux -mcpu=invalid-cpu -### \
+-// RUN:   -no-integrated-as -c %s 2>&1 \
++// RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
+ // RUN:   | FileCheck -check-prefix=CHECK-SPARCV9 %s
+ // CHECK-SPARCV9: as
+ // CHECK-SPARCV9: -64
+@@ -173,7 +173,7 @@
+ // CHECK-SPARCV9: -o
+ //
+ // RUN: %clang -target sparc64-linux -mcpu=invalid-cpu -### \
+-// RUN:   -no-integrated-as -fpic -c %s 2>&1 \
++// RUN:   -no-integrated-as -c %s 2>&1 \
+ // RUN:   | FileCheck -check-prefix=CHECK-SPARCV9PIC %s
+ // CHECK-SPARCV9PIC: as
+ // CHECK-SPARCV9PIC: -64
+diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
+index cc505588331b..c7f81d2c5e49 100644
+--- a/clang/test/Driver/linux-ld.c
++++ b/clang/test/Driver/linux-ld.c
+@@ -1,4 +1,6 @@
+ // UNSUPPORTED: system-windows
++// XFAIL: linux
++
+ // General tests that ld invocations on Linux targets sane. Note that we use
+ // sysroot to make these tests independent of the host system.
+ //
+diff --git a/clang/test/Driver/ppc-abi.c b/clang/test/Driver/ppc-abi.c
+index a74a19953ca2..0452661ba5a7 100644
+--- a/clang/test/Driver/ppc-abi.c
++++ b/clang/test/Driver/ppc-abi.c
+@@ -1,20 +1,20 @@
+ // Check passing PowerPC ABI options to the backend.
+ 
+ // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+-// RUN:   | FileCheck -check-prefix=CHECK-ELFv1 %s
++// RUN:   | FileCheck -check-prefix=CHECK-ELFv1-PIE %s
+ // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+-// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1 %s
++// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-PIE %s
+ // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+-// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-BE %s
++// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-BE-PIE %s
+ 
+ // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+-// RUN:   | FileCheck -check-prefix=CHECK-ELFv2 %s
++// RUN:   | FileCheck -check-prefix=CHECK-ELFv2-PIE %s
+ // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+ // RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-LE %s
+ // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+-// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s
++// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-PIE %s
+ // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+-// RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
++// RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2-PIE %s
+ 
+ // RUN: %clang -target powerpc64-unknown-freebsd11 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s
+ // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s
+@@ -26,10 +26,14 @@
+ 
+ // CHECK-ELFv1: "-mrelocation-model" "static"
+ // CHECK-ELFv1: "-target-abi" "elfv1"
+-// CHECK-ELFv1-LE: "-mrelocation-model" "static"
++// CHECK-ELFv1-PIE: "-mrelocation-model" "pic" "-pic-level" "2"
++// CHECK-ELFv1-PIE: "-target-abi" "elfv1"
++// CHECK-ELFv1-LE: "-mrelocation-model" "pic" "-pic-level" "2"
+ // CHECK-ELFv1-LE: "-target-abi" "elfv1"
+ // CHECK-ELFv2: "-mrelocation-model" "static"
+ // CHECK-ELFv2: "-target-abi" "elfv2"
++// CHECK-ELFv2-PIE: "-mrelocation-model" "pic" "-pic-level" "2"
++// CHECK-ELFv2-PIE: "-target-abi" "elfv2"
+ // CHECK-ELFv2-BE: "-mrelocation-model" "static"
+ // CHECK-ELFv2-BE: "-target-abi" "elfv2"
+ // CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"
+diff --git a/clang/test/Driver/riscv32-toolchain.c b/clang/test/Driver/riscv32-toolchain.c
+index a5852f5f3997..233d9ef003cf 100644
+--- a/clang/test/Driver/riscv32-toolchain.c
++++ b/clang/test/Driver/riscv32-toolchain.c
+@@ -84,7 +84,7 @@
+ // C-RV32-LINUX-MULTI-ILP32: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
+ // C-RV32-LINUX-MULTI-ILP32: "-m" "elf32lriscv"
+ // C-RV32-LINUX-MULTI-ILP32: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32.so.1"
+-// C-RV32-LINUX-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32{{/|\\\\}}crtbegin.o"
++// C-RV32-LINUX-MULTI-ILP32: "crtbeginS.o"
+ // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32"
+ // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32"
+ // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32"
+@@ -99,7 +99,7 @@
+ // C-RV32-LINUX-MULTI-ILP32D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
+ // C-RV32-LINUX-MULTI-ILP32D: "-m" "elf32lriscv"
+ // C-RV32-LINUX-MULTI-ILP32D: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32d.so.1"
+-// C-RV32-LINUX-MULTI-ILP32D: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32d{{/|\\\\}}crtbegin.o"
++// C-RV32-LINUX-MULTI-ILP32D: "crtbeginS.o"
+ // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32d"
+ // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32d"
+ // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32d"
+diff --git a/clang/test/Driver/riscv64-toolchain.c b/clang/test/Driver/riscv64-toolchain.c
+index e727f20bb601..a801e5eee462 100644
+--- a/clang/test/Driver/riscv64-toolchain.c
++++ b/clang/test/Driver/riscv64-toolchain.c
+@@ -84,7 +84,7 @@
+ // C-RV64-LINUX-MULTI-LP64: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
+ // C-RV64-LINUX-MULTI-LP64: "-m" "elf64lriscv"
+ // C-RV64-LINUX-MULTI-LP64: "-dynamic-linker" "/lib/ld-linux-riscv64-lp64.so.1"
+-// C-RV64-LINUX-MULTI-LP64: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64{{/|\\\\}}crtbegin.o"
++// C-RV64-LINUX-MULTI-LP64: "crtbeginS.o"
+ // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64"
+ // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib64/lp64"
+ // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64"
+@@ -99,7 +99,7 @@
+ // C-RV64-LINUX-MULTI-LP64D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
+ // C-RV64-LINUX-MULTI-LP64D: "-m" "elf64lriscv"
+ // C-RV64-LINUX-MULTI-LP64D: "-dynamic-linker" "/lib/ld-linux-riscv64-lp64d.so.1"
+-// C-RV64-LINUX-MULTI-LP64D: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64d{{/|\\\\}}crtbegin.o"
++// C-RV64-LINUX-MULTI-LP64D: "crtbeginS.o"
+ // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64d"
+ // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib64/lp64d"
+ // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64d"
+diff --git a/clang/test/Driver/stack-protector.c b/clang/test/Driver/stack-protector.c
+index a3e40b50eed8..dfffe0d6cf85 100644
+--- a/clang/test/Driver/stack-protector.c
++++ b/clang/test/Driver/stack-protector.c
+@@ -3,11 +3,11 @@
+ // NOSSP-NOT: "-stack-protector-buffer-size" 
+ 
+ // RUN: %clang -target i386-unknown-linux -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP
+-// SSP: "-stack-protector" "1"
++// SSP: "-stack-protector" "2"
+ // SSP-NOT: "-stack-protector-buffer-size" 
+ 
+ // RUN: %clang -target i386-unknown-linux -fstack-protector --param ssp-buffer-size=16 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-BUF
+-// SSP-BUF: "-stack-protector" "1"
++// SSP-BUF: "-stack-protector" "2"
+ // SSP-BUF: "-stack-protector-buffer-size" "16" 
+ 
+ // RUN: %clang -target i386-pc-openbsd -### %s 2>&1 | FileCheck %s -check-prefix=OPENBSD

Added: clang13/trunk/strip-exception-specifications-in-CFI-type-names.patch
===================================================================
--- clang13/trunk/strip-exception-specifications-in-CFI-type-names.patch	                        (rev 0)
+++ clang13/trunk/strip-exception-specifications-in-CFI-type-names.patch	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,59 @@
+From 0a14674f276b598d23353290635fc62f93e9ab30 Mon Sep 17 00:00:00 2001
+From: Peter Collingbourne <peter at pcc.me.uk>
+Date: Fri, 3 Dec 2021 14:48:57 -0500
+Subject: [PATCH] CodeGen: Strip exception specifications from function types
+ in CFI type names.
+
+With C++17 the exception specification has been made part of the
+function type, and therefore part of mangled type names.
+
+However, it's valid to convert function pointers with an exception
+specification to function pointers with the same argument and return
+types but without an exception specification, which means that e.g. a
+function of type "void () noexcept" can be called through a pointer
+of type "void ()". We must therefore consider the two types to be
+compatible for CFI purposes.
+
+We can do this by stripping the exception specification before mangling
+the type name, which is what this patch does.
+
+Differential Revision: https://reviews.llvm.org/D115015
+---
+ clang/lib/CodeGen/CodeGenModule.cpp          |  5 +++++
+ clang/test/CodeGenCXX/cfi-icall-noexcept.cpp | 11 +++++++++++
+ 2 files changed, 16 insertions(+)
+ create mode 100644 clang/test/CodeGenCXX/cfi-icall-noexcept.cpp
+
+diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
+index 9ba1a5c25e81a..39044617d6774 100644
+--- a/clang/lib/CodeGen/CodeGenModule.cpp
++++ b/clang/lib/CodeGen/CodeGenModule.cpp
+@@ -6398,6 +6398,11 @@ void CodeGenModule::EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D) {
+ llvm::Metadata *
+ CodeGenModule::CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,
+                                             StringRef Suffix) {
++  if (auto *FnType = T->getAs<FunctionProtoType>())
++    T = getContext().getFunctionType(
++        FnType->getReturnType(), FnType->getParamTypes(),
++        FnType->getExtProtoInfo().withExceptionSpec(EST_None));
++
+   llvm::Metadata *&InternalId = Map[T.getCanonicalType()];
+   if (InternalId)
+     return InternalId;
+diff --git a/clang/test/CodeGenCXX/cfi-icall-noexcept.cpp b/clang/test/CodeGenCXX/cfi-icall-noexcept.cpp
+new file mode 100644
+index 0000000000000..eabc4862b4c52
+--- /dev/null
++++ b/clang/test/CodeGenCXX/cfi-icall-noexcept.cpp
+@@ -0,0 +1,11 @@
++// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -emit-llvm -std=c++17 -o - %s | FileCheck %s
++
++// Tests that exception specifiers are stripped when forming the
++// mangled CFI type name.
++
++void f() noexcept {}
++
++// CHECK: define{{.*}} void @_Z1fv({{.*}} !type [[TS1:![0-9]+]] !type [[TS2:![0-9]+]]
++
++// CHECK: [[TS1]] = !{i64 0, !"_ZTSFvvE"}
++// CHECK: [[TS2]] = !{i64 0, !"_ZTSFvvE.generalized"}

Added: lld13/trunk/PKGBUILD
===================================================================
--- lld13/trunk/PKGBUILD	                        (rev 0)
+++ lld13/trunk/PKGBUILD	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,67 @@
+# Maintainer: Evangelos Foutras <evangelos at foutrelis.com>
+# Contributor: Jan "heftig" Steffens <jan.steffens at gmail.com>
+
+pkgname=lld13
+pkgver=13.0.1
+pkgrel=1
+pkgdesc="Linker from the LLVM project"
+arch=('x86_64')
+url="https://lld.llvm.org/"
+license=('custom:Apache 2.0 with LLVM Exception')
+depends=('llvm13-libs')
+makedepends=('llvm13' 'cmake' 'ninja' 'python')
+checkdepends=('llvm')
+options=('!lto') # LTO causes a couple of test failures
+_source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
+source=($_source_base/lld-$pkgver.src.tar.xz{,.sig}
+        $_source_base/llvm-$pkgver.src.tar.xz{,.sig}
+        $_source_base/libunwind-$pkgver.src.tar.xz{,.sig})
+sha256sums=('666af745e8bf7b680533b4d18b7a31dc7cab575b1e6e4d261922bbafd9644cfb'
+            'SKIP'
+            'ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834'
+            'SKIP'
+            'e206dbf1bbe058a113bffe189386ded99a160b2443ee1e2cd41ff810f78551ba'
+            'SKIP')
+validpgpkeys+=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <hans at chromium.org>
+validpgpkeys+=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar at redhat.com>
+
+prepare() {
+  # https://bugs.llvm.org/show_bug.cgi?id=49228
+  mv libunwind{-$pkgver.src,}
+
+  cd lld-$pkgver.src
+  mkdir build
+}
+
+build() {
+  cd lld-$pkgver.src/build
+
+  local cmake_args=(
+    -G Ninja
+    -DCMAKE_BUILD_TYPE=Release
+    -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm13
+    -DCMAKE_SKIP_RPATH=ON
+    -DLLVM_BUILD_TESTS=ON
+    -DLLVM_CONFIG_PATH=/usr/lib/llvm13/bin/llvm-config
+    -DLLVM_EXTERNAL_LIT=/usr/bin/lit
+    -DLLVM_INCLUDE_TESTS=ON
+    -DLLVM_LINK_LLVM_DYLIB=ON
+    -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
+  )
+  cmake .. "${cmake_args[@]}"
+  ninja
+}
+
+check() {
+  cd lld-$pkgver.src/build
+  ninja check-lld
+}
+
+package() {
+  cd lld-$pkgver.src/build
+
+  DESTDIR="$pkgdir" ninja install
+  install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
+
+# vim:set ts=2 sw=2 et:

Added: llvm13/trunk/PKGBUILD
===================================================================
--- llvm13/trunk/PKGBUILD	                        (rev 0)
+++ llvm13/trunk/PKGBUILD	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,110 @@
+# Maintainer: Evangelos Foutras <evangelos at foutrelis.com>
+# Contributor: Jan "heftig" Steffens <jan.steffens at gmail.com>
+
+pkgname=('llvm13' 'llvm13-libs')
+pkgver=13.0.1
+pkgrel=1
+arch=('x86_64')
+url="https://llvm.org/"
+license=('custom:Apache 2.0 with LLVM Exception')
+makedepends=('cmake' 'ninja' 'libffi' 'libedit' 'ncurses' 'libxml2'
+             'python')
+options=('staticlibs' '!lto') # Getting thousands of test failures with LTO
+_source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
+source=($_source_base/llvm-$pkgver.src.tar.xz{,.sig}
+        don-t-accept-nullptr-as-GEP-element-type.patch
+        don-t-override-__attribute__-no_stack_protector.patch
+        don-t-move-DBG_VALUE-instructions.patch
+        disable-A-B-A-B-and-BSWAP-in-InstCombine.patch
+        disable-DIArgList-in-SPIR-V.patch)
+sha256sums=('ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834'
+            'SKIP'
+            'a7e902a7612d0fdabe436a917468b043cc296bc89d8954bfc3126f737beb9ac4'
+            '9f0a4578b94eb8853b83af2f65e92705254b4b56d96f9a941714d174b932f465'
+            'f7d69f84241416398fdb3df8bb44f9fae3c49d89889c7ffa3b37aa2e9d78f708'
+            '34cc0d79a30599cb2287b47b4e9a1a5bf03d57a1f8bb35be3fe976ffc4a604f6'
+            '8642da2d556092e4284873ba6ddc6c9a67841f42cc16f923bcd523e4b304a3ff')
+validpgpkeys+=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <hans at chromium.org>
+validpgpkeys+=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar at redhat.com>
+
+prepare() {
+  cd llvm-$pkgver.src
+  mkdir build
+
+  # https://github.com/intel/intel-graphics-compiler/issues/204
+  patch -Rp2 -i ../don-t-accept-nullptr-as-GEP-element-type.patch
+
+  # Fixes Chromium error "*** stack smashing detected ***: terminated"
+  # (which also goes away with "--change-stack-guard-on-fork=disabled")
+  # https://reviews.llvm.org/D116589
+  patch -Np2 -i ../don-t-override-__attribute__-no_stack_protector.patch
+
+  # https://github.com/llvm/llvm-project/issues/53243
+  # https://github.com/rust-lang/rust/issues/92869
+  patch -Np2 -i ../don-t-move-DBG_VALUE-instructions.patch
+
+  # Patches needed for ISPC for Xe only
+  patch -Np2 -i ../disable-A-B-A-B-and-BSWAP-in-InstCombine.patch
+  patch -Np2 -i ../disable-DIArgList-in-SPIR-V.patch
+}
+
+build() {
+  cd llvm-$pkgver.src/build
+
+  local cmake_args=(
+    -G Ninja
+    -DCMAKE_BUILD_TYPE=Release
+    -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm13
+    -DCMAKE_SKIP_RPATH=ON
+    -DLLVM_BINUTILS_INCDIR=/usr/include
+    -DLLVM_BUILD_LLVM_DYLIB=ON
+    -DLLVM_BUILD_TESTS=ON
+    -DLLVM_ENABLE_BINDINGS=OFF
+    -DLLVM_ENABLE_FFI=ON
+    -DLLVM_ENABLE_RTTI=ON
+    -DLLVM_HOST_TRIPLE=$CHOST
+    -DLLVM_INSTALL_UTILS=ON
+    -DLLVM_LINK_LLVM_DYLIB=ON
+  )
+  cmake .. "${cmake_args[@]}"
+  ninja
+}
+
+check() {
+  cd llvm-$pkgver.src/build
+  LD_LIBRARY_PATH=$PWD/lib ninja check
+}
+
+package_llvm13() {
+  pkgdesc="Compiler infrastructure (LLVM 13)"
+  depends=('llvm13-libs' 'perl')
+
+  cd llvm-$pkgver.src/build
+
+  DESTDIR="$pkgdir" ninja install
+
+  # The runtime libraries go into llvm13-libs
+  mv -f "$pkgdir"/usr/lib/llvm13/lib/lib{LLVM,LTO,Remarks}*.so* "$srcdir"
+  mv -f "$pkgdir"/usr/lib/llvm13/lib/LLVMgold.so "$srcdir"
+
+  install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
+
+package_llvm13-libs() {
+  pkgdesc="LLVM 13 runtime libraries"
+  depends=('gcc-libs' 'zlib' 'libffi' 'libedit' 'ncurses' 'libxml2')
+
+  install -d "$pkgdir/usr/lib/llvm13/lib"
+  cp -P \
+    "$srcdir"/lib{LLVM,LTO,Remarks}*.so* \
+    "$srcdir"/LLVMgold.so \
+    "$pkgdir/usr/lib/llvm13/lib/"
+
+  install -d "$pkgdir/etc/ld.so.conf.d"
+  echo /usr/lib/llvm13/lib >"$pkgdir/etc/ld.so.conf.d/llvm13.conf"
+
+  install -Dm644 "$srcdir/llvm-$pkgver.src/LICENSE.TXT" \
+    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
+
+# vim:set ts=2 sw=2 et:

Added: llvm13/trunk/disable-A-B-A-B-and-BSWAP-in-InstCombine.patch
===================================================================
--- llvm13/trunk/disable-A-B-A-B-and-BSWAP-in-InstCombine.patch	                        (rev 0)
+++ llvm13/trunk/disable-A-B-A-B-and-BSWAP-in-InstCombine.patch	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,52 @@
+# This patch is needed for ISPC for Xe only
+
+# 1. Transformation of add to or is not safe for VC backend.
+# 2. bswap intrinsics is not supported in VC backend yet.
+diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+index d01a021bf3f4..bccce825a03d 100644
+--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
++++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+@@ -15,6 +15,7 @@
+ #include "llvm/ADT/APInt.h"
+ #include "llvm/ADT/STLExtras.h"
+ #include "llvm/ADT/SmallVector.h"
++#include "llvm/ADT/Triple.h"
+ #include "llvm/Analysis/InstructionSimplify.h"
+ #include "llvm/Analysis/ValueTracking.h"
+ #include "llvm/IR/Constant.h"
+@@ -1369,9 +1370,12 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
+     }
+   }
+ 
+-  // A+B --> A|B iff A and B have no bits set in common.
+-  if (haveNoCommonBitsSet(LHS, RHS, DL, &AC, &I, &DT))
+-    return BinaryOperator::CreateOr(LHS, RHS);
++  // Disable this transformation for ISPC SPIR-V
++  if (!Triple(I.getModule()->getTargetTriple()).isSPIR()) {
++    // A+B --> A|B iff A and B have no bits set in common.
++    if (haveNoCommonBitsSet(LHS, RHS, DL, &AC, &I, &DT))
++      return BinaryOperator::CreateOr(LHS, RHS);
++  }
+ 
+   // add (select X 0 (sub n A)) A  -->  select X A n
+   {
+diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+index 120852c44474..8de55311ce3e 100644
+--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
++++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+@@ -2671,9 +2671,12 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
+   if (Instruction *FoldedLogic = foldBinOpIntoSelectOrPhi(I))
+     return FoldedLogic;
+ 
+-  if (Instruction *BitOp = matchBSwapOrBitReverse(I, /*MatchBSwaps*/ true,
+-                                                  /*MatchBitReversals*/ true))
+-    return BitOp;
++  // Disable this transformation for ISPC SPIR-V
++  if (!Triple(I.getModule()->getTargetTriple()).isSPIR()) {
++    if (Instruction *BitOp = matchBSwapOrBitReverse(I, /*MatchBSwaps*/ true,
++                                                    /*MatchBitReversals*/ true))
++      return BitOp;
++  }
+ 
+   if (Instruction *Funnel = matchFunnelShift(I, *this))
+     return Funnel;

Added: llvm13/trunk/disable-DIArgList-in-SPIR-V.patch
===================================================================
--- llvm13/trunk/disable-DIArgList-in-SPIR-V.patch	                        (rev 0)
+++ llvm13/trunk/disable-DIArgList-in-SPIR-V.patch	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,23 @@
+# This patch is needed for ISPC for Xe only
+# It disables using of DIArgList for dbg.val if SPIR-V target is used.
+# It is needed till DIArgList is supported in SPIR-V Translator.
+diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
+index d03d76f57ca1..0b86e454df57 100644
+--- a/llvm/lib/Transforms/Utils/Local.cpp
++++ b/llvm/lib/Transforms/Utils/Local.cpp
+@@ -1771,7 +1771,14 @@ void llvm::salvageDebugInfoForDbgValues(
+     } else if (isa<DbgValueInst>(DII) &&
+                DII->getNumVariableLocationOps() + AdditionalValues.size() <=
+                    MaxDebugArgs) {
+-      DII->addVariableLocationOps(AdditionalValues, SalvagedExpr);
++      if (!Triple(I.getModule()->getTargetTriple()).isSPIR()) {
++        DII->addVariableLocationOps(AdditionalValues, SalvagedExpr);
++      } else {
++        // Do not salvage using DIArgList for dbg.val fpr SPIR-V target, as it is
++        // not currently supported by SPIR-V Translator.
++        Value *Undef = UndefValue::get(I.getOperand(0)->getType());
++        DII->replaceVariableLocationOp(I.getOperand(0), Undef);
++      }
+     } else {
+       // Do not salvage using DIArgList for dbg.addr/dbg.declare, as it is
+       // currently only valid for stack value expressions.

Added: llvm13/trunk/don-t-accept-nullptr-as-GEP-element-type.patch
===================================================================
--- llvm13/trunk/don-t-accept-nullptr-as-GEP-element-type.patch	                        (rev 0)
+++ llvm13/trunk/don-t-accept-nullptr-as-GEP-element-type.patch	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,63 @@
+From b00cff56cfb15cbfa74cb512c9cee1c402cce55b Mon Sep 17 00:00:00 2001
+From: Nikita Popov <nikita.ppv at gmail.com>
+Date: Thu, 8 Jul 2021 20:56:05 +0200
+Subject: [PATCH] Reapply [IR] Don't accept nullptr as GEP element type
+
+Reapply after fixing another occurrence in lldb that was relying
+on this in the preceding commit.
+
+-----
+
+GetElementPtrInst::Create() (and IRBuilder methods based on it)
+currently accept nullptr as the element type, and will fetch the
+element type from the pointer in that case. Remove this fallback,
+as it is incompatible with opaque pointers. I've removed a handful
+of leftover calls using this behavior as a preliminary step.
+
+Out-of-tree code affected by this change should either pass a proper
+type, or can temporarily explicitly call getPointerElementType(),
+if the newly added assertion is encountered.
+
+Differential Revision: https://reviews.llvm.org/D105653
+---
+ llvm/include/llvm/IR/Instructions.h | 20 ++++++--------------
+ 1 file changed, 6 insertions(+), 14 deletions(-)
+
+diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
+index a5cebf0a4626..0c43a56daa33 100644
+--- a/llvm/include/llvm/IR/Instructions.h
++++ b/llvm/include/llvm/IR/Instructions.h
+@@ -956,13 +956,9 @@ public:
+                                    const Twine &NameStr = "",
+                                    Instruction *InsertBefore = nullptr) {
+     unsigned Values = 1 + unsigned(IdxList.size());
+-    if (!PointeeType) {
+-      PointeeType =
+-          cast<PointerType>(Ptr->getType()->getScalarType())->getElementType();
+-    } else {
+-      assert(cast<PointerType>(Ptr->getType()->getScalarType())
+-                 ->isOpaqueOrPointeeTypeMatches(PointeeType));
+-    }
++    assert(PointeeType && "Must specify element type");
++    assert(cast<PointerType>(Ptr->getType()->getScalarType())
++               ->isOpaqueOrPointeeTypeMatches(PointeeType));
+     return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
+                                           NameStr, InsertBefore);
+   }
+@@ -972,13 +968,9 @@ public:
+                                    const Twine &NameStr,
+                                    BasicBlock *InsertAtEnd) {
+     unsigned Values = 1 + unsigned(IdxList.size());
+-    if (!PointeeType) {
+-      PointeeType =
+-          cast<PointerType>(Ptr->getType()->getScalarType())->getElementType();
+-    } else {
+-      assert(cast<PointerType>(Ptr->getType()->getScalarType())
+-                 ->isOpaqueOrPointeeTypeMatches(PointeeType));
+-    }
++    assert(PointeeType && "Must specify element type");
++    assert(cast<PointerType>(Ptr->getType()->getScalarType())
++               ->isOpaqueOrPointeeTypeMatches(PointeeType));
+     return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
+                                           NameStr, InsertAtEnd);
+   }

Added: llvm13/trunk/don-t-move-DBG_VALUE-instructions.patch
===================================================================
--- llvm13/trunk/don-t-move-DBG_VALUE-instructions.patch	                        (rev 0)
+++ llvm13/trunk/don-t-move-DBG_VALUE-instructions.patch	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,91 @@
+From e7c9a6cae09d99388d8384ca7c0fb5b24b353975 Mon Sep 17 00:00:00 2001
+From: Nikita Popov <npopov at redhat.com>
+Date: Mon, 17 Jan 2022 15:48:01 +0100
+Subject: [PATCH] [SDAG] Don't move DBG_VALUE instructions after insertion
+ point during scheduling (PR53243)
+
+EmitSchedule() shouldn't be touching instructions after the provided
+insertion point. The change introduced in D83561 performs a scan to
+the end of the block, and thus may move unrelated instructions. In
+particular, this ends up moving instructions that have been produced
+by FastISel and will later be deleted. Moving them means that more
+instructions than intended are removed.
+
+Fix this by stopping the iteration when the insertion point is
+reached.
+
+Fixes https://github.com/llvm/llvm-project/issues/53243.
+
+Differential Revision: https://reviews.llvm.org/D117489
+---
+ .../SelectionDAG/ScheduleDAGSDNodes.cpp       |  7 ++--
+ .../CodeGen/X86/pr53243-tail-call-fastisel.ll | 39 +++++++++++++++++++
+ 2 files changed, 43 insertions(+), 3 deletions(-)
+ create mode 100644 llvm/test/CodeGen/X86/pr53243-tail-call-fastisel.ll
+
+diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
+index bec240d6c4d4..403f34573899 100644
+--- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
++++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
+@@ -1057,12 +1057,13 @@ EmitSchedule(MachineBasicBlock::iterator &InsertPos) {
+            "first terminator cannot be a debug value");
+     for (MachineInstr &MI : make_early_inc_range(
+              make_range(std::next(FirstTerm), InsertBB->end()))) {
++      // Only scan up to insertion point.
++      if (&MI == InsertPos)
++        break;
++
+       if (!MI.isDebugValue())
+         continue;
+ 
+-      if (&MI == InsertPos)
+-        InsertPos = std::prev(InsertPos->getIterator());
+-
+       // The DBG_VALUE was referencing a value produced by a terminator. By
+       // moving the DBG_VALUE, the referenced value also needs invalidating.
+       MI.getOperand(0).ChangeToRegister(0, false);
+diff --git a/llvm/test/CodeGen/X86/pr53243-tail-call-fastisel.ll b/llvm/test/CodeGen/X86/pr53243-tail-call-fastisel.ll
+new file mode 100644
+index 000000000000..333eff8fb008
+--- /dev/null
++++ b/llvm/test/CodeGen/X86/pr53243-tail-call-fastisel.ll
+@@ -0,0 +1,39 @@
++; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
++; RUN: llc -O0 -fast-isel -mtriple=x86_64-- < %s | FileCheck %s
++
++define void @test() {
++; CHECK-LABEL: test:
++; CHECK:       # %bb.0:
++; CHECK-NEXT:    jmp set_state at PLT # TAILCALL
++  tail call void @set_state()
++  call void @llvm.dbg.value(metadata i64 0, metadata !10, metadata !DIExpression()), !dbg !16
++  ret void
++}
++
++declare void @set_state()
++
++; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
++declare void @llvm.dbg.value(metadata, metadata, metadata) #0
++
++attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }
++
++!llvm.module.flags = !{!0}
++!llvm.dbg.cu = !{!1}
++
++!0 = !{i32 2, !"Debug Info Version", i32 3}
++!1 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !2, producer: "clang LLVM (rustc version 1.60.0-nightly (ec4bcaac4 2022-01-15))", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !3)
++!2 = !DIFile(filename: "src/lib.rs/@/bug.63e521cd-cgu.0", directory: "/tmp/rust-bug")
++!3 = !{!4}
++!4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Option", file: !5, baseType: !6, size: 8, align: 8, flags: DIFlagEnumClass, elements: !7)
++!5 = !DIFile(filename: "<unknown>", directory: "")
++!6 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned)
++!7 = !{!8, !9}
++!8 = !DIEnumerator(name: "None", value: 0)
++!9 = !DIEnumerator(name: "Some", value: 1)
++!10 = !DILocalVariable(name: "msg", arg: 2, scope: !11, file: !12, line: 689, type: !6)
++!11 = distinct !DISubprogram(name: "expect<()>", linkageName: "_ZN4core6option15Option$LT$T$GT$6expect17h9a574c18f194c213E", scope: !4, file: !12, line: 689, type: !13, scopeLine: 689, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !1, templateParams: !15, retainedNodes: !15)
++!12 = !DIFile(filename: "/rustc/ec4bcaac450279b029f3480b8b8f1b82ab36a5eb/library/core/src/option.rs", directory: "", checksumkind: CSK_MD5, checksum: "4120c8557937a0772190a676ec193800")
++!13 = !DISubroutineType(types: !14)
++!14 = !{null, !4}
++!15 = !{}
++!16 = !DILocation(line: 0, scope: !11)

Added: llvm13/trunk/don-t-override-__attribute__-no_stack_protector.patch
===================================================================
--- llvm13/trunk/don-t-override-__attribute__-no_stack_protector.patch	                        (rev 0)
+++ llvm13/trunk/don-t-override-__attribute__-no_stack_protector.patch	2022-06-21 23:38:56 UTC (rev 449269)
@@ -0,0 +1,540 @@
+From 4a7c9b7d6f4a183fef8f43aef004ec865c37bbd8 Mon Sep 17 00:00:00 2001
+From: Hans Wennborg <hans at chromium.org>
+Date: Thu, 13 Jan 2022 11:31:11 +0100
+Subject: [PATCH 1/2] Simplify llvm/test/Transforms/Inline/inline_ssp.ll (NFC)
+
+The nounwind and uwtable attributes were just cluttering up the test.
+Using regexes to give symbolic names to the attribute lists make the
+test more readable.
+
+This is pre-committing parts of D116589.
+
+(cherry picked from commit 2eb7d8d749997e5f3048d39201a4d38b6b8d6455)
+---
+ llvm/test/Transforms/Inline/inline_ssp.ll | 81 +++++++++++------------
+ 1 file changed, 40 insertions(+), 41 deletions(-)
+
+diff --git a/llvm/test/Transforms/Inline/inline_ssp.ll b/llvm/test/Transforms/Inline/inline_ssp.ll
+index 2bf93d322842..ccfe93453159 100644
+--- a/llvm/test/Transforms/Inline/inline_ssp.ll
++++ b/llvm/test/Transforms/Inline/inline_ssp.ll
+@@ -12,150 +12,149 @@
+ ; propagated correctly.  The caller should have its SSP attribute set as:
+ ; strictest(caller-ssp-attr, callee-ssp-attr), where strictness is ordered as:
+ ;  sspreq > sspstrong > ssp > [no ssp]
+-define internal void @fun_sspreq() nounwind sspreq uwtable {
++define internal void @fun_sspreq() sspreq {
+ entry:
+   %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str3, i32 0, i32 0))
+   ret void
+ }
+ 
+-define internal void @fun_sspstrong() nounwind sspstrong uwtable {
++define internal void @fun_sspstrong() sspstrong {
+ entry:
+   %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str2, i32 0, i32 0))
+   ret void
+ }
+ 
+-define internal void @fun_ssp() nounwind ssp uwtable {
++define internal void @fun_ssp() ssp {
+ entry:
+   %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str1, i32 0, i32 0))
+   ret void
+ }
+ 
+-define internal void @fun_nossp() nounwind uwtable {
++define internal void @fun_nossp() {
+ entry:
+   %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0))
+   ret void
+ }
+ 
+-; Tests start below 
++; Tests start below.
+ 
+-define void @inline_req_req() nounwind sspreq uwtable {
++define void @inline_req_req() sspreq {
+ entry:
+-; CHECK: @inline_req_req() #0
++; CHECK: @inline_req_req() #[[SSPREQ:[0-9]]]
+   call void @fun_sspreq()
+   ret void
+ }
+ 
+-define void @inline_req_strong() nounwind sspstrong uwtable {
++define void @inline_req_strong() sspstrong {
+ entry:
+-; CHECK: @inline_req_strong() #0
++; CHECK: @inline_req_strong() #[[SSPREQ]]
+   call void @fun_sspreq()
+   ret void
+ }
+ 
+-define void @inline_req_ssp() nounwind ssp uwtable {
++define void @inline_req_ssp() ssp {
+ entry:
+-; CHECK: @inline_req_ssp() #0
++; CHECK: @inline_req_ssp() #[[SSPREQ]]
+   call void @fun_sspreq()
+   ret void
+ }
+ 
+-define void @inline_req_nossp() nounwind uwtable {
++define void @inline_req_nossp() {
+ entry:
+-; CHECK: @inline_req_nossp() #3
++; CHECK: @inline_req_nossp() {
+   call void @fun_sspreq()
+   ret void
+ }
+ 
+-define void @inline_strong_req() nounwind sspreq uwtable {
++define void @inline_strong_req() sspreq {
+ entry:
+-; CHECK: @inline_strong_req() #0
++; CHECK: @inline_strong_req() #[[SSPREQ]]
+   call void @fun_sspstrong()
+   ret void
+ }
+ 
+ 
+-define void @inline_strong_strong() nounwind sspstrong uwtable {
++define void @inline_strong_strong() sspstrong {
+ entry:
+-; CHECK: @inline_strong_strong() #1
++; CHECK: @inline_strong_strong() #[[SSPSTRONG:[0-9]]]
+   call void @fun_sspstrong()
+   ret void
+ }
+ 
+-define void @inline_strong_ssp() nounwind ssp uwtable {
++define void @inline_strong_ssp() ssp {
+ entry:
+-; CHECK: @inline_strong_ssp() #1
++; CHECK: @inline_strong_ssp() #[[SSPSTRONG]]
+   call void @fun_sspstrong()
+   ret void
+ }
+ 
+-define void @inline_strong_nossp() nounwind uwtable {
++define void @inline_strong_nossp() {
+ entry:
+-; CHECK: @inline_strong_nossp() #3
++; CHECK: @inline_strong_nossp() {
+   call void @fun_sspstrong()
+   ret void
+ }
+ 
+-define void @inline_ssp_req() nounwind sspreq uwtable {
++define void @inline_ssp_req() sspreq {
+ entry:
+-; CHECK: @inline_ssp_req() #0
++; CHECK: @inline_ssp_req() #[[SSPREQ]]
+   call void @fun_ssp()
+   ret void
+ }
+ 
+ 
+-define void @inline_ssp_strong() nounwind sspstrong uwtable {
++define void @inline_ssp_strong() sspstrong {
+ entry:
+-; CHECK: @inline_ssp_strong() #1
++; CHECK: @inline_ssp_strong() #[[SSPSTRONG]]
+   call void @fun_ssp()
+   ret void
+ }
+ 
+-define void @inline_ssp_ssp() nounwind ssp uwtable {
++define void @inline_ssp_ssp() ssp {
+ entry:
+-; CHECK: @inline_ssp_ssp() #2
++; CHECK: @inline_ssp_ssp() #[[SSP:[0-9]]]
+   call void @fun_ssp()
+   ret void
+ }
+ 
+-define void @inline_ssp_nossp() nounwind uwtable {
++define void @inline_ssp_nossp() {
+ entry:
+-; CHECK: @inline_ssp_nossp() #3
++; CHECK: @inline_ssp_nossp() {
+   call void @fun_ssp()
+   ret void
+ }
+ 
+-define void @inline_nossp_req() nounwind uwtable sspreq {
++define void @inline_nossp_req() sspreq {
+ entry:
+-; CHECK: @inline_nossp_req() #0
++; CHECK: @inline_nossp_req() #[[SSPREQ]]
+   call void @fun_nossp()
+   ret void
+ }
+ 
+ 
+-define void @inline_nossp_strong() nounwind sspstrong uwtable {
++define void @inline_nossp_strong() sspstrong {
+ entry:
+-; CHECK: @inline_nossp_strong() #1
++; CHECK: @inline_nossp_strong() #[[SSPSTRONG]]
+   call void @fun_nossp()
+   ret void
+ }
+ 
+-define void @inline_nossp_ssp() nounwind ssp uwtable {
++define void @inline_nossp_ssp() ssp {
+ entry:
+-; CHECK: @inline_nossp_ssp() #2
++; CHECK: @inline_nossp_ssp() #[[SSP]]
+   call void @fun_nossp()
+   ret void
+ }
+ 
+-define void @inline_nossp_nossp() nounwind uwtable {
++define void @inline_nossp_nossp() {
+ entry:
+-; CHECK: @inline_nossp_nossp() #3
++; CHECK: @inline_nossp_nossp() {
+   call void @fun_nossp()
+   ret void
+ }
+ 
+ declare i32 @printf(i8*, ...)
+ 
+-; CHECK: attributes #0 = { nounwind sspreq uwtable }
+-; CHECK: attributes #1 = { nounwind sspstrong uwtable }
+-; CHECK: attributes #2 = { nounwind ssp uwtable }
+-; CHECK: attributes #3 = { nounwind uwtable }
++; CHECK: attributes #[[SSPREQ]] = { sspreq }
++; CHECK: attributes #[[SSPSTRONG]] = { sspstrong }
++; CHECK: attributes #[[SSP]] = { ssp }
+
+From b52296ecaa3878648ceeb3aa39df05dc71e44597 Mon Sep 17 00:00:00 2001
+From: Hans Wennborg <hans at chromium.org>
+Date: Mon, 3 Jan 2022 18:03:43 +0100
+Subject: [PATCH 2/2] Don't override __attribute__((no_stack_protector)) by
+ inlining (PR52886)
+
+Since 26c6a3e736d3, LLVM's inliner will "upgrade" the caller's stack protector
+attribute based on the callee. This lead to surprising results with Clang's
+no_stack_protector attribute added in 4fbf84c1732f (D46300). Consider the
+following code compiled with clang -fstack-protector-strong -Os
+(https://godbolt.org/z/7s3rW7a1q).
+
+  extern void h(int* p);
+
+  inline __attribute__((always_inline)) int g() {
+    return 0;
+  }
+
+  int __attribute__((__no_stack_protector__)) f() {
+    int a[1];
+    h(a);
+    return g();
+  }
+
+LLVM will inline g() into f(), and f() would get a stack protector, against the
+users explicit wishes, potentially breaking the program e.g. if h() changes the
+value of the stack cookie. That's a miscompile.
+
+More recently, bc044a88ee3c (D91816) addressed this problem by preventing
+inlining when the stack protector is disabled in the caller and enabled in the
+callee or vice versa. However, the problem remained if the callee is marked
+always_inline as in the example above. This affected users, see e.g.
+http://crbug.com/1274129 and http://llvm.org/pr52886.
+
+One way to fix this would be to prevent inlining also in the always_inline
+case. Despite the name, always_inline does not guarantee inlining, so this
+would be legal but potentially surprising to users.
+
+However, I think the better fix is to not enable the stack protector in a
+caller based on the callee. The motivation for the old behaviour is unclear, it
+seems counter-intuitive, and causes real problems as we've seen.
+
+This commit implements that fix, which means in the example above, g() gets
+inlined into f() (also without always_inline), and f() is emitted without stack
+protector. I think that matches most developers' expectations, and that's also
+what GCC does.
+
+Another effect of this change is that a no_stack_protector function can now be
+inlined into a stack protected function, e.g. (https://godbolt.org/z/hafP6W856):
+
+  extern void h(int* p);
+
+  inline int __attribute__((__no_stack_protector__)) __attribute__((always_inline)) g() {
+    return 0;
+  }
+
+  int f() {
+    int a[1];
+    h(a);
+    return g();
+  }
+
+I think that's fine. Such code would be unusual since no_stack_protector is
+normally applied to a program entry point which sets up the stack canary. And
+even if such code exists, inlining doesn't change the semantics: there is still
+no stack cookie setup/check around entry/exit of the g() code region, but there
+may be in the surrounding context, as there was before inlining. This also
+matches GCC.
+
+See also the discussion at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94722
+
+Differential revision: https://reviews.llvm.org/D116589
+
+(cherry picked from commit 2bc57d85ebf244f19a3046295b58eb8c667f947d)
+---
+ llvm/docs/LangRef.rst                       | 26 +++++------
+ llvm/lib/Analysis/InlineCost.cpp            |  9 ----
+ llvm/lib/IR/Attributes.cpp                  |  6 +++
+ llvm/test/ThinLTO/X86/nossp.ll              | 23 ++++++----
+ llvm/test/Transforms/Inline/inline_nossp.ll | 50 ---------------------
+ llvm/test/Transforms/Inline/inline_ssp.ll   | 19 +++++++-
+ 6 files changed, 48 insertions(+), 85 deletions(-)
+ delete mode 100644 llvm/test/Transforms/Inline/inline_nossp.ll
+
+diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
+index 36e09355e485..69393eba3906 100644
+--- a/llvm/docs/LangRef.rst
++++ b/llvm/docs/LangRef.rst
+@@ -1965,11 +1965,9 @@ example:
+     Variables that are identified as requiring a protector will be arranged
+     on the stack such that they are adjacent to the stack protector guard.
+ 
+-    A function with the ``ssp`` attribute but without the ``alwaysinline``
+-    attribute cannot be inlined into a function without a
+-    ``ssp/sspreq/sspstrong`` attribute. If inlined, the caller will get the
+-    ``ssp`` attribute. ``call``, ``invoke``, and ``callbr`` instructions with
+-    the ``alwaysinline`` attribute force inlining.
++    If a function with an ``ssp`` attribute is inlined into a calling function,
++    the attribute is not carried over to the calling function.
++
+ ``sspstrong``
+     This attribute indicates that the function should emit a stack smashing
+     protector. This attribute causes a strong heuristic to be used when
+@@ -1994,12 +1992,10 @@ example:
+ 
+     This overrides the ``ssp`` function attribute.
+ 
+-    A function with the ``sspstrong`` attribute but without the
+-    ``alwaysinline`` attribute cannot be inlined into a function without a
+-    ``ssp/sspstrong/sspreq`` attribute. If inlined, the caller will get the
+-    ``sspstrong`` attribute unless the ``sspreq`` attribute exists.  ``call``,
+-    ``invoke``, and ``callbr`` instructions with the ``alwaysinline`` attribute
+-    force inlining.
++    If a function with an ``sspstrong`` attribute is inlined into a calling
++    function which has an ``ssp`` attribute, the calling function's attribute
++    will be upgraded to ``sspstrong``.
++
+ ``sspreq``
+     This attribute indicates that the function should *always* emit a stack
+     smashing protector. This overrides the ``ssp`` and ``sspstrong`` function
+@@ -2016,11 +2012,9 @@ example:
+     #. Variables that have had their address taken are 3rd closest to the
+        protector.
+ 
+-    A function with the ``sspreq`` attribute but without the ``alwaysinline``
+-    attribute cannot be inlined into a function without a
+-    ``ssp/sspstrong/sspreq`` attribute. If inlined, the caller will get the
+-    ``sspreq`` attribute.  ``call``, ``invoke``, and ``callbr`` instructions
+-    with the ``alwaysinline`` attribute force inlining.
++    If a function with an ``sspreq`` attribute is inlined into a calling
++    function which has an ``ssp`` or ``sspstrong`` attribute, the calling
++    function's attribute will be upgraded to ``sspreq``.
+ 
+ ``strictfp``
+     This attribute indicates that the function was called from a scope that
+diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
+index e8f79a28a8e8..1e68ec8ff7d6 100644
+--- a/llvm/lib/Analysis/InlineCost.cpp
++++ b/llvm/lib/Analysis/InlineCost.cpp
+@@ -2823,15 +2823,6 @@ Optional<InlineResult> llvm::getAttributeBasedInliningDecision(
+   if (Call.isNoInline())
+     return InlineResult::failure("noinline call site attribute");
+ 
+-  // Don't inline functions if one does not have any stack protector attribute
+-  // but the other does.
+-  if (Caller->hasStackProtectorFnAttr() && !Callee->hasStackProtectorFnAttr())
+-    return InlineResult::failure(
+-        "stack protected caller but callee requested no stack protector");
+-  if (Callee->hasStackProtectorFnAttr() && !Caller->hasStackProtectorFnAttr())
+-    return InlineResult::failure(
+-        "stack protected callee but caller requested no stack protector");
+-
+   return None;
+ }
+ 
+diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
+index 5cd1bafccc47..eec4629aa725 100644
+--- a/llvm/lib/IR/Attributes.cpp
++++ b/llvm/lib/IR/Attributes.cpp
+@@ -1957,6 +1957,12 @@ static void setOR(Function &Caller, const Function &Callee) {
+ /// If the inlined function had a higher stack protection level than the
+ /// calling function, then bump up the caller's stack protection level.
+ static void adjustCallerSSPLevel(Function &Caller, const Function &Callee) {
++  // If the calling function has *no* stack protection level (e.g. it was built
++  // with Clang's -fno-stack-protector or no_stack_protector attribute), don't
++  // change it as that could change the program's semantics.
++  if (!Caller.hasStackProtectorFnAttr())
++    return;
++
+   // If upgrading the SSP attribute, clear out the old SSP Attributes first.
+   // Having multiple SSP attributes doesn't actually hurt, but it adds useless
+   // clutter to the IR.
+diff --git a/llvm/test/ThinLTO/X86/nossp.ll b/llvm/test/ThinLTO/X86/nossp.ll
+index c542a85c6f74..cfc54d595ad7 100644
+--- a/llvm/test/ThinLTO/X86/nossp.ll
++++ b/llvm/test/ThinLTO/X86/nossp.ll
+@@ -23,7 +23,8 @@ declare void @ssp_callee() ssp
+ 
+ ; nossp caller should be able to inline nossp callee.
+ define void @nossp_caller() {
+-; CHECK-LABEL: @nossp_caller
++; CHECK-LABEL: define void @nossp_caller()
++; CHECK-NOT: #0
+ ; CHECK-NEXT: tail call void @foo
+   tail call void @nossp_callee()
+   ret void
+@@ -31,28 +32,34 @@ define void @nossp_caller() {
+ 
+ ; ssp caller should be able to inline ssp callee.
+ define void @ssp_caller() ssp {
+-; CHECK-LABEL: @ssp_caller
++; CHECK-LABEL: define void @ssp_caller()
++; CHECK-SAME: #0
+ ; CHECK-NEXT: tail call void @foo
+   tail call void @ssp_callee()
+   ret void
+ }
+ 
+-; nossp caller should *NOT* be able to inline ssp callee.
++; nossp caller should be able to inline ssp callee.
++; the ssp attribute is not propagated.
+ define void @nossp_caller2() {
+-; CHECK-LABEL: @nossp_caller2
+-; CHECK-NEXT: tail call void @ssp_callee
++; CHECK-LABEL: define void @nossp_caller2()
++; CHECK-NOT: #0
++; CHECK-NEXT: tail call void @foo
+   tail call void @ssp_callee()
+   ret void
+ }
+ 
+-; ssp caller should *NOT* be able to inline nossp callee.
++; ssp caller should be able to inline nossp callee.
+ define void @ssp_caller2() ssp {
+-; CHECK-LABEL: @ssp_caller2
+-; CHECK-NEXT: tail call void @nossp_callee
++; CHECK-LABEL: define void @ssp_caller2()
++; CHECK-SAME: #0
++; CHECK-NEXT: tail call void @foo
+   tail call void @nossp_callee()
+   ret void
+ }
+ 
++; CHECK: attributes #0 = { ssp }
++
+ ;--- b.ll
+ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+ target triple = "x86_64-pc-linux-gnu"
+diff --git a/llvm/test/Transforms/Inline/inline_nossp.ll b/llvm/test/Transforms/Inline/inline_nossp.ll
+deleted file mode 100644
+index 24fdab0b9f13..000000000000
+--- a/llvm/test/Transforms/Inline/inline_nossp.ll
++++ /dev/null
+@@ -1,50 +0,0 @@
+-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+-; RUN: opt -passes='cgscc(inline)' %s -S -pass-remarks-missed=inline 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-INLINE %s
+-; RUN: opt -passes=always-inline -o - -S %s | FileCheck %s
+-
+-; CHECK-INLINE: ssp not inlined into nossp_caller because it should never be inlined (cost=never): stack protected callee but caller requested no stack protector
+-; CHECK-INLINE: nossp not inlined into ssp_caller because it should never be inlined (cost=never): stack protected caller but callee requested no stack protector
+-
+-; Not interesting to test.
+-define i32 @nossp() { ret i32 41 }
+-define i32 @ssp() sspstrong { ret i32 42 }
+-define i32 @nossp_alwaysinline() alwaysinline { ret i32 43 }
+-define i32 @ssp_alwaysinline() sspstrong alwaysinline { ret i32 44 }
+-
+-; @ssp should not be inlined due to mismatch stack protector.
+-; @ssp_alwaysinline should be inlined due to alwaysinline.
+-define i32 @nossp_caller() {
+-; CHECK-LABEL: @nossp_caller(
+-; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @ssp()
+-; CHECK-NEXT:    ret i32 44
+-;
+-  call i32 @ssp()
+-  %2 = call i32 @ssp_alwaysinline()
+-  ret i32 %2
+-}
+-; @nossp should not be inlined due to mismatch stack protector.
+-; @nossp_alwaysinline should be inlined due to alwaysinline.
+-define i32 @ssp_caller() sspstrong {
+-; CHECK-LABEL: @ssp_caller(
+-; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @nossp()
+-; CHECK-NEXT:    ret i32 43
+-;
+-  call i32 @nossp()
+-  %2 = call i32 @nossp_alwaysinline()
+-  ret i32 %2
+-}
+-
+-; The alwaysinline attribute can also appear on the CallBase (ie. the call
+-; site), ie. when __attribute__((flatten)) is used on the caller. Treat this
+-; the same as if the caller had the fn attr alwaysinline and permit inline
+-; substitution, despite the mismatch between caller and callee on ssp attrs.
+-;
+-; Curiously, the always_inline attribute on a CallInst is only expanded by the
+-; inline pass, but not always_inline pass!
+-define i32 @nossp_alwaysinline_caller() {
+-; CHECK-INLINE-LABEL: @nossp_alwaysinline_caller(
+-; CHECK-INLINE-NEXT:    ret i32 42
+-;
+-  %1 = call i32 @ssp() alwaysinline
+-  ret i32 %1
+-}
+diff --git a/llvm/test/Transforms/Inline/inline_ssp.ll b/llvm/test/Transforms/Inline/inline_ssp.ll
+index ccfe93453159..a4f73f4dcd5a 100644
+--- a/llvm/test/Transforms/Inline/inline_ssp.ll
++++ b/llvm/test/Transforms/Inline/inline_ssp.ll
+@@ -9,15 +9,23 @@
+ 
+ ; These first four functions (@fun_sspreq, @fun_sspstrong, @fun_ssp, @fun_nossp)
+ ; are used by the remaining functions to ensure that the SSP attributes are
+-; propagated correctly.  The caller should have its SSP attribute set as:
++; propagated correctly.  If the caller had an SSP attribute before inlining, it
++; should have its new SSP attribute set as:
+ ; strictest(caller-ssp-attr, callee-ssp-attr), where strictness is ordered as:
+-;  sspreq > sspstrong > ssp > [no ssp]
++;  sspreq > sspstrong > ssp
++
+ define internal void @fun_sspreq() sspreq {
+ entry:
+   %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str3, i32 0, i32 0))
+   ret void
+ }
+ 
++define internal void @fun_sspreq_alwaysinline() sspreq alwaysinline {
++entry:
++  %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str3, i32 0, i32 0))
++  ret void
++}
++
+ define internal void @fun_sspstrong() sspstrong {
+ entry:
+   %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str2, i32 0, i32 0))
+@@ -66,6 +74,13 @@ entry:
+   ret void
+ }
+ 
++define void @alwaysinline_req_nossp() {
++entry:
++; CHECK: @alwaysinline_req_nossp() {
++  call void @fun_sspreq_alwaysinline()
++  ret void
++}
++
+ define void @inline_strong_req() sspreq {
+ entry:
+ ; CHECK: @inline_strong_req() #[[SSPREQ]]



More information about the arch-commits mailing list