LLVM  10.0.0svn
ValueLatticeUtils.cpp
Go to the documentation of this file.
1 //===-- ValueLatticeUtils.cpp - Utils for solving lattices ------*- C++ -*-===//
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 implements common functions useful for performing data-flow
10 // analyses that propagate values across function boundaries.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/IR/GlobalVariable.h"
16 #include "llvm/IR/Instructions.h"
17 using namespace llvm;
18 
20  return F->hasLocalLinkage() && !F->hasAddressTaken();
21 }
22 
24  return F->hasExactDefinition() && !F->hasFnAttribute(Attribute::Naked);
25 }
26 
28  if (GV->isConstant() || !GV->hasLocalLinkage() ||
30  return false;
31  return !any_of(GV->users(), [&](User *U) {
32  if (auto *Store = dyn_cast<StoreInst>(U)) {
33  if (Store->getValueOperand() == GV || Store->isVolatile())
34  return true;
35  } else if (auto *Load = dyn_cast<LoadInst>(U)) {
36  if (Load->isVolatile())
37  return true;
38  } else {
39  return true;
40  }
41  return false;
42  });
43 }
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
bool hasLocalLinkage() const
Definition: GlobalValue.h:445
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool canTrackArgumentsInterprocedurally(Function *F)
Determine if the values of the given function&#39;s arguments can be tracked interprocedurally.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:323
F(f)
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
bool canTrackReturnsInterprocedurally(Function *F)
Determine if the values of the given function&#39;s returns can be tracked interprocedurally.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1172
bool canTrackGlobalVariableInterprocedurally(GlobalVariable *GV)
Determine if the value maintained in the given global variable can be tracked interprocedurally.
iterator_range< user_iterator > users()
Definition: Value.h:420
bool hasExactDefinition() const
Return true if this global has an exact defintion.
Definition: GlobalValue.h:416
bool hasAddressTaken(const User **=nullptr) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
Definition: Function.cpp:1420