1 //===- Utils.cpp - llvm-reduce utility functions --------------------------===// 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 // 9 // This file contains some utility functions supporting llvm-reduce. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "Utils.h" 14 #include "llvm/IR/Constants.h" 15 #include "llvm/IR/GlobalAlias.h" 16 #include "llvm/IR/GlobalIFunc.h" 17 18 using namespace llvm; 19 20 extern cl::OptionCategory LLVMReduceOptions; 21 22 cl::opt<bool> llvm::Verbose("verbose", 23 cl::desc("Print extra debugging information"), 24 cl::init(false), cl::cat(LLVMReduceOptions)); 25 getDefaultValue(Type * T)26Value *llvm::getDefaultValue(Type *T) { 27 return T->isVoidTy() ? PoisonValue::get(T) : Constant::getNullValue(T); 28 } 29 hasAliasUse(Function & F)30bool llvm::hasAliasUse(Function &F) { 31 return any_of(F.users(), [](User *U) { 32 return isa<GlobalAlias>(U) || isa<GlobalIFunc>(U); 33 }); 34 } 35 hasAliasOrBlockAddressUse(Function & F)36bool llvm::hasAliasOrBlockAddressUse(Function &F) { 37 return any_of(F.users(), [](User *U) { 38 return isa<GlobalAlias, GlobalIFunc, BlockAddress>(U); 39 }); 40 } 41