diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -6964,9 +6964,11 @@ CI->setTailCallKind(TCK); CI->setCallingConv(CC); if (FMF.any()) { - if (!isa(CI)) + if (!isa(CI)) { + CI->deleteValue(); return Error(CallLoc, "fast-math-flags specified for call without " "floating-point scalar or vector return type"); + } CI->setFastMathFlags(FMF); } CI->setAttributes(PAL); diff --git a/llvm/test/CodeGen/Generic/fast-math-flags.ll b/llvm/test/CodeGen/Generic/fast-math-flags.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/Generic/fast-math-flags.ll @@ -0,0 +1,10 @@ +; RUN: not llc < %s 2>&1 | FileCheck %s + +; CHECK: error: fast-math-flags specified for call without floating-point scalar or vector return type +define i64 @test_lrintf(float %f) { +entry: + %0 = tail call fast i64 @llvm.lrint.i64.f32(float %f) + ret i64 %0 +} + +declare i64 @llvm.lrint.i64.f32(float)