return x + y;
}
+__attribute__((always_inline))
+inline int
+mcdc027_inlined (int a)
+{
+ if (a)
+ x = a;
+ else
+ x = 1;
+
+ return a + 1;
+}
+
+/* Check that conditions in a function inlined into a function without
+ conditionals works. */
+void
+mcdc027a (int a) /* conditions(1/2) false(0) */
+ /* conditions(end) */
+{
+ mcdc027_inlined (a);
+}
+
+/* Check that conditions in a function inlined into a function with
+ conditionals works and that the conditions are not mixed up. */
+void
+mcdc027b (int a) /* conditions(1/2) false(0) */
+ /* conditions(end) */
+{
+ int v = mcdc027_inlined (a);
+
+ if (v > 10) /* conditions(1/2) true(0) */
+ /* condiitions(end) */
+ x = 10;
+}
+
+/* Check that conditions in a function inlined into a function with
+ conditionals works and that the conditions are not mixed up. Use different
+ number of conditions to distinguish the expressions. */
+void
+mcdc027c (int a, int b) /* conditions(1/2) false(0) */
+ /* conditions(end) */
+{
+ int v = mcdc027_inlined (a);
+
+ if (v > 10 && b) /* conditions(1/4) true(0 1) false(1) */
+ /* condiitions(end) */
+ x = 10;
+}
+
int main ()
{
mcdc001a (0, 1);
mcdc026e (1, 1, 1, 0, 1);
mcdc026e (1, 1, 0, 0, 1);
mcdc026e (1, 1, 1, 1, 1);
+
+ mcdc027a (1);
+ mcdc027b (1);
+ mcdc027c (1, 0);
}
/* { dg-final { run-gcov conditions { --conditions gcov-19.c } } } */
copy_gsi = gsi_start_bb (copy_basic_block);
+ unsigned min_cond_uid = 0;
+ if (id->src_cfun->cond_uids)
+ {
+ if (!cfun->cond_uids)
+ cfun->cond_uids = new hash_map <gcond*, unsigned> ();
+
+ for (auto itr : *id->src_cfun->cond_uids)
+ if (itr.second >= min_cond_uid)
+ min_cond_uid = itr.second + 1;
+ }
+
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple_seq stmts;
if (gimple_nop_p (stmt))
continue;
+ /* If -fcondition-coverage is used, register the inlined conditions
+ in the cond->expression mapping of the caller. The expression tag
+ is shifted conditions from the two bodies are not mixed. */
+ if (id->src_cfun->cond_uids && is_a <gcond*> (orig_stmt))
+ {
+ gcond *orig_cond = as_a <gcond*> (orig_stmt);
+ gcond *cond = as_a <gcond*> (stmt);
+ unsigned *v = id->src_cfun->cond_uids->get (orig_cond);
+ if (v)
+ cfun->cond_uids->put (cond, *v + min_cond_uid);
+ }
+
gimple_duplicate_stmt_histograms (cfun, stmt, id->src_cfun,
orig_stmt);
BLOCK_SUPERCONTEXT (new_block) = current_block;
}
-/* Add local variables from CALLEE to CALLER. If set for condition coverage,
- copy basic condition -> expression mapping to CALLER. */
+/* Add local variables from CALLEE to CALLER. */
static inline void
add_local_variables (struct function *callee, struct function *caller,
}
add_local_decl (caller, new_var);
}
-
- /* If -fcondition-coverage is used and the caller has conditions, copy the
- mapping into the caller but and the end so the caller and callee
- expressions aren't mixed. */
- if (callee->cond_uids)
- {
- if (!caller->cond_uids)
- caller->cond_uids = new hash_map <gcond*, unsigned> ();
-
- unsigned dst_max_uid = 0;
- for (auto itr : *callee->cond_uids)
- if (itr.second >= dst_max_uid)
- dst_max_uid = itr.second + 1;
-
- for (auto itr : *callee->cond_uids)
- caller->cond_uids->put (itr.first, itr.second + dst_max_uid);
- }
}
/* Add to BINDINGS a debug stmt resetting SRCVAR if inlining might