Commit d7814b79 authored by 4ast's avatar 4ast Committed by GitHub

Merge pull request #1608 from iovisor/yhs_dev

setup some bpf_module data structures correctly when rw_engine is disabled
parents cab4d7c6 31bf1c5c
...@@ -486,6 +486,20 @@ int BPFModule::load_includes(const string &text) { ...@@ -486,6 +486,20 @@ int BPFModule::load_includes(const string &text) {
return 0; 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() { int BPFModule::annotate() {
for (auto fn = mod_->getFunctionList().begin(); fn != mod_->getFunctionList().end(); ++fn) for (auto fn = mod_->getFunctionList().begin(); fn != mod_->getFunctionList().end(); ++fn)
if (!fn->hasFnAttribute(Attribute::NoInline)) if (!fn->hasFnAttribute(Attribute::NoInline))
...@@ -945,6 +959,8 @@ int BPFModule::load_b(const string &filename, const string &proto_filename) { ...@@ -945,6 +959,8 @@ int BPFModule::load_b(const string &filename, const string &proto_filename) {
if (rw_engine_enabled_) { if (rw_engine_enabled_) {
if (int rc = annotate()) if (int rc = annotate())
return rc; return rc;
} else {
annotate_light();
} }
if (int rc = finalize()) if (int rc = finalize())
return rc; return rc;
...@@ -966,6 +982,8 @@ int BPFModule::load_c(const string &filename, const char *cflags[], int ncflags) ...@@ -966,6 +982,8 @@ int BPFModule::load_c(const string &filename, const char *cflags[], int ncflags)
if (rw_engine_enabled_) { if (rw_engine_enabled_) {
if (int rc = annotate()) if (int rc = annotate())
return rc; return rc;
} else {
annotate_light();
} }
if (int rc = finalize()) if (int rc = finalize())
return rc; return rc;
...@@ -983,6 +1001,8 @@ int BPFModule::load_string(const string &text, const char *cflags[], int ncflags ...@@ -983,6 +1001,8 @@ int BPFModule::load_string(const string &text, const char *cflags[], int ncflags
if (rw_engine_enabled_) { if (rw_engine_enabled_) {
if (int rc = annotate()) if (int rc = annotate())
return rc; return rc;
} else {
annotate_light();
} }
if (int rc = finalize()) if (int rc = finalize())
......
...@@ -61,6 +61,7 @@ class BPFModule { ...@@ -61,6 +61,7 @@ class BPFModule {
int parse(llvm::Module *mod); int parse(llvm::Module *mod);
int finalize(); int finalize();
int annotate(); int annotate();
void annotate_light();
std::unique_ptr<llvm::ExecutionEngine> finalize_rw(std::unique_ptr<llvm::Module> mod); 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_reader(llvm::Module *mod, llvm::Type *type);
std::string make_writer(llvm::Module *mod, llvm::Type *type); std::string make_writer(llvm::Module *mod, llvm::Type *type);
......
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