dump_function_to_file (node->decl, dump_file, dump_flags);
/* Create the basic block we place call into. It is the entry basic block
- split after last label. */
+ split after last label and after the last eos clobber and debug stmt. */
call_bb = split_point->entry_bb;
for (gimple_stmt_iterator gsi = gsi_start_bb (call_bb); !gsi_end_p (gsi);)
- if (gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
+ if (gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL
+ || gimple_clobber_p (gsi_stmt (gsi), CLOBBER_STORAGE_END)
+ || is_gimple_debug (gsi_stmt (gsi)))
{
last_stmt = gsi_stmt (gsi);
gsi_next (&gsi);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Wall -O2 -fdump-tree-optimized" } */
+/* PR tree-optimization/110091 */
+/* The clobbers are before the outlined code */
+
+struct tEntry
+{
+ int value;
+};
+int *out;
+
+extern int otherfunc(struct tEntry *);
+extern void anotherfunc(int val);
+
+void bar()
+{
+ {
+ struct tEntry entry1 = { 0 };
+ struct tEntry entry = { 0 };
+
+ if (otherfunc(&entry) != 0)
+ return;
+ if (otherfunc(&entry1) != 0)
+ return;
+ if (out)
+ *out = entry.value; /* { dg-bogus "dangling pointer to" } */
+ }
+ anotherfunc(5);
+}
+
+void foo()
+{
+ bar();
+}
+
+/* There should be 4 CLOBBERs, 2 for entry1 and 2 for entry. */
+/* { dg-final { scan-tree-dump-times "CLOBBER\\\(eos\\\)" 4 "optimized" } } */
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Wall -O2 -fdump-tree-optimized" } */
+/* PR tree-optimization/110091 */
+/* The clobbers are before the outlined code */
+
+struct tEntry
+{
+ int value;
+};
+int *out;
+
+extern int otherfunc(struct tEntry *);
+extern void anotherfunc(int val);
+
+void bar()
+{
+ {
+ struct tEntry entry = { 0 };
+
+ if (otherfunc(&entry) != 0)
+ return;
+ if (out)
+ *out = entry.value; /* { dg-bogus "dangling pointer to" } */
+ }
+ anotherfunc(5);
+}
+
+void foo()
+{
+ bar();
+}
+
+/* There should be 4 CLOBBERs, 4 for entry; inlined doubles the clobber; return path adds clobber. */
+/* { dg-final { scan-tree-dump-times "CLOBBER\\\(eos\\\)" 4 "optimized" } } */
+