+2012-05-22 Richard Guenther <rguenther@suse.de>
+
+ Backport from mainline
+ 2011-11-10 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/51071
+ * gimple.c (gimple_has_side_effects): Remove checking code
+ that doesn't belong here.
+
2012-05-22 Richard Guenther <rguenther@suse.de>
Backport from mainline
bool
gimple_has_side_effects (const_gimple s)
{
- unsigned i;
-
if (is_gimple_debug (s))
return false;
if (is_gimple_call (s))
{
- unsigned nargs = gimple_call_num_args (s);
+ int flags = gimple_call_flags (s);
- if (!(gimple_call_flags (s) & (ECF_CONST | ECF_PURE)))
- return true;
- else if (gimple_call_flags (s) & ECF_LOOPING_CONST_OR_PURE)
- /* An infinite loop is considered a side effect. */
+ /* An infinite loop is considered a side effect. */
+ if (!(flags & (ECF_CONST | ECF_PURE))
+ || (flags & ECF_LOOPING_CONST_OR_PURE))
return true;
- if (gimple_call_lhs (s)
- && TREE_SIDE_EFFECTS (gimple_call_lhs (s)))
- {
- gcc_checking_assert (gimple_has_volatile_ops (s));
- return true;
- }
-
- if (TREE_SIDE_EFFECTS (gimple_call_fn (s)))
- return true;
-
- for (i = 0; i < nargs; i++)
- if (TREE_SIDE_EFFECTS (gimple_call_arg (s, i)))
- {
- gcc_checking_assert (gimple_has_volatile_ops (s));
- return true;
- }
-
return false;
}
- else
- {
- for (i = 0; i < gimple_num_ops (s); i++)
- {
- tree op = gimple_op (s, i);
- if (op && TREE_SIDE_EFFECTS (op))
- {
- gcc_checking_assert (gimple_has_volatile_ops (s));
- return true;
- }
- }
- }
return false;
}
+2012-05-22 Richard Guenther <rguenther@suse.de>
+
+ Backport from mainline
+ 2011-11-10 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/51071
+ * gcc.dg/torture/pr51071.c: New testcase.
+ * gcc.dg/torture/pr51071-2.c: Likewise.
+
2012-05-22 Richard Guenther <rguenther@suse.de>
Backport from mainline
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fno-delete-null-pointer-checks" } */
+
+extern struct module __this_module;
+static inline void
+trace_module_get (struct module *mod, unsigned long ip) { }
+struct module;
+static inline __attribute__((no_instrument_function))
+int try_module_get(struct module *module)
+{
+ int ret = 1;
+ if (module)
+ {
+ if (module_is_live(module))
+ {
+ __label__ __here;
+ asm("");
+ __here:
+ trace_module_get(module, (unsigned long)&&__here);
+ }
+ else
+ ret = 0;
+ }
+ return ret;
+}
+struct net_device;
+struct net_device_ops {
+ int (*ndo_open)(struct net_device *dev);
+};
+int t3e3_open(struct net_device *dev)
+{
+ int ret = hdlc_open(dev);
+ if (ret)
+ return ret;
+ try_module_get((&__this_module));
+ return 0;
+}
+const struct net_device_ops t3e3_ops = { .ndo_open = t3e3_open };
--- /dev/null
+/* { dg-do compile } */
+
+void foo (void);
+void bar (void *);
+extern int t;
+
+static void kmalloc_large (int size, int flags)
+{
+ (void) size;
+ (void) flags;
+ foo ();
+ bar (({__here:&&__here;}));
+}
+
+static void kmalloc (int size, int flags)
+{
+ if (size)
+ {
+ if ((unsigned long) size > 0x1000)
+ kmalloc_large (size, flags);
+
+ if (flags)
+ bar (({__here:&&__here;}));
+ }
+}
+
+void compress_file_range (int i, int j, int k)
+{
+ int nr_pages = ({j < k;});
+
+ if (i || t)
+ kmalloc (0x1000UL * nr_pages, 0x40UL);
+}