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