@@ -180,74 +180,75 @@ bool MemInstFinderPass::runOnModule(Module& module) {
180180 auto & globals = mOpsCollector .globals ;
181181 NumDetectedGlobals += globals.size ();
182182 if (config[config::ConfigStdArgs::analysis_filter_global]) {
183- globals.erase (llvm::remove_if (
184- globals,
185- [&](const auto gdata) { // NOLINT
186- GlobalVariable* global = gdata.global ;
187- const auto name = global->getName ();
188-
189- LOG_DEBUG (" Analyzing global: " << name);
190-
191- if (name.empty ()) {
192- return true ;
193- }
194-
195- if (util::starts_with_any_of (name, " llvm." , " __llvm_gcov" , " __llvm_gcda" , " __profn" , " ___asan" ,
196- " __msan" , " __tsan" , " __typeart" , " _typeart" )) {
197- LOG_DEBUG (" Prefixed matched on " << name)
198- return true ;
199- }
200-
201- if (global->hasInitializer ()) {
202- auto * ini = global->getInitializer ();
203- std::string ini_name = util::dump (*ini);
204-
205- if (llvm::StringRef (ini_name).contains (" std::ios_base::Init" )) {
206- LOG_DEBUG (" std::ios" );
207- return true ;
208- }
209- }
210-
211- if (global->hasSection ()) {
212- // for instance, filters:
213- // a) (Coverage) -fprofile-instr-generate -fcoverage-mapping
214- // b) (PGO) -fprofile-instr-generate
215- StringRef Section = global->getSection ();
216- // Globals from llvm.metadata aren't emitted, do not instrument them.
217- if (Section == " llvm.metadata" ) {
218- LOG_DEBUG (" metadata" );
219- return true ;
220- }
221- // Do not instrument globals from special LLVM sections.
222- if (Section.find (" __llvm" ) != StringRef::npos || Section.find (" __LLVM" ) != StringRef::npos) {
223- LOG_DEBUG (" llvm section" );
224- return true ;
225- }
226- }
227-
228- if ((global->getLinkage () == GlobalValue::ExternalLinkage && global->isDeclaration ())) {
229- LOG_DEBUG (" Linkage: External" );
230- return true ;
231- }
232-
233- Type* global_type = global->getValueType ();
234- if (!global_type->isSized ()) {
235- LOG_DEBUG (" not sized" );
236- return true ;
237- }
238-
239- if (global_type->isArrayTy ()) {
240- global_type = global_type->getArrayElementType ();
241- }
242- if (auto structType = dyn_cast<StructType>(global_type)) {
243- if (structType->isOpaque ()) {
244- LOG_DEBUG (" Encountered opaque struct " << global_type->getStructName () << " - skipping..." );
245- return true ;
246- }
247- }
248- return false ;
249- }),
250- globals.end ());
183+ globals.erase (
184+ llvm::remove_if (
185+ globals,
186+ [&](const auto gdata) { // NOLINT
187+ GlobalVariable* global = gdata.global ;
188+ const auto name = global->getName ();
189+
190+ LOG_DEBUG (" Analyzing global: " << name);
191+
192+ if (name.empty ()) {
193+ return true ;
194+ }
195+
196+ if (util::starts_with_any_of (name, " llvm." , " __llvm_gcov" , " __llvm_gcda" , " __profn" , " ___asan" , " __msan" ,
197+ " __tsan" , " __typeart" , " _typeart" , " __tysan" , " __dfsan" , " __profc" )) {
198+ LOG_DEBUG (" Prefixed matched on " << name)
199+ return true ;
200+ }
201+
202+ if (global->hasInitializer ()) {
203+ auto * ini = global->getInitializer ();
204+ std::string ini_name = util::dump (*ini);
205+
206+ if (llvm::StringRef (ini_name).contains (" std::ios_base::Init" )) {
207+ LOG_DEBUG (" std::ios" );
208+ return true ;
209+ }
210+ }
211+
212+ if (global->hasSection ()) {
213+ // for instance, filters:
214+ // a) (Coverage) -fprofile-instr-generate -fcoverage-mapping
215+ // b) (PGO) -fprofile-instr-generate
216+ StringRef Section = global->getSection ();
217+ // Globals from llvm.metadata aren't emitted, do not instrument them.
218+ if (Section == " llvm.metadata" ) {
219+ LOG_DEBUG (" metadata" );
220+ return true ;
221+ }
222+ // Do not instrument globals from special LLVM sections.
223+ if (Section.find (" __llvm" ) != StringRef::npos || Section.find (" __LLVM" ) != StringRef::npos) {
224+ LOG_DEBUG (" llvm section" );
225+ return true ;
226+ }
227+ }
228+
229+ if ((global->getLinkage () == GlobalValue::ExternalLinkage && global->isDeclaration ())) {
230+ LOG_DEBUG (" Linkage: External" );
231+ return true ;
232+ }
233+
234+ Type* global_type = global->getValueType ();
235+ if (!global_type->isSized ()) {
236+ LOG_DEBUG (" not sized" );
237+ return true ;
238+ }
239+
240+ if (global_type->isArrayTy ()) {
241+ global_type = global_type->getArrayElementType ();
242+ }
243+ if (auto structType = dyn_cast<StructType>(global_type)) {
244+ if (structType->isOpaque ()) {
245+ LOG_DEBUG (" Encountered opaque struct " << global_type->getStructName () << " - skipping..." );
246+ return true ;
247+ }
248+ }
249+ return false ;
250+ }),
251+ globals.end ());
251252
252253 const auto beforeCallFilter = globals.size ();
253254 NumFilteredGlobals = NumDetectedGlobals - beforeCallFilter;
0 commit comments