Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2242,16 +2242,11 @@ if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false; if (F.getName().startswith("__asan_")) return false; - bool FunctionModified = false; - - // If needed, insert __asan_init before checking for SanitizeAddress attr. - // This function needs to be called even if the function body is not - // instrumented. - if (maybeInsertAsanInitAtFunctionEntry(F)) - FunctionModified = true; - // Leave if the function doesn't need instrumentation. - if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return FunctionModified; + // The __asan_init function needs to be called even if the function body is + // not instrumented. + if (!F.hasFnAttribute(Attribute::SanitizeAddress)) + return maybeInsertAsanInitAtFunctionEntry(F); DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n"); @@ -2261,6 +2256,7 @@ FunctionStateRAII CleanupObj(this); maybeInsertDynamicShadowAtFunctionEntry(F); + bool FunctionModified = maybeInsertAsanInitAtFunctionEntry(F); // We can't instrument allocas used with llvm.localescape. Only static allocas // can be passed to that intrinsic.