summaryrefslogtreecommitdiffhomepage
path: root/ir/ir
diff options
context:
space:
mode:
authorAndreas Fried <andreas.fried@kit.edu>2018-08-29 15:48:48 +0200
committerAndreas Fried <andreas.fried@kit.edu>2018-08-29 15:53:36 +0200
commit30e5a1abd334dfc16db82127aff840913d8764ac (patch)
tree8605783d8e3c34e9965a2f51ec685ab417fa4c76 /ir/ir
parent137232fc4070ecc828cb448b11bad355bcb10f90 (diff)
irio: Handle differences in initial types.
When exporting from one compiler and importing into another, the initial types may not fully match (e.g. if one compiler uses liboo). In this case, there are two things to do: (1) Do not freak about about the divergence, (2) stop deduplicating types.
Diffstat (limited to 'ir/ir')
-rw-r--r--ir/ir/irio.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/ir/ir/irio.c b/ir/ir/irio.c
index db32208..08d125d 100644
--- a/ir/ir/irio.c
+++ b/ir/ir/irio.c
@@ -95,6 +95,16 @@ static set *symtbl;
static int n_initial_types;
/**
+ * True, if we may still be looking at one of the initial types common
+ * to every program.
+ *
+ * As soon as the types diverge (because exporter and importer have
+ * initialized FIRM differently), we set this to false and stop
+ * deduplicating.
+ */
+static bool maybe_initial_type;
+
+/**
* Compare two symbol table entries.
*/
static int symbol_cmp(const void *elt, const void *key, size_t size)
@@ -1627,17 +1637,22 @@ static void read_type(read_env_t *env)
// That would destroy idempotency for `ir_export . ir_import`
// and bloat the resulting IR files.
- for (int i = 0; i < n_initial_types; ++i) {
- ir_type *t = get_irp_type(i);
- if (typenr != get_type_nr(t)) {
- continue;
+ if (maybe_initial_type) {
+ ir_type *candidate = NULL;
+ for (int i = 0; i < n_initial_types; ++i) {
+ ir_type *t = get_irp_type(i);
+ if (get_type_nr(t) == typenr) {
+ candidate = t;
+ break;
+ }
+ }
+ if (candidate && type_matches(candidate, opcode, size, align, state, flags)) {
+ type = candidate;
+ skip_to(env, '\n');
+ goto extend_env;
+ } else {
+ maybe_initial_type = false;
}
- type = t;
- // There are potentially more fields to compare, but this should
- // be indicative enough if anything went wrong.
- assert(type_matches(type, opcode, size, align, state, flags));
- skip_to(env, '\n');
- goto extend_env;
}
switch (opcode) {
@@ -2255,6 +2270,7 @@ int ir_import_file(FILE *input, const char *inputname)
set_optimize(0);
n_initial_types = get_irp_n_types();
+ maybe_initial_type = true;
while (true) {
keyword_t kw;