sparse, llvm: Fix symbol initializer code generation
PATCH 1/3 sparse, llvm: Fix symbol initializer code generation
The output_data() function does not see right hand side symbols for expressions such as this in target.c:
struct symbol *size_t_ctype = &uint_ctype;
Therefore, call output_data() recursively if LLVMGetNamedGlobal() returns NULL for a symbol.
Cc Christopher Li <[email protected]>
Cc Jeff Garzik <[email protected]>
Cc Linus Torvalds <[email protected]>
Signed-off-by Pekka Enberg <[email protected]>
--- sparse-llvm.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
sparse-llvm.c +4 -2
@@ -1055,7 +1055,7 @@ static void output_fn(LLVMModuleRef module, struct entrypoint *ep)END_FOR_EACH_PTR (bb); } -static int output_data (LLVMModuleRef module,struct symbol *sym) +static LLVMValueRef output_data (LLVMModuleRef module,struct symbol *sym) {struct expression *initializer = sym->initializer;LLVMValueRef initial_value;
@@ -1071,6 +1071,8 @@ static int output_data(LLVMModuleRef module, struct symbol *sym)struct symbol *sym = initializer->symbol; initial_value =LLVMGetNamedGlobal (module,show_ident (sym->ident)); +if (!initial_value) + initial_value =output_data (module, sym);break ; }default :
@@ -1090,7 +1092,7 @@ static int output_data(LLVMModuleRef module, struct symbol *sym)LLVMSetInitializer (data, initial_value); -return 0 ; +return data; }static int compile (LLVMModuleRef module,struct symbol_list *list)
Signature · 1 line
1.7.6.4
PATCH 2/3 sparse, llvm: Fix 'extern' symbol code generation
LLVMExternalLinkage is used for both extern and non-extern C symbols. The linkage is differentiated by LLVMSetInitializer() which is should not be called for extern symbols.
Cc Christopher Li <[email protected]>
Cc Jeff Garzik <[email protected]>
Cc Linus Torvalds <[email protected]>
Signed-off-by Pekka Enberg <[email protected]>
--- sparse-llvm.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
sparse-llvm.c +2 -1
@@ -1090,7 +1090,8 @@ static LLVMValueRef output_data(LLVMModuleRef module, struct symbol *sym)LLVMSetLinkage (data,data_linkage (sym)); -LLVMSetInitializer (data, initial_value); +if (!(sym->ctype.modifiers &MOD_EXTERN )) +LLVMSetInitializer (data, initial_value);return data; }
Signature · 1 line
1.7.6.4
PATCH 3/3 sparse, llvm: Make llc output to stdout in sparsec
In reply to Pekka EnbergThis patch fixes a bug in 'sparsec' that made it generate empty object files.
Cc Christopher Li <[email protected]>
Cc Jeff Garzik <[email protected]>
Cc Linus Torvalds <[email protected]>
Signed-off-by Pekka Enberg <[email protected]>
--- sparsec | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
sparsec +1 -1
@@ -34,7 +34,7 @@ TMPFILE=`mktemp -t tmp.XXXXXX`".o" $DIRNAME/sparse-llvm $SPARSEOPTS > $TMPLLVM -llc $TMPLLVM | as -o $TMPFILE +llc -o - $TMPLLVM | as -o $TMPFILE if [ $NEED_LINK -eq 1 ]; then if [ -z $OUTFILE ]; then
Signature · 1 line
1.7.6.4