Skip to content

Commit

Permalink
Reenable compilation tests for P4Smith. (#4791)
Browse files Browse the repository at this point in the history
* Add compilation support for P4Smith for DPDK, eBPF, V1model, and p4test.

Change $TEST_DIR/out.p4 to $TEST_DIR/out_$i.p4 to generate different programs with different seeds (to inspect the behavior of the generation and compilation process in a finer/smaller granularity)

Switch the order of --arch and --target

Revert the version of backends/p4tools/modules/smith/scripts/compilation-test.sh back to the commit d34f60e, and switch the order of core and generic in backends/p4tools/modules/smith/targets/generic/test/P4Tests.cmake

Modify the argument settings for multiple targets and architectures

Attempt to make sure that only primitive-type parameters are used when generating the parameter list for the BMv2 portion of the fuzzer

Fix the previous erroneous treatment of "bmv2" from archName to deviceName

Add TODOs to remind myself to revert `out_$i.p4` back to `out.p4` to
avoid dumping too many generated files after the debugging process

1. Instead of adding target-specific check in the target-independent core, preliminarily override the virtual method in the BMv2 backend (still hasn't worked yet)

2. Get rid of  and expand the function signature of

Refactor the implemented inheritance pattern

Clang-format some source file

Fix a linter issue

Implement a mechanism to maintain a list of "known" bugs and not fail the test if those bugs occur

Modify the output-printing mechanism

Add another element to `KNOWN_BUGS`

Add an echo statement to display the encounted bug using the `is_known_bug` function

Modify echo statements

Preliminarily add code to generate an approriate return statement for `pna_pre_output_metadata_t`

Fix a linter issue

Add a TODO to fix the casting bug

Make use of `new IR::Type_Name`

Hard-code to attempt to resolve the casting issue

The current type casting is still erroneous

Add commented-out code that doesn't work and add TODOs

Fix linter issues

Resolve the infinite recursing issue

Improve the implementation to be modular (but still doesn't work)

Fix some auxillary issues

Refine type resolving

Refine recursive type resolving

Fix the "Arch '<null>' not supported by P4Runtime serializer" error

Specify the compiler binary with extentions in the corresponding P4Tests.cmake file instead of the bash script

Simplify the constructor Bmv2V1ModelDeclarationGenerator

Remove 128 from the accepted bitwidths in the Expression Generator for the dpdk taget

Activate `byte_align_headers` to `true` to support bit alignments

Add a known bug: `terminate called after throwing an instance of 'Util::CompilerBug'`

Modify the previously documented known bug to a fine-grained version

Make further attempts to resolve type resolving

Resolve a typo made previously

Further refine type resolving and remove redundant code

Implement explicit casting for `SecurityAssocId_t` for both assignment and return statements

Revert the type signature of `genStructListExpr` from `IR::Expression` back to `IR::ListExpression`

Revert the type signature of `getTypeByName` from `IR::Type` back to `IR::Type_Declaration`

Revert the type signature of `genStructListExpr` from `IR::Expression` back to `IR::ListExpression`

Preliminarily modify the previous type resolving/casting mechanism

Remove the previous added, redundant `genBitType` with different arguments than the default `genBitType`

Add print-outs to address the tuple-wrapping issue

Resolve the typing issue of `SecurityAssocId_t` in a more generic way

Make the bug documented in `KNOWN_BUGS` more generic

Experimentally migrate the `Bmv2V1ModelDeclarationGenerator` class and its constructor and (overridden) member function to declarations.cpp and declarations.h in the `bmv2` target

Experimentally migrate the `Bmv2V1ModelDeclarationGenerator` class and its constructor and (overridden) member function to declarations.cpp and declarations.h in the `bmv2` target

Fix linter issues from the previous commit(s)

Fix the issue caused by erroneously formatting backends/p4tools/modules/smith/targets/bmv2/CMakeLists.txt

Set `byte_align_headers` true for the `nic` target

Prohibit `128` from being a valid bit size for the `nic` target

Document a known bug in the script

Fix the previous linter issue(s)

Support to generate well-typed parameter lists for the `nic` target

Remove the hard-coded rhs-casting(s) of assignment generations

Add a TODO (to make the bitwidth a generic parameter)

1. Preliminarily make the bitwidth a generic parameter (by implementing a template function)

2. Document a known bug

Revert backends/p4tools/modules/smith/scripts/compilation-test.sh back to its original form since it is cluelessly `clang-format`ed

Reactivate the executable permission of backends/p4tools/modules/smith/scripts/compilation-test.sh

Preliminarily implement `pna_main_parser_input_metadata_t`'s field generations (although `enum` is not supported right now)

Rename the previous `Bmv2V1ModelDeclarationGenerator` class to `Bmv2ModelDeclarationGenerator` and apply it (and its members) to the `psa` arch

1. Add a struct member in the `Constraints` struct to limit the maximum bit width (default value: 128)

2. Set it to 64 for the pna arch, dpdk target

Fixups.

Signed-off-by: zzmic <100326374+zzmic@users.noreply.github.com>
Signed-off-by: fruffy <fruffy@nyu.edu>

* Clean up initialization of probabilities.

Signed-off-by: fruffy <fruffy@nyu.edu>

* Add support for parallel test runs, simplify bit literal generation.

Signed-off-by: fruffy <fruffy@nyu.edu>

---------

Signed-off-by: zzmic <100326374+zzmic@users.noreply.github.com>
Signed-off-by: fruffy <fruffy@nyu.edu>
Co-authored-by: fruffy <fruffy@nyu.edu>
  • Loading branch information
zzmic and fruffy authored Aug 26, 2024
1 parent 30444b0 commit ceb8a9e
Show file tree
Hide file tree
Showing 27 changed files with 713 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-p4tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
- name: Run tests (Ubuntu 22.04)
# Need to use sudo for the eBPF kernel tests.
run: sudo -E ctest -R testgen- --output-on-failure --schedule-random
run: sudo -E ctest -R "testgen|smith" --output-on-failure --schedule-random
working-directory: ./build
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Run tests (MacOS)
run: |
source ~/.bash_profile
ctest --output-on-failure --schedule-random -LE "bpf|ubpf|testgen"
ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith"
working-directory: ./build

# Build and test p4c on MacOS 13 on x86.
Expand Down Expand Up @@ -111,5 +111,5 @@ jobs:
- name: Run tests (MacOS)
run: |
source ~/.bash_profile
ctest --output-on-failure --schedule-random -LE "bpf|ubpf|testgen"
ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith"
working-directory: ./build
1 change: 1 addition & 0 deletions backends/p4tools/modules/smith/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(SMITH_SOURCES
common/declarations.cpp
common/expressions.cpp
common/parser.cpp
common/probabilities.cpp
common/scope.cpp
common/statements.cpp
common/table.cpp
Expand Down
240 changes: 151 additions & 89 deletions backends/p4tools/modules/smith/common/declarations.cpp

Large diffs are not rendered by default.

179 changes: 106 additions & 73 deletions backends/p4tools/modules/smith/common/expressions.cpp

Large diffs are not rendered by default.

25 changes: 19 additions & 6 deletions backends/p4tools/modules/smith/common/expressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ using TyperefProbs = struct TyperefProbs {
int64_t p4_tuple;
int64_t p4_void;
int64_t p4_match_kind;

[[nodiscard]] std::string toString() const {
std::stringstream ss;
ss << "p4_bit=" << p4_bit << " p4_signed_bit=" << p4_signed_bit
<< " p4_varbit=" << p4_varbit << " p4_int=" << p4_int << " p4_error=" << p4_error
<< " p4_bool=" << p4_bool << " p4_string=" << p4_string << " p4_enum=" << p4_enum
<< " p4_header=" << p4_header << " p4_header_stack=" << p4_header_stack
<< " p4_struct=" << p4_struct << " p4_header_union=" << p4_header_union
<< " p4_tuple=" << p4_tuple << " p4_void=" << p4_void
<< " p4_match_kind=" << p4_match_kind;
return ss.str();
}
};

class ExpressionGenerator : public Generator {
Expand All @@ -40,25 +52,26 @@ class ExpressionGenerator : public Generator {

static constexpr size_t MAX_DEPTH = 3;

static constexpr int BIT_WIDTHS[6] = {4, 8, 16, 32, 64, 128};

static const IR::Type_Boolean *genBoolType();

static const IR::Type_InfInt *genIntType();

// isSigned, true -> int<>, false -> bit<>
static const IR::Type_Bits *genBitType(bool isSigned);
[[nodiscard]] const IR::Type_Bits *genBitType(bool isSigned) const;
[[nodiscard]] const IR::Type *pickRndBaseType(const std::vector<int64_t> &type_probs) const;

static const IR::Type *pickRndBaseType(const std::vector<int64_t> &type_probs);

virtual const IR::Type *pickRndType(TyperefProbs type_probs);
[[nodiscard]] virtual const IR::Type *pickRndType(TyperefProbs type_probs);

static IR::BoolLiteral *genBoolLiteral();

static IR::Constant *genIntLiteral(size_t bit_width = INTEGER_WIDTH);

static IR::Constant *genBitLiteral(const IR::Type *tb);

[[nodiscard]] virtual std::vector<int> availableBitWidths() const {
return {4, 8, 16, 32, 64, 128};
}

private:
IR::Expression *constructUnaryExpr(const IR::Type_Bits *tb);

Expand Down
8 changes: 5 additions & 3 deletions backends/p4tools/modules/smith/common/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ void ParserGenerator::genState(cstring name) {
// expression
IR::Expression *transition = nullptr;

std::vector<int64_t> percent = {PCT.P4STATE_TRANSITION_ACCEPT, PCT.P4STATE_TRANSITION_REJECT,
PCT.P4STATE_TRANSITION_STATE, PCT.P4STATE_TRANSITION_SELECT};
std::vector<int64_t> percent = {Probabilities::get().P4STATE_TRANSITION_ACCEPT,
Probabilities::get().P4STATE_TRANSITION_REJECT,
Probabilities::get().P4STATE_TRANSITION_STATE,
Probabilities::get().P4STATE_TRANSITION_SELECT};

P4Scope::endLocalScope();
switch (Utils::getRandInt(percent)) {
Expand All @@ -213,7 +215,7 @@ void ParserGenerator::genState(cstring name) {

IR::Vector<IR::Type> types;
for (size_t i = 0; i <= keySetLen; i++) {
auto *tb = ExpressionGenerator::genBitType(false);
const auto *tb = target().expressionGenerator().genBitType(false);
types.push_back(tb);
}

Expand Down
8 changes: 8 additions & 0 deletions backends/p4tools/modules/smith/common/probabilities.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_PROBABILITIES_H_
#define BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_PROBABILITIES_H_

#include "backends/p4tools/modules/smith/common/probabilities.h"

namespace P4::P4Tools::P4Smith {} // namespace P4::P4Tools::P4Smith

#endif /* BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_PROBABILITIES_H_ */
28 changes: 24 additions & 4 deletions backends/p4tools/modules/smith/common/probabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

#include <cstdint>

static struct Probabilities {
namespace P4::P4Tools::P4Smith {

struct Probabilities {
// assignment or method call
uint16_t ASSIGNMENTORMETHODCALLSTATEMENT_ASSIGN = 75;
uint16_t ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CALL = 25;
Expand Down Expand Up @@ -299,9 +301,17 @@ static struct Probabilities {
uint16_t VARIABLEDECLARATION_DERIVED_TUPLE = DERIVED_TUPLE;
uint16_t VARIABLEDECLARATION_TYPE_VOID = TYPE_VOID;
uint16_t VARIABLEDECLARATION_TYPE_MATCH_KIND = TYPE_MATCH_KIND;
} PCT;

static struct Declarations {
static Probabilities &get() {
static Probabilities INSTANCE;
return INSTANCE;
}

private:
Probabilities() = default;
};

struct Declarations {
// minimum and maximum number of type declarations
uint16_t MIN_TYPE = 1;
uint16_t MAX_TYPE = 8;
Expand All @@ -326,6 +336,16 @@ static struct Declarations {

uint16_t MIN_TABLE = 0;
uint16_t MAX_TABLE = 3;
} DECL;

static Declarations &get() {
static Declarations INSTANCE;
return INSTANCE;
}

private:
Declarations() = default;
};

} // namespace P4::P4Tools::P4Smith

#endif /* BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_PROBABILITIES_H_ */
36 changes: 25 additions & 11 deletions backends/p4tools/modules/smith/common/scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
#include "ir/vector.h"
#include "lib/cstring.h"
#include "lib/exceptions.h"
#include "lib/null.h"

namespace P4::P4Tools::P4Smith {

std::vector<IR::Vector<IR::Node> *> P4Scope::scope;
std::vector<IR::Vector<IR::Node> *> P4Scope::scope = std::vector<IR::Vector<IR::Node> *>();
std::set<cstring> P4Scope::usedNames;
std::map<cstring, std::map<int, std::set<cstring>>> P4Scope::lvalMap;
std::map<cstring, std::map<int, std::set<cstring>>> P4Scope::lvalMapRw;
Expand All @@ -31,6 +32,7 @@ Properties P4Scope::prop;
Requirements P4Scope::req;
Constraints P4Scope::constraints;
void P4Scope::addToScope(const IR::Node *node) {
CHECK_NULL(node);
auto *lScope = P4Scope::scope.back();
lScope->push_back(node);

Expand All @@ -41,10 +43,7 @@ void P4Scope::addToScope(const IR::Node *node) {
}
}

void P4Scope::startLocalScope() {
auto *localScope = new IR::Vector<IR::Node>();
scope.push_back(localScope);
}
void P4Scope::startLocalScope() { scope.push_back(new IR::Vector<IR::Node>()); }

void P4Scope::endLocalScope() {
IR::Vector<IR::Node> *localScope = scope.back();
Expand All @@ -61,7 +60,6 @@ void P4Scope::endLocalScope() {
}
}

delete localScope;
scope.pop_back();
}

Expand Down Expand Up @@ -98,6 +96,9 @@ void P4Scope::deleteLval(const IR::Type *tp, cstring name) {
} else if (tp->is<IR::Type_InfInt>()) {
typeKey = IR::Type_InfInt::static_type_name();
bitBucket = 1;
} else if (const auto *typeEnum = tp->to<IR::Type_Enum>()) {
typeKey = typeEnum->name.name;
bitBucket = 1;
} else if (const auto *ts = tp->to<IR::Type_Stack>()) {
size_t stackSize = ts->getSize();
typeKey = IR::Type_Stack::static_type_name();
Expand All @@ -119,12 +120,14 @@ void P4Scope::deleteLval(const IR::Type *tp, cstring name) {
if (const auto *td = getTypeByName(tnName)) {
if (const auto *tnType = td->to<IR::Type_StructLike>()) {
typeKey = tnName;
// width_bits should work here, do !know why not...
// width_bits should work here, do not know why not...
// bit_bucket = P4Scope::compound_type[tn_name]->width_bits();
bitBucket = 1;
deleteCompoundLvals(tnType, name);
} else if (const auto *typeDef = td->to<IR::Type_Typedef>()) {
deleteLval(typeDef->type, name);
} else {
BUG("Type_Name %s !found!", td->node_type_name());
BUG("Type_Name %s not found!", td->node_type_name());
}
} else {
printInfo("Type %s does not exist!\n", tnName.c_str());
Expand Down Expand Up @@ -171,6 +174,11 @@ void P4Scope::addLval(const IR::Type *tp, cstring name, bool read_only) {
} else if (tp->is<IR::Type_InfInt>()) {
typeKey = IR::Type_InfInt::static_type_name();
bitBucket = 1;
} else if (tp->is<IR::Type_Enum>()) {
// TODO: Add enum types.
return;
// typeKey = enumType->name.name;
// bitBucket = 1;
} else if (const auto *ts = tp->to<IR::Type_Stack>()) {
size_t stackSize = ts->getSize();
typeKey = IR::Type_Stack::static_type_name();
Expand All @@ -192,12 +200,18 @@ void P4Scope::addLval(const IR::Type *tp, cstring name, bool read_only) {
}
if (const auto *td = getTypeByName(tnName)) {
if (const auto *tnType = td->to<IR::Type_StructLike>()) {
// width_bits should work here, do !know why not...
// width_bits should work here, do not know why not...
typeKey = tnName;
// does !work for some reason...
// does not work for some reason...
// bit_bucket = P4Scope::compound_type[tn_name]->width_bits();
bitBucket = 1;
addCompoundLvals(tnType, name, read_only);
} else if (td->is<IR::Type_Typedef>()) {
// TODO: Add typedef types.
return;
// return addLval(typeDef->type, name, true);
// typeKey = typeDef->name.name;
// bitBucket = 1;
} else {
BUG("Type_Name %s not yet supported", td->node_type_name());
}
Expand Down Expand Up @@ -337,6 +351,6 @@ const IR::Type_Declaration *P4Scope::getTypeByName(cstring name) {
}
}
}
return nullptr;
BUG("Type %s not found", name);
}
} // namespace P4::P4Tools::P4Smith
3 changes: 3 additions & 0 deletions backends/p4tools/modules/smith/common/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ struct Constraints {
bool const_lshift_count{false};
bool single_stage_actions{false};
int max_phv_container_width{0};
// This is the maximum bitwidth that
// can be specified for different targets.
int max_bitwidth{128};
Constraints()

= default;
Expand Down
59 changes: 31 additions & 28 deletions backends/p4tools/modules/smith/common/statements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ namespace P4::P4Tools::P4Smith {

IR::Statement *StatementGenerator::genStatement(bool is_in_func) {
// functions can!have exit statements so set their probability to zero
int64_t pctExit = PCT.STATEMENT_EXIT;
int64_t pctExit = Probabilities::get().STATEMENT_EXIT;
if (is_in_func) {
pctExit = 0;
}
std::vector<int64_t> percent = {
PCT.STATEMENT_SWITCH,
PCT.STATEMENT_ASSIGNMENTORMETHODCALL,
PCT.STATEMENT_IF,
PCT.STATEMENT_RETURN,
Probabilities::get().STATEMENT_SWITCH,
Probabilities::get().STATEMENT_ASSIGNMENTORMETHODCALL,
Probabilities::get().STATEMENT_IF,
Probabilities::get().STATEMENT_RETURN,
pctExit,
PCT.STATEMENT_BLOCK,
Probabilities::get().STATEMENT_BLOCK,
// Add the for-loop statement and
// the for-in-loop statement generation percentages.
PCT.STATEMENT_FOR,
PCT.STATEMENT_FOR_IN,
Probabilities::get().STATEMENT_FOR,
Probabilities::get().STATEMENT_FOR_IN,
};
IR::Statement *stmt = nullptr;
bool useDefaultStmt = false;
Expand Down Expand Up @@ -96,8 +96,8 @@ IR::Statement *StatementGenerator::genStatement(bool is_in_func) {

IR::IndexedVector<IR::StatOrDecl> StatementGenerator::genBlockStatementHelper(bool is_in_func) {
// Randomize the total number of statements.
int maxStatements =
Utils::getRandInt(DECL.BLOCKSTATEMENT_MIN_STAT, DECL.BLOCKSTATEMENT_MAX_STAT);
int maxStatements = Utils::getRandInt(Declarations::get().BLOCKSTATEMENT_MIN_STAT,
Declarations::get().BLOCKSTATEMENT_MAX_STAT);
IR::IndexedVector<IR::StatOrDecl> statOrDecls;

// Put tab_name .apply() after some initializations.
Expand Down Expand Up @@ -170,8 +170,9 @@ IR::Statement *StatementGenerator::genAssignmentStatement() {
IR::Expression *left = nullptr;
IR::Expression *right = nullptr;

std::vector<int64_t> percent = {PCT.ASSIGNMENTORMETHODCALLSTATEMENT_ASSIGN_BIT,
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_ASSIGN_STRUCTLIKE};
std::vector<int64_t> percent = {
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_ASSIGN_BIT,
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_ASSIGN_STRUCTLIKE};

switch (Utils::getRandInt(percent)) {
case 0: {
Expand Down Expand Up @@ -235,21 +236,22 @@ IR::Statement *StatementGenerator::genMethodCallStatement(bool is_in_func) {
IR::MethodCallExpression *mce = nullptr;

// functions cannot call actions or tables so set their chance to zero
int16_t tmpActionPct = PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_ACTION;
int16_t tmpTblPct = PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_TABLE;
int16_t tmpCtrlPct = PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CTRL;
int16_t tmpActionPct = Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_ACTION;
int16_t tmpTblPct = Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_TABLE;
int16_t tmpCtrlPct = Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CTRL;
if (is_in_func) {
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_ACTION = 0;
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_TABLE = 0;
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_ACTION = 0;
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_TABLE = 0;
}
if (P4Scope::prop.in_action) {
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CTRL = 0;
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CTRL = 0;
}
std::vector<int64_t> percent = {PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_ACTION,
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_FUNCTION,
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_TABLE,
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CTRL,
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_BUILT_IN};
std::vector<int64_t> percent = {
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_ACTION,
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_FUNCTION,
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_TABLE,
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CTRL,
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_BUILT_IN};

switch (Utils::getRandInt(percent)) {
case 0: {
Expand Down Expand Up @@ -343,9 +345,9 @@ IR::Statement *StatementGenerator::genMethodCallStatement(bool is_in_func) {
}
}
// restore previous probabilities
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_ACTION = tmpActionPct;
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_TABLE = tmpTblPct;
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CTRL = tmpCtrlPct;
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_ACTION = tmpActionPct;
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_TABLE = tmpTblPct;
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CTRL = tmpCtrlPct;
if (mce != nullptr) {
return new IR::MethodCallStatement(mce);
}
Expand All @@ -354,8 +356,9 @@ IR::Statement *StatementGenerator::genMethodCallStatement(bool is_in_func) {
}

IR::Statement *StatementGenerator::genAssignmentOrMethodCallStatement(bool is_in_func) {
std::vector<int64_t> percent = {PCT.ASSIGNMENTORMETHODCALLSTATEMENT_ASSIGN,
PCT.ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CALL};
std::vector<int64_t> percent = {
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_ASSIGN,
Probabilities::get().ASSIGNMENTORMETHODCALLSTATEMENT_METHOD_CALL};
auto val = Utils::getRandInt(percent);
if (val == 0) {
return genAssignmentStatement();
Expand Down
Loading

0 comments on commit ceb8a9e

Please sign in to comment.