[PATCH] D69557: AsmParser: Allow FMF on varargs call

Tim Renouf via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 05:01:13 PDT 2019


tpr created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

D14707 <https://reviews.llvm.org/D14707> added code to allow FMF on a call with a float or vector of float
return type. But it accidentally disallowed it when using (...) syntax
for a varargs call. This commit fixes that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69557

Files:
  llvm/lib/AsmParser/LLParser.cpp
  llvm/test/Assembler/fast-math-flags.ll


Index: llvm/test/Assembler/fast-math-flags.ll
===================================================================
--- llvm/test/Assembler/fast-math-flags.ll
+++ llvm/test/Assembler/fast-math-flags.ll
@@ -189,3 +189,31 @@
 ; CHECK:  ret float %f
   ret float %f
 }
+
+; CHECK: @fmf_calls(
+define float @fmf_calls(float %x, float %y) {
+entry:
+; CHECK:  %vec = load <3 x float>, <3 x float>* @vec
+  %vec    = load <3 x float>, <3 x float>* @vec
+; CHECK:  %select = load i1, i1* @select
+  %select = load i1, i1* @select
+; CHECK:  %arr = load [3 x float], [3 x float]* @arr
+  %arr    = load [3 x float], [3 x float]* @arr
+
+; CHECK:  %a = call nnan ninf afn float @extfunc(float %x, float %y)
+  %a = call ninf nnan afn float @extfunc(float %x, float %y)
+; CHECK:  %a_vec = call reassoc nnan <3 x float> @extfunc_vec(<3 x float> %vec, <3 x float> %vec)
+  %a_vec = call reassoc nnan <3 x float> @extfunc_vec(<3 x float> %vec, <3 x float> %vec)
+; CHECK:  %b = call nnan ninf afn float (...) @var_extfunc(float %x, float %y)
+  %b = call ninf nnan afn float (...) @var_extfunc(float %x, float %y)
+; CHECK:  %b_vec = call reassoc nnan <3 x float> (...) @var_extfunc_vec(<3 x float> %vec, <3 x float> %vec)
+  %b_vec = call reassoc nnan <3 x float> (...) @var_extfunc_vec(<3 x float> %vec, <3 x float> %vec)
+; CHECK:  ret float %a
+  ret float %a
+}
+
+declare float @extfunc(float, float)
+declare <3 x float> @extfunc_vec(<3 x float>, <3 x float>)
+declare float @var_extfunc(...)
+declare <3 x float> @var_extfunc_vec(...)
+
Index: llvm/lib/AsmParser/LLParser.cpp
===================================================================
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -6785,10 +6785,6 @@
       ParseOptionalOperandBundles(BundleList, PFS))
     return true;
 
-  if (FMF.any() && !RetType->isFPOrFPVectorTy())
-    return Error(CallLoc, "fast-math-flags specified for call without "
-                          "floating-point scalar or vector return type");
-
   // If RetType is a non-function pointer type, then this is the short syntax
   // for the call, which means that RetType is just the return type.  Infer the
   // rest of the function argument types from the arguments that are present.
@@ -6803,7 +6799,12 @@
       return Error(RetTypeLoc, "Invalid result type for LLVM function");
 
     Ty = FunctionType::get(RetType, ParamTypes, false);
-  }
+  } else
+    RetType = Ty->getReturnType();
+
+  if (FMF.any() && !RetType->isFPOrFPVectorTy())
+    return Error(CallLoc, "fast-math-flags specified for call without "
+                          "floating-point scalar or vector return type");
 
   CalleeID.FTy = Ty;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69557.226875.patch
Type: text/x-patch
Size: 2679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191029/bd44f6d1/attachment.bin>


More information about the llvm-commits mailing list