[llvm] [ARM] Recognize abi tag module flags (PR #161306)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 6 09:32:16 PDT 2025


================
@@ -701,9 +701,21 @@ void ARMAsmPrinter::emitAttributes() {
                       ARMBuildAttrs::AddressDirect);
   }
 
+  Metadata *MDEx = nullptr;
+  Metadata *MDDM = nullptr;
+  Metadata *MDNM = nullptr;
+  if (const Module *M = MMI->getModule()) {
----------------
smithp35 wrote:

Is it ever possible for MMI->getModule() to be nullptr when writing build attributes? In the existing code for checkDenormalConsistency it is universally dereferenced?

If it isn't possible then I think it would be worth moving the M->getModuleFlag() calls closer to where they are used. I find it difficult to tell MDDM and MDNM apart with my eyesight.

For example (using SourceModule instead of M, as SourceModule is used on line 801).
```
const Module *SourceModule = MMI->getModule();
// Set FP Denormals
Metadata *MDDM = SourceModule->getModuleFlag("arm-eabi-fp-denormal");
if (auto *DM = mdconst::extract_or_null<ConstantInt>(MDDM))
  ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal, DM->getZExtValue());
else if (checkDenormalAttributeConsistency(*SourceModule,
                                             "denormal-fp-math",
                                             DenormalMode::getPreserveSign()))
```
If we do have to preserve the `if (const Module *M = MMI->getModule())` can you expand the MDDM and MDNM a bit? perhaps `MDDenorm` and `MDNumModel` .



https://github.com/llvm/llvm-project/pull/161306


More information about the llvm-commits mailing list