annotate lib/Analysis/ValueLatticeUtils.cpp @ 146:3fc4d5c3e21e

set tail call flag for code segment in CGCAll
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 19:23:36 +0900
parents 803732b1fca8
children c2174574ed3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 //===-- ValueLatticeUtils.cpp - Utils for solving lattices ------*- C++ -*-===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 // This file implements common functions useful for performing data-flow
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 // analyses that propagate values across function boundaries.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 #include "llvm/Analysis/ValueLatticeUtils.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16 #include "llvm/IR/GlobalVariable.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17 #include "llvm/IR/Instructions.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18 using namespace llvm;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 bool llvm::canTrackArgumentsInterprocedurally(Function *F) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21 return F->hasLocalLinkage() && !F->hasAddressTaken();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 bool llvm::canTrackReturnsInterprocedurally(Function *F) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 return F->hasExactDefinition() && !F->hasFnAttribute(Attribute::Naked);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 bool llvm::canTrackGlobalVariableInterprocedurally(GlobalVariable *GV) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 if (GV->isConstant() || !GV->hasLocalLinkage() ||
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 !GV->hasDefinitiveInitializer())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 return false;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 return !any_of(GV->users(), [&](User *U) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 if (auto *Store = dyn_cast<StoreInst>(U)) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34 if (Store->getValueOperand() == GV || Store->isVolatile())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 return true;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36 } else if (auto *Load = dyn_cast<LoadInst>(U)) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37 if (Load->isVolatile())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 return true;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39 } else {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40 return true;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42 return false;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 });
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44 }