diff options
| author | Pekka Enberg <penberg@kernel.org> | 2011-09-09 16:03:21 +0300 |
|---|---|---|
| committer | Pekka Enberg <penberg@kernel.org> | 2011-09-09 16:03:21 +0300 |
| commit | e577957155d2022e6636553421fba3a6dcb358b2 (patch) | |
| tree | 0c98fe9edd3f50ca3063a1ab70a4156367a04d9f | |
| parent | f567535353119eae0e57beef52a83519e0ebee3e (diff) | |
| download | sparse-dev-e577957155d2022e6636553421fba3a6dcb358b2.tar.gz | |
sparse, llvm: Add support for symbol initializers
Signed-off-by: Pekka Enberg <penberg@kernel.org>
| -rw-r--r-- | sparse-llvm.c | 13 | ||||
| -rw-r--r-- | validation/backend/struct.c | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c index f1c99dd3..b015ea3c 100644 --- a/sparse-llvm.c +++ b/sparse-llvm.c @@ -946,10 +946,19 @@ static int output_data(LLVMModuleRef module, struct symbol *sym) const char *name; if (initializer) { - if (initializer->type == EXPR_VALUE) + switch (initializer->type) { + case EXPR_VALUE: initial_value = LLVMConstInt(symbol_type(sym), initializer->value, 1); - else + break; + case EXPR_SYMBOL: { + struct symbol *sym = initializer->symbol; + + initial_value = LLVMGetNamedGlobal(module, show_ident(sym->ident)); + break; + } + default: assert(0); + } } else { LLVMTypeRef type = symbol_type(sym); diff --git a/validation/backend/struct.c b/validation/backend/struct.c index ef7d0d7e..9d0cb56f 100644 --- a/validation/backend/struct.c +++ b/validation/backend/struct.c @@ -10,6 +10,7 @@ struct symbol { static struct symbol sym; static struct symbol *sym_p; +static struct symbol *sym_q = &sym; /* * check-name: Struct code generation |
