Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1885,13 +1885,16 @@ if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false; if (F.getName().find("__asan_") != std::string::npos) return false; + bool function_modified = 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. - maybeInsertAsanInitAtFunctionEntry(F); + if (maybeInsertAsanInitAtFunctionEntry(F)) + function_modified = true; // Leave if the function doesn't need instrumentation. - if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return false; + if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return function_modified; DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n"); @@ -1992,11 +1995,13 @@ NumInstrumented++; } - bool res = NumInstrumented > 0 || ChangedStack || !NoReturnCalls.empty(); + if (NumInstrumented > 0 || ChangedStack || !NoReturnCalls.empty()) + function_modified = true; - DEBUG(dbgs() << "ASAN done instrumenting: " << res << " " << F << "\n"); + DEBUG(dbgs() << "ASAN done instrumenting: " << function_modified << " " + << F << "\n"); - return res; + return function_modified; } // Workaround for bug 11395: we don't want to instrument stack in functions