@@ -632,6 +632,19 @@ static bool checkDenormalAttributeConsistency(const Module &M, StringRef Attr,
632
632
});
633
633
}
634
634
635
+ // Returns true if all functions have different denormal modes.
636
+ static bool checkDenormalAttributeInconsistency (const Module &M) {
637
+ auto F = M.functions ().begin ();
638
+ auto E = M.functions ().end ();
639
+ if (F == E)
640
+ return false ;
641
+ DenormalMode Value = F->getDenormalModeRaw ();
642
+ ++F;
643
+ return std::any_of (F, E, [&](const Function &F) {
644
+ return !F.isDeclaration () && F.getDenormalModeRaw () != Value;
645
+ });
646
+ }
647
+
635
648
void ARMAsmPrinter::emitAttributes () {
636
649
MCTargetStreamer &TS = *OutStreamer->getTargetStreamer ();
637
650
ARMTargetStreamer &ATS = static_cast <ARMTargetStreamer &>(TS);
@@ -698,7 +711,9 @@ void ARMAsmPrinter::emitAttributes() {
698
711
DenormalMode::getPositiveZero ()))
699
712
ATS.emitAttribute (ARMBuildAttrs::ABI_FP_denormal,
700
713
ARMBuildAttrs::PositiveZero);
701
- else if (!TM.Options .UnsafeFPMath )
714
+ else if (checkDenormalAttributeInconsistency (*MMI->getModule ()) ||
715
+ checkDenormalAttributeConsistency (
716
+ *MMI->getModule (), " denormal-fp-math" , DenormalMode::getIEEE ()))
702
717
ATS.emitAttribute (ARMBuildAttrs::ABI_FP_denormal,
703
718
ARMBuildAttrs::IEEEDenormals);
704
719
else {
@@ -733,7 +748,7 @@ void ARMAsmPrinter::emitAttributes() {
733
748
TM.Options .NoTrappingFPMath )
734
749
ATS.emitAttribute (ARMBuildAttrs::ABI_FP_exceptions,
735
750
ARMBuildAttrs::Not_Allowed);
736
- else if (!TM. Options . UnsafeFPMath ) {
751
+ else {
737
752
ATS.emitAttribute (ARMBuildAttrs::ABI_FP_exceptions, ARMBuildAttrs::Allowed);
738
753
739
754
// If the user has permitted this code to choose the IEEE 754
0 commit comments