[llvm] r200976 - Refactor logic into a function predicate.
Rafael Espindola
rafael.espindola at gmail.com
Fri Feb 7 08:07:11 PST 2014
Author: rafael
Date: Fri Feb 7 10:07:11 2014
New Revision: 200976
URL: http://llvm.org/viewvc/llvm-project?rev=200976&view=rev
Log:
Refactor logic into a function predicate.
No functionality change.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=200976&r1=200975&r2=200976&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Feb 7 10:07:11 2014
@@ -234,6 +234,24 @@ bool AsmPrinter::doInitialization(Module
return false;
}
+static bool canBeHidden(const GlobalValue *GV, const MCAsmInfo &MAI) {
+ GlobalValue::LinkageTypes Linkage = GV->getLinkage();
+ if (Linkage != GlobalValue::LinkOnceODRLinkage)
+ return false;
+
+ if (!MAI.hasWeakDefCanBeHiddenDirective())
+ return false;
+
+ if (GV->hasUnnamedAddr())
+ return true;
+
+ GlobalStatus GS;
+ if (!GlobalStatus::analyzeGlobal(GV, GS) && !GS.IsCompared)
+ return true;
+
+ return false;
+}
+
void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
GlobalValue::LinkageTypes Linkage = GV->getLinkage();
switch (Linkage) {
@@ -247,20 +265,7 @@ void AsmPrinter::EmitLinkage(const Globa
// .globl _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
- bool CanBeHidden = false;
-
- if (Linkage == GlobalValue::LinkOnceODRLinkage &&
- MAI->hasWeakDefCanBeHiddenDirective()) {
- if (GV->hasUnnamedAddr()) {
- CanBeHidden = true;
- } else {
- GlobalStatus GS;
- if (!GlobalStatus::analyzeGlobal(GV, GS) && !GS.IsCompared)
- CanBeHidden = true;
- }
- }
-
- if (!CanBeHidden)
+ if (!canBeHidden(GV, *MAI))
// .weak_definition _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_WeakDefinition);
else
More information about the llvm-commits
mailing list