aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sparse-llvm.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-12-27 17:32:21 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-12-28 18:45:17 +0100
commit5881114fa8fa22353dc1e2e0f00c0f64e647411b (patch)
treee97f5f1be6e0081fe41497927208ef88fdb5e15b /sparse-llvm.c
parent18434703507423b58ecefe941438755525ec834a (diff)
downloadsparse-dev-5881114fa8fa22353dc1e2e0f00c0f64e647411b.tar.gz
llvm: default init of arrays & structs
Linearization of arrays & structs default initialization is done as if these objects would be an integer as large as the object. This integer is then simply zero-initialized. (This may be objectionable and will be done differently). However, sparse-llvm is not ready to handle this situation where a non-scalar is initialized with a scalar value. Workaround this by using LLVMConstNull() when possible. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'sparse-llvm.c')
-rw-r--r--sparse-llvm.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index 4c64f1aa..a1a48fd0 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -354,6 +354,12 @@ static LLVMValueRef constant_value(unsigned long long val, LLVMTypeRef dtype)
case LLVMIntegerTypeKind:
result = LLVMConstInt(dtype, val, 1);
break;
+ case LLVMArrayTypeKind:
+ case LLVMStructTypeKind:
+ if (val != 0)
+ return NULL;
+ result = LLVMConstNull(dtype);
+ break;
default:
return NULL;
}