From 2bd4130362966b71ae8bc0c0da56d5e064a09dae Mon Sep 17 00:00:00 2001 From: "Kevin P. Neal" Date: Tue, 21 Mar 2023 13:54:42 -0400 Subject: [PATCH] Update checks in advance of an update to D68233. In the past, the IR Verifier would bail out at the first broken function it found. This required trickery with sed to put multiple broken functions in a single test file. Now, the Verifier allows for multiple broken functions. The sed trickery is no longer needed. I've eliminated it. I've also split the test into two since one of them passes verification and we need to look at the output IR from 'opt'. The other fails and we need to look at the diagnostics printed by the Verifier. --- llvm/test/Verifier/fp-intrinsics-pass.ll | 43 +++++++++++++ llvm/test/Verifier/fp-intrinsics.ll | 100 ++++++++++++------------------- 2 files changed, 80 insertions(+), 63 deletions(-) create mode 100644 llvm/test/Verifier/fp-intrinsics-pass.ll diff --git a/llvm/test/Verifier/fp-intrinsics-pass.ll b/llvm/test/Verifier/fp-intrinsics-pass.ll new file mode 100644 index 0000000..45b0278 --- /dev/null +++ b/llvm/test/Verifier/fp-intrinsics-pass.ll @@ -0,0 +1,43 @@ +; RUN: opt -passes=verify -S < %s 2>&1 | FileCheck %s + +declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata) #0 +declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #0 + +; Test that the verifier accepts legal code, and that the correct attributes are +; attached to the FP intrinsic. The attributes are checked at the bottom. +; CHECK: declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata) #[[ATTR:[0-9]+]] +; CHECK: declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #[[ATTR]] +; Note: FP exceptions aren't usually caught through normal unwind mechanisms, +; but we may want to revisit this for asynchronous exception handling. +define double @f1(double %a, double %b) #0 { +; CHECK-LABEL: define double @f1 +; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[ATTR1:[0-9]+]] { +; CHECK-NEXT: entry: +; CHECK-NEXT: [[FADD:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[A]], double [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR1]] +; CHECK-NEXT: ret double [[FADD]] +entry: + %fadd = call double @llvm.experimental.constrained.fadd.f64( + double %a, double %b, + metadata !"round.dynamic", + metadata !"fpexcept.strict") #0 + ret double %fadd +} + +define double @f1u(double %a) #0 { +; CHECK-LABEL: define double @f1u +; CHECK-SAME: (double [[A:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: entry: +; CHECK-NEXT: [[FSQRT:%.*]] = call double @llvm.experimental.constrained.sqrt.f64(double [[A]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR1]] +; CHECK-NEXT: ret double [[FSQRT]] +; +entry: + %fsqrt = call double @llvm.experimental.constrained.sqrt.f64( + double %a, + metadata !"round.dynamic", + metadata !"fpexcept.strict") #0 + ret double %fsqrt +} + +attributes #0 = { strictfp } +; TODO: Why is strictfp not in the below list? +; CHECK: attributes #[[ATTR]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) } diff --git a/llvm/test/Verifier/fp-intrinsics.ll b/llvm/test/Verifier/fp-intrinsics.ll index cabb1ae..4934843 100644 --- a/llvm/test/Verifier/fp-intrinsics.ll +++ b/llvm/test/Verifier/fp-intrinsics.ll @@ -1,80 +1,54 @@ -; RUN: opt -passes=verify -S < %s 2>&1 | FileCheck --check-prefix=CHECK1 %s -; RUN: sed -e s/.T2:// %s | not opt -passes=verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK2 %s -; RUN: sed -e s/.T3:// %s | not opt -passes=verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK3 %s -; RUN: sed -e s/.T4:// %s | not opt -passes=verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK4 %s -; RUN: sed -e s/.T5:// %s | not opt -passes=verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK5 %s +; RUN: not opt -passes=verify -disable-output < %s 2>&1 | FileCheck %s -; Common declarations used for all runs. declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata) declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) -; Test that the verifier accepts legal code, and that the correct attributes are -; attached to the FP intrinsic. -; CHECK1: declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata) #[[ATTR:[0-9]+]] -; CHECK1: declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #[[ATTR]] -; CHECK1: attributes #[[ATTR]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) } -; Note: FP exceptions aren't usually caught through normal unwind mechanisms, -; but we may want to revisit this for asynchronous exception handling. -define double @f1(double %a, double %b) #0 { +; Test an illegal value for the rounding mode argument. +; CHECK: invalid rounding mode argument +; CHECK-NEXT: %fadd = call double @llvm.experimental.constrained.fadd.f64(double %a, double %b, metadata !"round.dynomic", metadata !"fpexcept.strict") #1 +define double @f2(double %a, double %b) #0 { entry: %fadd = call double @llvm.experimental.constrained.fadd.f64( - double %a, double %b, - metadata !"round.dynamic", - metadata !"fpexcept.strict") #0 + double %a, double %b, + metadata !"round.dynomic", + metadata !"fpexcept.strict") #0 ret double %fadd } -define double @f1u(double %a) #0 { +; Test an illegal value for the exception behavior argument. +; CHECK-NEXT: invalid exception behavior argument +; CHECK-NEXT: %fadd = call double @llvm.experimental.constrained.fadd.f64(double %a, double %b, metadata !"round.dynamic", metadata !"fpexcept.restrict") #1 +define double @f3(double %a, double %b) #0 { entry: - %fsqrt = call double @llvm.experimental.constrained.sqrt.f64( - double %a, - metadata !"round.dynamic", - metadata !"fpexcept.strict") #0 - ret double %fsqrt + %fadd = call double @llvm.experimental.constrained.fadd.f64( + double %a, double %b, + metadata !"round.dynamic", + metadata !"fpexcept.restrict") #0 + ret double %fadd } ; Test an illegal value for the rounding mode argument. -; CHECK2: invalid rounding mode argument -;T2: define double @f2(double %a, double %b) #0 { -;T2: entry: -;T2: %fadd = call double @llvm.experimental.constrained.fadd.f64( -;T2: double %a, double %b, -;T2: metadata !"round.dynomite", -;T2: metadata !"fpexcept.strict") #0 -;T2: ret double %fadd -;T2: } - -; Test an illegal value for the exception behavior argument. -; CHECK3: invalid exception behavior argument -;T3: define double @f3(double %a, double %b) #0 { -;T3: entry: -;T3: %fadd = call double @llvm.experimental.constrained.fadd.f64( -;T3: double %a, double %b, -;T3: metadata !"round.dynamic", -;T3: metadata !"fpexcept.restrict") #0 -;T3: ret double %fadd -;T3: } - -; Test an illegal value for the rounding mode argument. -; CHECK4: invalid rounding mode argument -;T4: define double @f4(double %a) #0 { -;T4: entry: -;T4: %fadd = call double @llvm.experimental.constrained.sqrt.f64( -;T4: double %a, -;T4: metadata !"round.dynomite", -;T4: metadata !"fpexcept.strict") #0 -;T4: ret double %fadd -;T4: } +; CHECK-NEXT: invalid rounding mode argument +; CHECK-NEXT: %fadd = call double @llvm.experimental.constrained.sqrt.f64(double %a, metadata !"round.dynomic", metadata !"fpexcept.strict") #1 +define double @f4(double %a) #0 { +entry: + %fadd = call double @llvm.experimental.constrained.sqrt.f64( + double %a, + metadata !"round.dynomic", + metadata !"fpexcept.strict") #0 + ret double %fadd +} ; Test an illegal value for the exception behavior argument. -; CHECK5: invalid exception behavior argument -;T5: define double @f5(double %a) #0 { -;T5: entry: -;T5: %fadd = call double @llvm.experimental.constrained.sqrt.f64( -;T5: double %a, -;T5: metadata !"round.dynamic", -;T5: metadata !"fpexcept.restrict") #0 -;T5: ret double %fadd -;T5: } +; CHECK-NEXT: invalid exception behavior argument +; CHECK-NEXT: %fadd = call double @llvm.experimental.constrained.sqrt.f64(double %a, metadata !"round.dynamic", metadata !"fpexcept.restrict") #1 +define double @f5(double %a) #0 { +entry: + %fadd = call double @llvm.experimental.constrained.sqrt.f64( + double %a, + metadata !"round.dynamic", + metadata !"fpexcept.restrict") #0 + ret double %fadd +} attributes #0 = { strictfp } -- 2.7.4