Loading...
Loading...
Compare original and translation side by side
skills/compilers/msvc-clskills/runtimes/sanitizersskills/compilers/msvc-clskills/runtimes/sanitizers| Feature | GCC | Clang |
|---|---|---|
| Min size | | |
| Optimise only hot | — | |
| Thin LTO | | |
| Static analyser | | |
| 特性 | GCC | Clang |
|---|---|---|
| 最小体积 | | |
| 仅优化热点代码 | — | |
| Thin LTO | | |
| 静态分析器 | | |
undefinedundefined
Clang's diagnostics include exact range highlighting and fix-it suggestions that GCC lacks.
Clang的诊断功能包含精确的范围高亮和GCC所没有的修复建议。undefinedundefined
Interpret remarks:
- `remark: foo inlined into bar` — inlining happened; good for hot paths
- `remark: loop not vectorized: loop control flow is not understood` — restructure the loop
- `remark: not vectorized: cannot prove it is safe to reorder...` — add `__restrict__` or `#pragma clang loop vectorize(assume_safety)`
解读优化备注:
- `remark: foo inlined into bar` — 已执行内联;适合热点路径
- `remark: loop not vectorized: loop control flow is not understood` — 需要重构循环
- `remark: not vectorized: cannot prove it is safe to reorder...` — 添加`__restrict__`或`#pragma clang loop vectorize(assume_safety)`undefinedundefined
Common `clang-tidy` check families:
- `bugprone-*`: real bugs (use-after-move, dangling, etc.)
- `clang-analyzer-*`: CSA checks (memory, null deref)
- `modernize-*`: C++11/14/17 modernisation
- `performance-*`: unnecessary copies, move candidates
- `readability-*`: naming, complexity
常见的`clang-tidy`检查家族:
- `bugprone-*`: 真实bug检查(比如use-after-move、悬空指针等)
- `clang-analyzer-*`: CSA检查(内存问题、空指针解引用等)
- `modernize-*`: C++11/14/17语法现代化检查
- `performance-*`: 不必要的拷贝、可移动候选检查
- `readability-*`: 命名规范、代码复杂度检查undefinedundefined
For large projects, ThinLTO is preferred: link times 5-10x faster than full LTO with comparable code quality.
对于大型项目,推荐使用ThinLTO:链接速度比完整LTO快5-10倍,同时代码质量相当。undefinedundefined
AutoFDO (sampling-based, less intrusive): collect with `perf`, convert with `create_llvm_prof`, use with `-fprofile-sample-use`. See `skills/profilers/linux-perf`.
AutoFDO(基于采样,侵入性更低):使用`perf`采集数据,通过`create_llvm_prof`转换,配合`-fprofile-sample-use`使用。详情请查看`skills/profilers/linux-perf`。__has_attribute(foo)-Weverything#include <x86intrin.h>__int128__float128-lquadmath__has_attribute(foo)-Weverything#include <x86intrin.h>__int128__float128-lquadmathclangld64lld-fuse-ld=lld-mmacosx-version-min=X.YDYLD_INSERT_LIBRARIESxcrun clangclangld64lld-fuse-ld=lld-mmacosx-version-min=X.YDYLD_INSERT_LIBRARIESxcrun clangskills/compilers/gccskills/runtimes/sanitizers-fsanitize=*skills/compilers/llvmoptllcllvm-disskills/compilers/msvc-clclang-clskills/binaries/linkers-ltoskills/compilers/gcc-fsanitize=*skills/runtimes/sanitizersoptllcllvm-disskills/compilers/llvmclang-clskills/compilers/msvc-clskills/binaries/linkers-lto