File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,9 @@ class LLVM_EXTERNAL_VISIBILITY Module {
202202 // /< ID and FunctionType maps to the extension that
203203 // /< is used to make the intrinsic name unique.
204204
205+ // / llvm.module.flags metadata
206+ NamedMDNode *ModuleFlags = nullptr ;
207+
205208 friend class Constant ;
206209
207210// / @}
@@ -528,7 +531,7 @@ class LLVM_EXTERNAL_VISIBILITY Module {
528531
529532 // / Returns the NamedMDNode in the module that represents module-level flags.
530533 // / This method returns null if there are no module-level flags.
531- NamedMDNode *getModuleFlagsMetadata () const ;
534+ NamedMDNode *getModuleFlagsMetadata () const { return ModuleFlags; }
532535
533536 // / Returns the NamedMDNode in the module that represents module-level flags.
534537 // / If module-level flags aren't found, it creates the named metadata that
Original file line number Diff line number Diff line change @@ -272,6 +272,8 @@ NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) {
272272 NMD = new NamedMDNode (Name);
273273 NMD->setParent (this );
274274 insertNamedMDNode (NMD);
275+ if (Name == " llvm.module.flags" )
276+ ModuleFlags = NMD;
275277 }
276278 return NMD;
277279}
@@ -280,6 +282,8 @@ NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) {
280282// / delete it.
281283void Module::eraseNamedMetadata (NamedMDNode *NMD) {
282284 NamedMDSymTab.erase (NMD->getName ());
285+ if (NMD == ModuleFlags)
286+ ModuleFlags = nullptr ;
283287 eraseNamedMDNode (NMD);
284288}
285289
@@ -323,17 +327,12 @@ Metadata *Module::getModuleFlag(StringRef Key) const {
323327 return nullptr ;
324328}
325329
326- // / getModuleFlagsMetadata - Returns the NamedMDNode in the module that
327- // / represents module-level flags. This method returns null if there are no
328- // / module-level flags.
329- NamedMDNode *Module::getModuleFlagsMetadata () const {
330- return getNamedMetadata (" llvm.module.flags" );
331- }
332-
333330// / getOrInsertModuleFlagsMetadata - Returns the NamedMDNode in the module that
334331// / represents module-level flags. If module-level flags aren't found, it
335332// / creates the named metadata that contains them.
336333NamedMDNode *Module::getOrInsertModuleFlagsMetadata () {
334+ if (ModuleFlags)
335+ return ModuleFlags;
337336 return getOrInsertNamedMetadata (" llvm.module.flags" );
338337}
339338
You can’t perform that action at this time.
0 commit comments