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(Val: false), cl::cat(LLVMReduceOptions)); |
25 | |
26 | Value *llvm::getDefaultValue(Type *T) { |
27 | return T->isVoidTy() ? PoisonValue::get(T) : Constant::getNullValue(Ty: T); |
28 | } |
29 | |
30 | bool llvm::hasAliasUse(Function &F) { |
31 | return any_of(Range: F.users(), P: [](User *U) { |
32 | return isa<GlobalAlias>(Val: U) || isa<GlobalIFunc>(Val: U); |
33 | }); |
34 | } |
35 | |
36 | bool llvm::hasAliasOrBlockAddressUse(Function &F) { |
37 | return any_of(Range: F.users(), P: [](User *U) { |
38 | return isa<GlobalAlias, GlobalIFunc, BlockAddress>(Val: U); |
39 | }); |
40 | } |
41 |