Revert r233595, "MC: For variable symbols, maintain MCSymbol::Section as a cache."
[oota-llvm.git] / lib / MC / MCSymbol.cpp
index 6582574ae941959761d39e9baa843f9b956ae39b..24165254e56a67d115c700f3f797df7f03086459 100644 (file)
@@ -55,7 +55,13 @@ void MCSymbol::setVariableValue(const MCExpr *Value) {
   assert(!IsUsed && "Cannot set a variable that has already been used.");
   assert(Value && "Invalid variable value!");
   this->Value = Value;
-  this->Section = nullptr;
+
+  // Variables should always be marked as in the same "section" as the value.
+  const MCSection *Section = Value->FindAssociatedSection();
+  if (Section)
+    setSection(*Section);
+  else
+    setUndefined();
 }
 
 void MCSymbol::print(raw_ostream &OS) const {