[llvm-dev] Instrument intrinsic invalid

Chen, Yuanfang via llvm-dev llvm-dev at lists.llvm.org
Sun Jul 19 00:19:39 PDT 2020


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


More information about the llvm-dev mailing list