GuardUtils.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- GuardUtils.h - Utils for work with guards ---------------*- 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. // Utils that are used to perform transformations related to guards and their
  14. // conditions.
  15. //===----------------------------------------------------------------------===//
  16. #ifndef LLVM_TRANSFORMS_UTILS_GUARDUTILS_H
  17. #define LLVM_TRANSFORMS_UTILS_GUARDUTILS_H
  18. namespace llvm {
  19. class BranchInst;
  20. class CallInst;
  21. class Function;
  22. class Value;
  23. /// Splits control flow at point of \p Guard, replacing it with explicit branch
  24. /// by the condition of guard's first argument. The taken branch then goes to
  25. /// the block that contains \p Guard's successors, and the non-taken branch
  26. /// goes to a newly-created deopt block that contains a sole call of the
  27. /// deoptimize function \p DeoptIntrinsic. If 'UseWC' is set, preserve the
  28. /// widenable nature of the guard by lowering to equivelent form. If not set,
  29. /// lower to a form without widenable semantics.
  30. void makeGuardControlFlowExplicit(Function *DeoptIntrinsic, CallInst *Guard,
  31. bool UseWC);
  32. /// Given a branch we know is widenable (defined per Analysis/GuardUtils.h),
  33. /// widen it such that condition 'NewCond' is also known to hold on the taken
  34. /// path. Branch remains widenable after transform.
  35. void widenWidenableBranch(BranchInst *WidenableBR, Value *NewCond);
  36. /// Given a branch we know is widenable (defined per Analysis/GuardUtils.h),
  37. /// *set* it's condition such that (only) 'Cond' is known to hold on the taken
  38. /// path and that the branch remains widenable after transform.
  39. void setWidenableBranchCond(BranchInst *WidenableBR, Value *Cond);
  40. } // llvm
  41. #endif // LLVM_TRANSFORMS_UTILS_GUARDUTILS_H
  42. #ifdef __GNUC__
  43. #pragma GCC diagnostic pop
  44. #endif