[llvm] r273912 - Verifier: Reject non-float !fpmath
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 27 12:43:15 PDT 2016
Author: arsenm
Date: Mon Jun 27 14:43:15 2016
New Revision: 273912
URL: http://llvm.org/viewvc/llvm-project?rev=273912&view=rev
Log:
Verifier: Reject non-float !fpmath
Code already assumes this is float. getFPAccuracy()
crashes on any other type.
Modified:
llvm/trunk/docs/LangRef.rst
llvm/trunk/lib/IR/Verifier.cpp
llvm/trunk/test/Verifier/fpmath.ll
Modified: llvm/trunk/docs/LangRef.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=273912&r1=273911&r2=273912&view=diff
==============================================================================
--- llvm/trunk/docs/LangRef.rst (original)
+++ llvm/trunk/docs/LangRef.rst Mon Jun 27 14:43:15 2016
@@ -4510,8 +4510,8 @@ it. ULP is defined as follows:
distance between the two non-equal finite floating-point numbers
nearest ``x``. Moreover, ``ulp(NaN)`` is ``NaN``.
-The metadata node shall consist of a single positive floating point
-number representing the maximum relative error, for example:
+The metadata node shall consist of a single positive float type number
+representing the maximum relative error, for example:
.. code-block:: llvm
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=273912&r1=273911&r2=273912&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Mon Jun 27 14:43:15 2016
@@ -3668,6 +3668,8 @@ void Verifier::visitInstruction(Instruct
if (ConstantFP *CFP0 =
mdconst::dyn_extract_or_null<ConstantFP>(MD->getOperand(0))) {
const APFloat &Accuracy = CFP0->getValueAPF();
+ Assert(&Accuracy.getSemantics() == &APFloat::IEEEsingle,
+ "fpmath accuracy must have float type", &I);
Assert(Accuracy.isFiniteNonZero() && !Accuracy.isNegative(),
"fpmath accuracy not a positive number!", &I);
} else {
Modified: llvm/trunk/test/Verifier/fpmath.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/fpmath.ll?rev=273912&r1=273911&r2=273912&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/fpmath.ll (original)
+++ llvm/trunk/test/Verifier/fpmath.ll Mon Jun 27 14:43:15 2016
@@ -19,6 +19,8 @@ define void @fpmath1(i32 %i, float %f, <
; CHECK: fpmath accuracy not a positive number!
%z = fadd float %f, %f, !fpmath !6
; CHECK: fpmath accuracy not a positive number!
+ %double.fpmath = fadd float %f, %f, !fpmath !7
+; CHECK: fpmath accuracy must have float type
ret void
}
@@ -29,3 +31,4 @@ define void @fpmath1(i32 %i, float %f, <
!4 = !{ float -1.0 }
!5 = !{ float 0.0 }
!6 = !{ float 0x7FFFFFFF00000000 }
+!7 = !{ double 1.0 }
More information about the llvm-commits
mailing list