[llvm] r328135 - Sink Analysis/ObjectUtil(canBeOmittedFromSymbolTable) into IR so it can be legitimately be used by Object/IRSymtab
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 21 12:23:45 PDT 2018
Author: dblaikie
Date: Wed Mar 21 12:23:45 2018
New Revision: 328135
URL: http://llvm.org/viewvc/llvm-project?rev=328135&view=rev
Log:
Sink Analysis/ObjectUtil(canBeOmittedFromSymbolTable) into IR so it can be legitimately be used by Object/IRSymtab
Removed:
llvm/trunk/include/llvm/Analysis/ObjectUtils.h
Modified:
llvm/trunk/include/llvm/IR/GlobalValue.h
llvm/trunk/include/llvm/LTO/LTO.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/IR/Globals.cpp
llvm/trunk/lib/LTO/LTOModule.cpp
llvm/trunk/lib/Object/IRSymtab.cpp
Removed: llvm/trunk/include/llvm/Analysis/ObjectUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ObjectUtils.h?rev=328134&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ObjectUtils.h (original)
+++ llvm/trunk/include/llvm/Analysis/ObjectUtils.h (removed)
@@ -1,42 +0,0 @@
-//===- Analysis/ObjectUtils.h - analysis utils for object files -*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_ANALYSIS_OBJECT_UTILS_H
-#define LLVM_ANALYSIS_OBJECT_UTILS_H
-
-#include "llvm/IR/GlobalVariable.h"
-
-namespace llvm {
-
-/// True if GV can be left out of the object symbol table. This is the case
-/// for linkonce_odr values whose address is not significant. While legal, it is
-/// not normally profitable to omit them from the .o symbol table. Using this
-/// analysis makes sense when the information can be passed down to the linker
-/// or we are in LTO.
-inline bool canBeOmittedFromSymbolTable(const GlobalValue *GV) {
- if (!GV->hasLinkOnceODRLinkage())
- return false;
-
- // We assume that anyone who sets global unnamed_addr on a non-constant knows
- // what they're doing.
- if (GV->hasGlobalUnnamedAddr())
- return true;
-
- // If it is a non constant variable, it needs to be uniqued across shared
- // objects.
- if (auto *Var = dyn_cast<GlobalVariable>(GV))
- if (!Var->isConstant())
- return false;
-
- return GV->hasAtLeastLocalUnnamedAddr();
-}
-
-}
-
-#endif
Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=328135&r1=328134&r2=328135&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalValue.h Wed Mar 21 12:23:45 2018
@@ -572,6 +572,13 @@ public:
V->getValueID() == Value::GlobalAliasVal ||
V->getValueID() == Value::GlobalIFuncVal;
}
+
+ /// True if GV can be left out of the object symbol table. This is the case
+ /// for linkonce_odr values whose address is not significant. While legal, it
+ /// is not normally profitable to omit them from the .o symbol table. Using
+ /// this analysis makes sense when the information can be passed down to the
+ /// linker or we are in LTO.
+ bool canBeOmittedFromSymbolTable() const;
};
} // end namespace llvm
Modified: llvm/trunk/include/llvm/LTO/LTO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTO.h?rev=328135&r1=328134&r2=328135&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/LTO.h (original)
+++ llvm/trunk/include/llvm/LTO/LTO.h Wed Mar 21 12:23:45 2018
@@ -19,7 +19,6 @@
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
-#include "llvm/Analysis/ObjectUtils.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/LTO/Config.h"
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=328135&r1=328134&r2=328135&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Mar 21 12:23:45 2018
@@ -31,7 +31,6 @@
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/EHPersonalities.h"
-#include "llvm/Analysis/ObjectUtils.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/BinaryFormat/ELF.h"
@@ -376,7 +375,7 @@ static bool canBeHidden(const GlobalValu
if (!MAI.hasWeakDefCanBeHiddenDirective())
return false;
- return canBeOmittedFromSymbolTable(GV);
+ return GV->canBeOmittedFromSymbolTable();
}
void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=328135&r1=328134&r2=328135&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Wed Mar 21 12:23:45 2018
@@ -281,6 +281,24 @@ Optional<ConstantRange> GlobalValue::get
return getConstantRangeFromMetadata(*MD);
}
+bool GlobalValue::canBeOmittedFromSymbolTable() const {
+ if (!hasLinkOnceODRLinkage())
+ return false;
+
+ // We assume that anyone who sets global unnamed_addr on a non-constant
+ // knows what they're doing.
+ if (hasGlobalUnnamedAddr())
+ return true;
+
+ // If it is a non constant variable, it needs to be uniqued across shared
+ // objects.
+ if (auto *Var = dyn_cast<GlobalVariable>(this))
+ if (!Var->isConstant())
+ return false;
+
+ return hasAtLeastLocalUnnamedAddr();
+}
+
//===----------------------------------------------------------------------===//
// GlobalVariable Implementation
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/LTO/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=328135&r1=328134&r2=328135&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOModule.cpp (original)
+++ llvm/trunk/lib/LTO/LTOModule.cpp Wed Mar 21 12:23:45 2018
@@ -14,7 +14,6 @@
#include "llvm/LTO/legacy/LTOModule.h"
#include "llvm/ADT/Triple.h"
-#include "llvm/Analysis/ObjectUtils.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/CodeGen/TargetLoweringObjectFile.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
@@ -444,7 +443,7 @@ void LTOModule::addDefinedSymbol(StringR
attr |= LTO_SYMBOL_SCOPE_HIDDEN;
else if (def->hasProtectedVisibility())
attr |= LTO_SYMBOL_SCOPE_PROTECTED;
- else if (canBeOmittedFromSymbolTable(def))
+ else if (def->canBeOmittedFromSymbolTable())
attr |= LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN;
else
attr |= LTO_SYMBOL_SCOPE_DEFAULT;
Modified: llvm/trunk/lib/Object/IRSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRSymtab.cpp?rev=328135&r1=328134&r2=328135&view=diff
==============================================================================
--- llvm/trunk/lib/Object/IRSymtab.cpp (original)
+++ llvm/trunk/lib/Object/IRSymtab.cpp Wed Mar 21 12:23:45 2018
@@ -15,7 +15,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
-#include "llvm/Analysis/ObjectUtils.h"
#include "llvm/IR/Comdat.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalAlias.h"
@@ -232,7 +231,7 @@ Error Builder::addSymbol(const ModuleSym
Sym.Flags |= 1 << storage::Symbol::FB_tls;
if (GV->hasGlobalUnnamedAddr())
Sym.Flags |= 1 << storage::Symbol::FB_unnamed_addr;
- if (canBeOmittedFromSymbolTable(GV))
+ if (GV->canBeOmittedFromSymbolTable())
Sym.Flags |= 1 << storage::Symbol::FB_may_omit;
Sym.Flags |= unsigned(GV->getVisibility()) << storage::Symbol::FB_visibility;
More information about the llvm-commits
mailing list