From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 1/5] llvm: warn instead of assert on global inits
Date: Mon, 18 Sep 2017 11:30:10 +0200 [thread overview]
Message-ID: <20170918093014.11878-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170918093014.11878-1-luc.vanoostenryck@gmail.com>
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 --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);
--
2.14.0
next prev parent reply other threads:[~2017-09-18 9:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-18 9:30 [PATCH 0/5] extra fixes for LLVM Luc Van Oostenryck
2017-09-18 9:30 ` Luc Van Oostenryck [this message]
2017-09-18 9:30 ` [PATCH 2/5] llvm: gracefully catch impossible type/value Luc Van Oostenryck
2017-09-18 9:30 ` [PATCH 3/5] llvm: add support for float initializer Luc Van Oostenryck
2017-09-18 9:30 ` [PATCH 4/5] llvm: give names easier to debug Luc Van Oostenryck
2017-09-18 9:30 ` [PATCH 5/5] llvm: only compare void pointers Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170918093014.11878-2-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).