Skip to content

Commit

Permalink
Merge branch 'cleanup'
Browse files Browse the repository at this point in the history
* small build cleanup related to LLVM
  * build: only need includedir from llvm-config
  * build: check if sparse-llvm needs libc++
* small cleanup
  * remove unneeded declarations in "compat.h"
  * remove unused arg in add_branch()
  * allocate BBs only after initial checks in linearize_short_conditional()
  • Loading branch information
lucvoo committed Dec 20, 2018
2 parents 9933b78 + 6bbd005 commit b19ebd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ ifeq ($(shell expr "$(LLVM_VERSION)" : '[3-9]\.'),2)
LLVM_PROGS := sparse-llvm
$(LLVM_PROGS): LD := g++
LLVM_LDFLAGS := $(shell $(LLVM_CONFIG) --ldflags)
LLVM_CFLAGS := $(shell $(LLVM_CONFIG) --cflags | sed -e "s/-DNDEBUG//g" | sed -e "s/-pedantic//g")
LLVM_CFLAGS := -I$(shell $(LLVM_CONFIG) --includedir)
LLVM_LIBS := $(shell $(LLVM_CONFIG) --libs)
LLVM_LIBS += $(shell $(LLVM_CONFIG) --system-libs 2>/dev/null)
LLVM_LIBS += $(shell $(LLVM_CONFIG) --cxxflags | grep -F -q -e '-stdlib=libc++' && echo -lc++)
PROGRAMS += $(LLVM_PROGS)
INST_PROGRAMS += sparse-llvm sparsec
sparse-llvm-cflags := $(LLVM_CFLAGS)
Expand Down
2 changes: 0 additions & 2 deletions compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
* - "string to long double" (C99 strtold())
* Missing in Solaris and MinGW
*/
struct stream;
struct stat;

/*
* Our "blob" allocator works on chunks that are multiples
Expand Down
12 changes: 7 additions & 5 deletions linearize.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ static struct basic_block * add_label(struct entrypoint *ep, struct symbol *labe
return bb;
}

static void add_branch(struct entrypoint *ep, struct expression *expr, pseudo_t cond, struct basic_block *bb_true, struct basic_block *bb_false)
static void add_branch(struct entrypoint *ep, pseudo_t cond, struct basic_block *bb_true, struct basic_block *bb_false)
{
struct basic_block *bb = ep->active;
struct instruction *br;
Expand Down Expand Up @@ -1646,16 +1646,18 @@ static pseudo_t linearize_short_conditional(struct entrypoint *ep, struct expres
{
pseudo_t src1, src2;
struct basic_block *bb_false;
struct basic_block *merge = alloc_basic_block(ep, expr->pos);
struct basic_block *merge;
pseudo_t phi1, phi2;

if (!expr_false || !ep->active)
return VOID;

bb_false = alloc_basic_block(ep, expr_false->pos);
merge = alloc_basic_block(ep, expr->pos);

src1 = linearize_expression(ep, cond);
phi1 = alloc_phi(ep->active, src1, expr->ctype);
add_branch(ep, expr, src1, merge, bb_false);
add_branch(ep, src1, merge, bb_false);

set_activeblock(ep, bb_false);
src2 = linearize_expression(ep, expr_false);
Expand Down Expand Up @@ -1790,7 +1792,7 @@ static pseudo_t linearize_cond_branch(struct entrypoint *ep, struct expression *

case EXPR_COMPARE:
cond = linearize_compare(ep, expr);
add_branch(ep, expr, cond, bb_true, bb_false);
add_branch(ep, cond, bb_true, bb_false);
break;

case EXPR_PREOP:
Expand All @@ -1799,7 +1801,7 @@ static pseudo_t linearize_cond_branch(struct entrypoint *ep, struct expression *
/* fall through */
default: {
cond = linearize_expression_to_bool(ep, expr);
add_branch(ep, expr, cond, bb_true, bb_false);
add_branch(ep, cond, bb_true, bb_false);

return VOID;
}
Expand Down

0 comments on commit b19ebd8

Please sign in to comment.