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 2/5] llvm: gracefully catch impossible type/value
Date: Mon, 18 Sep 2017 11:30:11 +0200 [thread overview]
Message-ID: <20170918093014.11878-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170918093014.11878-1-luc.vanoostenryck@gmail.com>
Until now, in sparse-llvm, an assert(0) was used each time
something which was not yet handled was encountered.
This is doubly annoying because:
- the assert gave no info about the cause
- it also hide possible further issuses.
Fix this by:
- removing the asserts
- use a warnng explaining what's at hand
- try to continue with the following instructions.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
sparse-llvm.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/sparse-llvm.c b/sparse-llvm.c
index 3a68d09d9..9855ae403 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -353,18 +353,23 @@ static LLVMValueRef constant_value(unsigned long long val, LLVMTypeRef dtype)
result = LLVMConstInt(dtype, val, 1);
break;
default:
- assert(0);
+ return NULL;
}
return result;
}
static LLVMValueRef val_to_value(unsigned long long val, struct symbol *ctype)
{
+ LLVMValueRef result;
LLVMTypeRef dtype;
assert(ctype);
dtype = symbol_type(ctype);
- return constant_value(val, dtype);
+ result = constant_value(val, dtype);
+ if (result)
+ return result;
+ sparse_error(ctype->pos, "no value possible for %s", show_typename(ctype));
+ return LLVMGetUndef(symbol_type(ctype));
}
static LLVMValueRef pseudo_to_value(struct function *fn, struct symbol *ctype, pseudo_t pseudo)
@@ -647,6 +652,8 @@ static void output_op_compare(struct function *fn, struct instruction *insn)
rhs = constant_value(insn->src2->value, LLVMTypeOf(lhs));
else
rhs = pseudo_to_value(fn, NULL, insn->src2);
+ if (!rhs)
+ rhs = LLVMGetUndef(symbol_type(insn->type));
pseudo_name(insn->target, target_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 ` [PATCH 1/5] llvm: warn instead of assert on global inits Luc Van Oostenryck
2017-09-18 9:30 ` Luc Van Oostenryck [this message]
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-3-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).