Skip to content

Commit 8d8bb40

Browse files
authored
[Verifier] Verify attribute denormal-fp-math[-f32] (#112310)
Some typos are also fixed. Address #112067 (review).
1 parent 9efb07f commit 8d8bb40

File tree

7 files changed

+39
-6
lines changed

7 files changed

+39
-6
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,19 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
24012401
if (!Info)
24022402
CheckFailed("invalid name for a VFABI variant: " + S, V);
24032403
}
2404+
2405+
if (auto A = Attrs.getFnAttr("denormal-fp-math"); A.isValid()) {
2406+
StringRef S = A.getValueAsString();
2407+
if (!parseDenormalFPAttribute(S).isValid())
2408+
CheckFailed("invalid value for 'denormal-fp-math' attribute: " + S, V);
2409+
}
2410+
2411+
if (auto A = Attrs.getFnAttr("denormal-fp-math-f32"); A.isValid()) {
2412+
StringRef S = A.getValueAsString();
2413+
if (!parseDenormalFPAttribute(S).isValid())
2414+
CheckFailed("invalid value for 'denormal-fp-math-f32' attribute: " + S,
2415+
V);
2416+
}
24042417
}
24052418

24062419
void Verifier::verifyFunctionMetadata(

llvm/test/CodeGen/AMDGPU/clamp-modifier.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
16571657

16581658
attributes #0 = { nounwind "denormal-fp-math-f32"="preserve-sign,preserve-sign" }
16591659
attributes #1 = { nounwind readnone }
1660-
attributes #2 = { nounwind "denormal-fp-math-f32"="ieee.ieee" }
1660+
attributes #2 = { nounwind "denormal-fp-math-f32"="ieee,ieee" }
16611661
attributes #3 = { nounwind "denormal-fp-math-f32"="ieee,ieee" "denormal-fp-math"="preserve-sign,preserve-sign" }
16621662

16631663
!llvm.dbg.cu = !{!0}

llvm/test/DebugInfo/COFF/fortran-contained-proc.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #3
7474
; Function Attrs: mustprogress nofree nosync nounwind readnone speculatable willreturn
7575
declare void @llvm.dbg.value(metadata, metadata, metadata) #3
7676

77-
attributes #0 = { nounwind uwtable "denormal-fp-math"="preserve_sign,preserve_sign" "frame-pointer"="none" "intel-lang"="fortran" "min-legal-vector-width"="0" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
78-
attributes #1 = { mustprogress nofree norecurse nosync nounwind uwtable willreturn writeonly "denormal-fp-math"="preserve_sign,preserve_sign" "frame-pointer"="none" "intel-lang"="fortran" "min-legal-vector-width"="0" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
77+
attributes #0 = { nounwind uwtable "denormal-fp-math"="preserve-sign,preserve-sign" "frame-pointer"="none" "intel-lang"="fortran" "min-legal-vector-width"="0" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
78+
attributes #1 = { mustprogress nofree norecurse nosync nounwind uwtable willreturn writeonly "denormal-fp-math"="preserve-sign,preserve-sign" "frame-pointer"="none" "intel-lang"="fortran" "min-legal-vector-width"="0" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
7979
attributes #2 = { nofree "intel-lang"="fortran" }
8080
attributes #3 = { mustprogress nofree nosync nounwind readnone speculatable willreturn }
8181
attributes #4 = { nounwind }

llvm/test/Transforms/Attributor/nofpclass-minimum-maximum.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,6 @@ attributes #3 = { "denormal-fp-math"="dynamic,dynamic" }
511511
attributes #4 = { "denormal-fp-math"="ieee,preserve-sign" }
512512
attributes #5 = { "denormal-fp-math"="preserve-sign,ieee" }
513513
attributes #6 = { "denormal-fp-math"="ieee,positive-zero" }
514-
attributes #7 = { "denormal-fp-math"="positive-zero-sign,ieee" }
514+
attributes #7 = { "denormal-fp-math"="positive-zero,ieee" }
515515
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
516516
; TUNIT: {{.*}}

llvm/test/Transforms/Attributor/nofpclass-minnum-maxnum.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,6 @@ attributes #3 = { "denormal-fp-math"="dynamic,dynamic" }
511511
attributes #4 = { "denormal-fp-math"="ieee,preserve-sign" }
512512
attributes #5 = { "denormal-fp-math"="preserve-sign,ieee" }
513513
attributes #6 = { "denormal-fp-math"="ieee,positive-zero" }
514-
attributes #7 = { "denormal-fp-math"="positive-zero-sign,ieee" }
514+
attributes #7 = { "denormal-fp-math"="positive-zero,ieee" }
515515
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
516516
; TUNIT: {{.*}}

llvm/test/Transforms/InstCombine/fcmp-denormals-are-zero.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,5 +350,5 @@ declare <2 x double> @llvm.fabs.v2f64(<2 x double>)
350350

351351
attributes #0 = { "denormal-fp-math"="ieee,preserve-sign" }
352352
attributes #1 = { "denormal-fp-math"="ieee,positive-zero" }
353-
attributes #2 = { "denormal-fp-math"="ieee,iee" }
353+
attributes #2 = { "denormal-fp-math"="ieee,ieee" }
354354
attributes #3 = { "denormal-fp-math-f32"="ieee,preserve-sign" }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck --implicit-check-not="invalid value" %s
2+
3+
define float @test_denormal_fp_math_valid() "denormal-fp-math"="ieee,ieee" {
4+
ret float 1.0
5+
}
6+
7+
; CHECK: invalid value for 'denormal-fp-math' attribute: foo,ieee
8+
define float @test_denormal_fp_math_invalid1() "denormal-fp-math"="foo,ieee" {
9+
ret float 1.0
10+
}
11+
12+
; CHECK: invalid value for 'denormal-fp-math' attribute: ieee,ieee,ieee
13+
define float @test_denormal_fp_math_invalid2() "denormal-fp-math"="ieee,ieee,ieee" {
14+
ret float 1.0
15+
}
16+
17+
; CHECK: invalid value for 'denormal-fp-math-f32' attribute: foo,ieee
18+
define float @test_denormal_fp_math_f32_invalid() "denormal-fp-math-f32"="foo,ieee" {
19+
ret float 1.0
20+
}

0 commit comments

Comments
 (0)