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

Kevin Enderby enderby at apple.com
Thu Sep 30 09:42:21 PDT 2010


Author: enderby
Date: Thu Sep 30 11:42:21 2010
New Revision: 115155

URL: http://llvm.org/viewvc/llvm-project?rev=115155&view=rev
Log:
Changes EvaluateAsAbsolute() to return the "current value" of the expression
if we are given a Layout object, even in cases when the value is not fixed.
This will be needed by the final patch for the dwarf .loc support to size a
new MCDwarf fragment needed to build and emit dwarf line number tables.

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=115155&r1=115154&r2=115155&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Thu Sep 30 11:42:21 2010
@@ -215,8 +215,23 @@
     return true;
   }
 
-  if (!EvaluateAsRelocatable(Value, Layout) || !Value.isAbsolute())
+  if (!EvaluateAsRelocatable(Value, Layout) || !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->getSymbolAddress(
+          &Layout->getAssembler().getSymbolData(Value.getSymA()->getSymbol()));
+      }
+      if (Value.getSymB()) {
+	Res -= Layout->getSymbolAddress(
+          &Layout->getAssembler().getSymbolData(Value.getSymB()->getSymbol()));
+      }
+    }
     return false;
+  }
 
   Res = Value.getConstant();
   return true;





More information about the llvm-commits mailing list