aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.misc-tests
diff options
context:
space:
mode:
authorJørgen Kvalsvik <j@lambda.is>2024-04-05 21:42:07 +0200
committerJørgen Kvalsvik <j@lambda.is>2024-04-06 13:10:29 +0200
commitc6892a430a9752aea167265621c3ae7a3e11159f (patch)
tree7c1a22cf3f526849aa57642fa17868f545a0105f /gcc/testsuite/gcc.misc-tests
parent888bf719728e9ab1da22900d39956e0d80889e30 (diff)
downloadgcc-c6892a430a9752aea167265621c3ae7a3e11159f.zip
gcc-c6892a430a9752aea167265621c3ae7a3e11159f.tar.gz
gcc-c6892a430a9752aea167265621c3ae7a3e11159f.tar.bz2
Copy condition->expr map when inlining [PR114599]
When a function is tree-inlined, copy the condition -> expression mapping from the inlined function into the caller, shifted so uids are not mixed. Tree inlining was always problematic under condition coverage - either through a nullptr dereference (triggered by the test case), or through quietly mixing caller conditions with the callee conditions. PR middle-end/114599 gcc/ChangeLog: * tree-inline.cc (add_local_variables): Copy cond_uids mappings. gcc/testsuite/ChangeLog: * gcc.misc-tests/gcov-pr114599.c: New test.
Diffstat (limited to 'gcc/testsuite/gcc.misc-tests')
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-pr114599.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-pr114599.c b/gcc/testsuite/gcc.misc-tests/gcov-pr114599.c
new file mode 100644
index 0000000..e4c78c9
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-pr114599.c
@@ -0,0 +1,25 @@
+/* PR middle-end/114599 */
+/* { dg-do compile } */
+/* { dg-options "-fcondition-coverage" } */
+
+/* Check that a function with a condition inlined into a function without a
+ conditional works. When inlining happens the condition -> expression
+ mapping must be carried over. */
+
+extern int type;
+
+void fn (void);
+
+__attribute__((always_inline))
+inline void
+do_all_fn_doall_arg (void)
+{
+ if (type)
+ fn ();
+}
+
+void
+do_all_fn_LHASH_DOALL_ARG_arg2 (void)
+{
+ do_all_fn_doall_arg ();
+}