[llvm-dev] How to set DebugLoc when using IRBuilder's CreateCall ?

Robinson, Paul via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 27 10:19:17 PST 2020


Applying a “wrong” DebugLoc to an Instruction will not cause any errors.  The “wrong” location would be carried through to the debugging information in the object file, which might cause your debugger to do something unexpected while debugging the program.

One tactic, which ought to be fairly easy, is to give your new Instruction the same DebugLoc as the Instruction before (or after) your new Instruction.  This will make your new Instruction appear to be part of the same source statement as the neighboring Instruction.

Hope this helps,
--paulr

From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of PenYiWang via llvm-dev
Sent: Thursday, February 27, 2020 6:33 AM
To: llvm-dev at lists.llvm.org
Subject: [llvm-dev] How to set DebugLoc when using IRBuilder's CreateCall ?


Hi

I want to insert some functions into the llvm bitcode ir files.

So I use IRBuilder and CreateCall().

But it how error : inlinable function call in a function with debug info must have a !dbg location.

I don't know what DebugLoc should I give the new CallInst  to setDebugLoc.

I Create this CallInst , so this CallInst doesn't hava so-called "DebugLoc" mapping to the source code , right ?

And also I want the compiler can do some inline optimization to my program.

So I have to give this CallInst a DebugLoc....

What would happen if the DebugLoc of an Instruction is wrong ?

would there be any error?

Thanks.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200227/e902f7c2/attachment-0001.html>


More information about the llvm-dev mailing list