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
OPTLEVEL = -O2
endif
ifdef NOASSERT
ASSERTIONS = -DNDEBUG
else
ASSERTIONS =
OBJDIR := $(OBJDIR)+Asserts
endif
$(info -----------------------------------------------)
$(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH))
$(info Using LLVM_BIN_PATH = $(LLVM_BIN_PATH))
......@@ -62,7 +69,7 @@ CCACHE := `command -v ccache`
CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++
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
LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib
......
......@@ -637,7 +637,6 @@ void Converter::convertFunctions() {
continue;
LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext());
Timer TConvert;
Cfg *Fcn = FunctionConverter.convertFunction(I);
translateFcn(Fcn);
}
......
......@@ -34,7 +34,6 @@
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h" // LLVM_STATIC_ASSERT
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Timer.h"
// Roll our own static_assert<> in the absence of C++11. TODO: change
// to static_assert<> with C++11.
......
......@@ -355,11 +355,9 @@ void TargetX8632::translateO2() {
Func->liveness(Liveness_Intervals);
if (Func->hasError())
return;
// Validate the live range computations. Do it outside the timing
// code. TODO: Put this under a flag.
bool ValidLiveness = Func->validateLiveness();
assert(ValidLiveness);
(void)ValidLiveness; // used only in assert()
// Validate the live range computations. The expensive validation
// call is deliberately only made when assertions are enabled.
assert(Func->validateLiveness());
ComputedLiveRanges = true;
// The post-codegen dump is done here, after liveness analysis and
// associated cleanup, to make the dump cleaner and more useful.
......
......@@ -12,6 +12,8 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/Timer.h"
#include "IceDefs.h"
#include "IceTimerTree.h"
......@@ -139,4 +141,9 @@ void TimerStack::dump(Ostream &Str) {
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
......@@ -50,10 +50,7 @@ public:
private:
void update();
static double timestamp() {
// TODO: Implement in terms of std::chrono for C++11.
return llvm::TimeRecord::getCurrentTime(false).getWallTime();
}
static double timestamp();
const double FirstTimestamp;
double LastTimestamp;
uint64_t StateChangeCount;
......
......@@ -91,6 +91,7 @@ void AssemblerX86::call(const ConstantRelocatable *label) {
EmitFixup(DirectCallRelocation::create(this, FK_PcRel_4, label));
EmitInt32(-4);
assert((buffer_.GetPosition() - call_start) == kCallExternalLabelSize);
(void)call_start;
}
void AssemblerX86::pushl(GPRRegister reg) {
......@@ -1749,6 +1750,7 @@ void AssemblerX86::notl(GPRRegister reg) {
void AssemblerX86::bswap(Type Ty, GPRRegister reg) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
assert(Ty == IceType_i32);
(void)Ty;
EmitUint8(0x0F);
EmitUint8(0xC8 | reg);
}
......@@ -2145,6 +2147,7 @@ void AssemblerX86::EmitGenericShift(int rm, const Operand &operand,
GPRRegister shifter) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
assert(shifter == RegX8632::Encoded_Reg_ecx);
(void)shifter;
EmitUint8(0xD3);
EmitOperand(rm, Operand(operand));
}
......
......@@ -329,6 +329,7 @@ public:
explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) {
// This mode is only needed and implemented for MIPS and ARM.
assert(!use_far_branches);
(void)use_far_branches;
}
~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