Open Hardcode84 opened 6 years ago
Usage:
CompilerSettings settings;
settings.profile = true;
compileDynamicCode(settings);
//... Some profiling runs
CompilerSettings settings;
settings.pgo = true;
compileDynamicCode(settings); // Use collected profile info
hmmmmmmm Best to raise this on llvm-dev and see what people think. Compiling with IR PGO instrumentation enabled is perhaps not too hard. However, getting the profile data may be very hard. (the profile runtime startup and exit code cannot be readily used for the dyn compile case)
With dynamic compilation we can switch profile info collection or usage dynamically without application recompilation (in theory).
One of the issues that LDC emit counters in function only if profiling was enabled. Instead we need to do something like this:
and hope LLVM optimizer will remove dead code and it won't impact any optimizations. Also we don't know is function dynamic during
DtoDefineFunction
because some functions can be implicitly marked dynamic later.And I don't know what additional runtime support required for PGO. @JohanEngelen what do you think?