@@ -49,6 +49,10 @@ Plugin::Plugin(plugin::Plugin::Type T, std::string LibraryName,
4949 ThisModule(Module), ThisConfig(Module.getConfig()),
5050 IsDefaultPlugin(DefaultPlugin) {}
5151
52+ bool Plugin::isTraced () const {
53+ return ThisConfig.options ().tracePlugin (getPluginType ());
54+ }
55+
5256std::string Plugin::resolvePath (const LinkerConfig &PConfig) {
5357 // Library already loaded!
5458 if (PluginLibraryHandle)
@@ -79,7 +83,7 @@ std::string Plugin::resolvePath(const LinkerConfig &PConfig) {
7983
8084 if (nullptr != NS ) {
8185 PluginLibraryName = NS ->getFullPath ();
82- if (ThisModule. getPrinter ()-> tracePlugins ())
86+ if (isTraced ())
8387 ThisConfig.raise (Diag::using_plugin) << PluginLibraryName << Name;
8488 }
8589 return PluginLibraryName;
@@ -151,15 +155,15 @@ bool Plugin::setFunctions() {
151155 return false ;
152156 }
153157
154- if (ThisModule. getPrinter ()-> tracePlugins ()) {
158+ if (isTraced ()) {
155159 ThisConfig.raise (Diag::found_register_function) << Register << LibraryName;
156160 ThisConfig.raise (Diag::found_function_for_plugintype)
157161 << PluginFunc << LibraryName;
158162 }
159163
160164 std::string PluginCleanupFunc = " Cleanup" ;
161165 void *C = DynamicLibrary::GetFunction (PluginLibraryHandle, PluginCleanupFunc);
162- if (C && ThisModule. getPrinter ()-> tracePlugins ()) {
166+ if (C && isTraced ()) {
163167 ThisConfig.raise (Diag::found_cleanup_function)
164168 << PluginCleanupFunc << LibraryName;
165169 }
@@ -182,7 +186,7 @@ bool Plugin::setFunctions() {
182186bool Plugin::getUserPlugin () {
183187 std::string LibraryName = DynamicLibrary::getLibraryName (Name);
184188
185- if (ThisModule. getPrinter ()-> tracePlugins ())
189+ if (isTraced ())
186190 ThisConfig.raise (Diag::registering_all_functions);
187191
188192 UserPluginHandle = (*GetPluginFunction)(getPluginType ().c_str ());
@@ -192,7 +196,7 @@ bool Plugin::getUserPlugin() {
192196 return false ;
193197 }
194198
195- if (ThisModule. getPrinter ()-> tracePlugins ())
199+ if (isTraced ())
196200 ThisConfig.raise (Diag::found_plugin_handler)
197201 << getPluginType () << LibraryName;
198202
@@ -211,7 +215,7 @@ bool Plugin::init(eld::OutputTarWriter *OutputTar) {
211215 return false ;
212216 eld::RegisterTimer T (
213217 " Init" , ThisModule.saveString (UserPluginHandle->GetName ()), Stats);
214- if (ThisModule. getPrinter ()-> tracePlugins ())
218+ if (isTraced ())
215219 ThisConfig.raise (Diag::note_initializing_plugin)
216220 << getPluginType () << DynamicLibrary::getLibraryName (Name)
217221 << UserPluginHandle->GetName ();
@@ -235,14 +239,14 @@ bool Plugin::run(std::vector<Plugin *> &Plugins) {
235239 return false ;
236240 eld::RegisterTimer T (
237241 " Run" , ThisModule.saveString (UserPluginHandle->GetName ()), Stats);
238- if (ThisModule. getPrinter ()-> tracePlugins ())
242+ if (isTraced ())
239243 ThisConfig.raise (Diag::running_plugin)
240244 << getPluginType () << DynamicLibrary::getLibraryName (Name)
241245 << UserPluginHandle->GetName ();
242246 Plugins.push_back (this );
243247 Running R (this );
244248 plugin::Plugin *P = llvm::cast<plugin::Plugin>(UserPluginHandle);
245- plugin::Plugin::Status S = P->Run (ThisModule. getPrinter ()-> tracePlugins ());
249+ plugin::Plugin::Status S = P->Run (isTraced ());
246250 if (S == plugin::Plugin::Status::ERROR || P->GetLastError ()) {
247251 ThisConfig.raise (Diag::plugin_has_error)
248252 << getPluginType () << DynamicLibrary::getLibraryName (Name)
@@ -290,7 +294,7 @@ bool Plugin::destroy() {
290294 return false ;
291295 eld::RegisterTimer T (
292296 " Destroy" , ThisModule.saveString (UserPluginHandle->GetName ()), Stats);
293- if (ThisModule. getPrinter ()-> tracePlugins ())
297+ if (isTraced ())
294298 ThisConfig.raise (Diag::plugin_destroy) << getPluginType ();
295299 plugin::Plugin *P = llvm::cast<plugin::Plugin>(UserPluginHandle);
296300 P->Destroy ();
@@ -332,7 +336,7 @@ bool Plugin::check() {
332336 return false ;
333337 }
334338
335- if (ThisModule. getPrinter ()-> tracePlugins ())
339+ if (isTraced ())
336340 ThisConfig.raise (Diag::note_plugin_version)
337341 << PluginMajor << PluginMinor << DynamicLibrary::getLibraryName (Name)
338342 << getPluginType ();
@@ -522,7 +526,7 @@ void Plugin::callInitHook() {
522526 plugin::LinkerPlugin *P = llvm::cast<plugin::LinkerPlugin>(UserPluginHandle);
523527 RegisterTimer T (" Init" , ThisModule.saveString (UserPluginHandle->GetName ()),
524528 Stats);
525- if (ThisModule. getPrinter ()-> tracePlugins ())
529+ if (isTraced ())
526530 ThisConfig.raise (Diag::trace_plugin_init) << getPluginName ();
527531 P->Init (PluginOptions);
528532}
@@ -531,15 +535,15 @@ void Plugin::callDestroyHook() {
531535 plugin::LinkerPlugin *P = llvm::cast<plugin::LinkerPlugin>(UserPluginHandle);
532536 RegisterTimer T (" Destroy" , ThisModule.saveString (UserPluginHandle->GetName ()),
533537 Stats);
534- if (ThisModule. getPrinter ()-> tracePlugins ())
538+ if (isTraced ())
535539 ThisConfig.raise (Diag::trace_plugin_destroy) << getPluginName ();
536540 P->Destroy ();
537541}
538542
539543void Plugin::registerCommandLineOption (
540544 const std::string &Option, bool HasValue,
541545 const CommandLineOptionSpec::OptionHandlerType &OptionHandler) {
542- if (ThisModule. getPrinter ()-> tracePlugins ()) {
546+ if (isTraced ()) {
543547 if (HasValue)
544548 ThisConfig.raise (Diag::trace_plugin_register_opt_with_val)
545549 << getPluginName () << Option;
@@ -568,7 +572,7 @@ void Plugin::callVisitSectionsHook(InputFile &IF) {
568572 plugin::LinkerPlugin *P = llvm::cast<plugin::LinkerPlugin>(UserPluginHandle);
569573 RegisterTimer T (" VisitSections" ,
570574 ThisModule.saveString (UserPluginHandle->GetName ()), Stats);
571- if (ThisModule. getPrinter ()-> tracePlugins ())
575+ if (isTraced ())
572576 ThisConfig.raise (Diag::trace_plugin_visit_sections)
573577 << getPluginName () << IF .getInput ()->decoratedPath ();
574578 P->VisitSections (plugin::InputFile (&IF ));
@@ -579,7 +583,7 @@ void Plugin::callVisitSymbolHook(LDSymbol *Sym, llvm::StringRef SymName,
579583 plugin::LinkerPlugin *P = llvm::cast<plugin::LinkerPlugin>(UserPluginHandle);
580584 RegisterTimer T (" VisitSymbol" ,
581585 ThisModule.saveString (UserPluginHandle->GetName ()), Stats);
582- if (ThisModule. getPrinter ()-> tracePlugins ())
586+ if (isTraced ())
583587 ThisConfig.raise (Diag::trace_plugin_visit_symbol)
584588 << getPluginName () << SymName;
585589 std::unique_ptr<SymbolInfo> UpSymInfo = std::make_unique<SymbolInfo>(SymInfo);
@@ -593,7 +597,7 @@ void Plugin::callActBeforeRuleMatchingHook() {
593597 plugin::LinkerPlugin *P = llvm::cast<plugin::LinkerPlugin>(UserPluginHandle);
594598 RegisterTimer T (HookName, ThisModule.saveString (UserPluginHandle->GetName ()),
595599 Stats);
596- if (ThisModule. getPrinter ()-> tracePlugins ())
600+ if (isTraced ())
597601 ThisConfig.raise (Diag::trace_plugin_hook) << getPluginName () << HookName;
598602 P->ActBeforeRuleMatching ();
599603}
@@ -603,7 +607,7 @@ void Plugin::callActBeforeSectionMergingHook() {
603607 plugin::LinkerPlugin *P = llvm::cast<plugin::LinkerPlugin>(UserPluginHandle);
604608 RegisterTimer T (HookName, ThisModule.saveString (UserPluginHandle->GetName ()),
605609 Stats);
606- if (ThisModule. getPrinter ()-> tracePlugins ())
610+ if (isTraced ())
607611 ThisConfig.raise (Diag::trace_plugin_hook) << getPluginName () << HookName;
608612 P->ActBeforeSectionMerging ();
609613}
@@ -613,7 +617,7 @@ void Plugin::callActBeforePerformingLayoutHook() {
613617 plugin::LinkerPlugin *P = llvm::cast<plugin::LinkerPlugin>(UserPluginHandle);
614618 RegisterTimer T (HookName, ThisModule.saveString (UserPluginHandle->GetName ()),
615619 Stats);
616- if (ThisModule. getPrinter ()-> tracePlugins ())
620+ if (isTraced ())
617621 ThisConfig.raise (Diag::trace_plugin_hook) << getPluginName () << HookName;
618622 P->ActBeforePerformingLayout ();
619623}
@@ -623,7 +627,7 @@ void Plugin::callActBeforeWritingOutputHook() {
623627 plugin::LinkerPlugin *P = llvm::cast<plugin::LinkerPlugin>(UserPluginHandle);
624628 RegisterTimer T (HookName, ThisModule.saveString (UserPluginHandle->GetName ()),
625629 Stats);
626- if (ThisModule. getPrinter ()-> tracePlugins ())
630+ if (isTraced ())
627631 ThisConfig.raise (Diag::trace_plugin_hook) << getPluginName () << HookName;
628632 P->ActBeforeWritingOutput ();
629633}
0 commit comments