LDC2 and classic profiling

Johan Engelen j at j.nl
Sun May 12 17:24:24 UTC 2019


On Saturday, 11 May 2019 at 11:34:35 UTC, Denis Feklushkin wrote:
> On Saturday, 11 May 2019 at 09:12:24 UTC, Johan Engelen wrote:
>
>> Those calls are to templated functions I presume?
>
> No

Then I don't understand how you'd see instrumentation on 
functions that you did not compile with -fprofile-instr-generate 
(indirect calls to such functions may be recorded); the std lib 
is not compiled with profiling instrumentation, and so you 
shouldn't see any internal instrumentation of it. Unless those 
functions are instantiated in your object file (e.g. templates or 
explicitly inlined functions).

>>
>>> Also I changed flags to "dflags-ldc": 
>>> ["-fprofile-instr-generate", "-O0"] - second flag disables 
>>> optimisation (I assumed that optimizations magically 
>>> completely remove calls to my functions. But this is probably 
>>> not the case.)
>>
>> No, indeed, -O0 doesn't (shouldn't!) matter.
>
> Ok.
>
>> It is strange that you don't see calls to your functions. Just 
>> to verify, could you compile a simple program manually 
>> (without dub) and verify that you see calls to your own 
>> functions?
>
> Tried, and it works!
>
>> Lambdas should also be instrumented, so please test that.
>
> Works on simple program too.

Excellent.

I think dub -v will output the exact commands that dub is 
executing.
Looks like some parts are not compiled with the compile flag, and 
some other parts are?

>> By the way, if you are on linux, then XRay should work like 
>> with clang ( -fxray-instrument )
>
> Tried it, and xray also does not returns any info about my own 
> functions...

You tried with DUB or manually? Note that XRay has a 
(configurable) threshold for not instrumenting very small 
functions.
See for example this test: 
https://github.com/ldc-developers/ldc/blob/master/tests/instrument/xray_simple_execution.d

-Johan



More information about the Digitalmars-d-learn mailing list