From ce486fc023085cfbc968f32fc74164e06039ef2e Mon Sep 17 00:00:00 2001 From: Etienne Bergeron Date: Thu, 15 Sep 2016 15:45:05 +0000 Subject: [PATCH] [compiler-rt] Changing function prototype returning unused value Summary: The return value of `maybeInsertAsanInitAtFunctionEntry` is ignored. Reviewers: rnk Subscribers: llvm-commits, chrisha, dberris Differential Revision: https://reviews.llvm.org/D24568 llvm-svn: 281620 --- .../Instrumentation/AddressSanitizer.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 62acd117af7..e86fa8beeb9 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1885,13 +1885,16 @@ bool AddressSanitizer::runOnFunction(Function &F) { 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. - maybeInsertAsanInitAtFunctionEntry(F); + if (maybeInsertAsanInitAtFunctionEntry(F)) + FunctionModified = true; // Leave if the function doesn't need instrumentation. - if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return false; + if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return FunctionModified; DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n"); @@ -1992,11 +1995,13 @@ bool AddressSanitizer::runOnFunction(Function &F) { NumInstrumented++; } - bool res = NumInstrumented > 0 || ChangedStack || !NoReturnCalls.empty(); + if (NumInstrumented > 0 || ChangedStack || !NoReturnCalls.empty()) + FunctionModified = true; - DEBUG(dbgs() << "ASAN done instrumenting: " << res << " " << F << "\n"); + DEBUG(dbgs() << "ASAN done instrumenting: " << FunctionModified << " " + << F << "\n"); - return res; + return FunctionModified; } // Workaround for bug 11395: we don't want to instrument stack in functions