[Mesa-dev] [PATCH 2/2] clover: Constify llvm::Function handling
Jan Vesely
jan.vesely at rutgers.edu
Thu Jun 23 00:52:27 UTC 2016
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
This can be squashed with the previous one
.../state_trackers/clover/llvm/invocation.cpp | 28 ++++++++++------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index db748b4..41064bd 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -276,12 +276,12 @@ namespace {
#endif
}
- std::vector<llvm::Function *>
- find_kernels(llvm::Module *mod) {
- std::vector<llvm::Function *> kernels;
+ std::vector<const llvm::Function *>
+ find_kernels(const llvm::Module *mod) {
+ std::vector<const llvm::Function *> kernels;
#if HAVE_LLVM >= 0x0309
- auto &list = mod->getFunctionList();
- for_each(list.begin(), list.end(), [&](llvm::Function &f){
+ const auto &list = mod->getFunctionList();
+ for_each(list.begin(), list.end(), [&](const llvm::Function &f){
if (f.getMetadata("kernel_arg_type"))
kernels.push_back(&f);
});
@@ -293,7 +293,7 @@ namespace {
// require that we return an error here, but there will be an error if
// the user tries to pass this program to a clCreateKernel() call.
if (!kernel_node) {
- return std::vector<llvm::Function *>();
+ return kernels;
}
kernels.reserve(kernel_node->getNumOperands());
@@ -317,7 +317,7 @@ namespace {
llvm::PassManager PM;
#endif
- const std::vector<llvm::Function *> kernels = find_kernels(mod);
+ const std::vector<const llvm::Function *> kernels = find_kernels(mod);
// Add a function internalizer pass.
//
@@ -618,7 +618,7 @@ namespace {
}
module
- build_module_llvm(llvm::Module *mod,
+ build_module_llvm(const llvm::Module *mod,
clang::LangAS::Map& address_spaces) {
module m;
@@ -632,7 +632,7 @@ namespace {
bitcode_ostream.flush();
#endif
- const std::vector<llvm::Function *> kernels = find_kernels(mod);
+ const std::vector<const llvm::Function *> kernels = find_kernels(mod);
for (unsigned i = 0; i < kernels.size(); ++i) {
std::string kernel_name = kernels[i]->getName();
std::vector<module::argument> args =
@@ -735,7 +735,7 @@ namespace {
std::map<std::string, unsigned>
get_kernel_offsets(std::vector<char> &code,
- const std::vector<llvm::Function *> &kernels,
+ const std::vector<const llvm::Function *> &kernels,
std::string &r_log) {
// One of the libelf implementations
@@ -786,9 +786,7 @@ namespace {
// Determine the offsets for each kernel
for (int i = 0; (symbol = gelf_getsym(symtab_data, i, &s)); i++) {
char *name = elf_strptr(elf, symtab_header.sh_link, symbol->st_name);
- for (std::vector<llvm::Function*>::const_iterator it = kernels.begin(),
- e = kernels.end(); it != e; ++it) {
- llvm::Function *f = *it;
+ for (const llvm::Function *f : kernels) {
if (f->getName() == std::string(name))
kernel_offsets[f->getName()] = symbol->st_value;
}
@@ -799,11 +797,11 @@ namespace {
module
build_module_native(std::vector<char> &code,
- llvm::Module *mod,
+ const llvm::Module *mod,
const clang::LangAS::Map &address_spaces,
std::string &r_log) {
- const std::vector<llvm::Function *> kernels = find_kernels(mod);
+ const std::vector<const llvm::Function *> kernels = find_kernels(mod);
std::map<std::string, unsigned> kernel_offsets =
get_kernel_offsets(code, kernels, r_log);
--
2.7.4
More information about the mesa-dev
mailing list