ART: Add -Wunused
Until the global CFLAGS are fixed, add Wunused. Fix declarations
in the optimizing compiler.
Change-Id: Ic4553f08e809dc54f3d82af57ac592622c98e000
diff --git a/compiler/optimizing/bounds_check_elimination.h b/compiler/optimizing/bounds_check_elimination.h
index 05cb185..9e98ccf 100644
--- a/compiler/optimizing/bounds_check_elimination.h
+++ b/compiler/optimizing/bounds_check_elimination.h
@@ -23,10 +23,13 @@
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 3e4a616..96196de 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -80,6 +80,8 @@
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 c592737..cabfa48 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 @@
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 @@
}
output_ << "])";
}
- if (pass_name_ == kLivenessPassName
+ if (IsPass(SsaLivenessAnalysis::kLivenessPassName)
&& is_after_pass_
&& instruction->GetLifetimePosition() != kNoLifetime) {
output_ << " (liveness: " << instruction->GetLifetimePosition();
@@ -221,7 +227,7 @@
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 @@
}
}
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 57e0487..e74d969 100644
--- a/compiler/optimizing/gvn.h
+++ b/compiler/optimizing/gvn.h
@@ -27,10 +27,12 @@
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 8e9cf83..2b08d3d 100644
--- a/compiler/optimizing/inliner.h
+++ b/compiler/optimizing/inliner.h
@@ -35,13 +35,15 @@
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 a7ff755..0244620 100644
--- a/compiler/optimizing/instruction_simplifier.h
+++ b/compiler/optimizing/instruction_simplifier.h
@@ -30,9 +30,11 @@
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 29cc8ef..dbb7cba 100644
--- a/compiler/optimizing/intrinsics.h
+++ b/compiler/optimizing/intrinsics.h
@@ -29,11 +29,13 @@
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 4812394..cb6170e 100644
--- a/compiler/optimizing/licm.h
+++ b/compiler/optimizing/licm.h
@@ -31,6 +31,8 @@
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 af39e09..8b20281 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 2fef8c7..eb98424 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -56,7 +56,7 @@
*/
class CodeVectorAllocator FINAL : public CodeAllocator {
public:
- CodeVectorAllocator() {}
+ CodeVectorAllocator() : size_(0) {}
virtual uint8_t* Allocate(size_t size) {
size_ = size;
@@ -361,11 +361,11 @@
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 @@
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 @@
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 815caab..733e18e 100644
--- a/compiler/optimizing/reference_type_propagation.h
+++ b/compiler/optimizing/reference_type_propagation.h
@@ -34,7 +34,7 @@
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 @@
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 ff2f106..579f069 100644
--- a/compiler/optimizing/register_allocator.h
+++ b/compiler/optimizing/register_allocator.h
@@ -81,6 +81,8 @@
+ 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 f1c98ac..415d10c 100644
--- a/compiler/optimizing/side_effects_analysis.h
+++ b/compiler/optimizing/side_effects_analysis.h
@@ -25,7 +25,7 @@
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 @@
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 148e959..f50da46 100644
--- a/compiler/optimizing/ssa_builder.h
+++ b/compiler/optimizing/ssa_builder.h
@@ -60,6 +60,8 @@
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 0e68a61..be72629 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -816,6 +816,8 @@
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 88a5279..c4b63ab 100644
--- a/compiler/optimizing/ssa_phi_elimination.h
+++ b/compiler/optimizing/ssa_phi_elimination.h
@@ -29,7 +29,7 @@
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 @@
void MarkDeadPhis();
void EliminateDeadPhis();
+ static constexpr const char* kSsaDeadPhiEliminationPassName = "dead_phi_elimination";
+
private:
GrowableArray<HPhi*> worklist_;
@@ -54,11 +56,13 @@
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_;