<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - UBSan errors in MC/SystemZ (left shift of negative value)"
   href="http://llvm.org/bugs/show_bug.cgi?id=20980">20980</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UBSan errors in MC/SystemZ (left shift of negative value)
          </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>normal
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>vonosmas@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>20815
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following SystemZ tests fail under UBSan bootstrap of LLVM:

    LLVM :: MC/SystemZ/insn-bad-z196.s
    LLVM :: MC/SystemZ/insn-bad.s
    LLVM :: MC/SystemZ/insn-good-z196.s
    LLVM :: MC/SystemZ/insn-good.s

The problem seem to be left shifts of negative values in SystemZ, which are
evaluated directly by the MC layer (left shift of negative value is undefined
behavior in C).

Example error report:
llvm/lib/MC/MCExpr.cpp:802:43: runtime error: left shift of negative value -1
    #0 0x104bf21 in llvm::MCExpr::EvaluateAsRelocatableImpl(llvm::MCValue&,
llvm::MCAssembler const*, llvm::MCAsmLayout const*, llvm::MCFixup const*,
llvm::DenseMap<llvm::MCSectionData const*, unsigned long,
llvm::DenseMapInfo<llvm::MCSectionData const*> > const*, bool, bool) const
llvm/lib/MC/MCExpr.cpp:802:30
    #1 0x10499f1 in llvm::MCExpr::evaluateAsAbsolute(long&, llvm::MCAssembler
const*, llvm::MCAsmLayout const*, llvm::DenseMap<llvm::MCSectionData const*,
unsigned long, llvm::DenseMapInfo<llvm::MCSectionData const*> > const*, bool)
const llvm/lib/MC/MCExpr.cpp:499:24
    #2 0x10492b1 in llvm::MCExpr::EvaluateAsAbsolute(long&, llvm::MCAssembler
const*, llvm::MCAsmLayout const*, llvm::DenseMap<llvm::MCSectionData const*,
unsigned long, llvm::DenseMapInfo<llvm::MCSectionData const*> > const*) const
llvm/lib/MC/MCExpr.cpp:485:10
    #3 0x1049197 in llvm::MCExpr::EvaluateAsAbsolute(long&) const
llvm/lib/MC/MCExpr.cpp:452:10
    #4 0x11ae495 in (anonymous
namespace)::AsmParser::parseExpression(llvm::MCExpr const*&, llvm::SMLoc&)
llvm/lib/MC/MCParser/AsmParser.cpp:1051:7
    #5 0x12a813b in llvm::MCAsmParser::parseExpression(llvm::MCExpr const*&)
llvm/lib/MC/MCParser/MCAsmParser.cpp:43:10
    #6 0xd11359 in (anonymous
namespace)::SystemZAsmParser::parseAddress(unsigned int&, llvm::MCExpr const*&,
unsigned int&, llvm::MCExpr const*&, unsigned int const*, (anonymous
namespace)::RegisterKind)
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp:500:7
    #7 0xd0e9a6 in (anonymous
namespace)::SystemZAsmParser::parseOperand(llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand,
std::default_delete<llvm::MCParsedAsmOperand> > >&, llvm::StringRef)
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp:665:7
    #8 0xcfe697 in (anonymous
namespace)::SystemZAsmParser::ParseInstruction(llvm::ParseInstructionInfo&,
llvm::StringRef, llvm::SMLoc,
llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand,
std::default_delete<llvm::MCParsedAsmOperand> > >&)
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp:616:11
    #9 0x11c2563 in (anonymous namespace)::AsmParser::parseStatement((anonymous
namespace)::ParseStatementInfo&) llvm/lib/MC/MCParser/AsmParser.cpp:1576:19
    #10 0x11a222c in (anonymous namespace)::AsmParser::Run(bool, bool)
llvm/lib/MC/MCParser/AsmParser.cpp:643:10
    #11 0x4494f0 in AssembleInput(char const*, llvm::Target const*,
llvm::SourceMgr&, llvm::MCContext&, llvm::MCStreamer&, llvm::MCAsmInfo&,
llvm::MCSubtargetInfo&, llvm::MCInstrInfo&, llvm::MCTargetOptions&)
llvm/tools/llvm-mc/llvm-mc.cpp:338:13
    #12 0x43d4ee in main llvm/tools/llvm-mc/llvm-mc.cpp:486:11
    #13 0x7fc2d9c4676c in __libc_start_main
/build/buildd/eglibc-2.15/csu/libc-start.c:226
    #14 0x420504 in _start (llvm_ubsan/bin/llvm-mc+0x420504)


To reproduce: build LLVM with just-built Clang and
-DLLVM_USE_SANITIZER=Undefined CMake option. I'm going to disable all
MC/SystemZ tests under UBSan in test/MC/SystemZ/lit.local.cfg, so that
suppression will have to be removed as well.</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>