]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Analysis/ObjectUtils.h
libfdt: Update to 1.4.6, switch to using libfdt for overlay support
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Analysis / ObjectUtils.h
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