[LLParser] Delete temp CallInst when error occurs

Only functions with floating-point return type accepts fast-math flags.
When adding such flags to function returning integer, we'll see a crash,
because there's still an undeleted value referencing the argument. This
patch manually removes the temporary instruction when error occurs.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D78355
This commit is contained in:
Qiu Chaofan 2020-06-16 11:41:25 +08:00
parent 2ba320846b
commit e62912b190
2 changed files with 13 additions and 1 deletions

View File

@ -6964,9 +6964,11 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
CI->setTailCallKind(TCK);
CI->setCallingConv(CC);
if (FMF.any()) {
if (!isa<FPMathOperator>(CI))
if (!isa<FPMathOperator>(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);

View File

@ -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)