diff mbox

[1/2] llvm: warn instead of assert on global inits

Message ID 20170814194152.36289-2-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Luc Van Oostenryck Aug. 14, 2017, 7:41 p.m. UTC
Currently, sparse-llvm can't emit the needed code for
all initializers and when it's the case it stop abruptly
with an assert(0).

This is kinda useless.

Somehow fix this by issuing a warning instead and try to
continue gracefully.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 sparse-llvm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/sparse-llvm.c b/sparse-llvm.c
index 3a68d09d9..9a32efe36 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -1212,7 +1212,9 @@  static LLVMValueRef output_data(LLVMModuleRef module, struct symbol *sym)
 			break;
 		}
 		default:
-			assert(0);
+			warning(initializer->pos, "can't initialize type: %s", show_typename(sym));
+			initial_value = NULL;
+			break;
 		}
 	} else {
 		LLVMTypeRef type = symbol_type(sym);
@@ -1220,6 +1222,9 @@  static LLVMValueRef output_data(LLVMModuleRef module, struct symbol *sym)
 		initial_value = LLVMConstNull(type);
 	}
 
+	if (!initial_value)
+		return NULL;
+
 	name = sym->ident ? show_ident(sym->ident) : "" ;
 
 	data = LLVMAddGlobal(module, LLVMTypeOf(initial_value), name);