Index: lib/MC/MCExpr.cpp =================================================================== --- lib/MC/MCExpr.cpp +++ lib/MC/MCExpr.cpp @@ -734,6 +734,11 @@ // width, and gas defines the result of comparisons differently from // Apple as. int64_t LHS = LHSValue.getConstant(), RHS = RHSValue.getConstant(); + + // Handle division by zero. + if (ABE->getOpcode() == MCBinaryExpr::Div && RHS == 0) + return false; + int64_t Result = 0; switch (ABE->getOpcode()) { case MCBinaryExpr::AShr: Result = LHS >> RHS; break; Index: test/MC/ELF/div-by-zero.s =================================================================== --- test/MC/ELF/div-by-zero.s +++ test/MC/ELF/div-by-zero.s @@ -0,0 +1,4 @@ +// Check that llvm-mc doesn't crash on division by zero. +// RUN: llvm-mc -triple x86_64-pc-linux-gnu %s -o - 2>&1 + +.int 1/0