Commit 9c234e2a by Jim Stichnoth

Subzero: Allow builds with assertions disabled.

1. Setting command-line make variable NOASSERT=1 adds -DNDEBUG and builds in a separate directory. By default, we still get Release+Asserts. 2. Add "(void)foo;" as necessary when foo is only used in an assert(), to remove warnings. 3. Minimize inclusion of llvm/Support/Timer.h because it adds warnings. 4. Call validateLiveness() only when asserts are enabled, because it's relatively expensive. BUG= none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/623493002
parent a18cc9c6
...@@ -45,6 +45,13 @@ else ...@@ -45,6 +45,13 @@ else
OPTLEVEL = -O2 OPTLEVEL = -O2
endif endif
ifdef NOASSERT
ASSERTIONS = -DNDEBUG
else
ASSERTIONS =
OBJDIR := $(OBJDIR)+Asserts
endif
$(info -----------------------------------------------) $(info -----------------------------------------------)
$(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH)) $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH))
$(info Using LLVM_BIN_PATH = $(LLVM_BIN_PATH)) $(info Using LLVM_BIN_PATH = $(LLVM_BIN_PATH))
...@@ -62,7 +69,7 @@ CCACHE := `command -v ccache` ...@@ -62,7 +69,7 @@ CCACHE := `command -v ccache`
CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++ CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++
CXXFLAGS := $(LLVM_CXXFLAGS) -std=c++11 -Wall -Wextra -Werror -fno-rtti \ CXXFLAGS := $(LLVM_CXXFLAGS) -std=c++11 -Wall -Wextra -Werror -fno-rtti \
-fno-exceptions $(OPTLEVEL) -g $(HOST_FLAGS) \ -fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g $(HOST_FLAGS) \
-Wno-error=unused-parameter -I$(LIBCXX_INSTALL_PATH)/include/c++/v1 -Wno-error=unused-parameter -I$(LIBCXX_INSTALL_PATH)/include/c++/v1
LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib
......
...@@ -637,7 +637,6 @@ void Converter::convertFunctions() { ...@@ -637,7 +637,6 @@ void Converter::convertFunctions() {
continue; continue;
LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext()); LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext());
Timer TConvert;
Cfg *Fcn = FunctionConverter.convertFunction(I); Cfg *Fcn = FunctionConverter.convertFunction(I);
translateFcn(Fcn); translateFcn(Fcn);
} }
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "llvm/Support/Casting.h" #include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h" // LLVM_STATIC_ASSERT #include "llvm/Support/Compiler.h" // LLVM_STATIC_ASSERT
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Timer.h"
// Roll our own static_assert<> in the absence of C++11. TODO: change // Roll our own static_assert<> in the absence of C++11. TODO: change
// to static_assert<> with C++11. // to static_assert<> with C++11.
......
...@@ -355,11 +355,9 @@ void TargetX8632::translateO2() { ...@@ -355,11 +355,9 @@ void TargetX8632::translateO2() {
Func->liveness(Liveness_Intervals); Func->liveness(Liveness_Intervals);
if (Func->hasError()) if (Func->hasError())
return; return;
// Validate the live range computations. Do it outside the timing // Validate the live range computations. The expensive validation
// code. TODO: Put this under a flag. // call is deliberately only made when assertions are enabled.
bool ValidLiveness = Func->validateLiveness(); assert(Func->validateLiveness());
assert(ValidLiveness);
(void)ValidLiveness; // used only in assert()
ComputedLiveRanges = true; ComputedLiveRanges = true;
// The post-codegen dump is done here, after liveness analysis and // The post-codegen dump is done here, after liveness analysis and
// associated cleanup, to make the dump cleaner and more useful. // associated cleanup, to make the dump cleaner and more useful.
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Support/Timer.h"
#include "IceDefs.h" #include "IceDefs.h"
#include "IceTimerTree.h" #include "IceTimerTree.h"
...@@ -139,4 +141,9 @@ void TimerStack::dump(Ostream &Str) { ...@@ -139,4 +141,9 @@ void TimerStack::dump(Ostream &Str) {
Str << "Number of timer updates: " << StateChangeCount << "\n"; Str << "Number of timer updates: " << StateChangeCount << "\n";
} }
double TimerStack::timestamp() {
// TODO: Implement in terms of std::chrono for C++11.
return llvm::TimeRecord::getCurrentTime(false).getWallTime();
}
} // end of namespace Ice } // end of namespace Ice
...@@ -50,10 +50,7 @@ public: ...@@ -50,10 +50,7 @@ public:
private: private:
void update(); void update();
static double timestamp() { static double timestamp();
// TODO: Implement in terms of std::chrono for C++11.
return llvm::TimeRecord::getCurrentTime(false).getWallTime();
}
const double FirstTimestamp; const double FirstTimestamp;
double LastTimestamp; double LastTimestamp;
uint64_t StateChangeCount; uint64_t StateChangeCount;
......
...@@ -91,6 +91,7 @@ void AssemblerX86::call(const ConstantRelocatable *label) { ...@@ -91,6 +91,7 @@ void AssemblerX86::call(const ConstantRelocatable *label) {
EmitFixup(DirectCallRelocation::create(this, FK_PcRel_4, label)); EmitFixup(DirectCallRelocation::create(this, FK_PcRel_4, label));
EmitInt32(-4); EmitInt32(-4);
assert((buffer_.GetPosition() - call_start) == kCallExternalLabelSize); assert((buffer_.GetPosition() - call_start) == kCallExternalLabelSize);
(void)call_start;
} }
void AssemblerX86::pushl(GPRRegister reg) { void AssemblerX86::pushl(GPRRegister reg) {
...@@ -1749,6 +1750,7 @@ void AssemblerX86::notl(GPRRegister reg) { ...@@ -1749,6 +1750,7 @@ void AssemblerX86::notl(GPRRegister reg) {
void AssemblerX86::bswap(Type Ty, GPRRegister reg) { void AssemblerX86::bswap(Type Ty, GPRRegister reg) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_); AssemblerBuffer::EnsureCapacity ensured(&buffer_);
assert(Ty == IceType_i32); assert(Ty == IceType_i32);
(void)Ty;
EmitUint8(0x0F); EmitUint8(0x0F);
EmitUint8(0xC8 | reg); EmitUint8(0xC8 | reg);
} }
...@@ -2145,6 +2147,7 @@ void AssemblerX86::EmitGenericShift(int rm, const Operand &operand, ...@@ -2145,6 +2147,7 @@ void AssemblerX86::EmitGenericShift(int rm, const Operand &operand,
GPRRegister shifter) { GPRRegister shifter) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_); AssemblerBuffer::EnsureCapacity ensured(&buffer_);
assert(shifter == RegX8632::Encoded_Reg_ecx); assert(shifter == RegX8632::Encoded_Reg_ecx);
(void)shifter;
EmitUint8(0xD3); EmitUint8(0xD3);
EmitOperand(rm, Operand(operand)); EmitOperand(rm, Operand(operand));
} }
......
...@@ -329,6 +329,7 @@ public: ...@@ -329,6 +329,7 @@ public:
explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) { explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) {
// This mode is only needed and implemented for MIPS and ARM. // This mode is only needed and implemented for MIPS and ARM.
assert(!use_far_branches); assert(!use_far_branches);
(void)use_far_branches;
} }
~AssemblerX86() {} ~AssemblerX86() {}
......
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