Skip to content

[Verifier] Verify attribute denormal-fp-math[-f32] #112310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,19 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
if (!Info)
CheckFailed("invalid name for a VFABI variant: " + S, V);
}

if (auto A = Attrs.getFnAttr("denormal-fp-math"); A.isValid()) {
StringRef S = A.getValueAsString();
if (!parseDenormalFPAttribute(S).isValid())
CheckFailed("invalid value for 'denormal-fp-math' attribute: " + S, V);
}

if (auto A = Attrs.getFnAttr("denormal-fp-math-f32"); A.isValid()) {
StringRef S = A.getValueAsString();
if (!parseDenormalFPAttribute(S).isValid())
CheckFailed("invalid value for 'denormal-fp-math-f32' attribute: " + S,
V);
}
}

void Verifier::verifyFunctionMetadata(
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/AMDGPU/clamp-modifier.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1

attributes #0 = { nounwind "denormal-fp-math-f32"="preserve-sign,preserve-sign" }
attributes #1 = { nounwind readnone }
attributes #2 = { nounwind "denormal-fp-math-f32"="ieee.ieee" }
attributes #2 = { nounwind "denormal-fp-math-f32"="ieee,ieee" }
attributes #3 = { nounwind "denormal-fp-math-f32"="ieee,ieee" "denormal-fp-math"="preserve-sign,preserve-sign" }

!llvm.dbg.cu = !{!0}
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/DebugInfo/COFF/fortran-contained-proc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #3
; Function Attrs: mustprogress nofree nosync nounwind readnone speculatable willreturn
declare void @llvm.dbg.value(metadata, metadata, metadata) #3

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" }
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" }
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" }
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" }
attributes #2 = { nofree "intel-lang"="fortran" }
attributes #3 = { mustprogress nofree nosync nounwind readnone speculatable willreturn }
attributes #4 = { nounwind }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,6 @@ attributes #3 = { "denormal-fp-math"="dynamic,dynamic" }
attributes #4 = { "denormal-fp-math"="ieee,preserve-sign" }
attributes #5 = { "denormal-fp-math"="preserve-sign,ieee" }
attributes #6 = { "denormal-fp-math"="ieee,positive-zero" }
attributes #7 = { "denormal-fp-math"="positive-zero-sign,ieee" }
attributes #7 = { "denormal-fp-math"="positive-zero,ieee" }
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; TUNIT: {{.*}}
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Attributor/nofpclass-minnum-maxnum.ll
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,6 @@ attributes #3 = { "denormal-fp-math"="dynamic,dynamic" }
attributes #4 = { "denormal-fp-math"="ieee,preserve-sign" }
attributes #5 = { "denormal-fp-math"="preserve-sign,ieee" }
attributes #6 = { "denormal-fp-math"="ieee,positive-zero" }
attributes #7 = { "denormal-fp-math"="positive-zero-sign,ieee" }
attributes #7 = { "denormal-fp-math"="positive-zero,ieee" }
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; TUNIT: {{.*}}
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,5 @@ declare <2 x double> @llvm.fabs.v2f64(<2 x double>)

attributes #0 = { "denormal-fp-math"="ieee,preserve-sign" }
attributes #1 = { "denormal-fp-math"="ieee,positive-zero" }
attributes #2 = { "denormal-fp-math"="ieee,iee" }
attributes #2 = { "denormal-fp-math"="ieee,ieee" }
attributes #3 = { "denormal-fp-math-f32"="ieee,preserve-sign" }
20 changes: 20 additions & 0 deletions llvm/test/Verifier/denormal-fp-math.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck --implicit-check-not="invalid value" %s

define float @test_denormal_fp_math_valid() "denormal-fp-math"="ieee,ieee" {
ret float 1.0
}

; CHECK: invalid value for 'denormal-fp-math' attribute: foo,ieee
define float @test_denormal_fp_math_invalid1() "denormal-fp-math"="foo,ieee" {
ret float 1.0
}

; CHECK: invalid value for 'denormal-fp-math' attribute: ieee,ieee,ieee
define float @test_denormal_fp_math_invalid2() "denormal-fp-math"="ieee,ieee,ieee" {
ret float 1.0
}

; CHECK: invalid value for 'denormal-fp-math-f32' attribute: foo,ieee
define float @test_denormal_fp_math_f32_invalid() "denormal-fp-math-f32"="foo,ieee" {
ret float 1.0
}
Loading