[fpc-devel] Wrong debug info when using clang backend

Martin Frb lazarus at mfriebe.de
Wed Dec 6 22:17:54 CET 2023


On 06/12/2023 21:58, Martin Frb via fpc-devel wrote:
> On 06/12/2023 21:05, Jonas Maebe via fpc-devel wrote:
>> On 06/12/2023 17:37, Martin Frb via fpc-devel wrote:
>>> Not suer if the issue is within Fpc or clang...
>>>
>>> Should this be reported against Fpc?
>>
>> FPC defines the variables' debug info at the start of the function 
>> and defines their lifetime as starting at the beginning of the 
>> function and continuing until the end. But LLVM is free to modify 
>> these if it notices these are too pessimistic
>>
>> My guess is that even without optimisations, LLVM notices these 
>> variables' values are not really used later on and reduces the 
>> variables' live range.
>
> Strange, then clang has a serious issue.

But, yes it probably is clang.

If I have enough code, so clang does not optimize the entire function 
away in -O1, then clang writes info for some of the lines.
Actually the variable is in a (or several?) registers.
And clang misses some lines too.
But it covers some lines in the procedure.


With -O- it never is in a register...
Well it gets loaded sometimes, but it' always also on the stack.
Seems like clang doesn't see it while it is on the stack.


More information about the fpc-devel mailing list