Commit b45f7186 authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

[gcmole] Enable extra logging for --dead-vars

Bug: v8:10009
Change-Id: Iccc42a9b5f9f7340851542185473ac49683c838c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2253843Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68430}
parent a2ef686f
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
namespace { namespace {
bool g_tracing_enabled = false; bool g_tracing_enabled = false;
bool g_dead_vars_analysis = false;
#define TRACE(str) \ #define TRACE(str) \
do { \ do { \
...@@ -61,9 +62,11 @@ bool g_tracing_enabled = false; ...@@ -61,9 +62,11 @@ bool g_tracing_enabled = false;
} \ } \
} while (false) } while (false)
// Node: The following is used when tracing --dead-vars
// to provide extra info for the GC suspect.
#define TRACE_LLVM_DECL(str, decl) \ #define TRACE_LLVM_DECL(str, decl) \
do { \ do { \
if (g_tracing_enabled) { \ if (g_dead_vars_analysis) { \
std::cout << str << std::endl; \ std::cout << str << std::endl; \
decl->dump(); \ decl->dump(); \
} \ } \
...@@ -678,8 +681,7 @@ class FunctionAnalyzer { ...@@ -678,8 +681,7 @@ class FunctionAnalyzer {
clang::CXXRecordDecl* smi_decl, clang::CXXRecordDecl* smi_decl,
clang::CXXRecordDecl* no_gc_decl, clang::CXXRecordDecl* no_gc_decl,
clang::CXXRecordDecl* no_heap_access_decl, clang::CXXRecordDecl* no_heap_access_decl,
clang::DiagnosticsEngine& d, clang::SourceManager& sm, clang::DiagnosticsEngine& d, clang::SourceManager& sm)
bool dead_vars_analysis)
: ctx_(ctx), : ctx_(ctx),
object_decl_(object_decl), object_decl_(object_decl),
maybe_object_decl_(maybe_object_decl), maybe_object_decl_(maybe_object_decl),
...@@ -688,8 +690,7 @@ class FunctionAnalyzer { ...@@ -688,8 +690,7 @@ class FunctionAnalyzer {
no_heap_access_decl_(no_heap_access_decl), no_heap_access_decl_(no_heap_access_decl),
d_(d), d_(d),
sm_(sm), sm_(sm),
block_(NULL), block_(NULL) {}
dead_vars_analysis_(dead_vars_analysis) {}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Expressions // Expressions
...@@ -985,7 +986,7 @@ class FunctionAnalyzer { ...@@ -985,7 +986,7 @@ class FunctionAnalyzer {
// pointers produces too many false positives in the dead variable // pointers produces too many false positives in the dead variable
// analysis. // analysis.
if (IsInternalPointerType(var_type) && !env.IsAlive(var_name) && if (IsInternalPointerType(var_type) && !env.IsAlive(var_name) &&
!HasActiveGuard() && dead_vars_analysis_) { !HasActiveGuard() && g_dead_vars_analysis) {
ReportUnsafe(parent, DEAD_VAR_MSG); ReportUnsafe(parent, DEAD_VAR_MSG);
} }
return ExprEffect::RawUse(); return ExprEffect::RawUse();
...@@ -1491,7 +1492,6 @@ class FunctionAnalyzer { ...@@ -1491,7 +1492,6 @@ class FunctionAnalyzer {
clang::SourceManager& sm_; clang::SourceManager& sm_;
Block* block_; Block* block_;
bool dead_vars_analysis_;
struct GCGuard { struct GCGuard {
clang::CompoundStmt* stmt = NULL; clang::CompoundStmt* stmt = NULL;
...@@ -1508,10 +1508,10 @@ class ProblemsFinder : public clang::ASTConsumer, ...@@ -1508,10 +1508,10 @@ class ProblemsFinder : public clang::ASTConsumer,
public: public:
ProblemsFinder(clang::DiagnosticsEngine& d, clang::SourceManager& sm, ProblemsFinder(clang::DiagnosticsEngine& d, clang::SourceManager& sm,
const std::vector<std::string>& args) const std::vector<std::string>& args)
: d_(d), sm_(sm), dead_vars_analysis_(false) { : d_(d), sm_(sm) {
for (unsigned i = 0; i < args.size(); ++i) { for (unsigned i = 0; i < args.size(); ++i) {
if (args[i] == "--dead-vars") { if (args[i] == "--dead-vars") {
dead_vars_analysis_ = true; g_dead_vars_analysis = true;
} }
if (args[i] == "--verbose") { if (args[i] == "--verbose") {
g_tracing_enabled = true; g_tracing_enabled = true;
...@@ -1559,10 +1559,10 @@ class ProblemsFinder : public clang::ASTConsumer, ...@@ -1559,10 +1559,10 @@ class ProblemsFinder : public clang::ASTConsumer,
no_heap_access_decl = no_heap_access_decl->getDefinition(); no_heap_access_decl = no_heap_access_decl->getDefinition();
if (object_decl != NULL && smi_decl != NULL && maybe_object_decl != NULL) { if (object_decl != NULL && smi_decl != NULL && maybe_object_decl != NULL) {
function_analyzer_ = new FunctionAnalyzer( function_analyzer_ =
clang::ItaniumMangleContext::create(ctx, d_), object_decl, new FunctionAnalyzer(clang::ItaniumMangleContext::create(ctx, d_),
maybe_object_decl, smi_decl, no_gc_decl, no_heap_access_decl, d_, sm_, object_decl, maybe_object_decl, smi_decl,
dead_vars_analysis_); no_gc_decl, no_heap_access_decl, d_, sm_);
TraverseDecl(ctx.getTranslationUnitDecl()); TraverseDecl(ctx.getTranslationUnitDecl());
} else { } else {
if (object_decl == NULL) { if (object_decl == NULL) {
...@@ -1595,7 +1595,6 @@ class ProblemsFinder : public clang::ASTConsumer, ...@@ -1595,7 +1595,6 @@ class ProblemsFinder : public clang::ASTConsumer,
private: private:
clang::DiagnosticsEngine& d_; clang::DiagnosticsEngine& d_;
clang::SourceManager& sm_; clang::SourceManager& sm_;
bool dead_vars_analysis_;
FunctionAnalyzer* function_analyzer_; FunctionAnalyzer* function_analyzer_;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment