@@ -701,9 +701,21 @@ void ARMAsmPrinter::emitAttributes() {
701701 ARMBuildAttrs::AddressDirect);
702702 }
703703
704+ Metadata *MDEx = nullptr ;
705+ Metadata *MDDM = nullptr ;
706+ Metadata *MDNM = nullptr ;
707+ if (const Module *M = MMI->getModule ()) {
708+ MDEx = M->getModuleFlag (" arm-eabi-fp-exceptions" );
709+ MDDM = M->getModuleFlag (" arm-eabi-fp-denormal" );
710+ MDNM = M->getModuleFlag (" arm-eabi-fp-number-model" );
711+ }
712+
704713 // Set FP Denormals.
705- if (checkDenormalAttributeConsistency (*MMI->getModule (), " denormal-fp-math" ,
706- DenormalMode::getPreserveSign ()))
714+ if (auto *DM = mdconst::extract_or_null<ConstantInt>(MDDM))
715+ ATS.emitAttribute (ARMBuildAttrs::ABI_FP_denormal, DM->getZExtValue ());
716+ else if (checkDenormalAttributeConsistency (*MMI->getModule (),
717+ " denormal-fp-math" ,
718+ DenormalMode::getPreserveSign ()))
707719 ATS.emitAttribute (ARMBuildAttrs::ABI_FP_denormal,
708720 ARMBuildAttrs::PreserveFPSign);
709721 else if (checkDenormalAttributeConsistency (*MMI->getModule (),
@@ -743,9 +755,11 @@ void ARMAsmPrinter::emitAttributes() {
743755 }
744756
745757 // Set FP exceptions and rounding
746- if (checkFunctionsAttributeConsistency (*MMI->getModule (),
747- " no-trapping-math" , " true" ) ||
748- TM.Options .NoTrappingFPMath )
758+ if (auto *Ex = mdconst::extract_or_null<ConstantInt>(MDEx))
759+ ATS.emitAttribute (ARMBuildAttrs::ABI_FP_exceptions, Ex->getZExtValue ());
760+ else if (checkFunctionsAttributeConsistency (*MMI->getModule (),
761+ " no-trapping-math" , " true" ) ||
762+ TM.Options .NoTrappingFPMath )
749763 ATS.emitAttribute (ARMBuildAttrs::ABI_FP_exceptions,
750764 ARMBuildAttrs::Not_Allowed);
751765 else {
@@ -759,7 +773,9 @@ void ARMAsmPrinter::emitAttributes() {
759773
760774 // TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath is the
761775 // equivalent of GCC's -ffinite-math-only flag.
762- if (TM.Options .NoInfsFPMath && TM.Options .NoNaNsFPMath )
776+ if (auto *NM = mdconst::extract_or_null<ConstantInt>(MDNM))
777+ ATS.emitAttribute (ARMBuildAttrs::ABI_FP_number_model, NM->getZExtValue ());
778+ else if (TM.Options .NoInfsFPMath && TM.Options .NoNaNsFPMath )
763779 ATS.emitAttribute (ARMBuildAttrs::ABI_FP_number_model,
764780 ARMBuildAttrs::Allowed);
765781 else
0 commit comments