mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[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:
parent
f772c98f9f
commit
71cc6e9751
@ -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);
|
||||
|
10
test/CodeGen/Generic/fast-math-flags.ll
Normal file
10
test/CodeGen/Generic/fast-math-flags.ll
Normal 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)
|
Loading…
Reference in New Issue
Block a user