1//===- TransactionAlwaysRevert.h --------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This is a region pass that always reverts the transaction without checking
10// its cost. This is mainly used as a final pass in lit tests.
11//
12
13#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONALWAYSREVERT_H
14#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONALWAYSREVERT_H
15
16#include "llvm/SandboxIR/Pass.h"
17#include "llvm/SandboxIR/Region.h"
18
19namespace llvm::sandboxir {
20
21class TransactionAlwaysRevert : public RegionPass {
22public:
23 TransactionAlwaysRevert() : RegionPass("tr-revert") {}
24 bool runOnRegion(Region &Rgn, const Analyses &A) final {
25 auto &Tracker = Rgn.getContext().getTracker();
26 bool HasChanges = !Tracker.empty();
27 Tracker.revert();
28 return HasChanges;
29 }
30};
31
32} // namespace llvm::sandboxir
33
34#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_TRANSACTIONALWAYSREVERT_H
35