Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / tools / llvm-reduce / deltas / Utils.cpp
blob669b9db8a825a8295dba120aed55acb491440211
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.
11 //===----------------------------------------------------------------------===//
13 #include "Utils.h"
14 #include "llvm/IR/Constants.h"
15 #include "llvm/IR/GlobalAlias.h"
16 #include "llvm/IR/GlobalIFunc.h"
18 using namespace llvm;
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);
33 });
36 bool llvm::hasAliasOrBlockAddressUse(Function &F) {
37 return any_of(F.users(), [](User *U) {
38 return isa<GlobalAlias, GlobalIFunc, BlockAddress>(U);
39 });