1 //===- Analysis/ObjectUtils.h - analysis utils for object files -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_ANALYSIS_OBJECT_UTILS_H
11 #define LLVM_ANALYSIS_OBJECT_UTILS_H
13 #include "llvm/IR/GlobalVariable.h"
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
22 inline bool canBeOmittedFromSymbolTable(const GlobalValue *GV) {
23 if (!GV->hasLinkOnceODRLinkage())
26 // We assume that anyone who sets global unnamed_addr on a non-constant knows
27 // what they're doing.
28 if (GV->hasGlobalUnnamedAddr())
31 // If it is a non constant variable, it needs to be uniqued across shared
33 if (auto *Var = dyn_cast<GlobalVariable>(GV))
34 if (!Var->isConstant())
37 return GV->hasAtLeastLocalUnnamedAddr();