[llvm-commits] [llvm] r122427 - /llvm/trunk/lib/MC/MCExpr.cpp

Rafael Espindola rafael.espindola at gmail.com
Wed Dec 22 11:05:49 PST 2010


Author: rafael
Date: Wed Dec 22 13:05:49 2010
New Revision: 122427

URL: http://llvm.org/viewvc/llvm-project?rev=122427&view=rev
Log:
Revert r122359 while I debug PR8845.

Modified:
    llvm/trunk/lib/MC/MCExpr.cpp

Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=122427&r1=122426&r2=122427&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Wed Dec 22 13:05:49 2010
@@ -269,13 +269,27 @@
   // FIXME: The use if InSet = Addrs is a hack. Setting InSet causes us
   // absolutize differences across sections and that is what the MachO writer
   // uses Addrs for.
-  bool IsRelocatable =
-    EvaluateAsRelocatableImpl(Value, Asm, Layout, Addrs, /*InSet*/ Addrs);
+  if (!EvaluateAsRelocatableImpl(Value, Asm, Layout, Addrs, /*InSet*/ Addrs) ||
+      !Value.isAbsolute()) {
+    // EvaluateAsAbsolute is defined to return the "current value" of
+    // the expression if we are given a Layout object, even in cases
+    // when the value is not fixed.
+    if (Layout) {
+      Res = Value.getConstant();
+      if (Value.getSymA()) {
+       Res += Layout->getSymbolOffset(
+          &Layout->getAssembler().getSymbolData(Value.getSymA()->getSymbol()));
+      }
+      if (Value.getSymB()) {
+       Res -= Layout->getSymbolOffset(
+          &Layout->getAssembler().getSymbolData(Value.getSymB()->getSymbol()));
+      }
+    }
+    return false;
+  }
 
-  // Record the current value.
   Res = Value.getConstant();
-
-  return IsRelocatable && Value.isAbsolute();
+  return true;
 }
 
 /// \brief Helper method for \see EvaluateSymbolAdd().





More information about the llvm-commits mailing list