From patchwork Sun Jun 2 04:05:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 248096 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id DF1FE2C008C for ; Sun, 2 Jun 2013 14:05:53 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=fUOwHeDDTUBY22jq4xm04H9G3+EH/K0QymsgksJiNA/ 4TJfDk/PlTFxXrA+F1ZEo0kYlfkpHSCUdFKerIOUB6B4fUEi8bk9WYo7LT3cbvtU k3jtFzOjegLdcpFR54dkzDE8Fdylu9nmYRYYUQ4stIh0zq8DOD+JBuNvlCo10gPI = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=aPiezYdtHlrhd03M4d7l2ZtiHcs=; b=G9WzxQqL1J2c8XEiI CPWaQbX49ggXjBGW9DEw+uiceDQyc/ol5WwnhLmjjRlh2VGFst4vQmf7EvYbsuFl 5eDYPOFMnu2tD9T5XLcWh21NOCsza4hD18ke8uNl8YCChEPuFW6rnJ/z/IRvLtO/ t4ot2+ioQYFsdJdPujaItliE2A= Received: (qmail 30370 invoked by alias); 2 Jun 2013 04:05:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 30328 invoked by uid 89); 2 Jun 2013 04:05:33 -0000 X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-ea0-f180.google.com (HELO mail-ea0-f180.google.com) (209.85.215.180) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 02 Jun 2013 04:05:32 +0000 Received: by mail-ea0-f180.google.com with SMTP id k10so212520eaj.11 for ; Sat, 01 Jun 2013 21:05:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=+vFbWu7dnpjeq/gmPR/YN+gj0s28RBG69XmWnogJFn0=; b=kBeVeOQ0LlXUcDeX1+RGt3Vhey5Uh7jxB4ZetiGU6Vzi6WR5ENcqD2s9hW5Cq5qoqM 72e6grWyOEwN8e+7P1fMmhlaywiIQSnWa3NGEoxIgkPEo+3XwJYsMf86+BO6tuersEqZ ox/5ma+UmDj5mD21lu04dCDwNB5L4iJxBCe0RKAxRKyPp9TC8WYGGSdsLHwPl0bqZw6U ErqL9Z5kCxzXc/+yNhyUMS6Y8hrQUggHds3cls4r+TPuMidPWj6qLHZtylKI/waJNtRn 5mIt7NvI9wXe4RiCyRKu1I0pHg63Jz5bP21VXB9lA00D5OdOrSy+ReXCXhAe+TA4siCR LyoA== MIME-Version: 1.0 X-Received: by 10.14.3.4 with SMTP id 4mr3248389eeg.8.1370145930305; Sat, 01 Jun 2013 21:05:30 -0700 (PDT) Received: by 10.14.220.9 with HTTP; Sat, 1 Jun 2013 21:05:30 -0700 (PDT) Date: Sat, 1 Jun 2013 21:05:30 -0700 Message-ID: Subject: [GOOGLE] Fix uninitialized memory in AutoFDO implementation From: Dehao Chen To: GCC Patches Cc: David Li X-Gm-Message-State: ALoCoQljj6uWrNGBr3UpVmqPIsyS4RibJs5Z9+3rMg3J8MLxH70fq+wmNDTF7PUhvAomc8yDHBoos8edWIMTXKMMc8q/8T3faHDV3ubLMtJo1D39Y0opUSSxaUeDJcmYJ6MR95Ax1FlnKPVx1GD2fKJWK09u7oS6AxxH9oY0re/gqZhHOoxZRtWW3+DgbrsK8USLvsn0Q3jC This patch fixes an uninitialized memory error and a hashtable comparison bug in AutoFDO. Bootstrapped and passed regression test. OK for google branches? Thanks, Dehao Index: gcc/auto-profile.c =================================================================== --- gcc/auto-profile.c (revision 199461) +++ gcc/auto-profile.c (working copy) @@ -310,10 +310,11 @@ afdo_stack_eq (const void *p, const void *q) if (s2->callee_name != NULL) return 0; } - else if (s2->callee_name != NULL - && strcmp (afdo_get_bfd_name (s1->callee_name), - afdo_get_bfd_name (s2->callee_name))) + else if (s2->callee_name == NULL) return 0; + else if (strcmp (afdo_get_bfd_name (s1->callee_name), + afdo_get_bfd_name (s2->callee_name))) + return 0; i = afdo_get_original_name_size (s1->func_name); if (i != afdo_get_original_name_size (s2->func_name)) @@ -1214,6 +1215,8 @@ process_auto_profile (void) new_stack->num_inst = 0; new_stack->count = 0; new_stack->max_count = 0; + new_stack->hist_size = 0; + new_stack->hist = NULL; stack_slot = (struct gcov_stack **) htab_find_slot (stack_htab, new_stack, INSERT); if (!*stack_slot)