This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR 40445: C++ ICE when using __builtin_unreachable() as only statement in a function.


When we have:

const char * f (void)
{
  __builtint_unreachable();
}

rest_of_handle_eh() calls cleanup_cfg() and the empty first block of the function is removed. This causes havoc in several places, so I thought it best not to remove the first block at all in try_optimize_cfg().


Bootstrapped and regression tested with all default languages on x86_64-pc-linux-gnu with both -m32 and -m64. No regressions found.


OK to commit?

gcc/
2009-06-23  David Daney  <ddaney@caviumnetworks.com>

	PR rtl-optimization/40445
	* cfgcleanup.c (try_optimize_cfg): Don't remove the first block in
	a function.

gcc/testsuite
2009-06-23  David Daney  <ddaney@caviumnetworks.com>

	PR rtl-optimization/40445
	* g++.dg/other/builtin-unreachable-1.C: New testcase.
Index: cavium-octeon/octeon-usb-host.c
===================================================================
--- cavium-octeon/octeon-usb-host.c	(revision 41009)
+++ cavium-octeon/octeon-usb-host.c	(working copy)
@@ -106,6 +106,7 @@ static void octeon_usb_urb_complete_call
     struct urb *urb = user_data;
     DEBUG_CALL("OcteonUSB: %s called\n", __FUNCTION__);
     urb->actual_length = bytes_transferred;
+    kfree(urb->hcpriv);
     urb->hcpriv = NULL;
 
     /* For Isochronous transactions we need to update the URB packet status
@@ -169,6 +170,13 @@ static void octeon_usb_urb_complete_call
     spin_lock(&priv->lock);
 }
 
+
+struct enqueue_handle
+{
+	int submit_handle;
+	int pipe_handle;
+};
+
 static int octeon_usb_urb_enqueue(struct usb_hcd *hcd,
                                   struct urb *urb,
                                   gfp_t mem_flags)
@@ -179,6 +187,11 @@ static int octeon_usb_urb_enqueue(struct
     unsigned long flags;
     cvmx_usb_iso_packet_t *iso_packet;
     struct usb_host_endpoint *ep = urb->ep;
+    struct enqueue_handle *enqh;
+
+    enqh = kmalloc(sizeof(struct enqueue_handle), GFP_ATOMIC);
+    if (enqh == NULL)
+	    return -ENOMEM;
 
     DEBUG_CALL("OcteonUSB: %s called\n", __FUNCTION__);
     spin_lock_irqsave(&priv->lock, flags);
@@ -254,6 +267,7 @@ static int octeon_usb_urb_enqueue(struct
         {
             spin_unlock_irqrestore(&priv->lock, flags);
             DEBUG_ERROR("OcteonUSB: %s failed to create pipe\n", __FUNCTION__);
+	    kfree(enqh);
             return -ENOMEM;
         }
         ep->hcpriv = (void*)(0x10000L + pipe_handle);
@@ -329,9 +343,12 @@ static int octeon_usb_urb_enqueue(struct
     {
         spin_unlock_irqrestore(&priv->lock, flags);
         DEBUG_ERROR("OcteonUSB: %s failed to submit\n", __FUNCTION__);
+	kfree(enqh);
         return -ENOMEM;
     }
-    urb->hcpriv = (void*)(long)submit_handle;
+    enqh->submit_handle = submit_handle;
+    enqh->pipe_handle = pipe_handle;
+    urb->hcpriv = enqh;
     spin_unlock_irqrestore(&priv->lock, flags);
     return 0;
 }
@@ -339,25 +356,18 @@ static int octeon_usb_urb_enqueue(struct
 static int octeon_usb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 {
     octeon_usb_priv_t *priv = (octeon_usb_priv_t *)hcd->hcd_priv;
-    int ep_num = usb_pipeendpoint(urb->pipe);
-    struct usb_host_endpoint *ep;
-    int pipe_handle;
-    int submit_handle;
     unsigned long flags;
+    struct enqueue_handle *enqh;
 
     DEBUG_CALL("OcteonUSB: %s called\n", __FUNCTION__);
 
     if (!urb->dev)
         return -EINVAL;
 
-    ep = (usb_pipein(urb->pipe)) ? urb->dev->ep_in[ep_num] : urb->dev->ep_out[ep_num];
-    if (!ep)
-        return -EINVAL;
+    enqh = urb->hcpriv;
 
-    pipe_handle = 0xffff & (long)ep->hcpriv;
-    submit_handle = (long)urb->hcpriv;
     spin_lock_irqsave(&priv->lock, flags);
-    if (cvmx_usb_cancel(&priv->usb, pipe_handle, submit_handle))
+    if (cvmx_usb_cancel(&priv->usb, enqh->pipe_handle, enqh->submit_handle))
     {
         spin_unlock_irqrestore(&priv->lock, flags);
         DEBUG_ERROR("OcteonUSB: Canceling URB failed\n");

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]