[LLVMdev] PGO for macro expansion code

Yuanfang Chen cyfmxc at gmail.com
Thu May 28 12:27:56 PDT 2015


#define GET_BIT(lll)    \
    // blah blah

#define G(label1,label2)   \
{                                      \
  // decent amount code  \
  ...
  while (1) {                       \
  GET_BIT(label2);             \
  };                                    \
}

void f() {
   if (..)
     G('c', 'd');

   while ( .. )
       G('a','b');
}

After perf sampling, a lot of samples that should have landed in G and
GET_BIT is attributed to the two lines that have G expansion.
Discriminator does not work either for this case. However  the last
field of DW_TAG_lexical_block ("Unique ID to identify blocks from a
template function") is unique for all instances of scopes in G and
GET_BIT. Can we use that to get better profile of hot and cold paths
inside macro? If not, any workaround for now? Thank you.

Yuanfang



More information about the llvm-dev mailing list