OSDN Git Service

ART: Add -Wunused
authorAndreas Gampe <agampe@google.com>
Fri, 20 Feb 2015 02:21:24 +0000 (18:21 -0800)
committerAndreas Gampe <agampe@google.com>
Tue, 24 Feb 2015 23:57:15 +0000 (15:57 -0800)
Until the global CFLAGS are fixed, add Wunused. Fix declarations
in the optimizing compiler.

Change-Id: Ic4553f08e809dc54f3d82af57ac592622c98e000

19 files changed:
build/Android.common_build.mk
compiler/optimizing/bounds_check_elimination.h
compiler/optimizing/builder.h
compiler/optimizing/graph_visualizer.cc
compiler/optimizing/gvn.h
compiler/optimizing/inliner.h
compiler/optimizing/instruction_simplifier.h
compiler/optimizing/intrinsics.h
compiler/optimizing/licm.h
compiler/optimizing/optimization.h
compiler/optimizing/optimizing_compiler.cc
compiler/optimizing/reference_type_propagation.h
compiler/optimizing/register_allocator.h
compiler/optimizing/side_effects_analysis.h
compiler/optimizing/ssa_builder.h
compiler/optimizing/ssa_liveness_analysis.h
compiler/optimizing/ssa_phi_elimination.h
runtime/arch/stub_test.cc
test/004-SignalTest/signaltest.cc

index 3000cdf..36c9342 100644 (file)
@@ -191,6 +191,7 @@ art_cflags := \
   -Wunreachable-code \
   -Wredundant-decls \
   -Wshadow \
+  -Wunused \
   -fvisibility=protected \
   $(art_default_gc_type_cflags)
 
index 05cb185..9e98ccf 100644 (file)
@@ -23,10 +23,13 @@ namespace art {
 
 class BoundsCheckElimination : public HOptimization {
  public:
-  explicit BoundsCheckElimination(HGraph* graph) : HOptimization(graph, true, "BCE") {}
+  explicit BoundsCheckElimination(HGraph* graph)
+      : HOptimization(graph, true, kBoundsCheckEliminiationPassName) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kBoundsCheckEliminiationPassName = "BCE";
+
  private:
   DISALLOW_COPY_AND_ASSIGN(BoundsCheckElimination);
 };
index 3e4a616..96196de 100644 (file)
@@ -80,6 +80,8 @@ class HGraphBuilder : public ValueObject {
 
   bool BuildGraph(const DexFile::CodeItem& code);
 
+  static constexpr const char* kBuilderPassName = "builder";
+
  private:
   // Analyzes the dex instruction and adds HInstruction to the graph
   // to execute that instruction. Returns whether the instruction can
index c592737..cabfa48 100644 (file)
 #include "graph_visualizer.h"
 
 #include "code_generator.h"
+#include "licm.h"
 #include "nodes.h"
 #include "optimization.h"
+#include "register_allocator.h"
 #include "ssa_liveness_analysis.h"
 
 namespace art {
@@ -188,6 +190,10 @@ class HGraphVisualizerPrinter : public HGraphVisitor {
     output_ << " " << phi->GetRegNumber();
   }
 
+  bool IsPass(const char* name) {
+    return strcmp(pass_name_, name) == 0;
+  }
+
   void PrintInstruction(HInstruction* instruction) {
     output_ << instruction->DebugName();
     instruction->Accept(this);
@@ -211,7 +217,7 @@ class HGraphVisualizerPrinter : public HGraphVisitor {
       }
       output_ << "])";
     }
-    if (pass_name_ == kLivenessPassName
+    if (IsPass(SsaLivenessAnalysis::kLivenessPassName)
         && is_after_pass_
         && instruction->GetLifetimePosition() != kNoLifetime) {
       output_ << " (liveness: " << instruction->GetLifetimePosition();
@@ -221,7 +227,7 @@ class HGraphVisualizerPrinter : public HGraphVisitor {
         interval.Dump(output_);
       }
       output_ << ")";
-    } else if (pass_name_ == kRegisterAllocatorPassName && is_after_pass_) {
+    } else if (IsPass(RegisterAllocator::kRegisterAllocatorPassName) && is_after_pass_) {
       LocationSummary* locations = instruction->GetLocations();
       if (locations != nullptr) {
         output_ << " ( ";
@@ -236,7 +242,7 @@ class HGraphVisualizerPrinter : public HGraphVisitor {
         }
       }
       output_ << " (liveness: " << instruction->GetLifetimePosition() << ")";
-    } else if (pass_name_ == kLoopInvariantCodeMotionPassName) {
+    } else if (IsPass(LICM::kLoopInvariantCodeMotionPassName)) {
       output_ << " ( loop_header:";
       HLoopInformation* info = instruction->GetBlock()->GetLoopInformation();
       if (info == nullptr) {
index 57e0487..e74d969 100644 (file)
@@ -27,10 +27,12 @@ class SideEffectsAnalysis;
 class GVNOptimization : public HOptimization {
  public:
   GVNOptimization(HGraph* graph, const SideEffectsAnalysis& side_effects)
-      : HOptimization(graph, true, "GVN"), side_effects_(side_effects) {}
+      : HOptimization(graph, true, kGlobalValueNumberingPassName), side_effects_(side_effects) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kGlobalValueNumberingPassName = "GVN";
+
  private:
   const SideEffectsAnalysis& side_effects_;
 
index 8e9cf83..2b08d3d 100644 (file)
@@ -35,13 +35,15 @@ class HInliner : public HOptimization {
            CompilerDriver* compiler_driver,
            OptimizingCompilerStats* stats,
            size_t depth = 0)
-      : HOptimization(outer_graph, true, "inliner", stats),
+      : HOptimization(outer_graph, true, kInlinerPassName, stats),
         outer_compilation_unit_(outer_compilation_unit),
         compiler_driver_(compiler_driver),
         depth_(depth) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kInlinerPassName = "inliner";
+
  private:
   bool TryInline(HInvoke* invoke_instruction, uint32_t method_index, InvokeType invoke_type) const;
 
index a7ff755..0244620 100644 (file)
@@ -30,9 +30,11 @@ class InstructionSimplifier : public HOptimization {
  public:
   InstructionSimplifier(HGraph* graph,
                         OptimizingCompilerStats* stats = nullptr,
-                        const char* name = "instruction_simplifier")
+                        const char* name = kInstructionSimplifierPassName)
     : HOptimization(graph, true, name, stats) {}
 
+  static constexpr const char* kInstructionSimplifierPassName = "instruction_simplifier";
+
   void Run() OVERRIDE;
 };
 
index 29cc8ef..dbb7cba 100644 (file)
@@ -29,11 +29,13 @@ class DexFile;
 class IntrinsicsRecognizer : public HOptimization {
  public:
   IntrinsicsRecognizer(HGraph* graph, const DexFile* dex_file, CompilerDriver* driver)
-      : HOptimization(graph, true, "intrinsics_recognition"),
+      : HOptimization(graph, true, kIntrinsicsRecognizerPassName),
         dex_file_(dex_file), driver_(driver) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kIntrinsicsRecognizerPassName = "intrinsics_recognition";
+
  private:
   const DexFile* dex_file_;
   CompilerDriver* driver_;
index 4812394..cb6170e 100644 (file)
@@ -31,6 +31,8 @@ class LICM : public HOptimization {
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kLoopInvariantCodeMotionPassName = "licm";
+
  private:
   const SideEffectsAnalysis& side_effects_;
 
index af39e09..8b20281 100644 (file)
 
 namespace art {
 
-static const char* kBuilderPassName = "builder";
-static const char* kSsaBuilderPassName = "ssa_builder";
-static const char* kLivenessPassName = "liveness";
-static const char* kRegisterAllocatorPassName = "register";
-static const char* kLoopInvariantCodeMotionPassName = "licm";
-
 /**
  * Abstraction to implement an optimization pass.
  */
index 2fef8c7..eb98424 100644 (file)
@@ -56,7 +56,7 @@ namespace art {
  */
 class CodeVectorAllocator FINAL : public CodeAllocator {
  public:
-  CodeVectorAllocator() {}
+  CodeVectorAllocator() : size_(0) {}
 
   virtual uint8_t* Allocate(size_t size) {
     size_ = size;
@@ -361,11 +361,11 @@ CompiledMethod* OptimizingCompiler::CompileOptimized(HGraph* graph,
   PrepareForRegisterAllocation(graph).Run();
   SsaLivenessAnalysis liveness(*graph, codegen);
   {
-    PassInfo pass_info(kLivenessPassName, pass_info_printer);
+    PassInfo pass_info(SsaLivenessAnalysis::kLivenessPassName, pass_info_printer);
     liveness.Analyze();
   }
   {
-    PassInfo pass_info(kRegisterAllocatorPassName, pass_info_printer);
+    PassInfo pass_info(RegisterAllocator::kRegisterAllocatorPassName, pass_info_printer);
     RegisterAllocator(graph->GetArena(), codegen, liveness).AllocateRegisters();
   }
 
@@ -495,7 +495,7 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item,
   VLOG(compiler) << "Building " << method_name;
 
   {
-    PassInfo pass_info(kBuilderPassName, &pass_info_printer);
+    PassInfo pass_info(HGraphBuilder::kBuilderPassName, &pass_info_printer);
     if (!builder.BuildGraph(*code_item)) {
       CHECK(!shouldCompile) << "Could not build graph in optimizing compiler";
       return nullptr;
@@ -508,7 +508,7 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item,
     VLOG(compiler) << "Optimizing " << method_name;
 
     {
-      PassInfo pass_info(kSsaBuilderPassName, &pass_info_printer);
+      PassInfo pass_info(SsaBuilder::kSsaBuilderPassName, &pass_info_printer);
       if (!graph->TryBuildingSsa()) {
         // We could not transform the graph to SSA, bailout.
         LOG(INFO) << "Skipping compilation of " << method_name << ": it contains a non natural loop";
index 815caab..733e18e 100644 (file)
@@ -34,7 +34,7 @@ class ReferenceTypePropagation : public HOptimization {
                            const DexFile& dex_file,
                            const DexCompilationUnit& dex_compilation_unit,
                            StackHandleScopeCollection* handles)
-    : HOptimization(graph, true, "reference_type_propagation"),
+    : HOptimization(graph, true, kReferenceTypePropagationPassName),
       dex_file_(dex_file),
       dex_compilation_unit_(dex_compilation_unit),
       handles_(handles),
@@ -42,6 +42,8 @@ class ReferenceTypePropagation : public HOptimization {
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kReferenceTypePropagationPassName = "reference_type_propagation";
+
  private:
   void VisitNewInstance(HNewInstance* new_instance);
   void VisitLoadClass(HLoadClass* load_class);
index ff2f106..579f069 100644 (file)
@@ -81,6 +81,8 @@ class RegisterAllocator {
         + double_spill_slots_.Size();
   }
 
+  static constexpr const char* kRegisterAllocatorPassName = "register";
+
  private:
   // Main methods of the allocator.
   void LinearScan();
index f1c98ac..415d10c 100644 (file)
@@ -25,7 +25,7 @@ namespace art {
 class SideEffectsAnalysis : public HOptimization {
  public:
   explicit SideEffectsAnalysis(HGraph* graph)
-      : HOptimization(graph, true, "SideEffects"),
+      : HOptimization(graph, true, kSideEffectsAnalysisPassName),
         graph_(graph),
         block_effects_(graph->GetArena(), graph->GetBlocks().Size(), SideEffects::None()),
         loop_effects_(graph->GetArena(), graph->GetBlocks().Size(), SideEffects::None()) {}
@@ -38,6 +38,8 @@ class SideEffectsAnalysis : public HOptimization {
 
   bool HasRun() const { return has_run_; }
 
+  static constexpr const char* kSideEffectsAnalysisPassName = "SideEffects";
+
  private:
   void UpdateLoopEffects(HLoopInformation* info, SideEffects effects);
 
index 148e959..f50da46 100644 (file)
@@ -60,6 +60,8 @@ class SsaBuilder : public HGraphVisitor {
 
   static HInstruction* GetReferenceTypeEquivalent(HInstruction* instruction);
 
+  static constexpr const char* kSsaBuilderPassName = "ssa_builder";
+
  private:
   // Locals for the current block being visited.
   HEnvironment* current_locals_;
index 0e68a61..be72629 100644 (file)
@@ -816,6 +816,8 @@ class SsaLivenessAnalysis : public ValueObject {
     return number_of_ssa_values_;
   }
 
+  static constexpr const char* kLivenessPassName = "liveness";
+
  private:
   // Linearize the graph so that:
   // (1): a block is always after its dominator,
index 88a5279..c4b63ab 100644 (file)
@@ -29,7 +29,7 @@ namespace art {
 class SsaDeadPhiElimination : public HOptimization {
  public:
   explicit SsaDeadPhiElimination(HGraph* graph)
-      : HOptimization(graph, true, "dead_phi_elimination"),
+      : HOptimization(graph, true, kSsaDeadPhiEliminationPassName),
         worklist_(graph->GetArena(), kDefaultWorklistSize) {}
 
   void Run() OVERRIDE;
@@ -37,6 +37,8 @@ class SsaDeadPhiElimination : public HOptimization {
   void MarkDeadPhis();
   void EliminateDeadPhis();
 
+  static constexpr const char* kSsaDeadPhiEliminationPassName = "dead_phi_elimination";
+
  private:
   GrowableArray<HPhi*> worklist_;
 
@@ -54,11 +56,13 @@ class SsaDeadPhiElimination : public HOptimization {
 class SsaRedundantPhiElimination : public HOptimization {
  public:
   explicit SsaRedundantPhiElimination(HGraph* graph)
-      : HOptimization(graph, true, "redundant_phi_elimination"),
+      : HOptimization(graph, true, kSsaRedundantPhiEliminationPassName),
         worklist_(graph->GetArena(), kDefaultWorklistSize) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kSsaRedundantPhiEliminationPassName = "redundant_phi_elimination";
+
  private:
   GrowableArray<HPhi*> worklist_;
 
index 6acc2a7..0d41a8f 100644 (file)
@@ -278,6 +278,7 @@ class StubTest : public CommonRuntimeTest {
           "memory");  // clobber all
     // TODO: Should we clobber the other registers?
 #else
+    UNUSED(arg0, arg1, arg2, code, referrer);
     LOG(WARNING) << "Was asked to invoke for an architecture I do not understand.";
     result = 0;
 #endif
@@ -503,6 +504,7 @@ class StubTest : public CommonRuntimeTest {
           "memory");  // clobber all
     // TODO: Should we clobber the other registers?
 #else
+    UNUSED(arg0, arg1, arg2, code, referrer, hidden);
     LOG(WARNING) << "Was asked to invoke for an architecture I do not understand.";
     result = 0;
 #endif
@@ -792,6 +794,7 @@ static void TestUnlockObject(StubTest* test) NO_THREAD_SAFETY_ANALYSIS {
 
   // Test done.
 #else
+  UNUSED(test);
   LOG(INFO) << "Skipping unlock_object as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping unlock_object as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1326,6 +1329,7 @@ static void GetSetBooleanStatic(Handle<mirror::ArtField>* f, Thread* self,
     EXPECT_EQ(values[i], static_cast<uint8_t>(res)) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set_boolean_static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_boolean_static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1353,6 +1357,7 @@ static void GetSetByteStatic(Handle<mirror::ArtField>* f, Thread* self,
     EXPECT_EQ(values[i], static_cast<int8_t>(res)) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set_byte_static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_byte_static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1388,6 +1393,7 @@ static void GetSetBooleanInstance(Handle<mirror::Object>* obj, Handle<mirror::Ar
     EXPECT_EQ(res, static_cast<uint8_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set_boolean_instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_boolean_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1420,6 +1426,7 @@ static void GetSetByteInstance(Handle<mirror::Object>* obj, Handle<mirror::ArtFi
     EXPECT_EQ(res, static_cast<int8_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set_byte_instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_byte_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1449,6 +1456,7 @@ static void GetSetCharStatic(Handle<mirror::ArtField>* f, Thread* self, mirror::
     EXPECT_EQ(values[i], static_cast<uint16_t>(res)) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set_char_static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_char_static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1477,6 +1485,7 @@ static void GetSetShortStatic(Handle<mirror::ArtField>* f, Thread* self,
     EXPECT_EQ(static_cast<int16_t>(res), values[i]) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set_short_static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_short_static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1510,6 +1519,7 @@ static void GetSetCharInstance(Handle<mirror::Object>* obj, Handle<mirror::ArtFi
     EXPECT_EQ(res, static_cast<uint16_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set_char_instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_char_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1542,6 +1552,7 @@ static void GetSetShortInstance(Handle<mirror::Object>* obj, Handle<mirror::ArtF
     EXPECT_EQ(res, static_cast<int16_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set_short_instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_short_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1571,6 +1582,7 @@ static void GetSet32Static(Handle<mirror::ArtField>* f, Thread* self, mirror::Ar
     EXPECT_EQ(res, values[i]) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set32static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set32static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1607,6 +1619,7 @@ static void GetSet32Instance(Handle<mirror::Object>* obj, Handle<mirror::ArtFiel
     EXPECT_EQ(res, static_cast<int32_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set32instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set32instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1648,6 +1661,7 @@ static void GetSetObjStatic(Handle<mirror::ArtField>* f, Thread* self, mirror::A
 
   set_and_check_static((*f)->GetDexFieldIndex(), nullptr, self, referrer, test);
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping setObjstatic as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping setObjstatic as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1692,6 +1706,7 @@ static void GetSetObjInstance(Handle<mirror::Object>* obj, Handle<mirror::ArtFie
 
   set_and_check_instance(f, obj->Get(), nullptr, self, referrer, test);
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping setObjinstance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping setObjinstance as I don't know how to do that on " << kRuntimeISA << std::endl;
index 31371f6..876d27e 100644 (file)
@@ -65,6 +65,8 @@ static void signalhandler(int sig ATTRIBUTE_UNUSED, siginfo_t* info ATTRIBUTE_UN
 #elif defined(__i386__) || defined(__x86_64__)
   struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
   uc->CTX_EIP += 3;
+#else
+  UNUSED(context);
 #endif
 }