Skip to content

Commit

Permalink
Remove the least useful code
Browse files Browse the repository at this point in the history
Eager reducer and simple delta reducer: we have proven them to be less
efficient than CReduce.
Msp filters: I suggest we use a new mechanism for silicon vendors to
restrict which arithmetic operations are supported on their processors.
The mechanism should be through a config file, instead of we creating
vendor specific filters in Csmith.
Splat extension: Splat seems to be less popular than klee and crest
nowadays. Even for klee and crest, we should move them out of Csmith in
the future when we have a generic way to support outputing the random
programs in customized ways.
  • Loading branch information
jxyang committed Apr 1, 2019
1 parent 821deef commit e167530
Show file tree
Hide file tree
Showing 33 changed files with 10 additions and 4,154 deletions.
4 changes: 0 additions & 4 deletions src/AbsRndNumGenerator.cpp
Expand Up @@ -39,7 +39,6 @@

#include "DefaultRndNumGenerator.h"
#include "DFSRndNumGenerator.h"
#include "SimpleDeltaRndNumGenerator.h"

using namespace std;

Expand Down Expand Up @@ -80,9 +79,6 @@ AbsRndNumGenerator::make_rndnum_generator(RNDNUM_GENERATOR impl, const unsigned
case rDFSRndNumGenerator:
rImpl = DFSRndNumGenerator::make_rndnum_generator();
break;
case rSimpleDeltaRndNumGenerator:
rImpl = SimpleDeltaRndNumGenerator::make_rndnum_generator(seed);
break;
default:
assert(!"unknown random generator");
break;
Expand Down
3 changes: 1 addition & 2 deletions src/AbsRndNumGenerator.h
Expand Up @@ -38,10 +38,9 @@ class Filter;
enum RNDNUM_GENERATOR {
rDefaultRndNumGenerator = 0,
rDFSRndNumGenerator,
rSimpleDeltaRndNumGenerator,
};

#define MAX_RNDNUM_GENERATOR (rSimpleDeltaRndNumGenerator+1)
#define MAX_RNDNUM_GENERATOR (rDFSRndNumGenerator+1)

// I could make AbsRndNumGenerator not pure, but want to force each subclass implement
// it's own member functions, in case of forgetting something.
Expand Down
1 change: 0 additions & 1 deletion src/ArrayVariable.cpp
Expand Up @@ -448,7 +448,6 @@ bool
ArrayVariable::no_loop_initializer(void) const
{
// don't use loop initializer if we are doing test case reduction
// if (CGOptions::get_reducer()) return true;
// can not use loop initializer if either array member are structs, or they are constants, or it has > 1 initial values
return type->eType==eStruct || type->eType==eUnion || is_const() || is_global() || (init_values.size() > 0);
}
Expand Down
32 changes: 3 additions & 29 deletions src/CGOptions.cpp
Expand Up @@ -43,13 +43,11 @@
#include "Bookkeeper.h"
#include "CompatibleChecker.h"
#include "PartialExpander.h"
#include "DeltaMonitor.h"
#include "Probabilities.h"
#include "OutputMgr.h"
#include "StringUtils.h"

using namespace std;
Reducer* CGOptions::reducer_ = NULL;
vector<int> CGOptions::safe_math_wrapper_ids_;
map<string, bool> CGOptions::enabled_builtin_kinds_;
int CGOptions::int_size_ = 0;
Expand Down Expand Up @@ -114,9 +112,7 @@ DEFINE_GETTER_SETTER_BOOL(dfs_exhaustive)
DEFINE_GETTER_SETTER_STRING_REF(dfs_debug_sequence)
DEFINE_GETTER_SETTER_INT (max_exhaustive_depth)
DEFINE_GETTER_SETTER_BOOL(compact_output)
DEFINE_GETTER_SETTER_BOOL(msp)
DEFINE_GETTER_SETTER_INT(func1_max_params)
DEFINE_GETTER_SETTER_BOOL(splat)
DEFINE_GETTER_SETTER_BOOL(klee)
DEFINE_GETTER_SETTER_BOOL(crest)
DEFINE_GETTER_SETTER_BOOL(ccomp)
Expand Down Expand Up @@ -240,9 +236,7 @@ CGOptions::set_default_settings(void)
use_struct(true);
use_union(true);
compact_output(false);
msp(false);
func1_max_params(CGOPTIONS_DEFAULT_FUNC1_MAX_PARAMS);
splat(false);
klee(false);
crest(false);
ccomp(false);
Expand Down Expand Up @@ -451,7 +445,7 @@ bool CGOptions::resolve_exhaustive_options()
}

if (CGOptions::has_extension_support()) {
conflict_msg_ = "exhaustive mode doesn't support splat|klee|crest|coverage-test extension";
conflict_msg_ = "exhaustive mode doesn't support klee|crest|coverage-test extension";
return true;
}
// For effeciency reason, we fix the size of struct fields
Expand All @@ -476,9 +470,6 @@ bool
CGOptions::has_extension_conflict()
{
int count = 0;

if (CGOptions::splat())
count++;
if (CGOptions::klee())
count++;
if (CGOptions::crest())
Expand All @@ -487,7 +478,7 @@ CGOptions::has_extension_conflict()
count++;

if (count > 1) {
conflict_msg_ = "You could only specify --splat or --klee or --crest or --coverage-test";
conflict_msg_ = "You could only specify --klee or --crest or --coverage-test";
return true;
}
return false;
Expand All @@ -496,7 +487,7 @@ CGOptions::has_extension_conflict()
bool
CGOptions::has_extension_support()
{
return (CGOptions::splat() || CGOptions::klee()
return (CGOptions::klee()
|| CGOptions::crest() || CGOptions::coverage_test());
}

Expand Down Expand Up @@ -559,23 +550,6 @@ CGOptions::has_conflict(void)
}
}

if (!CGOptions::delta_monitor().empty()) {
string msg;
if (!DeltaMonitor::init(msg, CGOptions::delta_monitor(), CGOptions::delta_output())) {
conflict_msg_ = msg;
return true;
}
}

if (!CGOptions::go_delta().empty()) {
string msg;
if (!DeltaMonitor::init_for_running(msg, CGOptions::go_delta(), CGOptions::delta_output(),
CGOptions::delta_input(), CGOptions::no_delta_reduction())) {
conflict_msg_ = msg;
return true;
}
}

if (!CGOptions::lang_cpp() && CGOptions::cpp11()) {
conflict_msg_ = "--cpp11 option makes sense only with --lang-cpp option enabled.";
return true;
Expand Down
13 changes: 0 additions & 13 deletions src/CGOptions.h
Expand Up @@ -33,7 +33,6 @@
#include <string>
#include <vector>
#include <map>
#include "Reducer.h"
using namespace std;

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -178,15 +177,9 @@ class CGOptions {
static bool compact_output(void);
static bool compact_output(bool p);

static bool msp(void);
static bool msp(bool p);

static int func1_max_params(void);
static int func1_max_params(int p);

static bool splat(void);
static bool splat(bool p);

static bool klee(void);
static bool klee(bool p);

Expand Down Expand Up @@ -382,9 +375,6 @@ class CGOptions {
static int max_array_num_in_loop();
static int max_array_num_in_loop(int p);

static void init_reducer(std::string fname) { reducer_ = new Reducer(fname);}
static Reducer* get_reducer(void) { return reducer_; }

static bool x86_64();

static bool identify_wrappers(void);
Expand Down Expand Up @@ -523,9 +513,7 @@ class CGOptions {
static std::string dfs_debug_sequence_;
static int max_exhaustive_depth_;
static bool compact_output_;
static bool msp_;
static int func1_max_params_;
static bool splat_;
static bool klee_;
static bool crest_;
static bool ccomp_;
Expand Down Expand Up @@ -610,7 +598,6 @@ class CGOptions {
static bool take_union_field_addr_;
static bool vol_struct_union_fields_;
static bool const_struct_union_fields_;
static Reducer* reducer_;
static bool fast_execution_;

// flag to indicate language
Expand Down
14 changes: 0 additions & 14 deletions src/CMakeLists.txt
Expand Up @@ -87,8 +87,6 @@ set(csmith_SOURCES
DefaultProgramGenerator.h
DefaultRndNumGenerator.cpp
DefaultRndNumGenerator.h
DeltaMonitor.cpp
DeltaMonitor.h
DepthSpec.cpp
DepthSpec.h
Effect.cpp
Expand Down Expand Up @@ -138,8 +136,6 @@ set(csmith_SOURCES
Lhs.h
LinearSequence.cpp
LinearSequence.h
MspFilters.cpp
MspFilters.h
OutputMgr.cpp
OutputMgr.h
PartialExpander.cpp
Expand All @@ -150,23 +146,13 @@ set(csmith_SOURCES
RandomNumber.cpp
RandomNumber.h
RandomProgramGenerator.cpp
Reducer.cpp
Reducer.h
ReducerOutputMgr.cpp
ReducerOutputMgr.h
SafeOpFlags.cpp
SafeOpFlags.h
Sequence.cpp
Sequence.h
SequenceFactory.cpp
SequenceFactory.h
SequenceLineParser.h
SimpleDeltaRndNumGenerator.cpp
SimpleDeltaRndNumGenerator.h
SimpleDeltaSequence.cpp
SimpleDeltaSequence.h
SplatExtension.cpp
SplatExtension.h
Statement.cpp
Statement.h
StatementArrayOp.cpp
Expand Down
5 changes: 0 additions & 5 deletions src/DefaultOutputMgr.cpp
Expand Up @@ -45,7 +45,6 @@
#include "VariableSelector.h"
#include "Type.h"
#include "random.h"
#include "DeltaMonitor.h"
#include "Error.h"

static std::string filename_prefix = "rnd_output";
Expand Down Expand Up @@ -201,9 +200,6 @@ void
DefaultOutputMgr::Output()
{
std::ostream &out = get_main_out();
if (DeltaMonitor::is_running() && (Error::get_error() != SUCCESS)) {
out << "Delta reduction error!\n";
}
if (is_split()) {
OutputGlobals();
OutputAllHeaders();
Expand All @@ -223,7 +219,6 @@ DefaultOutputMgr::Output()
if (!CGOptions::nomain())
OutputMain(out);
OutputTail(out);
DeltaMonitor::Output(out);
}

std::ostream &
Expand Down
15 changes: 2 additions & 13 deletions src/DefaultProgramGenerator.cpp
Expand Up @@ -37,11 +37,9 @@
#include "RandomNumber.h"
#include "AbsRndNumGenerator.h"
#include "DefaultOutputMgr.h"
#include "ReducerOutputMgr.h"
#include "Finalization.h"
#include "Function.h"
#include "Type.h"
#include "DeltaMonitor.h"
#include "CGOptions.h"
#include "SafeOpFlags.h"
#include "ExtensionMgr.h"
Expand All @@ -64,17 +62,8 @@ DefaultProgramGenerator::~DefaultProgramGenerator()
void
DefaultProgramGenerator::initialize()
{
if (DeltaMonitor::is_delta()) {
DeltaMonitor::CreateRndNumInstance(seed_);
}
else {
RandomNumber::CreateInstance(rDefaultRndNumGenerator, seed_);
}
if (CGOptions::get_reducer()) {
output_mgr_ = new ReducerOutputMgr();
} else {
output_mgr_ = DefaultOutputMgr::CreateInstance();
}
RandomNumber::CreateInstance(rDefaultRndNumGenerator, seed_);
output_mgr_ = DefaultOutputMgr::CreateInstance();
assert(output_mgr_);

ExtensionMgr::CreateExtension();
Expand Down
3 changes: 0 additions & 3 deletions src/DefaultRndNumGenerator.cpp
Expand Up @@ -43,7 +43,6 @@
#include "SequenceFactory.h"
#include "Sequence.h"
#include "CGOptions.h"
#include "DeltaMonitor.h"

DefaultRndNumGenerator *DefaultRndNumGenerator::impl_ = 0;

Expand Down Expand Up @@ -104,8 +103,6 @@ DefaultRndNumGenerator::get_prefixed_name(const std::string &name)
void
DefaultRndNumGenerator::add_number(int v, int bound, int k)
{
if (DeltaMonitor::is_running())
seq_->add_number(v, bound, k);
}

/*
Expand Down

0 comments on commit e167530

Please sign in to comment.