Skip to content

[SandboxVec][BottomUpVec] Implement InstrMaps #122848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2025
Merged

Conversation

vporpo
Copy link
Contributor

@vporpo vporpo commented Jan 14, 2025

InstrMaps is a helper data structure that maps scalars to vectors and the reverse. This is used by the vectorizer to figure out which vectors it can extract scalar values from.

@llvmbot
Copy link
Member

llvmbot commented Jan 14, 2025

@llvm/pr-subscribers-vectorizers

@llvm/pr-subscribers-llvm-transforms

Author: vporpo (vporpo)

Changes

InstrMaps is a helper data structure that maps scalars to vectors and the reverse. This is used by the vectorizer to figure out which vectors it can extract scalar values from.


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

11 Files Affected:

  • (added) llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h (+77)
  • (modified) llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h (+78-4)
  • (modified) llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h (+3)
  • (modified) llvm/lib/Transforms/Vectorize/CMakeLists.txt (+1)
  • (added) llvm/lib/Transforms/Vectorize/SandboxVectorizer/InstrMaps.cpp (+21)
  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp (+29-2)
  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp (+110-94)
  • (modified) llvm/test/Transforms/SandboxVectorizer/bottomup_basic.ll (+20)
  • (modified) llvm/unittests/Transforms/Vectorize/SandboxVectorizer/CMakeLists.txt (+1)
  • (added) llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp (+78)
  • (modified) llvm/unittests/Transforms/Vectorize/SandboxVectorizer/LegalityTest.cpp (+72-3)
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h
new file mode 100644
index 00000000000000..35d27315541217
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h
@@ -0,0 +1,77 @@
+//===- InstructionMaps.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRUCTIONMAPS_H
+#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRUCTIONMAPS_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/SandboxIR/Value.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm::sandboxir {
+
+/// Maps the original instructions to the vectorized instrs and the reverse.
+/// For now an original instr can only map to a single vector.
+class InstrMaps {
+  /// A map from the original values that got combined into vectors, to the
+  /// vector value(s).
+  DenseMap<Value *, Value *> OrigToVectorMap;
+  /// A map from the vector value to a map of the original value to its lane.
+  /// Please note that for constant vectors, there may multiple original values
+  /// with the same lane, as they may be coming from vectorizing different
+  /// original values.
+  DenseMap<Value *, DenseMap<Value *, unsigned>> VectorToOrigLaneMap;
+
+public:
+  /// \Returns all the vector value that we got from vectorizing \p Orig, or
+  /// nullptr if not found.
+  Value *getVectorForOrig(Value *Orig) const {
+    auto It = OrigToVectorMap.find(Orig);
+    return It != OrigToVectorMap.end() ? It->second : nullptr;
+  }
+  /// \Returns the lane of \p Orig before it got vectorized into \p Vec, or
+  /// nullopt if not found.
+  std::optional<int> getOrigLane(Value *Vec, Value *Orig) const {
+    auto It1 = VectorToOrigLaneMap.find(Vec);
+    if (It1 == VectorToOrigLaneMap.end())
+      return std::nullopt;
+    const auto &OrigToLaneMap = It1->second;
+    auto It2 = OrigToLaneMap.find(Orig);
+    if (It2 == OrigToLaneMap.end())
+      return std::nullopt;
+    return It2->second;
+  }
+  /// Update the map to reflect that \p Origs got vectorized into \p Vec.
+  void registerVector(ArrayRef<Value *> Origs, Value *Vec) {
+    auto &OrigToLaneMap = VectorToOrigLaneMap[Vec];
+    for (auto [Lane, Orig] : enumerate(Origs)) {
+      auto Pair = OrigToVectorMap.try_emplace(Orig, Vec);
+      assert(Pair.second && "Orig already exists in the map!");
+      OrigToLaneMap[Orig] = Lane;
+    }
+  }
+  void clear() {
+    OrigToVectorMap.clear();
+    VectorToOrigLaneMap.clear();
+  }
+#ifndef NDEBUG
+  void dump(raw_ostream &OS) const {
+    OS << "OrigToVectorMap:\n";
+    for (auto [Orig, Vec] : OrigToVectorMap)
+      OS << *Orig << " : " << *Vec << "\n";
+  }
+  LLVM_DUMP_METHOD void dump() const;
+#endif
+};
+} // namespace llvm::sandboxir
+
+#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRUCTIONMAPS_H
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
index 233cf82a1b3dfb..fe5b269f09e589 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
@@ -23,10 +23,12 @@ namespace llvm::sandboxir {
 
 class LegalityAnalysis;
 class Value;
+class InstrMaps;
 
 enum class LegalityResultID {
-  Pack,  ///> Collect scalar values.
-  Widen, ///> Vectorize by combining scalars to a vector.
+  Pack,         ///> Collect scalar values.
+  Widen,        ///> Vectorize by combining scalars to a vector.
+  DiamondReuse, ///> Don't generate new code, reuse existing vector.
 };
 
 /// The reason for vectorizing or not vectorizing.
@@ -50,6 +52,8 @@ struct ToStr {
       return "Pack";
     case LegalityResultID::Widen:
       return "Widen";
+    case LegalityResultID::DiamondReuse:
+      return "DiamondReuse";
     }
     llvm_unreachable("Unknown LegalityResultID enum");
   }
@@ -137,6 +141,19 @@ class Widen final : public LegalityResult {
   }
 };
 
+class DiamondReuse final : public LegalityResult {
+  friend class LegalityAnalysis;
+  Value *Vec;
+  DiamondReuse(Value *Vec)
+      : LegalityResult(LegalityResultID::DiamondReuse), Vec(Vec) {}
+
+public:
+  static bool classof(const LegalityResult *From) {
+    return From->getSubclassID() == LegalityResultID::DiamondReuse;
+  }
+  Value *getVector() const { return Vec; }
+};
+
 class Pack final : public LegalityResultWithReason {
   Pack(ResultReason Reason)
       : LegalityResultWithReason(LegalityResultID::Pack, Reason) {}
@@ -148,6 +165,57 @@ class Pack final : public LegalityResultWithReason {
   }
 };
 
+/// Describes how to collect the values needed by each lane.
+class CollectDescr {
+public:
+  /// Describes how to get a value element. If the value is a vector then it
+  /// also provides the index to extract it from.
+  class ExtractElementDescr {
+    Value *V;
+    /// The index in `V` that the value can be extracted from.
+    /// This is nullopt if we need to use `V` as a whole.
+    std::optional<int> ExtractIdx;
+
+  public:
+    ExtractElementDescr(Value *V, int ExtractIdx)
+        : V(V), ExtractIdx(ExtractIdx) {}
+    ExtractElementDescr(Value *V) : V(V), ExtractIdx(std::nullopt) {}
+    Value *getValue() const { return V; }
+    bool needsExtract() const { return ExtractIdx.has_value(); }
+    int getExtractIdx() const { return *ExtractIdx; }
+  };
+
+  using DescrVecT = SmallVector<ExtractElementDescr, 4>;
+  DescrVecT Descrs;
+
+public:
+  CollectDescr(SmallVectorImpl<ExtractElementDescr> &&Descrs)
+      : Descrs(std::move(Descrs)) {}
+  std::optional<std::pair<Value *, bool>> getSingleInput() const {
+    const auto &Descr0 = *Descrs.begin();
+    Value *V0 = Descr0.getValue();
+    if (!Descr0.needsExtract())
+      return std::nullopt;
+    bool NeedsShuffle = Descr0.getExtractIdx() != 0;
+    int Lane = 1;
+    for (const auto &Descr : drop_begin(Descrs)) {
+      if (!Descr.needsExtract())
+        return std::nullopt;
+      if (Descr.getValue() != V0)
+        return std::nullopt;
+      if (Descr.getExtractIdx() != Lane++)
+        NeedsShuffle = true;
+    }
+    return std::make_pair(V0, NeedsShuffle);
+  }
+  bool hasVectorInputs() const {
+    return any_of(Descrs, [](const auto &D) { return D.needsExtract(); });
+  }
+  const SmallVector<ExtractElementDescr, 4> &getDescrs() const {
+    return Descrs;
+  }
+};
+
 /// Performs the legality analysis and returns a LegalityResult object.
 class LegalityAnalysis {
   Scheduler Sched;
@@ -160,11 +228,17 @@ class LegalityAnalysis {
 
   ScalarEvolution &SE;
   const DataLayout &DL;
+  InstrMaps &IMaps;
+
+  /// Finds how we can collect the values in \p Bndl from the vectorized or
+  /// non-vectorized code. It returns a map of the value we should extract from
+  /// and the corresponding shuffle mask we need to use.
+  CollectDescr getHowToCollectValues(ArrayRef<Value *> Bndl) const;
 
 public:
   LegalityAnalysis(AAResults &AA, ScalarEvolution &SE, const DataLayout &DL,
-                   Context &Ctx)
-      : Sched(AA, Ctx), SE(SE), DL(DL) {}
+                   Context &Ctx, InstrMaps &IMaps)
+      : Sched(AA, Ctx), SE(SE), DL(DL), IMaps(IMaps) {}
   /// A LegalityResult factory.
   template <typename ResultT, typename... ArgsT>
   ResultT &createLegalityResult(ArgsT... Args) {
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
index 1a53ca6e06f5fd..69cea3c4c7b53b 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
@@ -18,6 +18,7 @@
 #include "llvm/SandboxIR/Pass.h"
 #include "llvm/SandboxIR/PassManager.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h"
 
 namespace llvm::sandboxir {
@@ -26,6 +27,8 @@ class BottomUpVec final : public FunctionPass {
   bool Change = false;
   std::unique_ptr<LegalityAnalysis> Legality;
   DenseSet<Instruction *> DeadInstrCandidates;
+  /// Maps scalars to vectors.
+  InstrMaps IMaps;
 
   /// Creates and returns a vector instruction that replaces the instructions in
   /// \p Bndl. \p Operands are the already vectorized operands.
diff --git a/llvm/lib/Transforms/Vectorize/CMakeLists.txt b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
index d769d5100afd23..6a025652f92f8e 100644
--- a/llvm/lib/Transforms/Vectorize/CMakeLists.txt
+++ b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
@@ -4,6 +4,7 @@ add_llvm_component_library(LLVMVectorize
   LoopVectorizationLegality.cpp
   LoopVectorize.cpp
   SandboxVectorizer/DependencyGraph.cpp
+  SandboxVectorizer/InstrMaps.cpp
   SandboxVectorizer/Interval.cpp
   SandboxVectorizer/Legality.cpp
   SandboxVectorizer/Passes/BottomUpVec.cpp
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/InstrMaps.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/InstrMaps.cpp
new file mode 100644
index 00000000000000..5ebcf90e74255b
--- /dev/null
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/InstrMaps.cpp
@@ -0,0 +1,21 @@
+//===- InstructionMaps.cpp - Maps scalars to vectors and reverse ----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h"
+#include "llvm/Support/Debug.h"
+
+namespace llvm::sandboxir {
+
+#ifndef NDEBUG
+void InstrMaps::dump() const {
+  dump(dbgs());
+  dbgs() << "\n";
+}
+#endif // NDEBUG
+
+} // namespace llvm::sandboxir
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
index 8c6deeb7df249d..45acdf09f2f2c7 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
@@ -12,6 +12,7 @@
 #include "llvm/SandboxIR/Utils.h"
 #include "llvm/SandboxIR/Value.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h"
 
 namespace llvm::sandboxir {
@@ -184,6 +185,22 @@ static void dumpBndl(ArrayRef<Value *> Bndl) {
 }
 #endif // NDEBUG
 
+CollectDescr
+LegalityAnalysis::getHowToCollectValues(ArrayRef<Value *> Bndl) const {
+  SmallVector<CollectDescr::ExtractElementDescr, 4> Vec;
+  Vec.reserve(Bndl.size());
+  for (auto [Lane, V] : enumerate(Bndl)) {
+    if (auto *VecOp = IMaps.getVectorForOrig(V)) {
+      // If there is a vector containing `V`, then get the lane it came from.
+      std::optional<int> ExtractIdxOpt = IMaps.getOrigLane(VecOp, V);
+      Vec.emplace_back(VecOp, ExtractIdxOpt ? *ExtractIdxOpt : -1);
+    } else {
+      Vec.emplace_back(V);
+    }
+  }
+  return CollectDescr(std::move(Vec));
+}
+
 const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl,
                                                      bool SkipScheduling) {
   // If Bndl contains values other than instructions, we need to Pack.
@@ -193,11 +210,21 @@ const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl,
     return createLegalityResult<Pack>(ResultReason::NotInstructions);
   }
 
+  auto CollectDescrs = getHowToCollectValues(Bndl);
+  if (CollectDescrs.hasVectorInputs()) {
+    if (auto ValueShuffleOpt = CollectDescrs.getSingleInput()) {
+      auto [Vec, NeedsShuffle] = *ValueShuffleOpt;
+      if (!NeedsShuffle)
+        return createLegalityResult<DiamondReuse>(Vec);
+      llvm_unreachable("TODO: Unimplemented");
+    } else {
+      llvm_unreachable("TODO: Unimplemented");
+    }
+  }
+
   if (auto ReasonOpt = notVectorizableBasedOnOpcodesAndTypes(Bndl))
     return createLegalityResult<Pack>(*ReasonOpt);
 
-  // TODO: Check for existing vectors containing values in Bndl.
-
   if (!SkipScheduling) {
     // TODO: Try to remove the IBndl vector.
     SmallVector<Instruction *, 8> IBndl;
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
index d44199609838d7..6b2032be535603 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
@@ -56,103 +56,114 @@ getInsertPointAfterInstrs(ArrayRef<Value *> Instrs) {
 
 Value *BottomUpVec::createVectorInstr(ArrayRef<Value *> Bndl,
                                       ArrayRef<Value *> Operands) {
-  Change = true;
-  assert(all_of(Bndl, [](auto *V) { return isa<Instruction>(V); }) &&
-         "Expect Instructions!");
-  auto &Ctx = Bndl[0]->getContext();
+  auto CreateVectorInstr = [](ArrayRef<Value *> Bndl,
+                              ArrayRef<Value *> Operands) -> Value * {
+    assert(all_of(Bndl, [](auto *V) { return isa<Instruction>(V); }) &&
+           "Expect Instructions!");
+    auto &Ctx = Bndl[0]->getContext();
 
-  Type *ScalarTy = VecUtils::getElementType(Utils::getExpectedType(Bndl[0]));
-  auto *VecTy = VecUtils::getWideType(ScalarTy, VecUtils::getNumLanes(Bndl));
+    Type *ScalarTy = VecUtils::getElementType(Utils::getExpectedType(Bndl[0]));
+    auto *VecTy = VecUtils::getWideType(ScalarTy, VecUtils::getNumLanes(Bndl));
 
-  BasicBlock::iterator WhereIt = getInsertPointAfterInstrs(Bndl);
+    BasicBlock::iterator WhereIt = getInsertPointAfterInstrs(Bndl);
 
-  auto Opcode = cast<Instruction>(Bndl[0])->getOpcode();
-  switch (Opcode) {
-  case Instruction::Opcode::ZExt:
-  case Instruction::Opcode::SExt:
-  case Instruction::Opcode::FPToUI:
-  case Instruction::Opcode::FPToSI:
-  case Instruction::Opcode::FPExt:
-  case Instruction::Opcode::PtrToInt:
-  case Instruction::Opcode::IntToPtr:
-  case Instruction::Opcode::SIToFP:
-  case Instruction::Opcode::UIToFP:
-  case Instruction::Opcode::Trunc:
-  case Instruction::Opcode::FPTrunc:
-  case Instruction::Opcode::BitCast: {
-    assert(Operands.size() == 1u && "Casts are unary!");
-    return CastInst::create(VecTy, Opcode, Operands[0], WhereIt, Ctx, "VCast");
-  }
-  case Instruction::Opcode::FCmp:
-  case Instruction::Opcode::ICmp: {
-    auto Pred = cast<CmpInst>(Bndl[0])->getPredicate();
-    assert(all_of(drop_begin(Bndl),
-                  [Pred](auto *SBV) {
-                    return cast<CmpInst>(SBV)->getPredicate() == Pred;
-                  }) &&
-           "Expected same predicate across bundle.");
-    return CmpInst::create(Pred, Operands[0], Operands[1], WhereIt, Ctx,
-                           "VCmp");
-  }
-  case Instruction::Opcode::Select: {
-    return SelectInst::create(Operands[0], Operands[1], Operands[2], WhereIt,
-                              Ctx, "Vec");
-  }
-  case Instruction::Opcode::FNeg: {
-    auto *UOp0 = cast<UnaryOperator>(Bndl[0]);
-    auto OpC = UOp0->getOpcode();
-    return UnaryOperator::createWithCopiedFlags(OpC, Operands[0], UOp0, WhereIt,
-                                                Ctx, "Vec");
-  }
-  case Instruction::Opcode::Add:
-  case Instruction::Opcode::FAdd:
-  case Instruction::Opcode::Sub:
-  case Instruction::Opcode::FSub:
-  case Instruction::Opcode::Mul:
-  case Instruction::Opcode::FMul:
-  case Instruction::Opcode::UDiv:
-  case Instruction::Opcode::SDiv:
-  case Instruction::Opcode::FDiv:
-  case Instruction::Opcode::URem:
-  case Instruction::Opcode::SRem:
-  case Instruction::Opcode::FRem:
-  case Instruction::Opcode::Shl:
-  case Instruction::Opcode::LShr:
-  case Instruction::Opcode::AShr:
-  case Instruction::Opcode::And:
-  case Instruction::Opcode::Or:
-  case Instruction::Opcode::Xor: {
-    auto *BinOp0 = cast<BinaryOperator>(Bndl[0]);
-    auto *LHS = Operands[0];
-    auto *RHS = Operands[1];
-    return BinaryOperator::createWithCopiedFlags(BinOp0->getOpcode(), LHS, RHS,
-                                                 BinOp0, WhereIt, Ctx, "Vec");
-  }
-  case Instruction::Opcode::Load: {
-    auto *Ld0 = cast<LoadInst>(Bndl[0]);
-    Value *Ptr = Ld0->getPointerOperand();
-    return LoadInst::create(VecTy, Ptr, Ld0->getAlign(), WhereIt, Ctx, "VecL");
-  }
-  case Instruction::Opcode::Store: {
-    auto Align = cast<StoreInst>(Bndl[0])->getAlign();
-    Value *Val = Operands[0];
-    Value *Ptr = Operands[1];
-    return StoreInst::create(Val, Ptr, Align, WhereIt, Ctx);
-  }
-  case Instruction::Opcode::Br:
-  case Instruction::Opcode::Ret:
-  case Instruction::Opcode::PHI:
-  case Instruction::Opcode::AddrSpaceCast:
-  case Instruction::Opcode::Call:
-  case Instruction::Opcode::GetElementPtr:
-    llvm_unreachable("Unimplemented");
-    break;
-  default:
-    llvm_unreachable("Unimplemented");
-    break;
+    auto Opcode = cast<Instruction>(Bndl[0])->getOpcode();
+    switch (Opcode) {
+    case Instruction::Opcode::ZExt:
+    case Instruction::Opcode::SExt:
+    case Instruction::Opcode::FPToUI:
+    case Instruction::Opcode::FPToSI:
+    case Instruction::Opcode::FPExt:
+    case Instruction::Opcode::PtrToInt:
+    case Instruction::Opcode::IntToPtr:
+    case Instruction::Opcode::SIToFP:
+    case Instruction::Opcode::UIToFP:
+    case Instruction::Opcode::Trunc:
+    case Instruction::Opcode::FPTrunc:
+    case Instruction::Opcode::BitCast: {
+      assert(Operands.size() == 1u && "Casts are unary!");
+      return CastInst::create(VecTy, Opcode, Operands[0], WhereIt, Ctx,
+                              "VCast");
+    }
+    case Instruction::Opcode::FCmp:
+    case Instruction::Opcode::ICmp: {
+      auto Pred = cast<CmpInst>(Bndl[0])->getPredicate();
+      assert(all_of(drop_begin(Bndl),
+                    [Pred](auto *SBV) {
+                      return cast<CmpInst>(SBV)->getPredicate() == Pred;
+                    }) &&
+             "Expected same predicate across bundle.");
+      return CmpInst::create(Pred, Operands[0], Operands[1], WhereIt, Ctx,
+                             "VCmp");
+    }
+    case Instruction::Opcode::Select: {
+      return SelectInst::create(Operands[0], Operands[1], Operands[2], WhereIt,
+                                Ctx, "Vec");
+    }
+    case Instruction::Opcode::FNeg: {
+      auto *UOp0 = cast<UnaryOperator>(Bndl[0]);
+      auto OpC = UOp0->getOpcode();
+      return UnaryOperator::createWithCopiedFlags(OpC, Operands[0], UOp0,
+                                                  WhereIt, Ctx, "Vec");
+    }
+    case Instruction::Opcode::Add:
+    case Instruction::Opcode::FAdd:
+    case Instruction::Opcode::Sub:
+    case Instruction::Opcode::FSub:
+    case Instruction::Opcode::Mul:
+    case Instruction::Opcode::FMul:
+    case Instruction::Opcode::UDiv:
+    case Instruction::Opcode::SDiv:
+    case Instruction::Opcode::FDiv:
+    case Instruction::Opcode::URem:
+    case Instruction::Opcode::SRem:
+    case Instruction::Opcode::FRem:
+    case Instruction::Opcode::Shl:
+    case Instruction::Opcode::LShr:
+    case Instruction::Opcode::AShr:
+    case Instruction::Opcode::And:
+    case Instruction::Opcode::Or:
+    case Instruction::Opcode::Xor: {
+      auto *BinOp0 = cast<BinaryOperator>(Bndl[0]);
+      auto *LHS = Operands[0];
+      auto *RHS = Operands[1];
+      return BinaryOperator::createWithCopiedFlags(
+          BinOp0->getOpcode(), LHS, RHS, BinOp0, WhereIt, Ctx, "Vec");
+    }
+    case Instruction::Opcode::Load: {
+      auto *Ld0 = cast<LoadInst>(Bndl[0]);
+      Value *Ptr = Ld0->getPointerOperand();
+      return LoadInst::create(VecTy, Ptr, Ld0->getAlign(), WhereIt, Ctx,
+                              "VecL");
+    }
+    case Instruction::Opcode::Store: {
+      auto Align = cast<StoreInst>(Bndl[0])->getAlign();
+      Value *Val = Operan...
[truncated]

@vporpo vporpo force-pushed the Legality branch 3 times, most recently from fbcc84a to 693e4d0 Compare January 16, 2025 16:46
@@ -0,0 +1,77 @@
//===- InstructionMaps.h ----------------------------------------*- C++ -*-===//
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the comment doesn't match the file name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRUCTIONMAPS_H
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The include guard also doesn't match the file name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

DenseMap<Value *, DenseMap<Value *, unsigned>> VectorToOrigLaneMap;

public:
/// \Returns all the vector value that we got from vectorizing \p Orig, or
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the "all" here a typo? The function only returns one value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a typo, fixed.

}
/// \Returns the lane of \p Orig before it got vectorized into \p Vec, or
/// nullopt if not found.
std::optional<int> getOrigLane(Value *Vec, Value *Orig) const {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lane is stored in the map as unsigned but here we return an int (wrapped in an optional).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it to optional.

InstrMaps is a helper data structure that maps scalars to vectors and the
reverse. This is used by the vectorizer to figure out which vectors it can
extract scalar values from.
@vporpo vporpo merged commit e902c69 into llvm:main Jan 16, 2025
5 of 7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 17, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-lld-multistage-test running on ppc64le-lld-multistage-test while building llvm at step 12 "build-stage2-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/7595

Here is the relevant piece of the build log for the reference
Step 12 (build-stage2-unified-tree) failure: build (failure)
...
12.197 [1/8/15] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o
23.054 [1/7/16] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangOpenCLBuiltinEmitter.cpp.o
31.144 [1/6/17] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/RISCVVEmitter.cpp.o
32.526 [1/5/18] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/SveEmitter.cpp.o
35.129 [1/4/19] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o
45.554 [1/3/20] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/MveEmitter.cpp.o
50.363 [1/2/21] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o
67.593 [1/1/22] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o
67.652 [0/1/23] Linking CXX executable bin/clang-tblgen
91.295 [3934/257/2212] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o
FAILED: unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/install/stage1/bin/clang++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/unittests/Transforms/Vectorize/SandboxVectorizer -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o -MF unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o.d -o unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp:15:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googlemock/include/gmock/gmock.h:56:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googlemock/include/gmock/gmock-actions.h:145:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h:50:
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1379:11: error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare]
 1379 |   if (lhs == rhs) {
      |       ~~~ ^  ~~~
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1398:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here
 1398 |     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
      |            ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp:67:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here
   67 |   EXPECT_EQ(*IMaps.getOrigLane(VAdd0, Add0), 0);
      |   ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1869:54: note: expanded from macro 'EXPECT_EQ'
 1869 |   EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
      |                                                      ^
1 error generated.
103.537 [3934/45/2424] Building CXX object lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/NewGVN.cpp.o
104.202 [3934/43/2426] Building CXX object lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/SampleProfile.cpp.o
104.690 [3934/42/2427] Building CXX object unittests/TargetParser/CMakeFiles/TargetParserTests.dir/TargetParserTest.cpp.o
104.863 [3934/41/2428] Building CXX object unittests/Transforms/Instrumentation/CMakeFiles/InstrumentationTests.dir/MemProfUseTest.cpp.o
104.866 [3934/40/2429] Building CXX object unittests/Transforms/Vectorize/CMakeFiles/VectorizeTests.dir/VPlanTest.cpp.o
105.270 [3934/39/2430] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MachinePipeliner.cpp.o
106.281 [3934/38/2431] Building CXX object lib/Passes/CMakeFiles/LLVMPasses.dir/StandardInstrumentations.cpp.o
107.261 [3934/37/2432] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/LiveDebugValues/InstrRefBasedImpl.cpp.o
107.327 [3934/36/2433] Building CXX object unittests/IR/CMakeFiles/IRTests.dir/PatternMatch.cpp.o
107.413 [3934/35/2434] Building CXX object lib/CodeGen/SelectionDAG/CMakeFiles/LLVMSelectionDAG.dir/SelectionDAG.cpp.o
107.463 [3934/34/2435] Building CXX object lib/AsmParser/CMakeFiles/LLVMAsmParser.dir/LLParser.cpp.o
108.040 [3934/33/2436] Building CXX object lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TargetLibraryInfo.cpp.o
108.504 [3934/32/2437] Building CXX object unittests/Support/CMakeFiles/SupportTests.dir/VirtualFileSystemTest.cpp.o
108.837 [3934/31/2438] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/CodeGenPrepare.cpp.o
108.895 [3934/30/2439] Building CXX object unittests/IR/CMakeFiles/IRTests.dir/MetadataTest.cpp.o
110.347 [3934/29/2440] Building CXX object lib/CodeGen/SelectionDAG/CMakeFiles/LLVMSelectionDAG.dir/SelectionDAGBuilder.cpp.o
111.545 [3934/28/2441] Building CXX object unittests/ProfileData/CMakeFiles/ProfileDataTests.dir/InstrProfTest.cpp.o
112.248 [3934/27/2442] Building CXX object lib/ObjCopy/CMakeFiles/LLVMObjCopy.dir/ELF/ELFObject.cpp.o
112.409 [3934/26/2443] Building CXX object unittests/IR/CMakeFiles/IRTests.dir/ConstantRangeTest.cpp.o
116.761 [3934/25/2444] Building CXX object tools/llvm-profdata/CMakeFiles/llvm-profdata.dir/llvm-profdata.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 17, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64le-rhel running on ppc64le-clang-rhel-test while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/4491

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
0.182 [2/3/1] Building CXX object compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_dynamic_version_script_dummy.powerpc64le.dir/dummy.cpp.o
0.183 [1/3/2] Building CXX object compiler-rt/lib/asan/CMakeFiles/RTAsan_dynamic_version_script_dummy.powerpc64le.dir/dummy.cpp.o
0.397 [0/3/3] Linking CXX shared library /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/clang/20/lib/powerpc64le-unknown-linux-gnu/libclang_rt.ubsan_standalone.so
0.425 [0/2/4] Linking CXX shared library /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/clang/20/lib/powerpc64le-unknown-linux-gnu/libclang_rt.asan.so
1.992 [0/1/5] Generating /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/compile_commands.json
24.559 [4/3/1205] cd /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/runtimes/runtimes-bins && /home/buildbots/llvm-external-buildbots/cmake-3.28.2/bin/cmake --build /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/runtimes/runtimes-bins/ --target runtimes-test-depends --config Release
ninja: no work to do.
24.626 [3/3/1206] No install step for 'runtimes'
24.647 [2/3/1208] Completed 'runtimes'
28.488 [2/2/1209] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o
FAILED: unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o 
ccache /home/docker/llvm-external-buildbots/clang.17.0.6/bin/clang++ --gcc-toolchain=/gcc-toolchain/usr -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/unittests/Transforms/Vectorize/SandboxVectorizer -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o -MF unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o.d -o unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp:15:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googlemock/include/gmock/gmock.h:56:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googlemock/include/gmock/gmock-actions.h:145:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h:50:
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1379:11: error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare]
 1379 |   if (lhs == rhs) {
      |       ~~~ ^  ~~~
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1398:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here
 1398 |     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
      |            ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp:67:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here
   67 |   EXPECT_EQ(*IMaps.getOrigLane(VAdd0, Add0), 0);
      |   ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1869:54: note: expanded from macro 'EXPECT_EQ'
 1869 |   EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
      |                                                      ^
1 error generated.
31.686 [2/1/1210] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/LegalityTest.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 17, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-win running on as-worker-93 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2096

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests.exe/38/87' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-20512-38-87.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=38 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied




********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 18, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64-aix running on aix-ppc64 while building llvm at step 3 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/64/builds/2004

Here is the relevant piece of the build log for the reference
Step 3 (clean-build-dir) failure: Delete failed. (failure) (timed out)
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
...
1040.086 [81/50/917] Building CXX object unittests/Transforms/Utils/CMakeFiles/UtilsTests.dir/ModuleUtilsTest.cpp.o
1040.272 [80/50/918] Building CXX object unittests/Transforms/Utils/CMakeFiles/UtilsTests.dir/ScalarEvolutionExpanderTest.cpp.o
1040.392 [79/50/919] Building CXX object unittests/Transforms/Utils/CMakeFiles/UtilsTests.dir/ValueMapperTest.cpp.o
1040.517 [78/50/920] Building CXX object unittests/Transforms/Vectorize/CMakeFiles/VectorizeTests.dir/VPlanTest.cpp.o
1040.655 [77/50/921] Building CXX object unittests/Transforms/Vectorize/CMakeFiles/VectorizeTests.dir/VPDomTreeTest.cpp.o
1040.781 [76/50/922] Building CXX object unittests/Transforms/Vectorize/CMakeFiles/VectorizeTests.dir/VPlanHCFGTest.cpp.o
1040.787 [76/49/923] Building CXX object unittests/Transforms/Vectorize/CMakeFiles/VectorizeTests.dir/VPlanSlpTest.cpp.o
1040.793 [76/48/924] Building CXX object unittests/Transforms/Vectorize/CMakeFiles/VectorizeTests.dir/VPlanVerifierTest.cpp.o
1040.805 [76/47/925] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/DependencyGraphTest.cpp.o
1040.811 [76/46/926] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o
FAILED: unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o 
/usr/local/clang-17.0.2/bin/clang++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_LARGE_FILE_API -D_XOPEN_SOURCE=700 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/unittests/Transforms/Vectorize/SandboxVectorizer -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/include -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/include -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googlemock/include -mcmodel=large -fPIC -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o -MF unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o.d -o unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/InstrMapsTest.cpp.o -c /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp:15:
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googlemock/include/gmock/gmock.h:56:
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googlemock/include/gmock/gmock-actions.h:145:
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h:50:
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1379:11: error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare]
 1379 |   if (lhs == rhs) {
      |       ~~~ ^  ~~~
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1398:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here
 1398 |     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
      |            ^
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrMapsTest.cpp:67:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here
   67 |   EXPECT_EQ(*IMaps.getOrigLane(VAdd0, Add0), 0);
      |   ^
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1869:54: note: expanded from macro 'EXPECT_EQ'
 1869 |   EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
      |                                                      ^
1 error generated.
1040.817 [76/45/927] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/IntervalTest.cpp.o
1040.835 [76/44/928] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/LegalityTest.cpp.o
1040.841 [76/43/929] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/SchedulerTest.cpp.o
1040.847 [76/42/930] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/SeedCollectorTest.cpp.o
1040.859 [76/41/931] Building CXX object unittests/Transforms/Vectorize/SandboxVectorizer/CMakeFiles/SandboxVectorizerTests.dir/VecUtilsTest.cpp.o
1040.865 [76/40/932] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/FDRBlockIndexerTest.cpp.o
1040.871 [76/39/933] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/FDRBlockVerifierTest.cpp.o
1040.877 [76/38/934] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/FDRProducerConsumerTest.cpp.o
1040.883 [76/37/935] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/FDRRecordPrinterTest.cpp.o
1040.889 [76/36/936] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/FDRRecordsTest.cpp.o
1040.907 [76/35/937] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/FDRTraceWriterTest.cpp.o
1040.913 [76/34/938] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/GraphTest.cpp.o
1040.919 [76/33/939] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/ProfileTest.cpp.o
1040.924 [76/32/940] Building CXX object unittests/tools/llvm-cfi-verify/CMakeFiles/CFIVerifyTests.dir/FileAnalysis.cpp.o
1040.931 [76/31/941] Building CXX object unittests/tools/llvm-cfi-verify/CMakeFiles/CFIVerifyTests.dir/GraphBuilder.cpp.o
1040.937 [76/30/942] Building CXX object unittests/tools/llvm-exegesis/CMakeFiles/LLVMExegesisTests.dir/BenchmarkRunnerTest.cpp.o
1040.949 [76/29/943] Building CXX object unittests/tools/llvm-exegesis/CMakeFiles/LLVMExegesisTests.dir/ClusteringTest.cpp.o
1040.954 [76/28/944] Building CXX object unittests/tools/llvm-exegesis/CMakeFiles/LLVMExegesisTests.dir/ProgressMeterTest.cpp.o
1040.960 [76/27/945] Building CXX object unittests/tools/llvm-exegesis/CMakeFiles/LLVMExegesisTests.dir/RegisterValueTest.cpp.o
1040.966 [76/26/946] Building CXX object unittests/tools/llvm-exegesis/CMakeFiles/LLVMExegesisTests.dir/ResultAggregatorTest.cpp.o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants