* [PATCH 1/8] dump-ir: add defines for the compilation passes
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
@ 2017-09-15 7:40 ` Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 2/8] dump-ir: allow to specify the passes to execute via cli's options Luc Van Oostenryck
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luc Van Oostenryck @ 2017-09-15 7:40 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib.h b/lib.h
index 307ccaeb2..27c990251 100644
--- a/lib.h
+++ b/lib.h
@@ -107,6 +107,22 @@ extern void expression_error(struct expression *, const char *, ...) FORMAT_ATTR
#define ERROR_PREV_PHASE (1 << 1)
extern int has_error;
+
+enum phase {
+ PASS__PARSE,
+ PASS__LINEARIZE,
+ PASS__MEM2REG,
+ PASS__OPTIM,
+ PASS__FINAL,
+};
+
+#define PASS_PARSE (1UL << PASS__PARSE)
+#define PASS_LINEARIZE (1UL << PASS__LINEARIZE)
+#define PASS_MEM2REG (1UL << PASS__MEM2REG)
+#define PASS_OPTIM (1UL << PASS__OPTIM)
+#define PASS_FINAL (1UL << PASS__FINAL)
+
+
extern void add_pre_buffer(const char *fmt, ...) FORMAT_ATTR(1);
extern int preprocess_only;
--
2.14.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 2/8] dump-ir: allow to specify the passes to execute via cli's options
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 1/8] dump-ir: add defines for the compilation passes Luc Van Oostenryck
@ 2017-09-15 7:40 ` Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 3/8] dump-ir: activate/deactive pass 'mem2reg' Luc Van Oostenryck
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luc Van Oostenryck @ 2017-09-15 7:40 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
Documentation/options.md | 18 ++++++++++++++++++
cgcc | 1 +
lib.c | 37 +++++++++++++++++++++++++++++++++++++
lib.h | 1 +
4 files changed, 57 insertions(+)
create mode 100644 Documentation/options.md
diff --git a/Documentation/options.md b/Documentation/options.md
new file mode 100644
index 000000000..5677789e1
--- /dev/null
+++ b/Documentation/options.md
@@ -0,0 +1,18 @@
+# Options
+
+This file is a complement of man page for sparse but meant
+for options not to be used by sparse itself but by the other
+tools.
+
+## Developer options:
+
+### Select the passes
+
+* '-f\<name-of-the-pass\>[-disable|-enable|=last]'
+
+ If '=last' is used, all passes after the specified one are disabled.
+ By default all passes are enabled.
+
+ The passes currently understood are:
+ * 'mem2reg'
+ * 'optim'
diff --git a/cgcc b/cgcc
index a8d7b4f21..75eee26fe 100755
--- a/cgcc
+++ b/cgcc
@@ -104,6 +104,7 @@ sub check_only_option {
return 1 if $arg =~ /^-W(no-?)?(address-space|bitwise|cast-to-as|cast-truncate|context|decl|default-bitfield-sign|designated-init|do-while|enum-mismatch|init-cstring|memcpy-max-count|non-pointer-null|old-initializer|one-bit-signed-bitfield|override-init-all|paren-string|ptr-subtraction-blows|return-void|sizeof-bool|sparse-all|sparse-error|transparent-union|typesign|undef|unknown-attribute)$/;
return 1 if $arg =~ /^-v(no-?)?(entry|dead)$/;
return 1 if $arg =~ /^-f(dump-linearize|memcpy-max-count)(=\S*)?$/;
+ return 1 if $arg =~ /^-f(mem2reg|optim)(-enable|-disable|=last)?$/;
return 0;
}
diff --git a/lib.c b/lib.c
index a03a94d69..a78926dfd 100644
--- a/lib.c
+++ b/lib.c
@@ -260,6 +260,7 @@ int dbg_dead = 0;
int fmem_report = 0;
int fdump_linearize;
unsigned long long fmemcpy_max_count = 100000;
+unsigned long fpasses = ~0UL;
int preprocess_only;
@@ -760,6 +761,40 @@ static int handle_ftabstop(const char *arg, const char *opt, const struct flag *
return 1;
}
+static int handle_fpasses(const char *arg, const char *opt, const struct flag *flag, int options)
+{
+ unsigned long mask;
+
+ mask = flag->mask;
+ if (*opt == '\0') {
+ if (options & OPT_INVERSE)
+ fpasses &= ~mask;
+ else
+ fpasses |= mask;
+ return 1;
+ }
+ if (options & OPT_INVERSE)
+ goto error;
+ if (!strcmp(opt, "-enable")) {
+ fpasses |= mask;
+ return 1;
+ }
+ if (!strcmp(opt, "-disable")) {
+ fpasses &= ~mask;
+ return 1;
+ }
+ if (!strcmp(opt, "=last")) {
+ // clear everything above
+ mask |= mask - 1;
+ fpasses &= mask;
+ return 1;
+ }
+ return 0;
+
+error:
+ die("error: wrong option \"%s\"", arg);
+}
+
static int handle_fdump_ir(const char *arg, const char *opt, const struct flag *flag, int options)
{
if (*opt == '\0')
@@ -783,6 +818,8 @@ static struct flag fflags[] = {
{ "mem-report", &fmem_report },
{ "memcpy-max-count=", NULL, handle_fmemcpy_max_count },
{ "tabstop=", NULL, handle_ftabstop },
+ { "mem2reg", NULL, handle_fpasses, PASS_MEM2REG },
+ { "optim", NULL, handle_fpasses, PASS_OPTIM },
{ },
};
diff --git a/lib.h b/lib.h
index 27c990251..5111a0eb9 100644
--- a/lib.h
+++ b/lib.h
@@ -169,6 +169,7 @@ extern int dbg_dead;
extern int fmem_report;
extern int fdump_linearize;
extern unsigned long long fmemcpy_max_count;
+extern unsigned long fpasses;
extern int arch_m64;
extern int arch_msize_long;
--
2.14.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 3/8] dump-ir: activate/deactive pass 'mem2reg'
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 1/8] dump-ir: add defines for the compilation passes Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 2/8] dump-ir: allow to specify the passes to execute via cli's options Luc Van Oostenryck
@ 2017-09-15 7:40 ` Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 4/8] dump-ir: set the default optimization level to 2 Luc Van Oostenryck
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luc Van Oostenryck @ 2017-09-15 7:40 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
linearize.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/linearize.c b/linearize.c
index ba76397ea..31cc94806 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2235,7 +2235,8 @@ static struct entrypoint *linearize_fn(struct symbol *sym, struct symbol *base_t
/*
* Turn symbols into pseudos
*/
- simplify_symbol_usage(ep);
+ if (fpasses & PASS_MEM2REG)
+ simplify_symbol_usage(ep);
repeat:
/*
--
2.14.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 4/8] dump-ir: set the default optimization level to 2
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
` (2 preceding siblings ...)
2017-09-15 7:40 ` [PATCH 3/8] dump-ir: activate/deactive pass 'mem2reg' Luc Van Oostenryck
@ 2017-09-15 7:40 ` Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 5/8] dump-ir: use -O0 Luc Van Oostenryck
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luc Van Oostenryck @ 2017-09-15 7:40 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib.c b/lib.c
index a78926dfd..6f8ee1e59 100644
--- a/lib.c
+++ b/lib.c
@@ -45,7 +45,9 @@
#include "target.h"
#include "version.h"
-int verbose, optimize, optimize_size, preprocessing;
+int verbose, preprocessing;
+int optimize = 2;
+int optimize_size = 0;
int die_if_error = 0;
int has_error = 0;
--
2.14.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 5/8] dump-ir: use -O0
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
` (3 preceding siblings ...)
2017-09-15 7:40 ` [PATCH 4/8] dump-ir: set the default optimization level to 2 Luc Van Oostenryck
@ 2017-09-15 7:40 ` Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 6/8] dump-ir: saner use of fdump_linearize Luc Van Oostenryck
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luc Van Oostenryck @ 2017-09-15 7:40 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
linearize.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/linearize.c b/linearize.c
index 31cc94806..65a4baf96 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2238,6 +2238,8 @@ static struct entrypoint *linearize_fn(struct symbol *sym, struct symbol *base_t
if (fpasses & PASS_MEM2REG)
simplify_symbol_usage(ep);
+ if (optimize == 0)
+ return ep;
repeat:
/*
* Remove trivial instructions, and try to CSE
--
2.14.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 6/8] dump-ir: saner use of fdump_linearize
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
` (4 preceding siblings ...)
2017-09-15 7:40 ` [PATCH 5/8] dump-ir: use -O0 Luc Van Oostenryck
@ 2017-09-15 7:40 ` Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 7/8] dump-ir: rename -fdump-linearize to -fdump-ir Luc Van Oostenryck
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luc Van Oostenryck @ 2017-09-15 7:40 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
linearize.c | 5 +----
test-linearize.c | 2 ++
test-unssa.c | 2 ++
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/linearize.c b/linearize.c
index 65a4baf96..4970771bc 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2220,11 +2220,8 @@ static struct entrypoint *linearize_fn(struct symbol *sym, struct symbol *base_t
add_one_insn(ep, insn);
}
- if (fdump_linearize) {
- if (fdump_linearize == 2)
- return ep;
+ if (fdump_linearize)
show_entry(ep);
- }
/*
* Do trivial flow simplification - branches to
diff --git a/test-linearize.c b/test-linearize.c
index fe0673bef..284526781 100644
--- a/test-linearize.c
+++ b/test-linearize.c
@@ -47,6 +47,8 @@ static void clean_up_symbols(struct symbol_list *list)
expand_symbol(sym);
ep = linearize_symbol(sym);
+ if (fdump_linearize == 2)
+ continue;
if (ep)
show_entry(ep);
} END_FOR_EACH_PTR(sym);
diff --git a/test-unssa.c b/test-unssa.c
index 240d99601..ec5c93015 100644
--- a/test-unssa.c
+++ b/test-unssa.c
@@ -62,6 +62,8 @@ static int compile(struct symbol_list *list)
struct entrypoint *ep;
expand_symbol(sym);
ep = linearize_symbol(sym);
+ if (fdump_linearize == 2)
+ continue;
if (ep)
output_fn(ep);
else
--
2.14.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 7/8] dump-ir: rename -fdump-linearize to -fdump-ir
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
` (5 preceding siblings ...)
2017-09-15 7:40 ` [PATCH 6/8] dump-ir: saner use of fdump_linearize Luc Van Oostenryck
@ 2017-09-15 7:40 ` Luc Van Oostenryck
2017-09-15 7:40 ` [PATCH 8/8] dump-ir: make it more flexible Luc Van Oostenryck
2017-09-15 17:06 ` [PATCH 0/8] dump the IR Christopher Li
8 siblings, 0 replies; 10+ messages in thread
From: Luc Van Oostenryck @ 2017-09-15 7:40 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
as it will be used for dumping the IR not only just after
linearization but after other passes too.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
cgcc | 2 +-
lib.c | 8 ++++----
lib.h | 2 +-
linearize.c | 2 +-
sparse.1 | 2 +-
test-linearize.c | 2 +-
test-unssa.c | 2 +-
validation/linear/bitfield-init-mask.c | 2 +-
8 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/cgcc b/cgcc
index 75eee26fe..4aeb2da65 100755
--- a/cgcc
+++ b/cgcc
@@ -103,7 +103,7 @@ sub check_only_option {
my ($arg) = @_;
return 1 if $arg =~ /^-W(no-?)?(address-space|bitwise|cast-to-as|cast-truncate|context|decl|default-bitfield-sign|designated-init|do-while|enum-mismatch|init-cstring|memcpy-max-count|non-pointer-null|old-initializer|one-bit-signed-bitfield|override-init-all|paren-string|ptr-subtraction-blows|return-void|sizeof-bool|sparse-all|sparse-error|transparent-union|typesign|undef|unknown-attribute)$/;
return 1 if $arg =~ /^-v(no-?)?(entry|dead)$/;
- return 1 if $arg =~ /^-f(dump-linearize|memcpy-max-count)(=\S*)?$/;
+ return 1 if $arg =~ /^-f(dump-ir|memcpy-max-count)(=\S*)?$/;
return 1 if $arg =~ /^-f(mem2reg|optim)(-enable|-disable|=last)?$/;
return 0;
}
diff --git a/lib.c b/lib.c
index 6f8ee1e59..e7bdc0783 100644
--- a/lib.c
+++ b/lib.c
@@ -259,8 +259,8 @@ int dump_macro_defs = 0;
int dbg_entry = 0;
int dbg_dead = 0;
+int fdump_ir;
int fmem_report = 0;
-int fdump_linearize;
unsigned long long fmemcpy_max_count = 100000;
unsigned long fpasses = ~0UL;
@@ -800,9 +800,9 @@ error:
static int handle_fdump_ir(const char *arg, const char *opt, const struct flag *flag, int options)
{
if (*opt == '\0')
- fdump_linearize = 1;
+ fdump_ir = 1;
else if (!strcmp(opt, "=only"))
- fdump_linearize = 2;
+ fdump_ir = 2;
else
die("error: wrong option \"%s\"", arg);
@@ -816,7 +816,7 @@ static int handle_fmemcpy_max_count(const char *arg, const char *opt, const stru
}
static struct flag fflags[] = {
- { "dump-linearize", NULL, handle_fdump_ir },
+ { "dump-ir", NULL, handle_fdump_ir },
{ "mem-report", &fmem_report },
{ "memcpy-max-count=", NULL, handle_fmemcpy_max_count },
{ "tabstop=", NULL, handle_ftabstop },
diff --git a/lib.h b/lib.h
index 5111a0eb9..bfcfd2a08 100644
--- a/lib.h
+++ b/lib.h
@@ -167,7 +167,7 @@ extern int dbg_entry;
extern int dbg_dead;
extern int fmem_report;
-extern int fdump_linearize;
+extern int fdump_ir;
extern unsigned long long fmemcpy_max_count;
extern unsigned long fpasses;
diff --git a/linearize.c b/linearize.c
index 4970771bc..8ab93e0b3 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2220,7 +2220,7 @@ static struct entrypoint *linearize_fn(struct symbol *sym, struct symbol *base_t
add_one_insn(ep, insn);
}
- if (fdump_linearize)
+ if (fdump_ir)
show_entry(ep);
/*
diff --git a/sparse.1 b/sparse.1
index bec8d6d73..810fb3219 100644
--- a/sparse.1
+++ b/sparse.1
@@ -357,7 +357,7 @@ normalized GNU triplet. (e.g. i386-linux-gnu).
.
.SH DEBUG OPTIONS
.TP
-.B \-fdump-linearize[=only]
+.B \-fdump-ir[=only]
Dump the IR code of a function directly after its linearization,
before any simplifications is made. If the argument \fB=only\fR is
also given no further processing is done on the function.
diff --git a/test-linearize.c b/test-linearize.c
index 284526781..c7122080e 100644
--- a/test-linearize.c
+++ b/test-linearize.c
@@ -47,7 +47,7 @@ static void clean_up_symbols(struct symbol_list *list)
expand_symbol(sym);
ep = linearize_symbol(sym);
- if (fdump_linearize == 2)
+ if (fdump_ir == 2)
continue;
if (ep)
show_entry(ep);
diff --git a/test-unssa.c b/test-unssa.c
index ec5c93015..e0981802d 100644
--- a/test-unssa.c
+++ b/test-unssa.c
@@ -62,7 +62,7 @@ static int compile(struct symbol_list *list)
struct entrypoint *ep;
expand_symbol(sym);
ep = linearize_symbol(sym);
- if (fdump_linearize == 2)
+ if (fdump_ir == 2)
continue;
if (ep)
output_fn(ep);
diff --git a/validation/linear/bitfield-init-mask.c b/validation/linear/bitfield-init-mask.c
index 94afa400c..f43605855 100644
--- a/validation/linear/bitfield-init-mask.c
+++ b/validation/linear/bitfield-init-mask.c
@@ -18,7 +18,7 @@ struct bfu bfu_init_20_23(int a)
/*
* check-name: bitfield initializer mask
- * check-command: test-linearize -fdump-linearize=only -Wno-decl $file
+ * check-command: test-linearize -fdump-ir=only -Wno-decl $file
* check-output-ignore
*
* check-output-contains: and\\..*fffff800\$
--
2.14.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 8/8] dump-ir: make it more flexible
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
` (6 preceding siblings ...)
2017-09-15 7:40 ` [PATCH 7/8] dump-ir: rename -fdump-linearize to -fdump-ir Luc Van Oostenryck
@ 2017-09-15 7:40 ` Luc Van Oostenryck
2017-09-15 17:06 ` [PATCH 0/8] dump the IR Christopher Li
8 siblings, 0 replies; 10+ messages in thread
From: Luc Van Oostenryck @ 2017-09-15 7:40 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
Documentation/options.md | 11 ++++++
lib.c | 70 ++++++++++++++++++++++++++++++----
lib.h | 2 +-
linearize.c | 2 +-
sparse.1 | 6 ---
test-linearize.c | 2 +-
test-unssa.c | 2 +-
validation/linear/bitfield-init-mask.c | 2 +-
8 files changed, 78 insertions(+), 19 deletions(-)
diff --git a/Documentation/options.md b/Documentation/options.md
index 5677789e1..14698a981 100644
--- a/Documentation/options.md
+++ b/Documentation/options.md
@@ -16,3 +16,14 @@ tools.
The passes currently understood are:
* 'mem2reg'
* 'optim'
+
+### Internal Representation
+
+* '-fdump-ir[=\<pass\>[,\<pass\>...]]'
+
+ Dump the IR at each of the given passes.
+
+ The passes currently understood are:
+ * 'linearize'
+ * 'mem2reg'
+ * 'final'
diff --git a/lib.c b/lib.c
index e7bdc0783..03250c9e9 100644
--- a/lib.c
+++ b/lib.c
@@ -259,7 +259,7 @@ int dump_macro_defs = 0;
int dbg_entry = 0;
int dbg_dead = 0;
-int fdump_ir;
+unsigned long fdump_ir;
int fmem_report = 0;
unsigned long long fmemcpy_max_count = 100000;
unsigned long fpasses = ~0UL;
@@ -487,6 +487,57 @@ const char *match_option(const char *arg, const char *prefix)
}
+struct mask_map {
+ const char *name;
+ unsigned long mask;
+};
+
+static int apply_mask(unsigned long *val, const char *str, unsigned len, const struct mask_map *map, int neg)
+{
+ const char *name;
+
+ for (;(name = map->name); map++) {
+ if (!strncmp(name, str, len) && !name[len]) {
+ if (neg == 0)
+ *val |= map->mask;
+ else
+ *val &= ~map->mask;
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static int handle_suboption_mask(const char *arg, const char *opt, const struct mask_map *map, unsigned long *flag)
+{
+ if (*opt == '\0') {
+ apply_mask(flag, "", 0, map, 0);
+ return 1;
+ }
+ if (*opt++ != '=')
+ return 0;
+ while (1) {
+ unsigned int len = strcspn(opt, ",+");
+ int neg = 0;
+ if (len == 0)
+ goto end;
+ if (!strncmp(opt, "no-", 3)) {
+ opt += 3;
+ len -= 3;
+ neg = 1;
+ }
+ if (apply_mask(flag, opt, len, map, neg))
+ die("error: wrong option '%.*s' for \'%s\'", len, opt, arg);
+
+end:
+ opt += len;
+ if (*opt++ == '\0')
+ break;
+ }
+ return 1;
+}
+
+
#define OPT_INVERSE 1
struct flag {
const char *name;
@@ -799,14 +850,15 @@ error:
static int handle_fdump_ir(const char *arg, const char *opt, const struct flag *flag, int options)
{
- if (*opt == '\0')
- fdump_ir = 1;
- else if (!strcmp(opt, "=only"))
- fdump_ir = 2;
- else
- die("error: wrong option \"%s\"", arg);
+ static const struct mask_map dump_ir_options[] = {
+ { "", PASS_LINEARIZE },
+ { "linearize", PASS_LINEARIZE },
+ { "mem2reg", PASS_MEM2REG },
+ { "final", PASS_FINAL },
+ { },
+ };
- return 1;
+ return handle_suboption_mask(arg, opt, dump_ir_options, &fdump_ir);
}
static int handle_fmemcpy_max_count(const char *arg, const char *opt, const struct flag *flag, int options)
@@ -1405,6 +1457,8 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list
handle_switch_v_finalize();
handle_arch_finalize();
+ if (fdump_ir == 0)
+ fdump_ir = PASS_FINAL;
list = NULL;
if (!ptr_list_empty(filelist)) {
diff --git a/lib.h b/lib.h
index bfcfd2a08..8d3c67a0d 100644
--- a/lib.h
+++ b/lib.h
@@ -167,7 +167,7 @@ extern int dbg_entry;
extern int dbg_dead;
extern int fmem_report;
-extern int fdump_ir;
+extern unsigned long fdump_ir;
extern unsigned long long fmemcpy_max_count;
extern unsigned long fpasses;
diff --git a/linearize.c b/linearize.c
index 8ab93e0b3..212a5feaf 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2220,7 +2220,7 @@ static struct entrypoint *linearize_fn(struct symbol *sym, struct symbol *base_t
add_one_insn(ep, insn);
}
- if (fdump_ir)
+ if (fdump_ir & PASS_LINEARIZE)
show_entry(ep);
/*
diff --git a/sparse.1 b/sparse.1
index 810fb3219..377d1d3cb 100644
--- a/sparse.1
+++ b/sparse.1
@@ -356,12 +356,6 @@ The \fIdir\fR name would normally take the form of the target's
normalized GNU triplet. (e.g. i386-linux-gnu).
.
.SH DEBUG OPTIONS
-.TP
-.B \-fdump-ir[=only]
-Dump the IR code of a function directly after its linearization,
-before any simplifications is made. If the argument \fB=only\fR is
-also given no further processing is done on the function.
-.
.B \-fmem-report
Report some statistics about memory allocation used by the tool.
.
diff --git a/test-linearize.c b/test-linearize.c
index c7122080e..e6d1ee3cd 100644
--- a/test-linearize.c
+++ b/test-linearize.c
@@ -47,7 +47,7 @@ static void clean_up_symbols(struct symbol_list *list)
expand_symbol(sym);
ep = linearize_symbol(sym);
- if (fdump_ir == 2)
+ if (!(fdump_ir & PASS_FINAL))
continue;
if (ep)
show_entry(ep);
diff --git a/test-unssa.c b/test-unssa.c
index e0981802d..80752f432 100644
--- a/test-unssa.c
+++ b/test-unssa.c
@@ -62,7 +62,7 @@ static int compile(struct symbol_list *list)
struct entrypoint *ep;
expand_symbol(sym);
ep = linearize_symbol(sym);
- if (fdump_ir == 2)
+ if (!(fdump_ir & PASS_FINAL))
continue;
if (ep)
output_fn(ep);
diff --git a/validation/linear/bitfield-init-mask.c b/validation/linear/bitfield-init-mask.c
index f43605855..aac21e614 100644
--- a/validation/linear/bitfield-init-mask.c
+++ b/validation/linear/bitfield-init-mask.c
@@ -18,7 +18,7 @@ struct bfu bfu_init_20_23(int a)
/*
* check-name: bitfield initializer mask
- * check-command: test-linearize -fdump-ir=only -Wno-decl $file
+ * check-command: test-linearize -fdump-ir=linearize -Wno-decl $file
* check-output-ignore
*
* check-output-contains: and\\..*fffff800\$
--
2.14.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 0/8] dump the IR
2017-09-15 7:40 [PATCH 0/8] dump the IR Luc Van Oostenryck
` (7 preceding siblings ...)
2017-09-15 7:40 ` [PATCH 8/8] dump-ir: make it more flexible Luc Van Oostenryck
@ 2017-09-15 17:06 ` Christopher Li
8 siblings, 0 replies; 10+ messages in thread
From: Christopher Li @ 2017-09-15 17:06 UTC (permalink / raw)
To: Luc Van Oostenryck; +Cc: Linux-Sparse
On Fri, Sep 15, 2017 at 3:40 AM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> The goal of thsi series is to allow and control dumping of
> the IR at different stage of the processing.
>
> This is meant to be used for testing & debugging.
>
>
> Note: this series depends on the series 'option-parsing'
>
>
> This series is also available for review in the git repository at:
>
> git://github.com/lucvoo/sparse.git dump-ir
>
I think with more extend on the dumping IR is good.
We might be able to get ride of test-linearize and test-parsing.
Just use sparse to do the dumping.
Chris
^ permalink raw reply [flat|nested] 10+ messages in thread