Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -7865,6 +7865,7 @@ /// visitInlineAsm - Handle a call to an InlineAsm object. void SelectionDAGBuilder::visitInlineAsm(ImmutableCallSite CS) { + LLVMContext &Ctx = *DAG.getContext(); const InlineAsm *IA = cast(CS.getCalledValue()); /// ConstraintOperands - Information about all of the constraints. @@ -7907,7 +7908,7 @@ OpInfo.ConstraintVT = OpInfo - .getCallOperandValEVT(*DAG.getContext(), TLI, DAG.getDataLayout()) + .getCallOperandValEVT(Ctx, TLI, DAG.getDataLayout()) .getSimpleVT(); } else if (OpInfo.Type == InlineAsm::isOutput && !OpInfo.isIndirect) { // The return value of the call is this value. As such, there is no @@ -7935,6 +7936,12 @@ // Compute the constraint code and ConstraintType to use. TLI.ComputeConstraintToUse(T, SDValue()); + if (T.ConstraintCode == "n" && !isa(OpInfo.CallOperand)) + // We've delayed emitting a diagnostic for the "n" constraint because + // inlining could cause an integer showing up. + return emitInlineAsmError(CS, "constraint 'n' expects an integer " + "constant expression"); + ExtraInfo.update(T); }