Line data Source code
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 :
15 : #include "llvm/Analysis/ValueLatticeUtils.h"
16 : #include "llvm/IR/GlobalVariable.h"
17 : #include "llvm/IR/Instructions.h"
18 : using namespace llvm;
19 :
20 102302 : bool llvm::canTrackArgumentsInterprocedurally(Function *F) {
21 15765 : return F->hasLocalLinkage() && !F->hasAddressTaken();
22 : }
23 :
24 542180 : bool llvm::canTrackReturnsInterprocedurally(Function *F) {
25 587464 : return F->hasExactDefinition() && !F->hasFnAttribute(Attribute::Naked);
26 : }
27 :
28 88075 : bool llvm::canTrackGlobalVariableInterprocedurally(GlobalVariable *GV) {
29 225561 : if (GV->isConstant() || !GV->hasLocalLinkage() ||
30 49411 : !GV->hasDefinitiveInitializer())
31 38685 : return false;
32 49390 : 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 49390 : });
44 : }
|