测试环境
鲲鹏920服务器
gcc for openEuler : 2.3.3
鲲鹏编译器:2.5.0
测试用例
测试命令
使用-mllvm -struct-peel-this=my_struct自定义优化选项,同时记录输出pass,该选项需要开启-O3优化。
clang -mcpu=tsv110 -O3 -mllvm -print-after-all -mllvm -struct-peel-this=my_struct -S test4.c -o test4_struct-peel.ll > test4_struct-peel.log 2>&1
另外,设置一个对比测试,只开启-O3优化,同时记录输出的pass记录。
clang -mcpu=tsv110 -O3 -mllvm -print-after-all -S test4.c -o test4_O3.ll > test4_O3.log 2>&1
测试结果
通过上面两个命令测试,得到的中间文件以及输出pass的log文件都一样,这说明自定义优化选项并没有成功开启。
此外我们也测试了其他的自定义优化选项,如-mllvm -sad-pattern-recognition=<true|false>,得到的结果与上面的一样,开启优化选项和只开启-O3优化时,输出结果都一样。
另外,我们也测试过gcc for openEuler中-fipa-struct-reorg选项,输出经过的优化pass,但是显示ipa-struct-reog一直显示未开启。
求解
是使用的命令不对吗?有无关于自定义优化选项更加详细的使用说明?
测试环境
鲲鹏920服务器
gcc for openEuler : 2.3.3
鲲鹏编译器:2.5.0
测试用例
#include <stdio.h> #include <stdlib.h> #include <time.h> #define ARRAY_SIZE 100000000 typedef struct { long long x; int y; int m; } my_struct; my_struct array[ARRAY_SIZE]; void initx() { for (int i = 0; i < ARRAY_SIZE; i++) { array[i].x = rand() % 10; } } void inity() { for (int i = 0; i < ARRAY_SIZE; i++) { array[i].y = rand() % 10; } } void initm() { for (int i = 0; i < ARRAY_SIZE; i++) { array[i].m = rand() % 10; } } int get_sum() { long long sum = 0; for (int i = 0; i < ARRAY_SIZE; i++) { sum += array[i].x; } return sum; } int main() { srand(time(NULL)); long long sum = 0; initx(); inity(); initm(); sum = get_sum(); printf("Sum of x: %lld\n", sum); return 0; }测试命令
使用
-mllvm -struct-peel-this=my_struct自定义优化选项,同时记录输出pass,该选项需要开启-O3优化。clang -mcpu=tsv110 -O3 -mllvm -print-after-all -mllvm -struct-peel-this=my_struct -S test4.c -o test4_struct-peel.ll > test4_struct-peel.log 2>&1另外,设置一个对比测试,只开启
-O3优化,同时记录输出的pass记录。clang -mcpu=tsv110 -O3 -mllvm -print-after-all -S test4.c -o test4_O3.ll > test4_O3.log 2>&1测试结果
通过上面两个命令测试,得到的中间文件以及输出pass的log文件都一样,这说明自定义优化选项并没有成功开启。
此外我们也测试了其他的自定义优化选项,如
-mllvm -sad-pattern-recognition=<true|false>,得到的结果与上面的一样,开启优化选项和只开启-O3优化时,输出结果都一样。另外,我们也测试过gcc for openEuler中
-fipa-struct-reorg选项,输出经过的优化pass,但是显示ipa-struct-reog一直显示未开启。求解
是使用的命令不对吗?有无关于自定义优化选项更加详细的使用说明?