Could you please elaborate on what are you trying to do? `llvm.dbg.label` is for
debuginfo generation of the program being compiled, not for attaching user info
and passing around.
________________________________________
From: Jinyan <phantom0308 at zju.edu.cn>
Sent: Sunday, July 19, 2020 2:16 AM
To: Chen, Yuanfang
Subject: Re: Re: [llvm-dev] Instrument intrinsic invalid
Wow ! It seems insertLabel internal is also use builder to create, the key point
in my bug is to convert the MDNode* to a DILabel*, after passing a DILAble as
arg, it works, thks! I want to use llvm.dbg.label to instrument some machine
instructions at the backend, but now the metadata must obey the format of
DILabel, I can only pass my info in name field... Are there any existing
intrinsic that can be used to pass arbitrary metadata ? Please you get me some
suggestion ?
> -----Original Messages-----
> From: "Chen, Yuanfang" <Yuanfang.Chen at sony.com>
> Sent Time: 2020-07-19 15:19:39 (Sunday)
> To: "llvm-dev at lists.llvm.org" <llvm-dev at
lists.llvm.org>, Jinyan <phantom0308 at zju.edu.cn>
> Cc:
> Subject: Re: [llvm-dev] Instrument intrinsic invalid
>
> Hi,
>
> A successfully printed module could still be invalid such as this case. The
problem is that the metadata should contain a DILabel instead of a string. Try
using DIBuilder::insertLabel instead.
>
> ________________________________________
> From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of
Jinyan via llvm-dev <llvm-dev at lists.llvm.org>
> Sent: Saturday, July 18, 2020 11:48 PM
> To: llvm-dev at lists.llvm.org
> Subject: [llvm-dev] Instrument intrinsic invalid
>
> Hi, I try to use llvm-dis to disassemble the result after opt, my pass will
add a intrinsic after the load instruction, like following:
>
> bool fpscan::ldAddMetadata (Instruction *Inst, StringRef c) {
> std::vector<Metadata *> dataTuples;
> // Add metadata in list
> dataTuples.push_back(MDString::get(Inst->getContext(), c));
> MDNode* N = MDNode::get(Inst->getContext(), dataTuples);
>
> Value* meta = MetadataAsValue::get(Inst->getContext(), N);
> std::vector<Value*> args;
> args.push_back(meta);
> IRBuilder<> Builder(Inst->getNextNode());
> Builder.CreateCall(dbglabelPtr, args, "");
> }
>
> And before my pass finish, I print the IR, it shows I successfully add the
intrinsic
>
> %5 = load i32 (i32, i32)*, i32 (i32, i32)** %1, align 8, !dbg !35,
!ppp.load !36
> call void @llvm.dbg.label(metadata !36), !dbg !37
> ...
> ; Function Attrs: nounwind readnone speculatable willreturn
> declare void @llvm.dbg.label(metadata) #1
>
> But, when I use llvm-dis to disassemble the .bc generated by opt, it ignore
the code I insert:
>
> invalid llvm.dbg.label intrinsic variable
> call void @llvm.dbg.label(metadata !36), !dbg !37
> !36 = !{!"dbg1", !"dbgfromLoad"}
> llvm-dis: warning: ignoring invalid debug info in test.bc
>
> How to fix this warning ? thks
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev