Object level profile-directed feedback

About this task

In addition to optimizing entire executables, profile-directed feedback (PDF) can also be applied to specific object files. This approach can be an advantage in applications where patches or updates are distributed as object files or libraries rather than as executables. Also, specific areas of functionality in your application can be optimized without the process of relinking the entire application. In large applications, you can save the time and trouble that otherwise need to be spent relinking the application.

The process for using object level PDF is essentially the same as the executable level PDF process but with a small change to the PDF2 step. For object level PDF, compile your program by using the -qpdf1 option, run the resulting application with representative data, compile the program again with the -qpdf2 option. You need to specify -qnoipa with -qpdf2, which means you cannot use interprocedural analysis (IPA) optimizations and object level PDF at the same time.

If you specify -qpdf2 -qnoipa, object level PDF optimization is done in the compile step. You must take either one of the following actions to ensure that the compiler can recognize the correct PDF file:
  • In the PDF1 step, specify -qpdf1=defname to revert the PDF file name to ._pdf. Thus, the compiler looks for ._pdf in the PDF2 step.
  • In the PDF2 step, specify -qpdf2=pdfname=file_path, where file_path is the path and name of the generated PDF file.
The following steps outline this process:
  1. Compile your program by using the -qpdf1 option. For example:
    xlc -c -O3 -qpdf1 file1.c file2.c file3.c
    In this example, the optimization level -O3 is used, which is a moderate level of optimization.
  2. Link the object files to get an instrumented executable:
    xlc -O3 -qpdf1 file1.o file2.o file3.o
  3. Run the instrumented executable with sample data that is representative of the data you want to optimize for.
    a.out < sample_data
  4. Compile the program again by using the -qpdf2 option. Specify the -qnoipa option so that the linking step is skipped and PDF optimization is applied to the object files rather than to the entire executable.
    xlc -c -O3 -qpdf2 -qnoipa file1.c file2.c file3.c
    The resulting output of this step are object files optimized for the sample data processed by the original instrumented executable. In this example, the optimized object files would be file1.o, file2.o, and file3.o. These object files can be linked by using the system loader ld or by omitting the -c option in the PDF2 step.


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us