git: e3fe4a9e6dea - stable/13 - Apply clang fix for crash or assertion failure compiling part of llvm

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 27 Dec 2021 10:20:41 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=e3fe4a9e6dea04b303066822e63dee19f4f9524f

commit e3fe4a9e6dea04b303066822e63dee19f4f9524f
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-12-24 11:46:00 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-27 10:19:41 +0000

    Apply clang fix for crash or assertion failure compiling part of llvm
    
    Merge commit 77e8f4eeeeed from llvm git (by David Green):
    
      [ARM] Define ComplexPatternFuncMutatesDAG
    
      Some of the Arm complex pattern functions call canExtractShiftFromMul,
      which can modify the DAG in-place. For this to be valid and handled
      successfully we need to define ComplexPatternFuncMutatesDAG.
    
      Differential Revision: https://reviews.llvm.org/D107476
    
    When building parts of llvm targeting armv6 on stable/12, the following
    assertion can appear (or if assertions are disabled, clang is likely to
    crash):
    
    Assertion failed: (NodeToMatch->getOpcode() != ISD::DELETED_NODE && "NodeToMatch was removed partway through selection"), function SelectCodeCommon, file /usr/src/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp, line 3573.
    PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
    Stack dump:
    0.      Program arguments: /usr/obj/usr/src/freebsd12-amd64/tmp/usr/bin/c++ -cc1 -triple armv6kz-unknown-freebsd12.3-gnueabihf -S --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -mrelocation-model static -mconstructor-aliases -target-cpu arm1176jzf-s -target-feature +vfp2 -target-feature +vfp2sp -target-feature -vfp3 -target-feature -vfp3d16 -target-feature -vfp3d16sp -target-feature -vfp3sp -target-feature -fp16 -target-feature -vfp4 -target-feature -vfp4d16 -target-feature -vfp4d16sp -target-feature -vfp4sp -target-feature -fp-armv8 -target-feature -fp-armv8d16 -target-feature -fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 -target-feature +fp64 -target-feature -d32 -target-feature -neon -target-feature -sha2 -target-feature -aes -target-feature -fp16fml -target-feature +strict-align -target-abi aapcs-linux -mfloat-abi hard -fallow-half-arguments-and-returns -ffunction-sections -fdata-sections -O1 -std=c++14 -fdeprecated-macro
  -fno-rtti -fno-signed-char -faddrsig -fexperimental-new-pass-manager PPCISelLowering-009095.ii
    1.      <eof> parser at end of file
    2.      Code generation
    3.      Running pass 'Function Pass Manager' on module 'PPCISelLowering-009095.cpp'.
    4.      Running pass 'ARM Instruction Selection' on function '@_ZN4llvm17PPCTargetLoweringC2ERKNS_16PPCTargetMachineERKNS_12PPCSubtargetE'
    
    This crash or assertion is fixed by the upstream commit.
    
    MFC after:      3 days
    
    (cherry picked from commit ada8b24d48d93f0b13209b555b64f3d355ef61d9)
---
 contrib/llvm-project/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/contrib/llvm-project/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/contrib/llvm-project/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
index 9c7055deaaf8..7c238a1099d8 100644
--- a/contrib/llvm-project/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -79,6 +79,10 @@ public:
 
   void Select(SDNode *N) override;
 
+  /// Return true as some complex patterns, like those that call
+  /// canExtractShiftFromMul can modify the DAG inplace.
+  bool ComplexPatternFuncMutatesDAG() const override { return true; }
+
   bool hasNoVMLxHazardUse(SDNode *N) const;
   bool isShifterOpProfitable(const SDValue &Shift,
                              ARM_AM::ShiftOpc ShOpcVal, unsigned ShAmt);