Line number without -Debug ?

Hi list,

Is it possible to retrieve the source/IR line number
without being on a debug mode?

Thank you in advance,

Not sure what you mean, but the answer is likely “no” as there’s nothing for anything to retrieve. Diagnostics inside the compiler can usually get it from certain IR constructs that have line information, but I’m not sure if that’s what you mean.

-eric

Hi Eric and thanks for your answer,

What I mean is that I want to find the number of line on the IR code of a specific instruction.
I found out that I can use:

DebugLoc Loc = CurrentInstruction->getDebugLoc();
unsigned Line = Loc.getLine();

But this works only if DEBUGFLAG is True.
I’d like to be able to get the Line number without being on a ‘Debug’ mode. Is this possible?

Thanks again,

-irini

Since there is extra “work” required to store that sort of infromation, I wouldn’t want my compiler to do that unless I have specifically asked for it.

What is the actual problem you are trying to solve? I feel that you are asking an XY question (in other words, “I have problem X, I think solution is Y, so I ask how to do Y”, rather than asking “how do I do X”).

Is this “work” heavier than enabling the debug mode?

Nop. No XY question here. In fact it is just be more useful for me to have the information of line number but still be in release mode.
(if this is possible or in other words less “painful” for my pass)

Thanks

–irini

I see your point. But my issue here is just to have this #Line information (nothing more)
Since, as you said, there is a way to do it and still not enable debug mode …I would like to try it and see if I can get any benefit

Whatever frontend you’re using needs to annotate the instructions with the source level locations. With clang some instructions have it by default and for others you’ll need to enable -g for debug output to get source information (or -gline-tables-only for a minimum of metadata).

-eric

I’ll add a “+1” to Mats. We don’t know why you want that, what is the problem you’re trying to solve?
(i.e. why do you want the line number).