Skip to content

Conversation

@vporpo
Copy link
Contributor

@vporpo vporpo commented Feb 8, 2025

The TransactionAcceptOrRevert pass is the final pass in the Sandbox Vectorizer's default pass pipeline. It's job is to check the cost before/after vectorization and accept or revert the IR to its original state.

Since we are now starting the transaction in BottomUpVec, tests that run a custom pipeline need to accept the transaction. This is done with the help of the TransactionAlwaysAccept pass (tr-accept).

@llvmbot
Copy link
Member

llvmbot commented Feb 8, 2025

@llvm/pr-subscribers-vectorizers

@llvm/pr-subscribers-llvm-transforms

Author: vporpo (vporpo)

Changes

The TransactionAcceptOrRevert pass is the final pass in the Sandbox Vectorizer's default pass pipeline. It's job is to check the cost before/after vectorization and accept or revert the IR to its original state.

Since we are now starting the transaction in BottomUpVec, tests that run a custom pipeline need to accept the transaction. This is done with the help of the TransactionAlwaysAccept pass (tr-accept).


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

17 Files Affected:

  • (modified) llvm/include/llvm/SandboxIR/Tracker.h (+2)
  • (added) llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.h (+30)
  • (added) llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAlwaysAccept.h (+34)
  • (modified) llvm/lib/Transforms/Vectorize/CMakeLists.txt (+1)
  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp (+16-4)
  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/PassRegistry.def (+2)
  • (added) llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.cpp (+37)
  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp (+3-2)
  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.cpp (+2)
  • (added) llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll (+55)
  • (modified) llvm/test/Transforms/SandboxVectorizer/bottomup_basic.ll (+1-1)
  • (modified) llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice.ll (+1-1)
  • (modified) llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice_pow2.ll (+2-2)
  • (modified) llvm/test/Transforms/SandboxVectorizer/cross_bbs.ll (+1-1)
  • (modified) llvm/test/Transforms/SandboxVectorizer/default_pass_pipeline.ll (+2)
  • (modified) llvm/test/Transforms/SandboxVectorizer/pack.ll (+1-1)
  • (modified) llvm/unittests/SandboxIR/TrackerTest.cpp (+6)
diff --git a/llvm/include/llvm/SandboxIR/Tracker.h b/llvm/include/llvm/SandboxIR/Tracker.h
index 9a031f327083740..94b259722bbada9 100644
--- a/llvm/include/llvm/SandboxIR/Tracker.h
+++ b/llvm/include/llvm/SandboxIR/Tracker.h
@@ -473,6 +473,8 @@ class Tracker {
 
   ~Tracker();
   Context &getContext() const { return Ctx; }
+  /// \Returns true if there are no changes tracked.
+  bool empty() const { return Changes.empty(); }
   /// Record \p Change and take ownership. This is the main function used to
   /// track Sandbox IR changes.
   void track(std::unique_ptr<IRChangeBase> &&Change) {
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.h
new file mode 100644
index 000000000000000..fce9cc0c1bde778
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.h
@@ -0,0 +1,30 @@
+//===- TransactionAcceptOrRevert.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
+//
+//===----------------------------------------------------------------------===//
+//
+// This is a region pass that checks the region cost before/after vectorization
+// and accepts the state of Sandbox IR if the cost is better, or otherwise
+// reverts it.
+//
+
+#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONACCEPTORREVERT_H
+#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONACCEPTORREVERT_H
+
+#include "llvm/SandboxIR/Pass.h"
+#include "llvm/SandboxIR/Region.h"
+
+namespace llvm::sandboxir {
+
+class TransactionAcceptOrRevert : public RegionPass {
+public:
+  TransactionAcceptOrRevert() : RegionPass("tr-accept-or-revert") {}
+  bool runOnRegion(Region &Rgn, const Analyses &A) final;
+};
+
+} // namespace llvm::sandboxir
+
+#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONACCEPTORREVERT_H
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAlwaysAccept.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAlwaysAccept.h
new file mode 100644
index 000000000000000..ed6cf1bf7cf51e5
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAlwaysAccept.h
@@ -0,0 +1,34 @@
+//===- TransactionAlwaysAccept.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
+//
+//===----------------------------------------------------------------------===//
+//
+// This is a region pass that always accepts the transaction without checking
+// its cost. This is mainly used as a final pass in lit tests.
+//
+
+#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONALWAYSACCEPT_H
+#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONALWAYSACCEPT_H
+
+#include "llvm/SandboxIR/Pass.h"
+#include "llvm/SandboxIR/Region.h"
+
+namespace llvm::sandboxir {
+
+class TransactionAlwaysAccept : public RegionPass {
+public:
+  TransactionAlwaysAccept() : RegionPass("tr-accept") {}
+  bool runOnRegion(Region &Rgn, const Analyses &A) final {
+    auto &Tracker = Rgn.getContext().getTracker();
+    bool HasChanges = !Tracker.empty();
+    Tracker.accept();
+    return HasChanges;
+  }
+};
+
+} // namespace llvm::sandboxir
+
+#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONALWAYSACCEPT_H
diff --git a/llvm/lib/Transforms/Vectorize/CMakeLists.txt b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
index e5fabd318b82cc7..872e055294d5574 100644
--- a/llvm/lib/Transforms/Vectorize/CMakeLists.txt
+++ b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
@@ -9,6 +9,7 @@ add_llvm_component_library(LLVMVectorize
   SandboxVectorizer/Legality.cpp
   SandboxVectorizer/Passes/BottomUpVec.cpp
   SandboxVectorizer/Passes/RegionsFromMetadata.cpp
+  SandboxVectorizer/Passes/TransactionAcceptOrRevert.cpp
   SandboxVectorizer/SandboxVectorizer.cpp
   SandboxVectorizer/SandboxVectorizerPassBuilder.cpp
   SandboxVectorizer/Scheduler.cpp
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
index 6f65657d297906b..507d16324012700 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
@@ -12,6 +12,7 @@
 #include "llvm/SandboxIR/Function.h"
 #include "llvm/SandboxIR/Instruction.h"
 #include "llvm/SandboxIR/Module.h"
+#include "llvm/SandboxIR/Region.h"
 #include "llvm/SandboxIR/Utils.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h"
@@ -448,13 +449,24 @@ bool BottomUpVec::runOnFunction(Function &F, const Analyses &A) {
 
           assert(SeedSlice.size() >= 2 && "Should have been rejected!");
 
-          // TODO: If vectorization succeeds, run the RegionPassManager on the
-          // resulting region.
-
           // TODO: Refactor to remove the unnecessary copy to SeedSliceVals.
           SmallVector<Value *> SeedSliceVals(SeedSlice.begin(),
                                              SeedSlice.end());
-          Change |= tryVectorize(SeedSliceVals);
+          // Create an empty region. Instructions get added to the region
+          // automatically by the callbacks.
+          auto &Ctx = F.getContext();
+          Region Rgn(Ctx, A.getTTI());
+          // Save the state of the IR before we make any changes. The
+          // transaction gets accepted/reverted by the tr-accept-or-revert pass.
+          Ctx.save();
+          // Try to vectorize starting from the seed slice. The returned value
+          // is true if we found vectorizable code and generated some vector
+          // code for it. It does not mean that the code is profitable.
+          bool VecSuccess = tryVectorize(SeedSliceVals);
+          if (VecSuccess)
+            // WARNING: All passes should return false, except those that
+            // accept/revert the state.
+            Change |= RPM.runOnRegion(Rgn, A);
         }
       }
     }
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/PassRegistry.def b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/PassRegistry.def
index 0dc72842f1abe0e..f3aa12729860ff6 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/PassRegistry.def
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/PassRegistry.def
@@ -19,6 +19,8 @@
 
 REGION_PASS("null", ::llvm::sandboxir::NullPass)
 REGION_PASS("print-instruction-count", ::llvm::sandboxir::PrintInstructionCount)
+REGION_PASS("tr-accept", ::llvm::sandboxir::TransactionAlwaysAccept)
+REGION_PASS("tr-accept-or-revert", ::llvm::sandboxir::TransactionAcceptOrRevert)
 
 #undef REGION_PASS
 
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.cpp
new file mode 100644
index 000000000000000..73baace002a3229
--- /dev/null
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.cpp
@@ -0,0 +1,37 @@
+//===- TransactionAcceptOrRevert.cpp - Check cost and accept/revert region ===//
+//
+// 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/Passes/TransactionAcceptOrRevert.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InstructionCost.h"
+
+namespace llvm {
+
+static cl::opt<bool> CostThreshold("sbvec-cost-threshold", cl::init(0),
+                                   cl::Hidden,
+                                   cl::desc("Vectorization cost threshold."));
+
+namespace sandboxir {
+
+bool TransactionAcceptOrRevert::runOnRegion(Region &Rgn, const Analyses &A) {
+  const auto &SB = Rgn.getScoreboard();
+  InstructionCost CostAfterMinusBefore = SB.getAfterCost() - SB.getBeforeCost();
+  // TODO: Print costs / write to remarks.
+  auto &Tracker = Rgn.getContext().getTracker();
+  if (CostAfterMinusBefore < -CostThreshold) {
+    bool HasChanges = !Tracker.empty();
+    Tracker.accept();
+    return HasChanges;
+  }
+  // Revert the IR.
+  Rgn.getContext().getTracker().revert();
+  return false;
+}
+
+} // namespace sandboxir
+} // namespace llvm
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
index 798a0ad915375bc..b233d35212f9471 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
@@ -31,9 +31,10 @@ static cl::opt<std::string> UserDefinedPassPipeline(
 
 SandboxVectorizerPass::SandboxVectorizerPass() : FPM("fpm") {
   if (UserDefinedPassPipeline == DefaultPipelineMagicStr) {
-    // TODO: Add region passes to the default pipeline.
+    // TODO: Add passes to the default pipeline. It currently contains:
+    //       - the bottom-up-vectorizer pass
     FPM.setPassPipeline(
-        "bottom-up-vec<>",
+        "bottom-up-vec<tr-accept-or-revert>",
         sandboxir::SandboxVectorizerPassBuilder::createFunctionPass);
   } else {
     // Create the user-defined pipeline.
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.cpp
index 5ecf7b2ed0d258e..0c1ab55e91a5cfc 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.cpp
@@ -4,6 +4,8 @@
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAcceptOrRevert.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/TransactionAlwaysAccept.h"
 
 namespace llvm::sandboxir {
 
diff --git a/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll b/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll
new file mode 100644
index 000000000000000..2db50ce582f8343
--- /dev/null
+++ b/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll
@@ -0,0 +1,55 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 %s -S | FileCheck %s
+
+define void @simple_cost_test(ptr %ptr) {
+; CHECK-LABEL: define void @simple_cost_test(
+; CHECK-SAME: ptr [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:    [[PTR0:%.*]] = getelementptr double, ptr [[PTR]], i32 0
+; CHECK-NEXT:    [[VECL:%.*]] = load <2 x double>, ptr [[PTR0]], align 8
+; CHECK-NEXT:    store <2 x double> [[VECL]], ptr [[PTR0]], align 8
+; CHECK-NEXT:    ret void
+;
+  %ptr0 = getelementptr double, ptr %ptr, i32 0
+  %ptr1 = getelementptr double, ptr %ptr, i32 1
+  %ld0 = load double, ptr %ptr0
+  %ld1 = load double, ptr %ptr1
+  store double %ld0, ptr %ptr0
+  store double %ld1, ptr %ptr1
+  ret void
+}
+
+define void @pack_cost_test_(ptr %ptr) {
+; CHECK-LABEL: define void @pack_cost_test_(
+; CHECK-SAME: ptr [[PTR:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[PTR0:%.*]] = getelementptr float, ptr [[PTR]], i32 0
+; CHECK-NEXT:    [[PTR1:%.*]] = getelementptr float, ptr [[PTR]], i32 1
+; CHECK-NEXT:    [[LD0:%.*]] = load float, ptr [[PTR0]], align 4
+; CHECK-NEXT:    [[LD1:%.*]] = load float, ptr [[PTR1]], align 4
+; CHECK-NEXT:    [[PACK4:%.*]] = insertelement <4 x float> poison, float [[LD0]], i32 0
+; CHECK-NEXT:    [[PACK5:%.*]] = insertelement <4 x float> [[PACK4]], float [[LD1]], i32 1
+; CHECK-NEXT:    [[PACK6:%.*]] = insertelement <4 x float> [[PACK5]], float [[LD0]], i32 2
+; CHECK-NEXT:    [[PACK7:%.*]] = insertelement <4 x float> [[PACK6]], float [[LD1]], i32 3
+; CHECK-NEXT:    [[PACK:%.*]] = insertelement <4 x float> poison, float [[LD0]], i32 0
+; CHECK-NEXT:    [[PACK1:%.*]] = insertelement <4 x float> [[PACK]], float [[LD1]], i32 1
+; CHECK-NEXT:    [[PACK2:%.*]] = insertelement <4 x float> [[PACK1]], float [[LD0]], i32 2
+; CHECK-NEXT:    [[PACK3:%.*]] = insertelement <4 x float> [[PACK2]], float [[LD1]], i32 3
+; CHECK-NEXT:    [[VEC:%.*]] = fmul <4 x float> [[PACK3]], [[PACK7]]
+; CHECK-NEXT:    store <4 x float> [[VEC]], ptr [[PTR0]], align 4
+; CHECK-NEXT:    ret void
+;
+  %ptr0 = getelementptr float, ptr %ptr, i32 0
+  %ptr1 = getelementptr float, ptr %ptr, i32 1
+  %ptr2 = getelementptr float, ptr %ptr, i32 2
+  %ptr3 = getelementptr float, ptr %ptr, i32 3
+  %ld0 = load float, ptr %ptr0
+  %ld1 = load float, ptr %ptr1
+  %mul0 = fmul float %ld0, %ld0
+  %mul1 = fmul float %ld1, %ld1
+  %mul2 = fmul float %ld0, %ld0
+  %mul3 = fmul float %ld1, %ld1
+  store float %mul0, ptr %ptr0
+  store float %mul1, ptr %ptr1
+  store float %mul2, ptr %ptr2
+  store float %mul3, ptr %ptr3
+  ret void
+}
diff --git a/llvm/test/Transforms/SandboxVectorizer/bottomup_basic.ll b/llvm/test/Transforms/SandboxVectorizer/bottomup_basic.ll
index ee5a3a514b3c58e..ee8592c04b62c0a 100644
--- a/llvm/test/Transforms/SandboxVectorizer/bottomup_basic.ll
+++ b/llvm/test/Transforms/SandboxVectorizer/bottomup_basic.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="bottom-up-vec<>" %s -S | FileCheck %s
+; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="bottom-up-vec<tr-accept>" %s -S | FileCheck %s
 
 define void @store_load(ptr %ptr) {
 ; CHECK-LABEL: define void @store_load(
diff --git a/llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice.ll b/llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice.ll
index 8459c3addaa83f1..202b5a6fbd6c968 100644
--- a/llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice.ll
+++ b/llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="bottom-up-vec<>" %s -S | FileCheck %s
+; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="bottom-up-vec<tr-accept>" %s -S | FileCheck %s
 
 
 declare void @foo()
diff --git a/llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice_pow2.ll b/llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice_pow2.ll
index e186d5fa86e4a7f..f1c6e3297d79c7f 100644
--- a/llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice_pow2.ll
+++ b/llvm/test/Transforms/SandboxVectorizer/bottomup_seed_slice_pow2.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2=false -sbvec-passes="bottom-up-vec<>" %s -S | FileCheck %s --check-prefix=POW2
-; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2=true -sbvec-passes="bottom-up-vec<>" %s -S | FileCheck %s --check-prefix=NON-POW2
+; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2=false -sbvec-passes="bottom-up-vec<tr-accept>" %s -S | FileCheck %s --check-prefix=POW2
+; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2=true -sbvec-passes="bottom-up-vec<tr-accept>" %s -S | FileCheck %s --check-prefix=NON-POW2
 
 define void @pow2(ptr %ptr, float %val) {
 ; POW2-LABEL: define void @pow2(
diff --git a/llvm/test/Transforms/SandboxVectorizer/cross_bbs.ll b/llvm/test/Transforms/SandboxVectorizer/cross_bbs.ll
index 6ec31060d7e0fe7..ff1604173c31754 100644
--- a/llvm/test/Transforms/SandboxVectorizer/cross_bbs.ll
+++ b/llvm/test/Transforms/SandboxVectorizer/cross_bbs.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="bottom-up-vec<>" %s -S | FileCheck %s
+; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="bottom-up-vec<tr-accept>" %s -S | FileCheck %s
 
 define void @cross_bbs(ptr %ptr) {
 ; CHECK-LABEL: define void @cross_bbs(
diff --git a/llvm/test/Transforms/SandboxVectorizer/default_pass_pipeline.ll b/llvm/test/Transforms/SandboxVectorizer/default_pass_pipeline.ll
index 1d7be43336c8795..10de4338caf2325 100644
--- a/llvm/test/Transforms/SandboxVectorizer/default_pass_pipeline.ll
+++ b/llvm/test/Transforms/SandboxVectorizer/default_pass_pipeline.ll
@@ -4,8 +4,10 @@
 
 ; This checks the default pass pipeline for the sandbox vectorizer.
 define void @pipeline() {
+; CHECK: fpm
 ; CHECK: bottom-up-vec
 ; CHECK: rpm
+; CHECK: tr-accept-or-revert
 ; CHECK-EMPTY:
   ret void
 }
diff --git a/llvm/test/Transforms/SandboxVectorizer/pack.ll b/llvm/test/Transforms/SandboxVectorizer/pack.ll
index ec6e61a90c0fb3f..da41036e3a58b76 100644
--- a/llvm/test/Transforms/SandboxVectorizer/pack.ll
+++ b/llvm/test/Transforms/SandboxVectorizer/pack.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="bottom-up-vec<>" %s -S | FileCheck %s
+; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="bottom-up-vec<tr-accept>" %s -S | FileCheck %s
 
 define void @pack_constants(ptr %ptr) {
 ; CHECK-LABEL: define void @pack_constants(
diff --git a/llvm/unittests/SandboxIR/TrackerTest.cpp b/llvm/unittests/SandboxIR/TrackerTest.cpp
index 4eedab124bfa047..9c18247b6b96d0e 100644
--- a/llvm/unittests/SandboxIR/TrackerTest.cpp
+++ b/llvm/unittests/SandboxIR/TrackerTest.cpp
@@ -52,6 +52,9 @@ define void @foo(ptr %ptr) {
   auto *F = Ctx.createFunction(&LLVMF);
   auto *BB = &*F->begin();
   auto &Tracker = Ctx.getTracker();
+  // Check empty().
+  EXPECT_TRUE(Ctx.getTracker().empty());
+
   Tracker.save();
   auto It = BB->begin();
   auto *Gep0 = &*It++;
@@ -65,6 +68,9 @@ define void @foo(ptr %ptr) {
   EXPECT_EQ(St->getOperand(1), Gep1);
   EXPECT_EQ(Ld->getOperand(0), Gep1);
 
+  // Check empty().
+  EXPECT_FALSE(Ctx.getTracker().empty());
+
   Ctx.getTracker().revert();
   EXPECT_NE(St->getOperand(0), Ld);
   EXPECT_EQ(St->getOperand(1), Gep0);

@vporpo
Copy link
Contributor Author

vporpo commented Feb 8, 2025

This is the first patch of chain: #124620

Region Rgn(Ctx, A.getTTI());
// Save the state of the IR before we make any changes. The
// transaction gets accepted/reverted by the tr-accept-or-revert pass.
Ctx.save();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that this is replaced by a tr-save pass further in the patch chain. I would usually complain about the asymmetry of having a hardcoded save but having tr-accept in a pass, but I think it's okay as an intermediate step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this asymmetry will go away in a follow-up patch.

@@ -0,0 +1,55 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a test case where vectorization is rejected due to the cost threshold?

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 point, let me add one.

… pass

The TransactionAcceptOrRevert pass is the final pass in the Sandbox Vectorizer's
default pass pipeline. It's job is to check the cost before/after vectorization
and accept or revert the IR to its original state.

Since we are now starting the transaction in BottomUpVec, tests that run a
custom pipeline need to accept the transaction. This is done with the help
of the TransactionAlwaysAccept pass (tr-accept).
@vporpo vporpo merged commit 69b8cf4 into llvm:main Feb 8, 2025
8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder clang-armv8-quick running on linaro-clang-armv8-quick while building llvm at step 5 "ninja check 1".

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

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: Transforms/SandboxVectorizer/X86/simple_cost_test.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/opt -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll -S -sbvec-cost-threshold=0 | /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll --check-prefix=THRESHOLD_0
+ /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll --check-prefix=THRESHOLD_0
+ /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/opt -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll -S -sbvec-cost-threshold=0
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/opt: warning: failed to infer data layout: unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/opt: WARNING: failed to create target machine for 'x86_64-unknown-unknown': unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll:9:21: error: THRESHOLD_0-NEXT: expected string not found in input
; THRESHOLD_0-NEXT: [[VECL:%.*]] = load <2 x double>, ptr [[PTR0]], align 8, !sandboxvec [[META0:![0-9]+]]
                    ^
<stdin>:6:47: note: scanning from here
 %ptr0 = getelementptr double, ptr %ptr, i32 0
                                              ^
<stdin>:6:47: note: with "PTR0" equal to "%ptr0"
 %ptr0 = getelementptr double, ptr %ptr, i32 0
                                              ^
<stdin>:8:2: note: possible intended match here
 %ld0 = load double, ptr %ptr0, align 8
 ^
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll:37:21: error: THRESHOLD_0-NEXT: is not on the line after the previous match
; THRESHOLD_0-NEXT: [[LD0:%.*]] = load float, ptr [[PTR0]], align 4
                    ^
<stdin>:20:2: note: 'next' match was here
 %ld0 = load float, ptr %ptr0, align 4
 ^
<stdin>:17:46: note: previous match ended here
 %ptr1 = getelementptr float, ptr %ptr, i32 1
                                             ^
<stdin>:18:1: note: non-matching line after previous match is here
 %ptr2 = getelementptr float, ptr %ptr, i32 2
^

Input file: <stdin>
Check file: /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
          1: ; ModuleID = '/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll' 
          2: source_filename = "/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll" 
          3: target triple = "x86_64-unknown-unknown" 
          4:  
          5: define void @simple_cost_test(ptr %ptr) #0 { 
          6:  %ptr0 = getelementptr double, ptr %ptr, i32 0 
next:9'0                                                   X error: no match found
next:9'1                                                     with "PTR0" equal to "%ptr0"
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-quick running on linaro-clang-aarch64-quick while building llvm at step 5 "ninja check 1".

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

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: Transforms/SandboxVectorizer/X86/simple_cost_test.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll -S -sbvec-cost-threshold=0 | /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll --check-prefix=THRESHOLD_0
+ /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll -S -sbvec-cost-threshold=0
+ /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll --check-prefix=THRESHOLD_0
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt: warning: failed to infer data layout: unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt: WARNING: failed to create target machine for 'x86_64-unknown-unknown': unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll:9:21: error: THRESHOLD_0-NEXT: expected string not found in input
; THRESHOLD_0-NEXT: [[VECL:%.*]] = load <2 x double>, ptr [[PTR0]], align 8, !sandboxvec [[META0:![0-9]+]]
                    ^
<stdin>:6:47: note: scanning from here
 %ptr0 = getelementptr double, ptr %ptr, i32 0
                                              ^
<stdin>:6:47: note: with "PTR0" equal to "%ptr0"
 %ptr0 = getelementptr double, ptr %ptr, i32 0
                                              ^
<stdin>:8:2: note: possible intended match here
 %ld0 = load double, ptr %ptr0, align 8
 ^
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll:37:21: error: THRESHOLD_0-NEXT: is not on the line after the previous match
; THRESHOLD_0-NEXT: [[LD0:%.*]] = load float, ptr [[PTR0]], align 4
                    ^
<stdin>:20:2: note: 'next' match was here
 %ld0 = load float, ptr %ptr0, align 4
 ^
<stdin>:17:46: note: previous match ended here
 %ptr1 = getelementptr float, ptr %ptr, i32 1
                                             ^
<stdin>:18:1: note: non-matching line after previous match is here
 %ptr2 = getelementptr float, ptr %ptr, i32 2
^

Input file: <stdin>
Check file: /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
          1: ; ModuleID = '/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll' 
          2: source_filename = "/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll" 
          3: target triple = "x86_64-unknown-unknown" 
          4:  
          5: define void @simple_cost_test(ptr %ptr) #0 { 
          6:  %ptr0 = getelementptr double, ptr %ptr, i32 0 
next:9'0                                                   X error: no match found
next:9'1                                                     with "PTR0" equal to "%ptr0"
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-win-x-aarch64 running on as-builder-2 while building llvm at step 9 "test-check-llvm".

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

Here is the relevant piece of the build log for the reference
Step 9 (test-check-llvm) failure: Test just built components: check-llvm completed (failure)
******************** TEST 'LLVM :: Transforms/SandboxVectorizer/X86/simple_cost_test.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\buildbot\as-builder-2\x-aarch64\build\bin\opt.exe -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll -S -sbvec-cost-threshold=0 | c:\buildbot\as-builder-2\x-aarch64\build\bin\filecheck.exe C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll --check-prefix=THRESHOLD_0
# executed command: 'c:\buildbot\as-builder-2\x-aarch64\build\bin\opt.exe' -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 'C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll' -S -sbvec-cost-threshold=0
# .---command stderr------------
# | c:\buildbot\as-builder-2\x-aarch64\build\bin\opt.exe: warning: failed to infer data layout: unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
# | c:\buildbot\as-builder-2\x-aarch64\build\bin\opt.exe: WARNING: failed to create target machine for 'x86_64-unknown-unknown': unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: 'c:\buildbot\as-builder-2\x-aarch64\build\bin\filecheck.exe' 'C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll' --check-prefix=THRESHOLD_0
# .---command stderr------------
# | C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll:9:21: error: THRESHOLD_0-NEXT: expected string not found in input
# | ; THRESHOLD_0-NEXT: [[VECL:%.*]] = load <2 x double>, ptr [[PTR0]], align 8, !sandboxvec [[META0:![0-9]+]]
# |                     ^
# | <stdin>:6:47: note: scanning from here
# |  %ptr0 = getelementptr double, ptr %ptr, i32 0
# |                                               ^
# | <stdin>:6:47: note: with "PTR0" equal to "%ptr0"
# |  %ptr0 = getelementptr double, ptr %ptr, i32 0
# |                                               ^
# | <stdin>:8:2: note: possible intended match here
# |  %ld0 = load double, ptr %ptr0, align 8
# |  ^
# | C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll:37:21: error: THRESHOLD_0-NEXT: is not on the line after the previous match
# | ; THRESHOLD_0-NEXT: [[LD0:%.*]] = load float, ptr [[PTR0]], align 4
# |                     ^
# | <stdin>:20:2: note: 'next' match was here
# |  %ld0 = load float, ptr %ptr0, align 4
# |  ^
# | <stdin>:17:46: note: previous match ended here
# |  %ptr1 = getelementptr float, ptr %ptr, i32 1
# |                                              ^
# | <stdin>:18:1: note: non-matching line after previous match is here
# |  %ptr2 = getelementptr float, ptr %ptr, i32 2
# | ^
# | 
# | Input file: <stdin>
# | Check file: C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |           1: ; ModuleID = 'C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll' 
# |           2: source_filename = "C:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\llvm\\test\\Transforms\\SandboxVectorizer\\X86\\simple_cost_test.ll" 
# |           3: target triple = "x86_64-unknown-unknown" 
# |           4:  
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder clang-solaris11-sparcv9 running on solaris11-sparcv9 while building llvm at step 5 "ninja check 1".

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

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: Transforms/SandboxVectorizer/X86/simple_cost_test.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/opt -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll -S -sbvec-cost-threshold=0 | /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/FileCheck /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll --check-prefix=THRESHOLD_0
+ /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/opt -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll -S -sbvec-cost-threshold=0
+ /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/FileCheck /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll --check-prefix=THRESHOLD_0
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/opt: warning: failed to infer data layout: unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/opt: WARNING: failed to create target machine for 'x86_64-unknown-unknown': unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll:9:21: error: THRESHOLD_0-NEXT: expected string not found in input
; THRESHOLD_0-NEXT: [[VECL:%.*]] = load <2 x double>, ptr [[PTR0]], align 8, !sandboxvec [[META0:![0-9]+]]
                    ^
<stdin>:6:47: note: scanning from here
 %ptr0 = getelementptr double, ptr %ptr, i32 0
                                              ^
<stdin>:6:47: note: with "PTR0" equal to "%ptr0"
 %ptr0 = getelementptr double, ptr %ptr, i32 0
                                              ^
<stdin>:8:2: note: possible intended match here
 %ld0 = load double, ptr %ptr0, align 8
 ^
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll:37:21: error: THRESHOLD_0-NEXT: is not on the line after the previous match
; THRESHOLD_0-NEXT: [[LD0:%.*]] = load float, ptr [[PTR0]], align 4
                    ^
<stdin>:20:2: note: 'next' match was here
 %ld0 = load float, ptr %ptr0, align 4
 ^
<stdin>:17:46: note: previous match ended here
 %ptr1 = getelementptr float, ptr %ptr, i32 1
                                             ^
<stdin>:18:1: note: non-matching line after previous match is here
 %ptr2 = getelementptr float, ptr %ptr, i32 2
^

Input file: <stdin>
Check file: /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
          1: ; ModuleID = '/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll' 
          2: source_filename = "/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SandboxVectorizer/X86/simple_cost_test.ll" 
          3: target triple = "x86_64-unknown-unknown" 
          4:  
          5: define void @simple_cost_test(ptr %ptr) #0 { 
          6:  %ptr0 = getelementptr double, ptr %ptr, i32 0 
next:9'0                                                   X error: no match found
next:9'1                                                     with "PTR0" equal to "%ptr0"
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-win-x-armv7l running on as-builder-1 while building llvm at step 9 "test-check-llvm".

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

Here is the relevant piece of the build log for the reference
Step 9 (test-check-llvm) failure: Test just built components: check-llvm completed (failure)
******************** TEST 'LLVM :: Transforms/SandboxVectorizer/X86/simple_cost_test.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\buildbot\as-builder-1\x-armv7l\build\bin\opt.exe -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll -S -sbvec-cost-threshold=0 | c:\buildbot\as-builder-1\x-armv7l\build\bin\filecheck.exe C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll --check-prefix=THRESHOLD_0
# executed command: 'c:\buildbot\as-builder-1\x-armv7l\build\bin\opt.exe' -passes=sandbox-vectorizer -mtriple=x86_64-- -mattr=+sse4.1 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll' -S -sbvec-cost-threshold=0
# .---command stderr------------
# | c:\buildbot\as-builder-1\x-armv7l\build\bin\opt.exe: warning: failed to infer data layout: unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
# | c:\buildbot\as-builder-1\x-armv7l\build\bin\opt.exe: WARNING: failed to create target machine for 'x86_64-unknown-unknown': unable to get target for 'x86_64-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: 'c:\buildbot\as-builder-1\x-armv7l\build\bin\filecheck.exe' 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll' --check-prefix=THRESHOLD_0
# .---command stderr------------
# | C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll:9:21: error: THRESHOLD_0-NEXT: expected string not found in input
# | ; THRESHOLD_0-NEXT: [[VECL:%.*]] = load <2 x double>, ptr [[PTR0]], align 8, !sandboxvec [[META0:![0-9]+]]
# |                     ^
# | <stdin>:6:47: note: scanning from here
# |  %ptr0 = getelementptr double, ptr %ptr, i32 0
# |                                               ^
# | <stdin>:6:47: note: with "PTR0" equal to "%ptr0"
# |  %ptr0 = getelementptr double, ptr %ptr, i32 0
# |                                               ^
# | <stdin>:8:2: note: possible intended match here
# |  %ld0 = load double, ptr %ptr0, align 8
# |  ^
# | C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll:37:21: error: THRESHOLD_0-NEXT: is not on the line after the previous match
# | ; THRESHOLD_0-NEXT: [[LD0:%.*]] = load float, ptr [[PTR0]], align 4
# |                     ^
# | <stdin>:20:2: note: 'next' match was here
# |  %ld0 = load float, ptr %ptr0, align 4
# |  ^
# | <stdin>:17:46: note: previous match ended here
# |  %ptr1 = getelementptr float, ptr %ptr, i32 1
# |                                              ^
# | <stdin>:18:1: note: non-matching line after previous match is here
# |  %ptr2 = getelementptr float, ptr %ptr, i32 2
# | ^
# | 
# | Input file: <stdin>
# | Check file: C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |           1: ; ModuleID = 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\Transforms\SandboxVectorizer\X86\simple_cost_test.ll' 
# |           2: source_filename = "C:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\llvm\\test\\Transforms\\SandboxVectorizer\\X86\\simple_cost_test.ll" 
# |           3: target triple = "x86_64-unknown-unknown" 
# |           4:  
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 9, 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/2211

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)
******************** TEST 'Clang :: ClangScanDeps/verbose.test' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: rm -rf /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp
+ rm -rf /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp
RUN: at line 2: split-file /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/ClangScanDeps/verbose.test /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp
+ split-file /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/ClangScanDeps/verbose.test /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp
RUN: at line 3: sed -e "s|DIR|/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp|g" /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp/cdb.json.in > /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp/cdb.json
+ sed -e 's|DIR|/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp|g' /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp/cdb.json.in
RUN: at line 5: /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/bin/clang-scan-deps -compilation-database /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp/cdb.json -v -o /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp/result.json 2>&1 | /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/bin/FileCheck /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/ClangScanDeps/verbose.test
+ /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/bin/clang-scan-deps -compilation-database /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp/cdb.json -v -o /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/test/ClangScanDeps/Output/verbose.test.tmp/result.json
+ /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/bin/FileCheck /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/ClangScanDeps/verbose.test
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/ClangScanDeps/verbose.test:6:11: error: CHECK: expected string not found in input
// CHECK: *** Virtual File System Stats:
          ^
<stdin>:1:1: note: scanning from here
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
^
<stdin>:1:8: note: possible intended match here
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
       ^

Input file: <stdin>
Check file: /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/ClangScanDeps/verbose.test

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1: PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. 
check:6'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:6'1            ?                                                                                                     possible intended match
>>>>>>

--

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


Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
… pass (llvm#126325)

The TransactionAcceptOrRevert pass is the final pass in the Sandbox
Vectorizer's default pass pipeline. It's job is to check the cost
before/after vectorization and accept or revert the IR to its original
state.

Since we are now starting the transaction in BottomUpVec, tests that run
a custom pipeline need to accept the transaction. This is done with the
help of the TransactionAlwaysAccept pass (tr-accept).
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.

4 participants