SimplifyCFG.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- SimplifyCFG.h - Simplify and canonicalize the CFG --------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. /// \file
  14. /// This file provides the interface for the pass responsible for both
  15. /// simplifying and canonicalizing the CFG.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TRANSFORMS_SCALAR_SIMPLIFYCFG_H
  19. #define LLVM_TRANSFORMS_SCALAR_SIMPLIFYCFG_H
  20. #include "llvm/IR/Function.h"
  21. #include "llvm/IR/PassManager.h"
  22. #include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
  23. namespace llvm {
  24. /// A pass to simplify and canonicalize the CFG of a function.
  25. ///
  26. /// This pass iteratively simplifies the entire CFG of a function. It may change
  27. /// or remove control flow to put the CFG into a canonical form expected by
  28. /// other passes of the mid-level optimizer. Depending on the specified options,
  29. /// it may further optimize control-flow to create non-canonical forms.
  30. class SimplifyCFGPass : public PassInfoMixin<SimplifyCFGPass> {
  31. SimplifyCFGOptions Options;
  32. public:
  33. /// The default constructor sets the pass options to create canonical IR,
  34. /// rather than optimal IR. That is, by default we bypass transformations that
  35. /// are likely to improve performance but make analysis for other passes more
  36. /// difficult.
  37. SimplifyCFGPass();
  38. /// Construct a pass with optional optimizations.
  39. SimplifyCFGPass(const SimplifyCFGOptions &PassOptions);
  40. /// Run the pass over the function.
  41. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  42. void printPipeline(raw_ostream &OS,
  43. function_ref<StringRef(StringRef)> MapClassName2PassName);
  44. };
  45. }
  46. #endif
  47. #ifdef __GNUC__
  48. #pragma GCC diagnostic pop
  49. #endif