LLVM 20.0.0git
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
17using 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 all_of(GV->users(), [&](User *U) {
32 // Currently all users of a global variable have to be non-volatile loads
33 // or stores of the global type, and the global cannot be stored itself.
34 if (auto *Store = dyn_cast<StoreInst>(U))
35 return Store->getValueOperand() != GV && !Store->isVolatile() &&
36 Store->getValueOperand()->getType() == GV->getValueType();
37 if (auto *Load = dyn_cast<LoadInst>(U))
38 return !Load->isVolatile() && Load->getType() == GV->getValueType();
39
40 return false;
41 });
42}
#define F(x, y, z)
Definition: MD5.cpp:55
bool hasLocalLinkage() const
Definition: GlobalValue.h:528
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
iterator_range< user_iterator > users()
Definition: Value.h:421
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1722
bool canTrackGlobalVariableInterprocedurally(GlobalVariable *GV)
Determine if the value maintained in the given global variable can be tracked interprocedurally.
bool canTrackReturnsInterprocedurally(Function *F)
Determine if the values of the given function's returns can be tracked interprocedurally.
bool canTrackArgumentsInterprocedurally(Function *F)
Determine if the values of the given function's arguments can be tracked interprocedurally.