Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup warnings produced by Clang #3693

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

- name: Build (Ubuntu Linux, Clang)
run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg ENABLE_WERROR=OFF --build-arg COMPILE_WITH_CLANG=ON .
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg COMPILE_WITH_CLANG=ON .
./tools/export_ccache.sh

# run with sudo (...) --privileged
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clan
endmacro()
check_linker(BUILD_LINK_WITH_GOLD "gold" "GNU gold")
check_linker(BUILD_LINK_WITH_LLD "lld" "LLD")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_LD_OPT_USED}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_LD_OPT_USED}")
append("${_LD_OPT_USED}" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)
message(STATUS "Using the ${_LD_USED} linker.")
unset(LD_VERSION)
unset(_LD_USED)
Expand Down
2 changes: 1 addition & 1 deletion backends/bmv2/simple_switch/simpleSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class SimpleSwitchBackend : public Backend {
};

EXTERN_CONVERTER_W_FUNCTION(clone)
EXTERN_CONVERTER_W_FUNCTION_AND_MODEL(clone_preserving_field_list, P4V1::V1Model, v1model)
EXTERN_CONVERTER_W_FUNCTION(clone_preserving_field_list)
EXTERN_CONVERTER_W_FUNCTION_AND_MODEL(hash, P4V1::V1Model, v1model)
EXTERN_CONVERTER_W_FUNCTION(digest)
EXTERN_CONVERTER_W_FUNCTION(resubmit_preserving_field_list)
Expand Down
6 changes: 3 additions & 3 deletions backends/dpdk/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void DpdkBackend::convert(const IR::ToplevelBlock *tlb) {

std::set<const IR::P4Table*> invokedInKey;
auto convertToDpdk = new ConvertToDpdkProgram(refMap, typeMap, &structure, options);
auto genContextJson = new DpdkContextGenerator(refMap, typeMap, &structure, options);
auto genContextJson = new DpdkContextGenerator(refMap, &structure, options);

PassManager simplify = {
new DpdkArchFirst(),
Expand Down Expand Up @@ -84,7 +84,7 @@ void DpdkBackend::convert(const IR::ToplevelBlock *tlb) {
new P4::TypeChecking(refMap, typeMap, true),
new P4::ResolveReferences(refMap),
new StatementUnroll(refMap, &structure),
new IfStatementUnroll(refMap, &structure),
new IfStatementUnroll(refMap),
new P4::ClearTypeMap(typeMap),
new P4::TypeChecking(refMap, typeMap, true),
new ConvertBinaryOperationTo2Params(refMap),
Expand Down Expand Up @@ -117,7 +117,7 @@ void DpdkBackend::convert(const IR::ToplevelBlock *tlb) {
out->flush();
}
}),
new ReplaceHdrMetaField(typeMap, refMap, &structure),
new ReplaceHdrMetaField(),
// convert to assembly program
convertToDpdk,
};
Expand Down
7 changes: 2 additions & 5 deletions backends/dpdk/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,14 @@ class DpdkBackend {
DpdkOptions &options;
P4::ReferenceMap *refMap;
P4::TypeMap* typeMap;
P4::ConvertEnums::EnumMapping *enumMap;

const IR::DpdkAsmProgram *dpdk_program = nullptr;
const IR::ToplevelBlock* toplevel = nullptr;

public:
void convert(const IR::ToplevelBlock *tlb);
DpdkBackend(DpdkOptions &options, P4::ReferenceMap *refMap,
P4::TypeMap *typeMap,
P4::ConvertEnums::EnumMapping *enumMap)
: options(options), refMap(refMap), typeMap(typeMap), enumMap(enumMap) {}
P4::TypeMap *typeMap)
: options(options), refMap(refMap), typeMap(typeMap) {}
void codegen(std::ostream &) const;
};

Expand Down
4 changes: 2 additions & 2 deletions backends/dpdk/dpdkArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ bool ExpressionUnroll::preorder(const IR::BoolLiteral *) {
const IR::Node *IfStatementUnroll::postorder(IR::SwitchStatement *sw) {
auto code_block = new IR::IndexedVector<IR::StatOrDecl>;
expressionUnrollSanityCheck(sw->expression);
auto unroller = new LogicalExpressionUnroll(refMap, structure);
auto unroller = new LogicalExpressionUnroll(refMap);
unroller->setCalledBy(this);
sw->expression->apply(*unroller);
for (auto i : unroller->stmt)
Expand All @@ -927,7 +927,7 @@ const IR::Node *IfStatementUnroll::postorder(IR::SwitchStatement *sw) {
const IR::Node *IfStatementUnroll::postorder(IR::IfStatement *i) {
auto code_block = new IR::IndexedVector<IR::StatOrDecl>;
expressionUnrollSanityCheck(i->condition);
auto unroller = new LogicalExpressionUnroll(refMap, structure);
auto unroller = new LogicalExpressionUnroll(refMap);
unroller->setCalledBy(this);
i->condition->apply(*unroller);
for (auto i : unroller->stmt)
Expand Down
30 changes: 7 additions & 23 deletions backends/dpdk/dpdkArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,13 @@ class InjectFixedMetadataField : public Transform {
/// by combining few contiguous header fields and replaces uses with slices
/// to preserve the behavior
class AlignHdrMetaField : public Transform {
P4::TypeMap* typeMap;
P4::ReferenceMap *refMap;
DpdkProgramStructure *structure;

ordered_map<cstring, struct fieldInfo> field_name_list;

public:
AlignHdrMetaField(P4::TypeMap* typeMap,
P4::ReferenceMap *refMap,
DpdkProgramStructure* structure)
: typeMap(typeMap), refMap(refMap), structure(structure) {
explicit AlignHdrMetaField(DpdkProgramStructure* structure)
: structure(structure) {
CHECK_NULL(structure);
}
const IR::Node *preorder(IR::Type_StructLike *st) override;
Expand All @@ -264,7 +260,7 @@ struct ByteAlignment : public PassManager {
DpdkProgramStructure* structure)
: typeMap(typeMap), refMap(refMap), structure(structure) {
CHECK_NULL(structure);
passes.push_back(new AlignHdrMetaField(typeMap, refMap, structure));
passes.push_back(new AlignHdrMetaField(structure));
passes.push_back(new P4::ClearTypeMap(typeMap));
passes.push_back(new P4::TypeChecking(refMap, typeMap, true));
/* DoRemoveLeftSlices pass converts the slice Member (LHS in assn stm)
Expand All @@ -276,16 +272,7 @@ struct ByteAlignment : public PassManager {
};

class ReplaceHdrMetaField : public Transform {
P4::TypeMap* typeMap;
P4::ReferenceMap *refMap;
DpdkProgramStructure *structure;
public:
ReplaceHdrMetaField(P4::TypeMap* typeMap,
P4::ReferenceMap *refMap,
DpdkProgramStructure* structure)
: typeMap(typeMap), refMap(refMap), structure(structure) {
CHECK_NULL(structure);
}
const IR::Node* postorder(IR::Type_Struct *st) override;
};

Expand Down Expand Up @@ -402,12 +389,11 @@ class ExpressionUnroll : public Inspector {
class IfStatementUnroll : public Transform {
private:
P4::ReferenceMap *refMap;
DpdkProgramStructure *structure;
DeclarationInjector injector;

public:
IfStatementUnroll(P4::ReferenceMap* refMap, DpdkProgramStructure *structure) :
refMap(refMap), structure(structure) {
explicit IfStatementUnroll(P4::ReferenceMap* refMap) :
refMap(refMap) {
setName("IfStatementUnroll");
}
const IR::Node *postorder(IR::SwitchStatement *a) override;
Expand All @@ -422,7 +408,6 @@ class IfStatementUnroll : public Transform {
*/
class LogicalExpressionUnroll : public Inspector {
P4::ReferenceMap* refMap;
DpdkProgramStructure *structure;

public:
IR::IndexedVector<IR::StatOrDecl> stmt;
Expand All @@ -437,8 +422,8 @@ class LogicalExpressionUnroll : public Inspector {
return false;
}

LogicalExpressionUnroll(P4::ReferenceMap* refMap, DpdkProgramStructure *structure)
: refMap(refMap), structure(structure) {visitDagOnce = false;}
explicit LogicalExpressionUnroll(P4::ReferenceMap* refMap)
: refMap(refMap) {visitDagOnce = false;}
bool preorder(const IR::Operation_Unary *a) override;
bool preorder(const IR::Operation_Binary *a) override;
bool preorder(const IR::MethodCallExpression *a) override;
Expand Down Expand Up @@ -937,7 +922,6 @@ class SplitActionProfileTable : public SplitP4TableCommon {
* Handle ActionSelector and ActionProfile extern in PSA
*/
class ConvertActionSelectorAndProfile : public PassManager {
DpdkProgramStructure *structure;
public:
ConvertActionSelectorAndProfile(P4::ReferenceMap *refMap, P4::TypeMap* typeMap,
DpdkProgramStructure *structure) {
Expand Down
6 changes: 2 additions & 4 deletions backends/dpdk/dpdkContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ struct SelectionTable {
// This pass generates context JSON into user specified file
class DpdkContextGenerator : public Inspector {
P4::ReferenceMap *refmap;
P4::TypeMap *typemap;
DpdkProgramStructure *structure;
DpdkOptions &options;
// All tables are collected into this vector
Expand All @@ -142,10 +141,9 @@ class DpdkContextGenerator : public Inspector {
static unsigned newActionHandle;

public:
DpdkContextGenerator(P4::ReferenceMap *refmap, P4::TypeMap *typemap,
DpdkContextGenerator(P4::ReferenceMap *refmap,
DpdkProgramStructure *structure, DpdkOptions &options) :
refmap(refmap), typemap(typemap),
structure(structure), options(options) {}
refmap(refmap), structure(structure), options(options) {}

unsigned int getNewTableHandle();
unsigned int getNewActionHandle();
Expand Down
2 changes: 1 addition & 1 deletion backends/dpdk/dpdkMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PrependPassRecircId : public Transform {
public:
PrependPassRecircId() {}
bool isPass(const IR::Member *m);
const IR::Node *postorder(IR::DpdkAction *a);
const IR::Node *postorder(IR::DpdkAction *a) override;
const IR::Node *postorder(IR::DpdkListStatement *l) override;
IR::IndexedVector<IR::DpdkAsmStatement>
prependPassWithRecircid(IR::IndexedVector<IR::DpdkAsmStatement> stmts);
Expand Down
3 changes: 1 addition & 2 deletions backends/dpdk/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ int main(int argc, char *const argv[]) {
if (::errorCount() > 0)
return 1;

auto backend = new DPDK::DpdkBackend(options, &midEnd.refMap,
&midEnd.typeMap, &midEnd.enumMap);
auto backend = new DPDK::DpdkBackend(options, &midEnd.refMap, &midEnd.typeMap);

backend->convert(toplevel);
if (::errorCount() > 0)
Expand Down
2 changes: 1 addition & 1 deletion backends/ebpf/psa/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void PSASwitchBackend::convert(const IR::ToplevelBlock *tlb) {
program = toplevel->getProgram();

EBPFTypeFactory::createFactory(typeMap);
auto convertToEbpfPSA = new ConvertToEbpfPSA(options, structure, refMap, typeMap);
auto convertToEbpfPSA = new ConvertToEbpfPSA(options, refMap, typeMap);
PassManager toEBPF = {
new BMV2::DiscoverStructure(&structure),
new BMV2::InspectPsaProgram(refMap, typeMap, &structure),
Expand Down
6 changes: 3 additions & 3 deletions backends/ebpf/psa/ebpfPsaGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,22 +600,22 @@ bool ConvertToEbpfPipeline::preorder(const IR::PackageBlock *block) {
return false;
}

auto parser_converter = new ConvertToEBPFParserPSA(pipeline, refmap, typemap, options, type);
auto parser_converter = new ConvertToEBPFParserPSA(pipeline, typemap, type);
parserBlock->apply(*parser_converter);
pipeline->parser = parser_converter->getEBPFParser();
CHECK_NULL(pipeline->parser);

auto control_converter = new ConvertToEBPFControlPSA(pipeline,
pipeline->parser->headers,
refmap, typemap, options, type);
refmap, type);
controlBlock->apply(*control_converter);
pipeline->control = control_converter->getEBPFControl();
CHECK_NULL(pipeline->control);

auto deparser_converter = new ConvertToEBPFDeparserPSA(
pipeline,
pipeline->parser->headers, pipeline->control->outputStandardMetadata,
refmap, typemap, options, type);
typemap, type);
deparserBlock->apply(*deparser_converter);
pipeline->deparser = deparser_converter->getEBPFDeparser();
CHECK_NULL(pipeline->deparser);
Expand Down
37 changes: 10 additions & 27 deletions backends/ebpf/psa/ebpfPsaGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,14 @@ class PSAArchTC : public PSAEbpfGenerator {

class ConvertToEbpfPSA : public Transform {
const EbpfOptions& options;
BMV2::PsaProgramStructure& structure;
P4::TypeMap* typemap;
P4::ReferenceMap* refmap;
const PSAEbpfGenerator* ebpf_psa_arch;

public:
ConvertToEbpfPSA(const EbpfOptions &options,
BMV2::PsaProgramStructure &structure,
P4::ReferenceMap *refmap, P4::TypeMap *typemap)
: options(options), structure(structure), typemap(typemap), refmap(refmap),
: options(options), typemap(typemap), refmap(refmap),
ebpf_psa_arch(nullptr) {}

const PSAEbpfGenerator *build(const IR::ToplevelBlock *prog);
Expand Down Expand Up @@ -131,16 +129,13 @@ class ConvertToEBPFParserPSA : public Inspector {
pipeline_type type;

P4::TypeMap *typemap;
P4::ReferenceMap *refmap;
EBPF::EBPFPsaParser* parser;

const EbpfOptions &options;

public:
ConvertToEBPFParserPSA(EBPF::EBPFProgram* program, P4::ReferenceMap* refmap,
P4::TypeMap* typemap, const EbpfOptions &options, pipeline_type type) :
program(program), type(type), typemap(typemap), refmap(refmap),
parser(nullptr), options(options) {}
ConvertToEBPFParserPSA(EBPF::EBPFProgram* program, P4::TypeMap* typemap,
pipeline_type type)
: program(program), type(type), typemap(typemap),
parser(nullptr) {}

bool preorder(const IR::ParserBlock *prsr) override;
bool preorder(const IR::P4ValueSet* pvs) override;
Expand All @@ -153,18 +148,13 @@ class ConvertToEBPFControlPSA : public Inspector {
EBPF::EBPFControlPSA *control;

const IR::Parameter* parserHeaders;
P4::TypeMap *typemap;
P4::ReferenceMap *refmap;

const EbpfOptions &options;

public:
ConvertToEBPFControlPSA(EBPF::EBPFProgram *program, const IR::Parameter* parserHeaders,
P4::ReferenceMap *refmap, P4::TypeMap *typemap,
const EbpfOptions &options, pipeline_type type)
P4::ReferenceMap *refmap, pipeline_type type)
: program(program), type(type), control(nullptr),
parserHeaders(parserHeaders),
typemap(typemap), refmap(refmap), options(options) {}
parserHeaders(parserHeaders), refmap(refmap) {}

bool preorder(const IR::TableBlock *) override;
bool preorder(const IR::ControlBlock *) override;
Expand All @@ -183,21 +173,14 @@ class ConvertToEBPFDeparserPSA : public Inspector {
const IR::Parameter* parserHeaders;
const IR::Parameter* istd;
P4::TypeMap* typemap;
P4::ReferenceMap* refmap;
P4::P4CoreLibrary& p4lib;
EBPF::EBPFDeparserPSA* deparser;

const EbpfOptions &options;

public:
ConvertToEBPFDeparserPSA(EBPFProgram* program, const IR::Parameter* parserHeaders,
const IR::Parameter* istd,
P4::ReferenceMap* refmap, P4::TypeMap* typemap,
const EbpfOptions &options, pipeline_type type)
const IR::Parameter* istd, P4::TypeMap* typemap,
pipeline_type type)
: program(program), pipelineType(type), parserHeaders(parserHeaders),
istd(istd), typemap(typemap), refmap(refmap),
p4lib(P4::P4CoreLibrary::instance),
deparser(nullptr), options(options) {}
istd(istd), typemap(typemap), deparser(nullptr) {}

bool preorder(const IR::ControlBlock *) override;
bool preorder(const IR::Declaration_Instance *) override;
Expand Down
2 changes: 1 addition & 1 deletion backends/graphs/p4c-graphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int main(int argc, char *const argv[]) {
graphs::ControlGraphs cgen(&midEnd.refMap, &midEnd.typeMap, options.graphsDir);
top->getMain()->apply(cgen);
LOG2("Generating parser graphs");
graphs::ParserGraphs pgg(&midEnd.refMap, &midEnd.typeMap, options.graphsDir);
graphs::ParserGraphs pgg(&midEnd.refMap, options.graphsDir);
program->apply(pgg);

graphs::Graph_visitor gvs(options.graphsDir, options.graphs, options.fullGraph,
Expand Down
5 changes: 2 additions & 3 deletions backends/graphs/parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ Graph *ParserGraphs::CreateSubGraph(Graph &currentSubgraph, const cstring &name
return &newSubgraph;
}

ParserGraphs::ParserGraphs(P4::ReferenceMap *refMap, P4::TypeMap *typeMap,
const cstring &graphsDir)
: refMap(refMap), typeMap(typeMap), graphsDir(graphsDir) {
ParserGraphs::ParserGraphs(P4::ReferenceMap *refMap, const cstring &graphsDir)
: refMap(refMap), graphsDir(graphsDir) {
visitDagOnce = false;
}

Expand Down
4 changes: 2 additions & 2 deletions backends/graphs/parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ParserGraphs : public Graphs{
std::map<const IR::P4Parser*, safe_vector<const IR::ParserState*>> states;

public:
ParserGraphs(P4::ReferenceMap *refMap, P4::TypeMap *typeMap, const cstring &graphsDir);
ParserGraphs(P4::ReferenceMap *refMap, const cstring &graphsDir);

Graph *CreateSubGraph(Graph &currentSubgraph, const cstring &name);
void postorder(const IR::P4Parser* parser) override;
Expand All @@ -57,7 +57,7 @@ class ParserGraphs : public Graphs{
std::vector<Graph *> parserGraphsArray{};

private:
P4::ReferenceMap *refMap; P4::TypeMap *typeMap;
P4::ReferenceMap *refMap;
const cstring graphsDir;
boost::optional<cstring> instanceName{};
};
Expand Down
6 changes: 6 additions & 0 deletions cmake/P4CUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ macro(p4c_test_set_name name tag alias)
set(${name} ${tag}/${alias})
endmacro(p4c_test_set_name)

function(append value)
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endfunction()

# add a single test to the testsuite
# Arguments:
# - tag is a label for the set of test suite where this test belongs
Expand Down
Loading