ZHCUAQ1G June 2015 – August 2025
在某些情况下,如果用户通过在代码中提供附加信息来辅助编译器,编译器可以执行更好的优化。在此类情况下,编译器可以通过发出“Advice”来提示采取某些措施提高性能。
该性能建议有以下类型:
默认情况下不会发出性能建议。若要控制性能建议的生成,请使用以下选项:
| --advice:performance | 指示编译器发送建议,启用后,默认情况下会将建议发送到 stdout。默认为 off。 | |
| --advice:performance_file | 指示编译器将发出的任何建议发送到文件。 | |
| --advice:performance_dir | 指示编译器将发出的任何建议发送到特定目录中的文件中。 |
示例 1:以下示例将输出建议发送到 stdout:
cl6x -mv6400+ -o2 -k --advice:performance func.c
"func.c", line 10: advice #30006: Loop at line 8 cannot be scheduled efficiently
as it contains a function call ("_init"). Try making "_init" an inline
function.
"func.c", line 12: advice #30000: Loop at line 8 cannot be scheduled efficiently
as it contains a function call ("_calculate"). Try to inline call or
consider rewriting loop.
请注意,防止“软件流水线不合格”的建议(如上文所示)也将打印在 .asm 文件中。因此,func.asm 将包含:
;*----------------------------------------------------------------------------*
;* SOFTWARE PIPELINE INFORMATION
;* Disqualified loop: Loop contains a call
;* Loop at line 8 cannot be scheduled efficiently as it contains a
;* function call ("_init"). Try making "_init" an inline function.
;* Disqualified loop: Loop contains non-pipelinable instructions
;* Disqualified loop: Loop contains a call
;* Loop at line 8 cannot be scheduled efficiently as it contains a
;* function call ("_calculate"). Try to inline call or consider
;* rewriting loop.
;* Disqualified loop: Loop contains non-pipelinable instructions
;*----------------------------------------------------------------------------*
示例 2:下述示例发送输出建议到名为 filename.advice 的文件中:
cl6x -mv6400+ --advice:performance --advice:performance_file=filename.advice func.c
;******************************************************************************
;* TMS320C6x C/C++ Codegen Unix v7.5.0P12047 (a0322878 - Feb 16 2012) *
;* Date/Time created: Thu Feb 16 10:26:02 2012 *
;* *
;* Warning: This file is auto generated by the compiler and can be *
;* overwritten during the next compile. *
;* *
;******************************************************************************
;* User Options: --silicon_version=6400+
"func.c": advice #27000: Detecting compilation without optimization. Use
optimization option -o2 or higher.
示例 3:以下示例使用不同的选项将输出建议发送到 mydir 目录中名为 myfile.adv 的文件。
使用 --advice:performance_file 和 --advice:performance_dir 选项:
cl6x -mv6400+ -o2 -k --advice:performance_file=myfile.adv --advice:performance_dir=mydir basicloop.c
仅使用 --advice:performance_file 选项来指定完整的路径名称:
cl6x -mv6400+ -o2 -k --advice:performance_file=mydir/myfile.adv basicloop.c
如果同时指定 --advice_dir 选项和完整的路径名称,则忽略 --advice:performance_dir 选项,并在完整的路径名称建议文件中生成建议。另外,请注意目录“mydir”必须已经存在,才能在其中创建建议文件。
以下各小节介绍了支持的建议诊断。