From: Yonghong Song <yonghong.song@linux.dev>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Lorenz Bauer <lorenz.bauer@isovalent.com>,
Eduard Zingerman <eddyz87@gmail.com>
Cc: Yonghong Song <yhs@meta.com>, Lorenz Bauer <lmb@isovalent.com>,
bpf <bpf@vger.kernel.org>, Yonghong Song <yhs@fb.com>,
Andrii Nakryiko <andrii@kernel.org>
Subject: Re: bpf_core_type_id_kernel is not consistent with bpf_core_type_id_local
Date: Wed, 1 Nov 2023 17:34:32 -0700 [thread overview]
Message-ID: <bf1ab8f0-bb83-43d1-9ce0-cb6828fdc935@linux.dev> (raw)
In-Reply-To: <CAEf4BzZQQiD5x0PRwGD32bE7izUxhPvRRQTMpifQZYvu+0mMkA@mail.gmail.com>
On 11/1/23 3:42 PM, Andrii Nakryiko wrote:
> On Wed, Nov 1, 2023 at 7:18 AM Lorenz Bauer <lorenz.bauer@isovalent.com> wrote:
>> On Tue, Oct 31, 2023 at 6:24 PM Andrii Nakryiko
>> <andrii.nakryiko@gmail.com> 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<DIType>(MD);
- while (auto *DTy = dyn_cast<DIDerivedType>(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<DIType>(MD);
+ while (auto *DTy = dyn_cast<DIDerivedType>(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<DISubroutineType>(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
next prev parent reply other threads:[~2023-11-02 0:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-04 13:30 bpf_core_type_id_kernel is not consistent with bpf_core_type_id_local Lorenz Bauer
2023-07-06 4:50 ` Yonghong Song
2023-07-06 21:06 ` Andrii Nakryiko
2023-07-11 16:20 ` Lorenz Bauer
2023-07-11 16:38 ` Andrii Nakryiko
2023-10-31 15:46 ` Lorenz Bauer
2023-10-31 18:24 ` Andrii Nakryiko
2023-11-01 14:17 ` Lorenz Bauer
2023-11-01 22:42 ` Andrii Nakryiko
2023-11-02 0:34 ` Yonghong Song [this message]
2023-11-02 2:16 ` Andrii Nakryiko
2023-11-03 19:58 ` Yonghong Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf1ab8f0-bb83-43d1-9ce0-cb6828fdc935@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=lmb@isovalent.com \
--cc=lorenz.bauer@isovalent.com \
--cc=yhs@fb.com \
--cc=yhs@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox