From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DB791FB2 for ; Thu, 2 Nov 2023 00:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="csAJMU91" Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [IPv6:2001:41d0:203:375::b2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC98E101 for ; Wed, 1 Nov 2023 17:34:39 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698885278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Iu+GVul9AvnZuUmW/jEYWXX1rNGD/mAXaK4kMnDW9rQ=; b=csAJMU91N6CspKtDyLQqP4xNzyQQc31TlRhuYR206iwEeLf+9ThXv7HT5Jw77cjGGHRG7C YbC2+ESeDu60xCE6T8cDnAzBkxX1PyvezHjN82TfNwqvK+3lplRtAIq3Zwjsb5804bD5k4 ki9KKsUwsPDSn9hRiAhs0gDkj4Rm9k4= Date: Wed, 1 Nov 2023 17:34:32 -0700 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: bpf_core_type_id_kernel is not consistent with bpf_core_type_id_local To: Andrii Nakryiko , Lorenz Bauer , Eduard Zingerman Cc: Yonghong Song , Lorenz Bauer , bpf , Yonghong Song , Andrii Nakryiko References: Content-Language: en-GB X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 11/1/23 3:42 PM, Andrii Nakryiko wrote: > On Wed, Nov 1, 2023 at 7:18 AM Lorenz Bauer wrote: >> On Tue, Oct 31, 2023 at 6:24 PM Andrii Nakryiko >> wrote: >>>> Did you get round to fixing this, or did you decide to leave it as is? >>> Trying to recall, was there anything to do on the libbpf side, or was >>> it purely a compiler-side change? >> I'm not 100% sure TBH. I'd like clang to behave consistently for >> local_id and target_id. I don't know whether that would break libbpf. >> > *checks code* libbpf just passes through whatever ID compiler > generated, so there doesn't seem to be any change to libbpf. Seems > like compiler-only change. cc'ing Eduard as well, if he's curious > enough to check Okay, let us try to have a consistent behavior in local/remote type_id by changing local_id semantics to be the same as target_id. The corresponding llvm change is similar to [yhs@devbig309.ftw3 ~/work/llvm-project (ed)]$ git diff diff --git a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp index 78e1bf90f1bd..1fbe1207dc6e 100644 --- a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp +++ b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp @@ -86,15 +86,17 @@ static bool BPFPreserveDITypeImpl(Function &F) { Reloc = BTF::BTF_TYPE_ID_LOCAL; } else { Reloc = BTF::BTF_TYPE_ID_REMOTE; - DIType *Ty = cast(MD); - while (auto *DTy = dyn_cast(Ty)) { - unsigned Tag = DTy->getTag(); - if (Tag != dwarf::DW_TAG_const_type && - Tag != dwarf::DW_TAG_volatile_type) - break; - Ty = DTy->getBaseType(); - } + } + DIType *Ty = cast(MD); + while (auto *DTy = dyn_cast(Ty)) { + unsigned Tag = DTy->getTag(); + if (Tag != dwarf::DW_TAG_const_type && + Tag != dwarf::DW_TAG_volatile_type) + break; + Ty = DTy->getBaseType(); + } + if (Reloc == BTF::BTF_TYPE_ID_REMOTE) { if (Ty->getName().empty()) { if (isa(Ty)) report_fatal_error( @@ -102,8 +104,8 @@ static bool BPFPreserveDITypeImpl(Function &F) { else report_fatal_error("Empty type name for BTF_TYPE_ID_REMOTE reloc"); } - MD = Ty; } + MD = Ty; BasicBlock *BB = Call->getParent(); IntegerType *VarType = Type::getInt64Ty(BB->getContext()); Either Eduard or Myself will submit a llvm patch to fix this in llvm18. > > >> Lorenz