LLVM  8.0.1
ValueLatticeUtils.cpp
Go to the documentation of this file.
1 //===-- ValueLatticeUtils.cpp - Utils for solving lattices ------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements common functions useful for performing data-flow
11 // analyses that propagate values across function boundaries.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "llvm/IR/GlobalVariable.h"
17 #include "llvm/IR/Instructions.h"
18 using namespace llvm;
19 
21  return F->hasLocalLinkage() && !F->hasAddressTaken();
22 }
23 
26 }
27 
29  if (GV->isConstant() || !GV->hasLocalLinkage() ||
31  return false;
32  return !any_of(GV->users(), [&](User *U) {
33  if (auto *Store = dyn_cast<StoreInst>(U)) {
34  if (Store->getValueOperand() == GV || Store->isVolatile())
35  return true;
36  } else if (auto *Load = dyn_cast<LoadInst>(U)) {
37  if (Load->isVolatile())
38  return true;
39  } else {
40  return true;
41  }
42  return false;
43  });
44 }
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
bool hasLocalLinkage() const
Definition: GlobalValue.h:436
This class represents lattice values for constants.
Definition: AllocatorList.h:24
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:321
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:1193
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:400
bool hasExactDefinition() const
Return true if this global has an exact defintion.
Definition: GlobalValue.h:407
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:1254