From patchwork Thu May 29 11:00:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 353726 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9F211140098 for ; Thu, 29 May 2014 21:00:48 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=clMkdbde167wKwIg/P9B/6q23umuGqjok5JhNYnm/O1eGCOzxX3Rv nS5zbDLMX44dx722utNXBm0le2TNHXyPt9oniZbRq1a8Sdzjj94jgCTsMnq6a3n2 qNs20pO1A+1WoYRK+g0Aacj7APTVUDYTPvb8tlf9NjKJakwFTtfa+Q= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=GFBf8StdlvoKBXq59ESUEgG1in4=; b=fdSkUDZPU7BET5sXXGHX BC8Pxp0fpgHzAZy8cPu6GLTEsFk1H0uNYVnwfFbGd5lbvCjN+ARfkTV/A80K117D 2OEOjMXqrRrcqsnTPK2ph1VT75GbqFUe2zpO6vX+ASXuxEO0ZtDYfz9th/ViyjZH DdASSloY1FI8RLWZ3WLlv7w= Received: (qmail 8052 invoked by alias); 29 May 2014 11:00:41 -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 8031 invoked by uid 89); 29 May 2014 11:00:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pb0-f48.google.com Received: from mail-pb0-f48.google.com (HELO mail-pb0-f48.google.com) (209.85.160.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 29 May 2014 11:00:38 +0000 Received: by mail-pb0-f48.google.com with SMTP id rr13so189440pbb.21 for ; Thu, 29 May 2014 04:00:37 -0700 (PDT) X-Received: by 10.68.170.131 with SMTP id am3mr7635977pbc.97.1401361236866; Thu, 29 May 2014 04:00:36 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.54.42]) by mx.google.com with ESMTPSA id sy2sm663073pbc.28.2014.05.29.04.00.35 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 May 2014 04:00:36 -0700 (PDT) Date: Thu, 29 May 2014 15:00:27 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, i386, Pointer Bounds Checker 12/x] Recognize instrumented special functions Message-ID: <20140529110002.GA30323@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, This patch allows to recognize instrumented call to special function by using the original function name for recognition. Bootstrapped and tested on linux-x86_64. Thanks, Ilya --- gcc/ 2014-05-29 Ilya Enkovich * calls.c (special_function_p): Use original decl name when analyzing instrumentation clone. diff --git a/gcc/calls.c b/gcc/calls.c index f0c92dd..e1dc8eb 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -502,8 +502,16 @@ emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNU static int special_function_p (const_tree fndecl, int flags) { - if (fndecl && DECL_NAME (fndecl) - && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 17 + tree name_decl = DECL_NAME (fndecl); + + /* For instrumentation clones we want to derive flags + from the original name. */ + if (cgraph_get_node (fndecl) + && cgraph_get_node (fndecl)->instrumentation_clone) + name_decl = DECL_NAME (cgraph_get_node (fndecl)->orig_decl); + + if (fndecl && name_decl + && IDENTIFIER_LENGTH (name_decl) <= 17 /* Exclude functions not at the file scope, or not `extern', since they are not the magic functions we would otherwise think they are. @@ -515,16 +523,16 @@ special_function_p (const_tree fndecl, int flags) || TREE_CODE (DECL_CONTEXT (fndecl)) == TRANSLATION_UNIT_DECL) && TREE_PUBLIC (fndecl)) { - const char *name = IDENTIFIER_POINTER (DECL_NAME (fndecl)); + const char *name = IDENTIFIER_POINTER (name_decl); const char *tname = name; /* We assume that alloca will always be called by name. It makes no sense to pass it as a pointer-to-function to anything that does not understand its behavior. */ - if (((IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 6 + if (((IDENTIFIER_LENGTH (name_decl) == 6 && name[0] == 'a' && ! strcmp (name, "alloca")) - || (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 16 + || (IDENTIFIER_LENGTH (name_decl) == 16 && name[0] == '_' && ! strcmp (name, "__builtin_alloca")))) flags |= ECF_MAY_BE_ALLOCA;