From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by sourceware.org (Postfix) with ESMTPS id CC74A3857BB2 for ; Fri, 15 Jul 2022 08:29:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CC74A3857BB2 Received: by mail-pl1-f171.google.com with SMTP id x21so2642588plb.3 for ; Fri, 15 Jul 2022 01:29:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/fX5YJvDHJbmHP4ohN93XuQW+NzOHJJbqP3q/wA33rA=; b=Ung8dbxCjC/2EnzyZqe7QjUPJR10gtyltENEz0fsO1IQWVhdpQTaP4ElEqwdoRarHZ Ib7fnhYjRugHLucIb7H9DUMTtUsGs9dho0N9XEGPIkxFZodtXgk4yxbdX5kBydEo4ofI 8lQdXj6HjI8ZKWzJqkEV2JVMqr4P0hsA14frRDAZJjtJzM7j3M5f/AxSONXkszSdbnM0 icsd0QWm7RaLM0rd2tUQv+JEyuvMfr12z3QUD7KOtKmocWSFiR27SRw1N8CE10jYYOgT friN+lF3Ikx9ybB7xXGqFV5BeGO+RerffsYFqmS80pLFpySVWnEvGAvuT1GNo6BujjtJ pqfA== X-Gm-Message-State: AJIora/wAtVCz5IUMmUP7+nR50E/6gAt8UoZJjiZ/xZP3Xi5si1tx52M N4T75G1bYvUi3PtVuNLF4y3CQjUj0oKJSQ== X-Google-Smtp-Source: AGRyM1uuI1AJf4m953I67mM32kUULFuQZa3mpbIvhd86gpWP31UGNMZqaZU4jP87Kouq/V/vDVXL2g== X-Received: by 2002:a17:90b:4d05:b0:1e2:bf91:8af2 with SMTP id mw5-20020a17090b4d0500b001e2bf918af2mr14655767pjb.210.1657873742473; Fri, 15 Jul 2022 01:29:02 -0700 (PDT) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com. [209.85.210.177]) by smtp.gmail.com with ESMTPSA id i8-20020a056a00004800b00518285976cdsm3137005pfk.9.2022.07.15.01.29.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Jul 2022 01:29:01 -0700 (PDT) Received: by mail-pf1-f177.google.com with SMTP id l124so4064535pfl.8 for ; Fri, 15 Jul 2022 01:29:01 -0700 (PDT) X-Received: by 2002:a63:164e:0:b0:411:ce18:5532 with SMTP id 14-20020a63164e000000b00411ce185532mr11626367pgw.55.1657873741382; Fri, 15 Jul 2022 01:29:01 -0700 (PDT) MIME-Version: 1.0 References: <90b22551-734c-72e4-ad33-864385162f9f@suse.cz> <0d025b0a-0094-6457-0073-2bd7ccf51c80@suse.cz> In-Reply-To: <0d025b0a-0094-6457-0073-2bd7ccf51c80@suse.cz> From: Erick Ochoa Date: Fri, 15 Jul 2022 10:33:08 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Creating a wrapper around a function at compile time To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: Richard Biener , GCC Development X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2022 08:29:05 -0000 Awesome! Thanks! Let's go a little bit into the transformation mechanics itself. I am somewhat familiar with LTO but I am always confused about the transformations scheduled during WPA. Let's assume that: 1. we have the profiling pass, which profiles each argument in each callsite. 2. we are now running in the -fprofile-use so that means that we have access to the value profiles for each of the arguments 3. there's an IPA/LTO pass which creates edge summaries storing "likely" values for each of callsite/argument 4. we have a heuristic that let's us decide to some extent which subset of likely values will yield good results (heavily used and specialization is greatly beneficial if found) and run it during WPA. Then, what happens next? I know that the idea is to create some parameter tests at the callsite and call the respective parameter. The gap in my understanding is that at this point I am assuming we are in WPA and therefore have no function bodies to add these parameter tests. Would it be sufficient to do the following: 1. Store in optimization (edge) summaries the (argument position x value x specialized function version) 2. During LTRANS actually perform the transformation for the parameter test Or is there some other way? I am still working on understanding how ipa_make_edge_direct_to_target with speculative = true adds the edge and function test during WPA. Otherwise, if we go with the two steps above, the edges won't be visible to the rest of the IPA optimizations. I'll be reading the cgraph_edge::make_speculative and the rest of the infrastructure a bit more closely... Any help or direction is greatly appreciated. Thanks! -Erick