LLVM  6.0.0svn
ObjectUtils.h
Go to the documentation of this file.
1 //===- Analysis/ObjectUtils.h - analysis utils for object files -*- 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 #ifndef LLVM_ANALYSIS_OBJECT_UTILS_H
11 #define LLVM_ANALYSIS_OBJECT_UTILS_H
12 
13 #include "llvm/IR/GlobalVariable.h"
14 
15 namespace llvm {
16 
17 /// True if GV can be left out of the object symbol table. This is the case
18 /// for linkonce_odr values whose address is not significant. While legal, it is
19 /// not normally profitable to omit them from the .o symbol table. Using this
20 /// analysis makes sense when the information can be passed down to the linker
21 /// or we are in LTO.
22 inline bool canBeOmittedFromSymbolTable(const GlobalValue *GV) {
23  if (!GV->hasLinkOnceODRLinkage())
24  return false;
25 
26  // We assume that anyone who sets global unnamed_addr on a non-constant knows
27  // what they're doing.
28  if (GV->hasGlobalUnnamedAddr())
29  return true;
30 
31  // If it is a non constant variable, it needs to be uniqued across shared
32  // objects.
33  if (auto *Var = dyn_cast<GlobalVariable>(GV))
34  if (!Var->isConstant())
35  return false;
36 
37  return GV->hasAtLeastLocalUnnamedAddr();
38 }
39 
40 }
41 
42 #endif
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool canBeOmittedFromSymbolTable(const GlobalValue *GV)
True if GV can be left out of the object symbol table.
Definition: ObjectUtils.h:22
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value&#39;s address is not significant in this module.
Definition: GlobalValue.h:201
bool hasLinkOnceODRLinkage() const
Definition: GlobalValue.h:418
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:192