Index: llvm/trunk/test/MC/AsmParser/invalid-asm-variant.s =================================================================== --- llvm/trunk/test/MC/AsmParser/invalid-asm-variant.s +++ llvm/trunk/test/MC/AsmParser/invalid-asm-variant.s @@ -0,0 +1,3 @@ +//RUN: not llvm-mc --disassemble -triple=x86_64 --output-asm-variant=2 %s -o - 2>&1 | FileCheck %s + +//CHECK: error: unable to create instruction printer for target triple 'x86_64' with assembly variant 2. Index: llvm/trunk/tools/llvm-mc/llvm-mc.cpp =================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp @@ -563,6 +563,14 @@ IP = TheTarget->createMCInstPrinter(Triple(TripleName), OutputAsmVariant, *MAI, *MCII, *MRI); + if (!IP) { + errs() + << "error: unable to create instruction printer for target triple '" + << TheTriple.normalize() << "' with assembly variant " + << OutputAsmVariant << ".\n"; + return 1; + } + // Set the display preference for hex vs. decimal immediates. IP->setPrintImmHex(PrintImmHex);