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