Flame Graph Scanning Mode
You can add the --flamegraph parameter next to the./tiancheng flamegraph command to extract hotspot functions from a flame graph SVG file or a Performance Boundary Analyzer result JSON file and analyze them. It is recommended to use flame graph scanning mode for analysis.
Prerequisites
Assume that the Tiancheng Code Optimizer is installed in /home/tiancheng-x.x.x-Linux-Kunpeng.
Flame Graph Scanning
./tiancheng flamegraph --flamegraph /home/demo/flamegraph.svg --top=10 -I /path/to/code_project/include -o /home/demo -r /path/to/code_project
Parse the flamegraph.svg file in /home/demo, extract the top 10 hotspot functions, scan them, and specify the project header file to generate vectorization check report and JSON report files in /home/demo. In addition, specify the project root directory /path/to/code_project to avoid missing header files.
Command output:
Compile database file does not exist or is unreachable.
Target functions to analyze:
- FindCompoundDictionaryMatch (Score: 14.42%) // Indicates that the function to be analyzed is FindCompoundDictionaryMatch, and Score represents the sampling ratio of the function.
- FindLongestMatchH5.constprop.0 (Score: 12.39%)
- FindMatchLengthWithLimit (Score: 6.13%)
- FindLongestMatchH5.constprop.1 (Score: 5.80%)
- SortHuffmanTreeItems.constprop.0 (Score: 4.30%)
- BrotliOptimizeHuffmanCountsForRle (Score: 3.86%)
- StoreRangeH5 (Score: 3.67%)
- SortHuffmanTree (Score: 3.49%)
- CreateBackwardReferencesDH5.isra.0 (Score: 3.20%)
- BrotliCreateHuffmanTree (Score: 2.96%)
----------------------------------------------------------------------
Start to locate function: FindCompoundDictionaryMatch
[Clang] locating: FindCompoundDictionaryMatch file: hash.h
Start to locate function: FindLongestMatchH5.constprop.0
[Clang] locating: FindLongestMatchH5.constprop.0 file: hash.h
[Clang] locating: FindLongestMatchH5.constprop.0 file: hash_forgetful_chain_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.0 file: hash_longest_match64_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.0 file: backward_references_inc.h (via backward_references.c)
[Clang] locating: FindLongestMatchH5.constprop.0 file: hash_rolling_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.0 file: hash_longest_match_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.0 file: hash_longest_match_quickly_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.0 file: hash_composite_inc.h (via hash.h)
Start to locate function: FindMatchLengthWithLimit
[Clang] locating: FindMatchLengthWithLimit file: hash.h
[Clang] locating: FindMatchLengthWithLimit file: compress_fragment.c
[Clang] locating: FindMatchLengthWithLimit file: static_dict.c
[Clang] locating: FindMatchLengthWithLimit file: backward_references_hq.c
[Clang] locating: FindMatchLengthWithLimit file: compress_fragment_two_pass.c
[Clang] locating: FindMatchLengthWithLimit file: hash_forgetful_chain_inc.h (via hash.h)
[Clang] locating: FindMatchLengthWithLimit file: hash_longest_match64_inc.h (via hash.h)
[Clang] locating: FindMatchLengthWithLimit file: hash_to_binary_tree_inc.h (via hash.h)
Start to locate function: FindLongestMatchH5.constprop.1
[Clang] locating: FindLongestMatchH5.constprop.1 file: hash.h
[Clang] locating: FindLongestMatchH5.constprop.1 file: hash_forgetful_chain_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.1 file: hash_longest_match64_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.1 file: backward_references_inc.h (via backward_references.c)
[Clang] locating: FindLongestMatchH5.constprop.1 file: hash_rolling_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.1 file: hash_longest_match_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.1 file: hash_longest_match_quickly_inc.h (via hash.h)
[Clang] locating: FindLongestMatchH5.constprop.1 file: hash_composite_inc.h (via hash.h)
Start to locate function: SortHuffmanTreeItems.constprop.0
[Clang] locating: SortHuffmanTreeItems.constprop.0 file: entropy_encode.h
Start to locate function: BrotliOptimizeHuffmanCountsForRle
[Clang] locating: BrotliOptimizeHuffmanCountsForRle file: entropy_encode.c
Start to locate function: StoreRangeH5
[Clang] locating: StoreRangeH5 file: hash.h
[Clang] locating: StoreRangeH5 file: hash_forgetful_chain_inc.h (via hash.h)
[Clang] locating: StoreRangeH5 file: hash_longest_match64_inc.h (via hash.h)
[Clang] locating: StoreRangeH5 file: hash_to_binary_tree_inc.h (via hash.h)
[Clang] locating: StoreRangeH5 file: backward_references_inc.h (via backward_references.c)
[Clang] locating: StoreRangeH5 file: hash_rolling_inc.h (via hash.h)
[Clang] locating: StoreRangeH5 file: hash_longest_match_inc.h (via hash.h)
[Clang] locating: StoreRangeH5 file: hash_longest_match_quickly_inc.h (via hash.h)
Start to locate function: SortHuffmanTree
[Clang] locating: SortHuffmanTree file: brotli_bit_stream.c
[Clang] locating: SortHuffmanTree file: entropy_encode.c
[Clang] locating: SortHuffmanTree file: huffman.c
[Clang] locating: SortHuffmanTree file: huffman.h
[Clang] locating: SortHuffmanTree file: transform.c
[Clang] locating: SortHuffmanTree file: constants.c
[Clang] locating: SortHuffmanTree file: platform.c
[Clang] locating: SortHuffmanTree file: context.c
Start to locate function: CreateBackwardReferencesDH5.isra.0
[Clang] locating: CreateBackwardReferencesDH5.isra.0 file: backward_references_inc.h (via backward_references.c)
[Clang] locating: CreateBackwardReferencesDH5.isra.0 file: backward_references.c
[Clang] locating: CreateBackwardReferencesDH5.isra.0 file: transform.c
[Clang] locating: CreateBackwardReferencesDH5.isra.0 file: constants.c
[Clang] locating: CreateBackwardReferencesDH5.isra.0 file: platform.c
[Clang] locating: CreateBackwardReferencesDH5.isra.0 file: context.c
[Clang] locating: CreateBackwardReferencesDH5.isra.0 file: shared_dictionary.c
[Clang] locating: CreateBackwardReferencesDH5.isra.0 file: dictionary.c
Start to locate function: BrotliCreateHuffmanTree
[Clang] locating: BrotliCreateHuffmanTree file: entropy_encode.c
----------------------------------------------------------------------
[Locator] Analyzing: FindCompoundDictionaryMatch // Attempts to match the FindCompoundDictionaryMatch function.
-> [Match] /path/to/code_project/enc/hash.h: 510-611
// Successfully matched the hash.h source file containing the FindCompoundDictionaryMatch function. Lines 510-611 indicate the line range where the function is located.
[Locator] Analyzing: FindLongestMatchH5
-> [Match] /path/to/code_project/enc/hash_longest_match_inc.h: 163-278
[Locator] Analyzing: FindMatchLengthWithLimit
-> [Match] /path/to/code_project/enc/find_match_length.h: 37-141
[Locator] Analyzing: FindLongestMatchH5
-> [Match] /path/to/code_project/enc/hash_longest_match_inc.h: 163-278
[Locator] Analyzing: SortHuffmanTreeItems
-> [Match] /path/to/code_project/enc/entropy_encode.h: 84-117
[Locator] Analyzing: BrotliOptimizeHuffmanCountsForRle
-> [Match] /path/to/code_project/enc/entropy_encode.c: 248-377
[Locator] Analyzing: StoreRangeH5
-> [Match] /path/to/code_project/enc/hash_longest_match_inc.h: 116-130
[Locator] Analyzing: SortHuffmanTree
-> [Overload] Collected 2 candidates for: SortHuffmanTree
-> [Match] /path/to/code_project/enc/brotli_bit_stream.c: 400-403 [SortHuffmanTree(const HuffmanTree *, const HuffmanTree *)]
-> [Match] /path/to/code_project/enc/entropy_encode.c: 49-58 [SortHuffmanTree(const HuffmanTree *, const HuffmanTree *)]
[Locator] Analyzing: CreateBackwardReferencesDH5
-> [Match] /path/to/code_project/enc/backward_references_inc.h: 10-189
[Locator] Analyzing: BrotliCreateHuffmanTree
-> [Match] /path/to/code_project/enc/entropy_encode.c: 75-154
================================================================================
Analyzing file: /path/to/code_project/enc/backward_references_inc.h
--------------------------------------------------------------------------------
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
[Scan] Target : /path/to/code_project/enc/backward_references_inc.h
[Scan] Mode : template-include (no include guard / _inc.h suffix)
[Scan] Root : /path/to/code_project
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
Start to scan code.
================================================================================
Analyzing file: /path/to/code_project/enc/brotli_bit_stream.c
--------------------------------------------------------------------------------
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
[Scan] Target : /path/to/code_project/enc/brotli_bit_stream.c
[Scan] Mode : direct scan (source file)
[Scan] Entry : /path/to/code_project/enc/brotli_bit_stream.c
Start to scan code.
[Match Found] Function: SortHuffmanTree at /path/to/code_project/enc/brotli_bit_stream.c:400
================================================================================
Analyzing file: /path/to/code_project/enc/entropy_encode.c
--------------------------------------------------------------------------------
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
[Scan] Target : /path/to/code_project/enc/entropy_encode.c
[Scan] Mode : direct scan (source file)
[Scan] Entry : /path/to/code_project/enc/entropy_encode.c
Start to scan code.
[Match Found] Function: SortHuffmanTree at /path/to/code_project/enc/entropy_encode.c:49
[Match Found] Function: BrotliCreateHuffmanTree at /path/to/code_project/enc/entropy_encode.c:75
[Match Found] Function: BrotliOptimizeHuffmanCountsForRle at /path/to/code_project/enc/entropy_encode.c:248
[FilterAnchors] Limiting from 37 to 10 anchors
[CallDepth] Function 'BrotliOptimizeHuffmanCountsForRle': original anchors=37, filtered=10 → disabling interprocedural analysis
Vectorization check task is being executed. Please wait...
Scanning start time: 2026/08/13 16:04:15
================================================================================
Analyzing file: /path/to/code_project/enc/entropy_encode.h
--------------------------------------------------------------------------------
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
[Scan] Target : /path/to/code_project/enc/entropy_encode.h
[Scan] Mode : direct scan (standalone header)
[Scan] Entry : /path/to/code_project/enc/entropy_encode.h
Start to scan code.
[Match Found] Function: SortHuffmanTreeItems.constprop.0 at /path/to/code_project/enc/entropy_encode.h:84
Vectorization check task is being executed. Please wait...
Scanning start time: 2026/08/13 16:04:15
================================================================================
Analyzing file: /path/to/code_project/enc/find_match_length.h
--------------------------------------------------------------------------------
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
[Scan] Target : /path/to/code_project/enc/find_match_length.h
[Scan] Mode : direct scan (standalone header)
[Scan] Entry : /path/to/code_project/enc/find_match_length.h
Start to scan code.
[Match Found] Function: FindMatchLengthWithLimit at /path/to/code_project/enc/find_match_length.h:37
[FilterAnchors] Limiting from 23 to 10 anchors
[CallDepth] Function 'FindMatchLengthWithLimit': original anchors=23, filtered=10 → disabling interprocedural analysis
Vectorization check task is being executed. Please wait...
Scanning start time: 2026/08/13 16:04:15
================================================================================
Analyzing file: /path/to/code_project/enc/hash.h // Analyzes the hash.h source file.
--------------------------------------------------------------------------------
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
[Scan] Target : /path/to/code_project/enc/hash.h
[Scan] Mode : direct scan (standalone header)
[Scan] Entry : /path/to/code_project/enc/hash.h
Start to scan code.
[Match Found] Function: FindCompoundDictionaryMatch at /path/to/code_project/enc/hash.h:510 // Indicates that the FindCompoundDictionaryMatch function is successfully matched.
[FilterAnchors] Limiting from 51 to 10 anchors // Indicates that the number of anchors to be filtered is limited to 10 (down from 51).
[CallDepth] Function 'FindCompoundDictionaryMatch': original anchors=51, filtered=10 → disabling interprocedural analysis // Indicates that the call depth is restricted and cross-function analysis is disabled.
Vectorization check task is being executed. Please wait...
Scanning start time: 2026/08/13 16:04:16
================================================================================
Analyzing file: /path/to/code_project/enc/hash_longest_match_inc.h
--------------------------------------------------------------------------------
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
[Scan] Target : /path/to/code_project/enc/hash_longest_match_inc.h
[Scan] Mode : template-include (no include guard / _inc.h suffix)
[Scan] Root : /path/to/code_project
compile_commands.json not found under: /path/to/code_project
Recursively collecting include paths as fallback.
Start to scan code.
[Match Found] Function: StoreRangeH5 at /path/to/code_project/enc/hash_longest_match_inc.h:116
[Match Found] Function: FindLongestMatchH5.constprop.0 at /path/to/code_project/enc/hash_longest_match_inc.h:163
[FilterAnchors] Limiting from 40 to 10 anchors
[CallDepth] Function 'FindLongestMatchH5': original anchors=40, filtered=10 → disabling interprocedural analysis
Vectorization check task is being executed. Please wait...
Scanning start time: 2026/08/13 16:04:17
For the details information, please check:
Successfully generated vectorization report: /home/demo/Vectorization_Source_20260813_160350_662_6871.html
// Indicates the path to the HTML vectorization check report file.
Successfully generated vectorization optimization result: /home/demo/Vectorization_Optimization_Result_20260813_160350_662_6871.json // Indicates the path to the JSON report file.
The scanning task is complete, and the analysis result is saved to the specified output directory.
The output directory contains two types of analysis reports. You can view the reports as needed.
- JSON report file: contains only vectorizable code snippets that have been successfully optimized. It is suited for scenarios where optimization results need to be quickly extracted.
- HTML report file: provides a comprehensive view and displays three types of code: vectorizable, potentially vectorizable, and non-vectorizable. It is suitable for in-depth analysis of scenarios with optimization potential.
Viewing a Vectorization Check Report
- View an HTML vectorization check report file.
The report file includes top hotspot functions, a loop vectorization check report, a function vectorization check report, and task information. The following figure shows the details. For details about the report parameters, see Table 1.

As shown in the example, the top-ranked hotspot function is FindCompoundDictionaryMatch. The hotspot ratio indicates that this function accounts for 14.42% of the performance overhead, making it the highest-priority optimization target. You can optimize this function based on the priority. Click the corresponding operation to the right of the hotspot function to view detailed vectorization check information.
- If no optimization opportunities are detected for the hotspot function, the corresponding item in the Operation column is disabled.
- The function vectorization check report is generated only when the x86 Intel intrinsics analysis feature is enabled. If this feature is disabled, the function vectorization check report contains no data.
Table 1 Parameters of top hotspot functions Parameter
Description
Top Hotspot Functions
Hotspot Rank
Sorts hotspot functions in descending order by performance overhead percentage based on the specified Top N value. This helps determine optimization priorities.
Hotspot Percentage
Hotspot function performance overhead percentage.
Function Name
Hotspot function name.
Source File Path
Path to the source file containing the hotspot function.
Source Line
Starting line number of the source file for the function identified as a performance hotspot.
Function Optimizations
Optimization status of a function when the x86 Intel intrinsics analysis feature is enabled. The value 1 indicates that the function can be optimized, whereas the value 0 indicates that either the feature is disabled or the function cannot be optimized.
Loop Optimizations
Total number of loops that can be optimized.
Operation
Optimization information for functions or loops in the hotspot function.
Click Loop Vectorization Report to view the loop vectorization check result. The following figure shows the details. For details about the report parameters, see Table 2.

Table 2 Parameters in the loop vectorization check report Parameter
Description
Loop Vectorization Statistics
Total Loops
Total number of loops scanned in the source file.
Vectorizable
Number of vectorizable loops in the source file.
Potentially vectorizable
Number of loops that can be vectorized only after special processing (such as function inlining) is performed.
Non-vectorizable
Number of non-vectorizable loops in the source file.
Analyzed Loop Lines
Source line numbers of the code identified as a loop optimization candidate.
Result Category
Loop types that can be detected by the Tiancheng Code Optimizer, including vectorizable, potentially vectorizable, and non-vectorizable.
Loop Variable
Variable used in the loop iteration.
Source File Path
Path to the source file containing the loop.
Click Analyzed Loop Lines to view a loop analysis process, which can be vectorizable, potentially vectorizable, or non-vectorizable. Table 3 describes the parameters of the loop analysis process.
- The following figure shows the process of analyzing a vectorizable loop. As shown in the example, copy the vectorized optimized code snippet, replace the corresponding code in the source file (lines 315 to 317), and save the modified file to complete the rewrite.
For modules that support rewriting, the Tiancheng Code Optimizer directly provides optimized code snippets. For modules that cannot be matched for rewriting, the tool outputs vectorization check information during line-by-line analysis of the loop body. You can optimize the code based on the vectorization check result.
- The following figure shows the potentially vectorizable loop analysis process. Based on the check result, you can view the reason why the code at the corresponding location in the source file (lines 275 to 282) is potentially vectorizable.
- The following figure shows the non-vectorizable loop analysis process. Based on the check result, you can view the reason why the code at the corresponding location in the source file (lines 84 to 105) is not vectorizable.
Table 3 Parameters of the loop analysis process Type
Parameter
Description
Vectorizable
Complete Loop Snippet
Code snippet of the loop in the source file.
Vectorized Optimized Snippet
Code snippet of the loop after being vectorized by the Tiancheng Code Optimizer.
Potentially vectorizable
Complete Loop Snippet
Code snippet of the loop in the source file.
Non-vectorizable
Why Non-vectorizable
Reason why the Tiancheng Code Optimizer determines that the loop is not vectorizable.
Complete Loop Snippet
Code snippet of the loop in the source file.
Common parameters
Loop Body Analysis (Line-by-Line)
Loop analysis process performed by the Tiancheng Code Optimizer.
Lines of Code
Lines of code for the loop body.
Coverage
Indicates whether it is covered by a vectorization mode of the Tiancheng Code Optimizer.
Line Vectorization Status
Vectorization status of a single line of code in the loop body, which can be vectorizable, potentially vectorizable, or non-vectorizable.
Check Information
Result of code line analysis performed by the Tiancheng Code Optimizer.
NOTE:If the code line vectorization status is vectorizable, no check information is displayed. If the status is potentially vectorizable or non-vectorizable, the cause or suggestion is displayed.
When the x86 Intel intrinsics analysis feature is disabled, the function vectorization check report contains no data. For details, see the following figure:

Click Task Information to view the information about the current check report. The following figure shows the details. For details about the task information parameters, see Table 4.

In the Task Information tab page, you can quickly view the report name, report generation time, and source code path.
Table 4 Task information parameters Parameter
Description
Task Name
Name of the check task automatically created by the Tiancheng Code Optimizer.
Report Generated
Time when the Tiancheng Code Optimizer generates the report.
Source File Path
Path to the source file containing the scanned source code.
Flame Graph Path
Path to the scanned flame graph SVG file.
Specific Function Name
Name of the scanned function.
File Project
Root directory of the project containing the source file to be analyzed.
Clang File Path
Directory of the Clang built-in header file (for example, stddef.h).
GCC Toolchain
GCC installation directory, which is used as the toolchain path for code analysis.
Enable SVE
Indicates whether to convert the instruction set to the SVE instruction set.
The HTML report focuses on diagnostic analysis. You need to manually adjust the code structure based on the provided suggestions and verify the optimization effect again.
- View a JSON report file.
Open the generated JSON report file and analyze and confirm the modification points.
vim /home/demo/Vectorization_Optimization_Result_20260813_160350_662_6871.json
The JSON file content is as follows:
{ "advisor_items": [ { "opt_file": { "begin_line": 315, "description": "", "end_line": 317, "fileName": "/path/to/code_project/enc/entropy_encode.c", "headerFile": { "name": "#include <arm_neon.h>", "operation": "add" }, "headerLocBegin": 11, "headerLocEnd": 11, "sample_code": " k = 0;\n for (; k + 16 < step; k += 16) {\n vst1q_u8(good_for_rle + i - k - 1, vdupq_n_u8(1));\n }\n for (; k < step; ++k) {\n good_for_rle[i - k - 1] = 1;\n }" } }, { "opt_file": { "begin_line": 348, "description": "", "end_line": 352, "fileName": "/path/to/code_project/enc/entropy_encode.c", "headerFile": { "name": "#include <arm_neon.h>", "operation": "add" }, "headerLocBegin": 11, "headerLocEnd": 11, "sample_code": " k = 0;\n for (; k + 4 < stride; k += 4) {\n vst1q_u32(counts + i - k - 1, vdupq_n_u32(count));\n }\n for (; k < stride; ++k) {\n /* We don't want to change value at counts[i],\n that is already belonging to the next stride. Thus - 1. */\n counts[i - k - 1] = (uint32_t)count;\n }" } } ], "code": 0, "recognizedPattern": 2 }Table 5 Field description Field
Description
advisor_items
Array of code optimization suggestions. Each item in the array is a code tuning optimization.
opt_file
Detailed information about a single optimization suggestion.
begin_line
Start line number of the code to be optimized.
In the example, the start line number is 315.
description
Detailed description of the optimization suggestion.
end_line
End line number of the code to be optimized.
In the example, the end line number is 317.
fileName
Path to the analyzed source file.
In the example, the path is /path/to/code_project/enc/entropy_encode.c.
headerFile
Header file processing information used in the vectorization process.
In the example, "name": "#include <arm_neon.h>" indicates the target header file to be added or replaced in the source code, which is used to enable the NEON instruction set. "operation": "add" indicates the operation type for processing the specified header file.
The options of operation are:
- add: adds a target header file during scalar code vectorization.
- replace: replaces the existing x86 header file with the corresponding Arm header file during x86-to-Arm vectorization porting.
headerLocBegin
Start line number where the header file will be inserted.
- If the value is -1, the header file is already included in the code and does not need to be manually added.
- If the value is a positive integer, it indicates the start line number where the header file will be inserted.
In the example, the start line number is 11.
headerLocEnd
End line number where the header file will be inserted.
- If the value is -1, the header file is already included in the code and does not need to be manually added.
- If the value is a positive integer, it indicates the end line number where the header file will be inserted.
In the example, the end line number is 11.
sample_code
Recommended code vectorization sample, which can be directly used to replace the current code.
The following is an example of optimized code:
k = 0;\n for (; k + 16 < step; k += 16) {\n vst1q_u8(good_for_rle + i - k - 1, vdupq_n_u8(1));\n }\n for (; k < step; ++k) {\n good_for_rle[i - k - 1] = 1;\n }code
Tool execution status code.
- The value 0 indicates execution success.
- A non-zero value indicates an interruption.
In the example, 0 indicates that the tool is executed successfully.
recognizedPattern
Number of code snippets to be optimized.
In the example, the number is 2.
Rewrite the code based on the JSON file.
- View advisor_items, which contains all identified optimization suggestions.
- For each optimization suggestion, check the begin_line and end_line fields to determine the code range to be replaced.
- Copy the vectorized code from sample_code and replace the code in the source file between begin_line and end_line.
- Check the headerLocBegin and headerLocEnd fields.
- If the value is -1, the header file already exists and does not need to be added.
- If the value is a positive integer, add the header file declaration in headerFile to the specified location.
- Save the modified file to complete the automatic rewrite.


