MakeGuardsExplicit.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- MakeGuardsExplicit.h - Turn guard intrinsics into guard branches --===//
  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 lowers the @llvm.experimental.guard intrinsic to the new form of
  15. // guard represented as widenable explicit branch to the deopt block. The
  16. // difference between this pass and LowerGuardIntrinsic is that after this pass
  17. // the guard represented as intrinsic:
  18. //
  19. // call void(i1, ...) @llvm.experimental.guard(i1 %old_cond) [ "deopt"() ]
  20. //
  21. // transforms to a guard represented as widenable explicit branch:
  22. //
  23. // %widenable_cond = call i1 @llvm.experimental.widenable.condition()
  24. // br i1 (%old_cond & %widenable_cond), label %guarded, label %deopt
  25. //
  26. // Here:
  27. // - The semantics of @llvm.experimental.widenable.condition allows to replace
  28. // %widenable_cond with the construction (%widenable_cond & %any_other_cond)
  29. // without loss of correctness;
  30. // - %guarded is the lower part of old guard intrinsic's parent block split by
  31. // the intrinsic call;
  32. // - %deopt is a block containing a sole call to @llvm.experimental.deoptimize
  33. // intrinsic.
  34. //
  35. // Therefore, this branch preserves the property of widenability.
  36. //
  37. //===----------------------------------------------------------------------===//
  38. #ifndef LLVM_TRANSFORMS_SCALAR_MAKEGUARDSEXPLICIT_H
  39. #define LLVM_TRANSFORMS_SCALAR_MAKEGUARDSEXPLICIT_H
  40. #include "llvm/IR/PassManager.h"
  41. namespace llvm {
  42. struct MakeGuardsExplicitPass : public PassInfoMixin<MakeGuardsExplicitPass> {
  43. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  44. };
  45. } // namespace llvm
  46. #endif // LLVM_TRANSFORMS_SCALAR_MAKEGUARDSEXPLICIT_H
  47. #ifdef __GNUC__
  48. #pragma GCC diagnostic pop
  49. #endif