This is an archive of the discontinued LLVM Phabricator instance.

Add discriminators for call instructions that are from the same line and same basic block.
ClosedPublic

Authored by danielcdh on Nov 6 2015, 1:43 PM.

Details

Summary

Call instructions that are from the same line and same basic block needs to have separate discriminators to distinguish between different callsites.

Diff Detail

Event Timeline

danielcdh updated this revision to Diff 39584.Nov 6 2015, 1:43 PM
danielcdh retitled this revision from to Add discriminators for call instructions that are from the same line and same basic block..
danielcdh updated this object.
danielcdh added reviewers: dnovillo, dblaikie, davidxl.
danielcdh added a subscriber: llvm-commits.

Wouldn't you distinguish these by column number? Discriminator is intended to be for paths that can't be distinguished solely by source location.

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.

dblaikie edited edge metadata.Nov 6 2015, 4:44 PM
dblaikie added a subscriber: dblaikie.

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.

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.

dnovillo accepted this revision.Nov 9 2015, 5:47 AM
dnovillo edited edge metadata.

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.

This revision is now accepted and ready to land.Nov 9 2015, 5:47 AM

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)

danielcdh updated this revision to Diff 39709.Nov 9 2015, 9:32 AM
danielcdh edited edge metadata.

Add explaination how this would affect sample based FDO.

danielcdh closed this revision.Nov 9 2015, 9:33 AM