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;
    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


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.

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.