[llvm-dev] Instrument intrinsic invalid

Jinyan via llvm-dev llvm-dev at lists.llvm.org
Sat Jul 18 23:48:37 PDT 2020


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



More information about the llvm-dev mailing list