Utils.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include "Utils.h"
  13. #include "llvm/IR/Constants.h"
  14. #include "llvm/IR/GlobalAlias.h"
  15. #include "llvm/IR/GlobalIFunc.h"
  16. using namespace llvm;
  17. extern cl::OptionCategory LLVMReduceOptions;
  18. cl::opt<bool> llvm::Verbose("verbose",
  19. cl::desc("Print extra debugging information"),
  20. cl::init(false), cl::cat(LLVMReduceOptions));
  21. Value *llvm::getDefaultValue(Type *T) {
  22. return T->isVoidTy() ? PoisonValue::get(T) : Constant::getNullValue(T);
  23. }
  24. bool llvm::hasAliasUse(Function &F) {
  25. return any_of(F.users(), [](User *U) {
  26. return isa<GlobalAlias>(U) || isa<GlobalIFunc>(U);
  27. });
  28. }
  29. bool llvm::hasAliasOrBlockAddressUse(Function &F) {
  30. return any_of(F.users(), [](User *U) {
  31. return isa<GlobalAlias, GlobalIFunc, BlockAddress>(U);
  32. });
  33. }