Call instructions that are from the same line and same basic block needs to have separate discriminators to distinguish between different callsites.
Details
Diff Detail
Event Timeline
Wouldn't you distinguish these by column number? Discriminator is intended to be for paths that can't be distinguished solely by source location.
The main user of discriminator is AutoFDO, which does not use column number to index the profile for many reasons. So discriminator is used here to distinguish control flows that reside within the same line.
Even with column info, its insufficient if both calls came from the same
macro use:
#define X f(); f()
int main() {
X;
}
Both calls to 'f' will have the same line and column, the location of the X
use.
Of course if the column numbers are the same, you need the discriminator. The provided test case did not have that situation, which is why I asked. You don't want to be chewing up extra space in the line table if you don't need to.
Sure, we can redesign the sample profile format to index using (line, column), but this will lead to:
- profile size would nearly double
- llvm will not be able to use gcc profile
I can do the experiment to measure the debug info impact of this patch. As discriminator does not happen quite often, so it will only add very small amount to the debug info size.
LGTM with a minor documentation fix.
lib/Transforms/Utils/AddDiscriminators.cpp | ||
---|---|---|
229 | Add some explanation here as to why this is important for SamplePGO? Thanks. |
FYI, with this patch, clang-3.8 binary (built with clang itself in release mode with "-g" c/c++ option) increased from 1096.9MB to 1097.5 MB (around 0.05% increase)
Add some explanation here as to why this is important for SamplePGO? Thanks.