[llvm-commits] [llvm] r74565 - in /llvm/trunk: include/llvm/MC/MCValue.h test/MC/AsmParser/exprs.s tools/llvm-mc/AsmExpr.cpp

Daniel Dunbar daniel at zuster.org
Tue Jun 30 15:49:27 PDT 2009


Author: ddunbar
Date: Tue Jun 30 17:49:27 2009
New Revision: 74565

URL: http://llvm.org/viewvc/llvm-project?rev=74565&view=rev
Log:
llvm-mc: Symbols in a relocatable expression of the (a - b + cst) form are
allowed to be undefined when the expression is seen, we cannot enforce the
same-section requirement until the entire assembly file has been seen.

Modified:
    llvm/trunk/include/llvm/MC/MCValue.h
    llvm/trunk/test/MC/AsmParser/exprs.s
    llvm/trunk/tools/llvm-mc/AsmExpr.cpp

Modified: llvm/trunk/include/llvm/MC/MCValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCValue.h?rev=74565&r1=74564&r2=74565&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCValue.h (original)
+++ llvm/trunk/include/llvm/MC/MCValue.h Tue Jun 30 17:49:27 2009
@@ -26,7 +26,8 @@
 /// relocations of this general form, but we need to represent this anyway.
 ///
 /// In the general form, SymbolB can only be defined if SymbolA is, and both
-/// must be in the same (non-external) section.
+/// must be in the same (non-external) section. The latter constraint is not
+/// enforced, since a symbol's section may not be known at construction.
 ///
 /// Note that this class must remain a simple POD value class, because we need
 /// it to live in unions etc.
@@ -52,9 +53,7 @@
 
   static MCValue get(MCSymbol *SymA, MCSymbol *SymB = 0, int64_t Val = 0) {
     MCValue R;
-    assert((!SymB || (SymA && SymA->getSection() && 
-                      SymA->getSection() == SymB->getSection())) &&
-           "Invalid relocatable MCValue!");
+    assert((!SymB || SymA) && "Invalid relocatable MCValue!");
     R.Cst = Val;
     R.SymA = SymA;
     R.SymB = SymB;

Modified: llvm/trunk/test/MC/AsmParser/exprs.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/exprs.s?rev=74565&r1=74564&r2=74565&view=diff

==============================================================================
--- llvm/trunk/test/MC/AsmParser/exprs.s (original)
+++ llvm/trunk/test/MC/AsmParser/exprs.s Tue Jun 30 17:49:27 2009
@@ -52,4 +52,11 @@
         i = (j + 10) - (k + 2)
         .long i
         
+        l = m - n + 4
+        
+        .text
+m:
+n:
+        nop
+        
         
\ No newline at end of file

Modified: llvm/trunk/tools/llvm-mc/AsmExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmExpr.cpp?rev=74565&r1=74564&r2=74565&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmExpr.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmExpr.cpp Tue Jun 30 17:49:27 2009
@@ -37,12 +37,11 @@
   MCSymbol *A = LHS.getSymA() ? LHS.getSymA() : RHS_A;
   MCSymbol *B = LHS.getSymB() ? LHS.getSymB() : RHS_B;
   if (B) {
-    // If we have a negated symbol, then we must have also have a
-    // non-negated symbol, and both symbols must be in the same
-    // non-external section. We can do this check later to permit
-    // expressions which eventually fold to a representable form -- such
+    // If we have a negated symbol, then we must have also have a non-negated
+    // symbol in order to encode the expression. We can do this check later to
+    // permit expressions which eventually fold to a representable form -- such
     // as (a + (0 - b)) -- if necessary.
-    if (!A || !A->getSection() || A->getSection() != B->getSection())
+    if (!A)
       return false;
   }
   Res = MCValue::get(A, B, LHS.getConstant() + RHS_Cst);





More information about the llvm-commits mailing list