From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id D9749384BC0E for ; Tue, 10 Aug 2021 11:54:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D9749384BC0E Received: by mail-ed1-x52b.google.com with SMTP id g21so29849889edb.4 for ; Tue, 10 Aug 2021 04:54:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ta9fZA9CseFRod31pQiBbwLneB0oFxOTtkQNeDu7UoI=; b=ci8V4Wapo/tliK2adK10RH9nbDoyJ0y50ssoW57mQDLZ7FFK4Knakai0KMUoHm5dS1 NVt6Feq/rn0e0+yypW0WQc1JUxUiAWiZpdXqHV8THuizDmIW4yEugyL93FR+6fN/N8lm PS6mTFYnqS+RfbD5Uuh5hgRJXt7TxONPoOJLzTx2FUfRWKT70hfzjcl6zPGoRqC3Xm8K Ci+69Lq/2GNdxd0fGQPNRxuFCHPDCR8H7vYKqZAsDCgyHSI3RbHRZa9VXhbeVC04Ko9e bWgVyfzYvfGXiRRLwa+SIa/W5SHltXk8bkEQ4V8AlrMyEyGJuCarUH7DZsGzGXCyNJ4y 1pnA== X-Gm-Message-State: AOAM533t3zE5w1WDbmSgRBSRTXozCTuK5LHJlbeQsCaZX7Hn/3VqS4qG dsZ3gVxZfy8g1DxACJO1S4DfFk3GHVOW04ywJOA= X-Google-Smtp-Source: ABdhPJyZrGoUPlwIjycAQjXOcPD6BRxm3mQYxX4SqiRLmGCNHBdmxnBP9+tQd1dhRdYyo57yyeIc7RoOpnTCQLWN4e0= X-Received: by 2002:a05:6402:1603:: with SMTP id f3mr4457264edv.274.1628596477863; Tue, 10 Aug 2021 04:54:37 -0700 (PDT) MIME-Version: 1.0 References: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> <1628124628-28706-3-git-send-email-indu.bhagat@oracle.com> In-Reply-To: <1628124628-28706-3-git-send-email-indu.bhagat@oracle.com> From: Richard Biener Date: Tue, 10 Aug 2021 13:54:27 +0200 Message-ID: Subject: Re: [PATCH, V2 2/3] targhooks: New target hook for CTF/BTF debug info emission To: Indu Bhagat Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 11:54:49 -0000 On Thu, Aug 5, 2021 at 2:52 AM Indu Bhagat via Gcc-patches wrote: > > This patch adds a new target hook to detect if the CTF container can allow the > emission of CTF/BTF debug info at DWARF debug info early finish time. Some > backends, e.g., BPF when generating code for CO-RE usecase, may need to emit > the CTF/BTF debug info sections around the time when late DWARF debug is > finalized (dwarf2out_finish). Without looking at the dwarf2out.c usage in the next patch - I think the CTF part should be always emitted from dwarf2out_early_finish, the "hooks" should somehow arrange for the alternate output specific data to be preserved until dwarf2out_finish time so the late BTF data can be emitted from there. Lumping everything together now just makes it harder to see what info is required to persist and thus make LTO support more intrusive than necessary. > gcc/ChangeLog: > > * config/bpf/bpf.c (ctfc_debuginfo_early_finish_p): New definition. > (TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P): Undefine and override. > * doc/tm.texi: Regenerated. > * doc/tm.texi.in: Document the new hook. > * target.def: Add a new hook. > * targhooks.c (default_ctfc_debuginfo_early_finish_p): Likewise. > * targhooks.h (default_ctfc_debuginfo_early_finish_p): Likewise. > --- > gcc/config/bpf/bpf.c | 14 ++++++++++++++ > gcc/doc/tm.texi | 6 ++++++ > gcc/doc/tm.texi.in | 2 ++ > gcc/target.def | 10 ++++++++++ > gcc/targhooks.c | 6 ++++++ > gcc/targhooks.h | 2 ++ > 6 files changed, 40 insertions(+) > > diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c > index 028013e..85f6b76 100644 > --- a/gcc/config/bpf/bpf.c > +++ b/gcc/config/bpf/bpf.c > @@ -178,6 +178,20 @@ bpf_option_override (void) > #undef TARGET_OPTION_OVERRIDE > #define TARGET_OPTION_OVERRIDE bpf_option_override > > +/* Return FALSE iff -mcore has been specified. */ > + > +static bool > +ctfc_debuginfo_early_finish_p (void) > +{ > + if (TARGET_BPF_CORE) > + return false; > + else > + return true; > +} > + > +#undef TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P > +#define TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P ctfc_debuginfo_early_finish_p > + > /* Define target-specific CPP macros. This function in used in the > definition of TARGET_CPU_CPP_BUILTINS in bpf.h */ > > diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi > index cb01528..2d5ff05 100644 > --- a/gcc/doc/tm.texi > +++ b/gcc/doc/tm.texi > @@ -10400,6 +10400,12 @@ Define this macro if GCC should produce debugging output in BTF debug > format in response to the @option{-gbtf} option. > @end defmac > > +@deftypefn {Target Hook} bool TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P (void) > +This target hook returns nonzero if the CTF Container can allow the > + emission of the CTF/BTF debug info at the DWARF debuginfo early finish > + time. > +@end deftypefn > + > @node Floating Point > @section Cross Compilation and Floating Point > @cindex cross compilation and floating point > diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in > index 4a522ae..05b3c2c 100644 > --- a/gcc/doc/tm.texi.in > +++ b/gcc/doc/tm.texi.in > @@ -7020,6 +7020,8 @@ Define this macro if GCC should produce debugging output in BTF debug > format in response to the @option{-gbtf} option. > @end defmac > > +@hook TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P > + > @node Floating Point > @section Cross Compilation and Floating Point > @cindex cross compilation and floating point > diff --git a/gcc/target.def b/gcc/target.def > index 68a46aa..44e2251 100644 > --- a/gcc/target.def > +++ b/gcc/target.def > @@ -4016,6 +4016,16 @@ clobbered parts of a register altering the frame register size", > machine_mode, (int regno), > default_dwarf_frame_reg_mode) > > +/* Return nonzero if CTF Container can finalize the CTF/BTF emission > + at DWARF debuginfo early finish time. */ > +DEFHOOK > +(ctfc_debuginfo_early_finish_p, > + "This target hook returns nonzero if the CTF Container can allow the\n\ > + emission of the CTF/BTF debug info at the DWARF debuginfo early finish\n\ > + time.", > + bool, (void), > + default_ctfc_debuginfo_early_finish_p) > + > /* If expand_builtin_init_dwarf_reg_sizes needs to fill in table > entries not corresponding directly to registers below > FIRST_PSEUDO_REGISTER, this hook should generate the necessary > diff --git a/gcc/targhooks.c b/gcc/targhooks.c > index eb51909..e38566c 100644 > --- a/gcc/targhooks.c > +++ b/gcc/targhooks.c > @@ -2112,6 +2112,12 @@ default_dwarf_frame_reg_mode (int regno) > return save_mode; > } > > +bool > +default_ctfc_debuginfo_early_finish_p (void) > +{ > + return true; > +} > + > /* To be used by targets where reg_raw_mode doesn't return the right > mode for registers used in apply_builtin_return and apply_builtin_arg. */ > > diff --git a/gcc/targhooks.h b/gcc/targhooks.h > index f92e102..55dc443 100644 > --- a/gcc/targhooks.h > +++ b/gcc/targhooks.h > @@ -255,6 +255,8 @@ extern unsigned int default_dwarf_poly_indeterminate_value (unsigned int, > unsigned int *, > int *); > extern machine_mode default_dwarf_frame_reg_mode (int); > +extern bool default_ctfc_debuginfo_early_finish_p (void); > + > extern fixed_size_mode default_get_reg_raw_mode (int); > extern bool default_keep_leaf_when_profiled (); > > -- > 1.8.3.1 >