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 analyzes related to guards and their 9 // conditions. 10 //===----------------------------------------------------------------------===// 11 12 #ifndef LLVM_ANALYSIS_GUARDUTILS_H 13 #define LLVM_ANALYSIS_GUARDUTILS_H 14 15 namespace llvm { 16 17 class BasicBlock; 18 class User; 19 class Value; 20 21 /// Returns true iff \p U has semantics of a guard expressed in a form of call 22 /// of llvm.experimental.guard intrinsic. 23 bool isGuard(const User *U); 24 25 /// Returns true iff \p U has semantics of a guard expressed in a form of a 26 /// widenable conditional branch to deopt block. 27 bool isGuardAsWidenableBranch(const User *U); 28 29 /// If U is widenable branch looking like: 30 /// %cond = ... 31 /// %wc = call i1 @llvm.experimental.widenable.condition() 32 /// %branch_cond = and i1 %cond, %wc 33 /// br i1 %branch_cond, label %if_true_bb, label %if_false_bb ; <--- U 34 /// The function returns true, and the values %cond and %wc and blocks 35 /// %if_true_bb, if_false_bb are returned in 36 /// the parameters (Condition, WidenableCondition, IfTrueBB and IfFalseFF) 37 /// respectively. If \p U does not match this pattern, return false. 38 bool parseWidenableBranch(const User *U, Value *&Condition, 39 Value *&WidenableCondition, BasicBlock *&IfTrueBB, 40 BasicBlock *&IfFalseBB); 41 42 } // llvm 43 44 #endif // LLVM_ANALYSIS_GUARDUTILS_H 45