<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Integrated assembler errors on #(label-.-8): error: constant expression expected"
   href="https://bugs.llvm.org/show_bug.cgi?id=46919">46919</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Integrated assembler errors on #(label-.-8): error: constant expression expected
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: ARM
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>i@maskray.me
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com, Ties.Stuij@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>cat > a.s <<e
str r1, [pc, #(rewrite_3 - . - 8)]
cmp r0, #0
nop
rewrite_3:
e

% llvm-mc -filetype=obj -triple armv8 a.s
a.s:1:15: error: constant expression expected
str r1, [pc, #(rewrite_3 - . - 8)]
              ^

This may be tricky to fix because when #(rewrite_1 - . - 8) is parsed, we don't
know rewrite_1 is defined and thus we cannot fold `rewrite_1 - .`
The `MCConstExpr *` operand is immediately stored to to the
ARMOperand::MemoryOp::OffsetImm field. The field is referenced ~80 times and
many use sites assume that it is a MCConstantExpr. We may have to defer the
creation of the field to address the issue.


Call stack:

llvm/lib/MC/MCParser/AsmParser.cpp AsmParser::Run
llvm/lib/MC/MCParser/AsmParser.cpp AsmParser::parseStatement
llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
MCTargetAsmParser::ParseInstruction
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp ARMAsmParser::ParseInstruction
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp ARMAsmParser::parseOperand
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp ARMAsmParser::parseMemory</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>