工具链实践——llvm-stress
起初问这个问题给 GPT 时候,GPT 毫不犹豫回答出这个答案,我还以为他在说谎,没想到真有这个工具。
他的用法很简单,直接调用就行,然后你想重定向到哪里都可以。
使用方法列表:
❯ ~/clean/llvm-project/build/bin/llvm-stress --help-list-hidden
OVERVIEW: llvm codegen stress-tester
USAGE: llvm-stress [options]
OPTIONS:
--color - Use colors in output (default=autodetect)
--enable-scalable-vectors - Generate IR involving scalable vector types
-h - Alias for --help
-o <filename> - Override output filename
--print-all-options - Print all option values after command line parsing
--print-options - Print non-default options after command line parsing
--seed=<uint> - Seed used for randomness
--size=<uint> - The estimated size of the generated function (# of instrs)
--version - Display the version of this program
如果你想更复杂的话:
还有一些工具也可以做到随机化。
工具 | 说明 |
---|---|
llvm-fuzzer | 使用 libFuzzer 对 IR pass 进行 fuzz(LLVM test-suite 一部分) |
yarpgen | Intel 出品的 C 程序随机生成器,结合 LLVM 可测试中间 IR |
csmith → clang → IR | 从合法 C 代码生成复杂 IR,间接实现随机 IR |
评论