LCSSA.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- LCSSA.h - Loop-closed SSA transform Pass -----------------*- 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. //
  14. // This pass transforms loops by placing phi nodes at the end of the loops for
  15. // all values that are live across the loop boundary. For example, it turns
  16. // the left into the right code:
  17. //
  18. // for (...) for (...)
  19. // if (c) if (c)
  20. // X1 = ... X1 = ...
  21. // else else
  22. // X2 = ... X2 = ...
  23. // X3 = phi(X1, X2) X3 = phi(X1, X2)
  24. // ... = X3 + 4 X4 = phi(X3)
  25. // ... = X4 + 4
  26. //
  27. // This is still valid LLVM; the extra phi nodes are purely redundant, and will
  28. // be trivially eliminated by InstCombine. The major benefit of this
  29. // transformation is that it makes many other loop optimizations, such as
  30. // LoopUnswitching, simpler.
  31. //
  32. //===----------------------------------------------------------------------===//
  33. #ifndef LLVM_TRANSFORMS_UTILS_LCSSA_H
  34. #define LLVM_TRANSFORMS_UTILS_LCSSA_H
  35. #include "llvm/IR/PassManager.h"
  36. namespace llvm {
  37. /// Converts loops into loop-closed SSA form.
  38. class LCSSAPass : public PassInfoMixin<LCSSAPass> {
  39. public:
  40. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  41. };
  42. } // end namespace llvm
  43. #endif // LLVM_TRANSFORMS_UTILS_LCSSA_H
  44. #ifdef __GNUC__
  45. #pragma GCC diagnostic pop
  46. #endif