Skip to content

Commit

Permalink
Merge pull request iovisor#1608 from iovisor/yhs_dev
Browse files Browse the repository at this point in the history
setup some bpf_module data structures correctly when rw_engine is disabled
  • Loading branch information
4ast authored Feb 28, 2018
2 parents cab4d7c + 31bf1c5 commit d7814b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/cc/bpf_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,20 @@ int BPFModule::load_includes(const string &text) {
return 0;
}

void BPFModule::annotate_light() {
for (auto fn = mod_->getFunctionList().begin(); fn != mod_->getFunctionList().end(); ++fn)
if (!fn->hasFnAttribute(Attribute::NoInline))
fn->addFnAttr(Attribute::AlwaysInline);

size_t id = 0;
Path path({id_});
for (auto it = ts_->lower_bound(path), up = ts_->upper_bound(path); it != up; ++it) {
TableDesc &table = it->second;
tables_.push_back(&it->second);
table_names_[table.name] = id++;
}
}

int BPFModule::annotate() {
for (auto fn = mod_->getFunctionList().begin(); fn != mod_->getFunctionList().end(); ++fn)
if (!fn->hasFnAttribute(Attribute::NoInline))
Expand Down Expand Up @@ -945,6 +959,8 @@ int BPFModule::load_b(const string &filename, const string &proto_filename) {
if (rw_engine_enabled_) {
if (int rc = annotate())
return rc;
} else {
annotate_light();
}
if (int rc = finalize())
return rc;
Expand All @@ -966,6 +982,8 @@ int BPFModule::load_c(const string &filename, const char *cflags[], int ncflags)
if (rw_engine_enabled_) {
if (int rc = annotate())
return rc;
} else {
annotate_light();
}
if (int rc = finalize())
return rc;
Expand All @@ -983,6 +1001,8 @@ int BPFModule::load_string(const string &text, const char *cflags[], int ncflags
if (rw_engine_enabled_) {
if (int rc = annotate())
return rc;
} else {
annotate_light();
}

if (int rc = finalize())
Expand Down
1 change: 1 addition & 0 deletions src/cc/bpf_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BPFModule {
int parse(llvm::Module *mod);
int finalize();
int annotate();
void annotate_light();
std::unique_ptr<llvm::ExecutionEngine> finalize_rw(std::unique_ptr<llvm::Module> mod);
std::string make_reader(llvm::Module *mod, llvm::Type *type);
std::string make_writer(llvm::Module *mod, llvm::Type *type);
Expand Down

0 comments on commit d7814b7

Please sign in to comment.