Fix a bug with .weak_def_can_be_hidden: Mutable variables cannot use it.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / AsmPrinter.cpp
index 141a6686304d0239e84872746896bc08ccc2370f..89da65eb3fb7731643f51a1e8603142f089fffcc 100644 (file)
@@ -245,6 +245,18 @@ static bool canBeHidden(const GlobalValue *GV, const MCAsmInfo &MAI) {
   if (GV->hasUnnamedAddr())
     return true;
 
+  // This is only used for MachO, so right now it doesn't really matter how
+  // we handle alias. Revisit this once the MachO linker implements aliases.
+  if (isa<GlobalAlias>(GV))
+    return false;
+
+  // If it is a non constant variable, it needs to be uniqued across shared
+  // objects.
+  if (const GlobalVariable *Var = dyn_cast<GlobalVariable>(GV)) {
+    if (!Var->isConstant())
+      return false;
+  }
+
   GlobalStatus GS;
   if (!GlobalStatus::analyzeGlobal(GV, GS) && !GS.IsCompared)
     return true;