---
title: 标注后源码构建
description: "需要打开对应的优化开关，毕昇编译器才可以启用标注信息提供的编译优化指导。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdevps/compilation/ug-bisheng/kunpengbisheng_30_0042.html
sourcePath: /source/zh/kunpengdevps/compilation/ug-bisheng/kunpengbisheng_30_0042.html
indexId: 31497c0d5f1281db9069b5225dcc9209847d2805ee3f624c3c2420d9325ce2e474
---
# 标注后源码构建

需要打开对应的优化开关，毕昇编译器才可以启用标注信息提供的编译优化指导。

功能控制选项：-mllvm -enable-prob-annotate=true

ProfileSummary输入选项：-mllvm -profile-summary-json-file=***.json

请在开启以上两个编译选项后，编译构建标注后源码，该特性支持在优化等级大于O0的情况下生效。


示例说明：

假设有标注后的源码（test.c）如下：

```
extern double *a;
extern int N;
double __attribute__((hotness(0.630930))) func() {
    double res = 0;
    __attribute__((likelihood(0.999950))) for (int i = 0; i < N; ++i) {
        __attribute__((likelihood(0.250000))) if ((int)a[i] % 2 == 0) {
            res += a[i] + i;
        } else {
            res -= a[i] - i;
        }
    }
    return res;
}
```

开启相关特性支持进行编译（其中，-mllvm -profile-summary-json-file=/path/to/***.json为可选选项）：

```
clang  -O1 -mllvm -enable-prob-annotate=true -mllvm -profile-summary-json-file=/path/to/***.json test.c
```
