From: Andreas Gampe Date: Fri, 20 Feb 2015 02:21:24 +0000 (-0800) Subject: ART: Add -Wunused X-Git-Tag: android-x86-7.1-r1~889^2~1957^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7c3952f423b8213083d60596a5f0bf4237ca3f7b;p=android-x86%2Fart.git ART: Add -Wunused Until the global CFLAGS are fixed, add Wunused. Fix declarations in the optimizing compiler. Change-Id: Ic4553f08e809dc54f3d82af57ac592622c98e000 --- diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk index 3000cdf08..36c9342e3 100644 --- a/build/Android.common_build.mk +++ b/build/Android.common_build.mk @@ -191,6 +191,7 @@ art_cflags := \ -Wunreachable-code \ -Wredundant-decls \ -Wshadow \ + -Wunused \ -fvisibility=protected \ $(art_default_gc_type_cflags) diff --git a/compiler/optimizing/bounds_check_elimination.h b/compiler/optimizing/bounds_check_elimination.h index 05cb185ed..9e98ccf4b 100644 --- a/compiler/optimizing/bounds_check_elimination.h +++ b/compiler/optimizing/bounds_check_elimination.h @@ -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); }; diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h index 3e4a6169d..96196de58 100644 --- a/compiler/optimizing/builder.h +++ b/compiler/optimizing/builder.h @@ -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 diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index c59273753..cabfa488c 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -17,8 +17,10 @@ #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) { diff --git a/compiler/optimizing/gvn.h b/compiler/optimizing/gvn.h index 57e0487fc..e74d969f1 100644 --- a/compiler/optimizing/gvn.h +++ b/compiler/optimizing/gvn.h @@ -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_; diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h index 8e9cf837d..2b08d3d91 100644 --- a/compiler/optimizing/inliner.h +++ b/compiler/optimizing/inliner.h @@ -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; diff --git a/compiler/optimizing/instruction_simplifier.h b/compiler/optimizing/instruction_simplifier.h index a7ff755ae..024462081 100644 --- a/compiler/optimizing/instruction_simplifier.h +++ b/compiler/optimizing/instruction_simplifier.h @@ -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; }; diff --git a/compiler/optimizing/intrinsics.h b/compiler/optimizing/intrinsics.h index 29cc8efcc..dbb7cbaa9 100644 --- a/compiler/optimizing/intrinsics.h +++ b/compiler/optimizing/intrinsics.h @@ -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_; diff --git a/compiler/optimizing/licm.h b/compiler/optimizing/licm.h index 4812394a3..cb6170e96 100644 --- a/compiler/optimizing/licm.h +++ b/compiler/optimizing/licm.h @@ -31,6 +31,8 @@ class LICM : public HOptimization { void Run() OVERRIDE; + static constexpr const char* kLoopInvariantCodeMotionPassName = "licm"; + private: const SideEffectsAnalysis& side_effects_; diff --git a/compiler/optimizing/optimization.h b/compiler/optimizing/optimization.h index af39e092c..8b2028177 100644 --- a/compiler/optimizing/optimization.h +++ b/compiler/optimizing/optimization.h @@ -22,12 +22,6 @@ 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. */ diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 2fef8c7b3..eb984248a 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -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"; diff --git a/compiler/optimizing/reference_type_propagation.h b/compiler/optimizing/reference_type_propagation.h index 815caab4f..733e18e68 100644 --- a/compiler/optimizing/reference_type_propagation.h +++ b/compiler/optimizing/reference_type_propagation.h @@ -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); diff --git a/compiler/optimizing/register_allocator.h b/compiler/optimizing/register_allocator.h index ff2f106b7..579f069f5 100644 --- a/compiler/optimizing/register_allocator.h +++ b/compiler/optimizing/register_allocator.h @@ -81,6 +81,8 @@ class RegisterAllocator { + double_spill_slots_.Size(); } + static constexpr const char* kRegisterAllocatorPassName = "register"; + private: // Main methods of the allocator. void LinearScan(); diff --git a/compiler/optimizing/side_effects_analysis.h b/compiler/optimizing/side_effects_analysis.h index f1c98ac21..415d10cd9 100644 --- a/compiler/optimizing/side_effects_analysis.h +++ b/compiler/optimizing/side_effects_analysis.h @@ -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); diff --git a/compiler/optimizing/ssa_builder.h b/compiler/optimizing/ssa_builder.h index 148e9590c..f50da4604 100644 --- a/compiler/optimizing/ssa_builder.h +++ b/compiler/optimizing/ssa_builder.h @@ -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_; diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h index 0e68a6128..be7262945 100644 --- a/compiler/optimizing/ssa_liveness_analysis.h +++ b/compiler/optimizing/ssa_liveness_analysis.h @@ -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, diff --git a/compiler/optimizing/ssa_phi_elimination.h b/compiler/optimizing/ssa_phi_elimination.h index 88a5279e1..c4b63ab0e 100644 --- a/compiler/optimizing/ssa_phi_elimination.h +++ b/compiler/optimizing/ssa_phi_elimination.h @@ -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 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 worklist_; diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc index 6acc2a782..0d41a8fd2 100644 --- a/runtime/arch/stub_test.cc +++ b/runtime/arch/stub_test.cc @@ -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* f, Thread* self, EXPECT_EQ(values[i], static_cast(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* f, Thread* self, EXPECT_EQ(values[i], static_cast(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* obj, Handle(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* obj, Handle(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* f, Thread* self, mirror:: EXPECT_EQ(values[i], static_cast(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* f, Thread* self, EXPECT_EQ(static_cast(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* obj, Handle(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* obj, Handle(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* 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* obj, Handle(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* 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* obj, HandleGet(), 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; diff --git a/test/004-SignalTest/signaltest.cc b/test/004-SignalTest/signaltest.cc index 31371f6d2..876d27ec2 100644 --- a/test/004-SignalTest/signaltest.cc +++ b/test/004-SignalTest/signaltest.cc @@ -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(context); uc->CTX_EIP += 3; +#else + UNUSED(context); #endif }