aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2011-08-30 22:24:07 -0400
committerJeff Garzik <jgarzik@redhat.com>2011-08-30 22:24:07 -0400
commit0c8f7c8757d13a8116832d083ed2d71b6b679d89 (patch)
treeb3d0051467ec3c3590866e23137b7f878e4522a3
parenta99eaeda5e41fd15a27bf8db80a04eb2d129bc66 (diff)
downloadsparse-0c8f7c8757d13a8116832d083ed2d71b6b679d89.tar.gz
sparse, llvm: store module-local functions on function reference list
Fixes testcase: int sum(int x, int y) { return x + y; } int main(int argc, char *argv[]) { return sum(1, 2); }
-rw-r--r--sparse-llvm.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index 22ed397b..d3cb4f2e 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -549,7 +549,7 @@ static LLVMValueRef get_function(struct function *fn, struct instruction *insn)
func = LLVMAddFunction(fn->module, buffer, func_type);
- /* store built function on list, for later */
+ /* store built function on list, for later referencing */
f = calloc(1, sizeof(*f));
strncpy(f->name, buffer, sizeof(f->name) - 1);
f->func = func;
@@ -781,6 +781,7 @@ static void output_fn(LLVMModuleRef module, struct entrypoint *ep)
struct symbol *arg;
const char *name;
int nr_args = 0;
+ struct llfunc *f;
FOR_EACH_PTR(base_type->arguments, arg) {
struct symbol *arg_base_type = arg->ctype.base_type;
@@ -801,6 +802,13 @@ static void output_fn(LLVMModuleRef module, struct entrypoint *ep)
LLVMSetLinkage(function.fn, function_linkage(sym));
+ /* store built function on list, for later referencing */
+ f = calloc(1, sizeof(*f));
+ strncpy(f->name, name, sizeof(f->name) - 1);
+ f->func = function.fn;
+
+ add_ptr_list(&mi.llfunc_list, f);
+
function.builder = LLVMCreateBuilder();
static int nr_bb;