llvm.org GIT mirror llvm / 537523b
Move llvm::canBeOmittedFromSymbolTable() to Analysis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299182 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 3 years ago
6 changed file(s) with 45 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
0 //===- Analysis/ObjectUtils.h - analysis utils for object files -*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_ANALYSIS_OBJECT_UTILS_H
10 #define LLVM_ANALYSIS_OBJECT_UTILS_H
11
12 #include "llvm/IR/GlobalVariable.h"
13
14 namespace llvm {
15
16 /// True if GV can be left out of the object symbol table. This is the case
17 /// for linkonce_odr values whose address is not significant. While legal, it is
18 /// not normally profitable to omit them from the .o symbol table. Using this
19 /// analysis makes sense when the information can be passed down to the linker
20 /// or we are in LTO.
21 inline bool canBeOmittedFromSymbolTable(const GlobalValue *GV) {
22 if (!GV->hasLinkOnceODRLinkage())
23 return false;
24
25 // We assume that anyone who sets global unnamed_addr on a non-constant knows
26 // what they're doing.
27 if (GV->hasGlobalUnnamedAddr())
28 return true;
29
30 // If it is a non constant variable, it needs to be uniqued across shared
31 // objects.
32 if (auto *Var = dyn_cast(GV))
33 if (!Var->isConstant())
34 return false;
35
36 return GV->hasAtLeastLocalUnnamedAddr();
37 }
38
39 }
40
41 #endif
122122 const ReturnInst *Ret,
123123 const TargetLoweringBase &TLI);
124124
125 // True if GV can be left out of the object symbol table. This is the case
126 // for linkonce_odr values whose address is not significant. While legal, it is
127 // not normally profitable to omit them from the .o symbol table. Using this
128 // analysis makes sense when the information can be passed down to the linker
129 // or we are in LTO.
130 bool canBeOmittedFromSymbolTable(const GlobalValue *GV);
131
132125 DenseMap
133126 getFuncletMembership(const MachineFunction &MF);
134127
1818 #include "llvm/ADT/MapVector.h"
1919 #include "llvm/ADT/StringMap.h"
2020 #include "llvm/ADT/StringSet.h"
21 #include "llvm/CodeGen/Analysis.h"
21 #include "llvm/Analysis/ObjectUtils.h"
2222 #include "llvm/IR/DiagnosticInfo.h"
2323 #include "llvm/IR/ModuleSummaryIndex.h"
2424 #include "llvm/LTO/Config.h"
611611 return true;
612612 }
613613
614 bool llvm::canBeOmittedFromSymbolTable(const GlobalValue *GV) {
615 if (!GV->hasLinkOnceODRLinkage())
616 return false;
617
618 // We assume that anyone who sets global unnamed_addr on a non-constant knows
619 // what they're doing.
620 if (GV->hasGlobalUnnamedAddr())
621 return true;
622
623 // If it is a non constant variable, it needs to be uniqued across shared
624 // objects.
625 if (const GlobalVariable *Var = dyn_cast(GV)) {
626 if (!Var->isConstant())
627 return false;
628 }
629
630 return GV->hasAtLeastLocalUnnamedAddr();
631 }
632
633614 static void collectFuncletMembers(
634615 DenseMap &FuncletMembership, int Funclet,
635616 const MachineBasicBlock *MBB) {
2727 #include "llvm/ADT/Triple.h"
2828 #include "llvm/ADT/Twine.h"
2929 #include "llvm/Analysis/ConstantFolding.h"
30 #include "llvm/Analysis/ObjectUtils.h"
3031 #include "llvm/CodeGen/Analysis.h"
3132 #include "llvm/CodeGen/AsmPrinter.h"
3233 #include "llvm/CodeGen/GCMetadata.h"
1313
1414 #include "llvm/LTO/legacy/LTOModule.h"
1515 #include "llvm/ADT/Triple.h"
16 #include "llvm/Analysis/ObjectUtils.h"
1617 #include "llvm/Bitcode/BitcodeReader.h"
17 #include "llvm/CodeGen/Analysis.h"
1818 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
1919 #include "llvm/IR/Constants.h"
2020 #include "llvm/IR/DiagnosticPrinter.h"