bug_id string | issue_url string | bug_type string | base_commit string | knowledge_cutoff timestamp[us] | lit_test_dir list | hints dict | patch string | tests list | issue dict | verified bool | properties dict | bisect string | test_commit null |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
117537 | https://github.com/llvm/llvm-project/issues/117537 | crash | c979ec05642f292737d250c6682d85ed49bc7b6e | 2024-11-25T10:47:02 | [
"llvm/test/Transforms/SimpleLoopUnswitch"
] | {
"fix_commit": "fc5c89900f2a4b50e0f3a88ef7c89115d93684f4",
"components": [
"SimpleLoopUnswitch"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorComb... | commit fc5c89900f2a4b50e0f3a88ef7c89115d93684f4
Author: Nikita Popov <npopov@redhat.com>
Date: Wed Nov 27 11:47:22 2024 +0100
[SimpleLoopUnswitch] Fix LCSSA phi node invalidation
Fixes https://github.com/llvm/llvm-project/issues/117537.
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/l... | [
{
"file": "llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll",
"commands": [
"opt -S -passes='print<scalar-evolution>,simple-loop-unswitch<nontrivial>,print<scalar-evolution>' -verify-scev < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(p... | {
"title": "[SCEV] Assertion `isAvailableAtLoopEntry(Op, L) && \"SCEVAddRecExpr operand is not available at loop entry!\"' failed.",
"body": "Faulty IR:\n```\n; ModuleID = 'test.ll'\nsource_filename = \"/nfs/build-cache/zvm-dev-4598/jdk11/x86_64/fastdebug/lib/server/boilerplate.ll\"\ntarget datalayout = \"e-m:e-p27... | true | {
"is_single_file_fix": true,
"is_single_func_fix": true
} | 2d8d622c738e636c4405072825c01bb14f87bb2f | null |
101337 | https://github.com/llvm/llvm-project/issues/101337 | crash | 1b936e4812ab395328203f65cacd4ffe02bb318e | 2024-07-31T14:11:24 | [
"llvm/test/Transforms/LoopVectorize"
] | {
"fix_commit": "cd08fadd03904806fa26a1f117879ddae34fbf67",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.c... | commit cd08fadd03904806fa26a1f117879ddae34fbf67
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Aug 12 14:45:43 2024 +0100
[LV] Include chains feeding inductions in cost precomputation.
Include chain of ops feeding inductions in cost precomputation for
inductions, not just the induction increment. In... | [
{
"file": "llvm/test/Transforms/LoopVectorize/X86/induction-costs.ll",
"commands": [
"opt -p loop-vectorize -mtriple=x86_64-apple-macosx -S %s"
],
"tests": [
{
"test_name": "iv_and_step_trunc",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64... | {
"title": "Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "To reproduce run opt with \r\n```\r\n-passes=loop-vectorize --mcpu=skylake-avx512 --mattr=+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx51... | true | {
"is_single_file_fix": true,
"is_single_func_fix": true
} | 7d0a5848f2c72854d7d5a795fcc265b8ba787782 | null |
83931 | https://github.com/llvm/llvm-project/issues/83931 | crash | d95a0d7c0ff324c1e84606d26591416e6bf02984 | 2024-03-05T00:39:01 | [
"llvm/test/Transforms/InstCombine"
] | {
"fix_commit": "d51fcd4ed86ac6075c8a25b053c2b66051feaf62",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp... | commit d51fcd4ed86ac6075c8a25b053c2b66051feaf62
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Tue Mar 5 21:08:15 2024 +0800
[InstCombine] Handle scalable splat in `getFlippedStrictnessPredicateAndConstant` (#83980)
This patch adds support for canonicalization of icmp with a scalable
splat. Som... | [
{
"file": "llvm/test/Transforms/InstCombine/pr83931.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "dont_crash",
"test_body": "define <vscale x 2 x i1> @dont_crash(<vscale x 2 x i64> %x) {\nentry:\n %div = sdiv <vscale x 2 x i64> %x, sp... | {
"title": "[InstCombine][RISC-V] UNREACHABLE executed at InstCombineCompares.cpp:2788",
"body": "Testcase:\r\n```c\r\nchar a;\r\nint b;\r\nlong *c[5][5];\r\nint main() {\r\n for (int d = -2041027590; d; d++)\r\n a |= b <= c[3][d][8] / 309383;\r\n}\r\n```\r\n\r\nReduced LLVM IR:\r\n```llvm ir\r\n; ModuleID = 'r... | true | {
"is_single_file_fix": true,
"is_single_func_fix": true
} | Cannot find a good commit | null |
129373 | https://github.com/llvm/llvm-project/issues/129373 | hang | 88460137d97c0b8d3742203e0173ab9ed6c5c8a7 | 2025-03-01T09:39:32 | [
"llvm/test/Transforms/VectorCombine"
] | {
"fix_commit": "5ddf40fa78705384966c22da78e12134df7bd723",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.c... | commit 5ddf40fa78705384966c22da78e12134df7bd723
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Sat Mar 1 16:54:22 2025 +0000
[VectorCombine] scalarizeLoadExtract - don't create scalar loads if any extract is waiting to be erased (#129375)
If any extract is waiting to be erased, then bail out as th... | [
{
"file": "llvm/test/Transforms/VectorCombine/X86/load-extractelement-scalarization.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2"
],
"tests": [
{
"test_name": "multip... | {
"title": "[VectorCombine] scalarizeLoadExtract - infinite loop if we scalarize a dead extract waiting to be erased",
"body": "Reduced test case:\n\n```ll\ndefine void @infinite_loop(ptr %p0) {\n %load = load <4 x float>, ptr %p0, align 8\n %shuffle0 = shufflevector <4 x float> zeroinitializer, <4 x float> %load... | true | {
"is_single_file_fix": true,
"is_single_func_fix": true
} | 035e64c0ec02b237a266ebc672718037fdd53eb2 | null |
180780 | https://github.com/llvm/llvm-project/issues/180780 | crash | 0215f6b6cf810d9ab6d02fc7bbec5c26ad4701ff | 2026-02-10T17:09:08 | [
"llvm/test/Transforms/LoopVectorize"
] | {
"fix_commit": "d3afa171ee236dfef4b7cd4b4dd0b0fb165a48cc",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.c... | commit d3afa171ee236dfef4b7cd4b4dd0b0fb165a48cc
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Feb 11 20:52:07 2026 +0000
[LV] Don't scalarize loads that need predication in legacy CM.
The legacy cost model tries to scalarize loads that are used as
pointers. Skip if the load would need predicating w... | [
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "known_deref_load_tail_folding",
"test_body": "target datalayout = \"e-p:6... | {
"title": "[LV]VPlan cost model and legacy cost model disagreed",
"body": "https://godbolt.org/z/o9sPfa35r\n@fhahn \nMaybe related to https://github.com/llvm/llvm-project/commit/7defb0a4a35817ee7accb310d99912152a542ec2",
"author": "alexey-bataev",
"labels": [
"vectorizers",
"crash-on-valid"
],
"com... | true | {
"is_single_file_fix": true,
"is_single_func_fix": true
} | null | null |
116249 | https://github.com/llvm/llvm-project/issues/116249 | miscompilation | c1f6cb74634509d0e4204dadd46566185fa33e2b | 2024-11-14T15:57:03 | [
"llvm/test/Transforms/IndVarSimplify"
] | {
"fix_commit": "40a647fc7dc6048c92e2d580b61f5feca0785980",
"components": [
"IndVarSimplify"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.... | commit 40a647fc7dc6048c92e2d580b61f5feca0785980
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Nov 15 09:15:37 2024 +0800
[IndVarSimplify] Drop samesign flags after narrowing compares (#116263)
Samesign flag cannot be preserved after narrowing the compare since the
position of the sign bit ... | [
{
"file": "llvm/test/Transforms/IndVarSimplify/finite-exit-comparisons.ll",
"commands": [
"opt -passes=indvars -S < %s -indvars-predicate-loops=0"
],
"tests": [
{
"test_name": "test_drop_icmp_samesign",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16... | {
"title": "[IndVarSimplify] samesign flag should be dropped after narrowing",
"body": "Found with https://github.com/dtcxzyw/llvm-ub-aware-interpreter.\r\nReproducer: https://alive2.llvm.org/ce/z/fcnvLv\r\n```\r\n; bin/opt -passes=indvars test.ll -S\r\ndefine i8 @test(i1 %cond, i32 range(i32 0, 32) %x) {\r\nentry:... | true | {
"is_single_file_fix": true,
"is_single_func_fix": true
} | Cannot find a good commit | null |
181837 | https://github.com/llvm/llvm-project/issues/181837 | crash | 696aa3c0b0989037edc5982154d1d777f71374bf | 2026-02-17T15:19:26 | [
"llvm/test/Transforms/SimplifyCFG"
] | {
"fix_commit": "31e5f86a3cdc960ef7b2f0a533c4a37cf526cacd",
"components": [
"SimplifyCFG"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp... | commit 31e5f86a3cdc960ef7b2f0a533c4a37cf526cacd
Author: Congcong Cai <congcongcai0907@163.com>
Date: Fri Feb 20 07:03:27 2026 +0800
[SimplifyCFG] process prof data when remove case in umin (#182261)
In #164097, we introduce a optimization for umin. But it does not handle
profile data correctly.
... | [
{
"file": "llvm/test/Transforms/SimplifyCFG/switch-umin.ll",
"commands": [
"opt -S -passes=simplifycfg < %s"
],
"tests": [
{
"test_name": "switch_remove_dead_cases",
"test_body": "declare void @a()\n\ndeclare void @b()\n\ndefine void @switch_remove_dead_cases(i32 %x) {\n ... | {
"title": "[simplifycfg] number of prof branch_weights metadata operands does not correspond to number of succesors",
"body": "To reproduce run opt with the test below, -passes=simplifycfg \n\n[reduced-stripped.ll.zip](https://github.com/user-attachments/files/25368313/reduced-stripped.ll.zip)\n\nReproducer: https... | true | {
"is_single_file_fix": true,
"is_single_func_fix": true
} | null | null |
139202 | https://github.com/llvm/llvm-project/issues/139202 | miscompilation | 8bd35ca41253ea36fff78d5acf59956a30b6555b | 2025-05-09T03:49:41 | [
"llvm/test/Transforms/SLPVectorizer"
] | {"fix_commit":"c807395011a027caae9ac196edfac328fb90443a","components":["LoopAccessAnalysis","SLPVect(...TRUNCATED) | "commit c807395011a027caae9ac196edfac328fb90443a\nAuthor: Ramkumar Ramachandra <ramkumar.ramachandra(...TRUNCATED) | [{"file":"llvm/test/Transforms/SLPVectorizer/X86/long-pointer-distance.ll","commands":["opt -S --pas(...TRUNCATED) | {"title":"[SLPV] Pointer offsets truncated to 32-bits, resulting in wrong code","body":"Consider:\n\(...TRUNCATED) | true | {
"is_single_file_fix": false,
"is_single_func_fix": false
} | Cannot find a good commit | null |
174622 | https://github.com/llvm/llvm-project/issues/174622 | crash | c6db8f4229d70169949430185e156fb2e6e4150e | 2026-01-06T16:57:34 | [
"llvm/test/Transforms/LoopVectorize"
] | {"fix_commit":"2f7e218017db69454ea84e1849fcb9a11b1f7fef","components":["LoopVectorize"],"bug_locatio(...TRUNCATED) | "commit 2f7e218017db69454ea84e1849fcb9a11b1f7fef\nAuthor: Florian Hahn <flo@fhahn.com>\nDate: Sun (...TRUNCATED) | [{"file":"llvm/test/Transforms/LoopVectorize/AArch64/induction-costs.ll","commands":["opt -p loop-ve(...TRUNCATED) | {"title":"[LV]VPlan cost model and legacy cost model disagreed","body":"https://godbolt.org/z/Gr8nEM(...TRUNCATED) | true | {
"is_single_file_fix": true,
"is_single_func_fix": false
} | null | null |
117157 | https://github.com/llvm/llvm-project/issues/117157 | crash | d0246fe1e79c6ea06b6b72f66a71a96a3342aa42 | 2024-11-21T13:15:24 | [
"llvm/test/Transforms/LICM"
] | {"fix_commit":"d1408667de830da8817c24cb9788da6caae551c7","components":["MemorySSAUpdater"],"bug_loca(...TRUNCATED) | "commit d1408667de830da8817c24cb9788da6caae551c7\nAuthor: Nikita Popov <npopov@redhat.com>\nDate: (...TRUNCATED) | [{"file":"llvm/test/Transforms/LICM/pr117157.ll","commands":["opt -S -passes=licm -verify-memoryssa (...TRUNCATED) | {"title":"[clang] Crash at O1: Assertion `MSSA->dominates(NewDef, FirstDef) && \"Should have dominat(...TRUNCATED) | true | {
"is_single_file_fix": true,
"is_single_func_fix": false
} | Cannot find a good commit | null |
YAML Metadata Warning:The task_categories "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
LLVM APR Benchmark: A Large-Scale Automated Program Repair Benchmark of Real-World LLVM Middle-End Bugs
GitHub (We only accept pull requests from GitHub)
Motivation
The compiler is a critical infrastructure in the software development. The LLVM compiler infrastructure is widely used in both academia and industry. However, due to its inherent complexity, the LLVM compiler still contains many bugs that can be triggered in edge cases. As one of the LLVM maintainers, my job is to provide the minimal reproducible test cases for issues from fuzzers/ downstream users, and fix these bugs (or assign them to the right person). However, the process is time-consuming and boring. Thanks to the recent advances in compiler testing, we can automatically generate interesting test cases that trigger bugs and automatically reduce the tests to minimal ones. If we can also perform bug localization and repair automatically, it will significantly reduce the workload of us maintainers! Recently, LLM-based automated program repair (APR) techniques have been proposed. We have seen some successful cases in APR benchmarks like Defects4J and SWE-bench. But I believe that fixing LLVM bugs is more challenging than existing benchmarks due to its large C/C++ codebase, complex logic, long history, and the need for domain-specific knowledge. Therefore, I build this benchmark to see if we can automatically repair real-world LLVM bugs with the help of large language models and APR techniques. I hope this benchmark can help both SE researchers and LLVM community to understand how APR techniques work on a large-scale, real-world C/C++ project.
Dataset Description
In this benchmark, we only focus on three kinds of bugs in the LLVM middle-end:
- Crash: the compiler terminates exceptionally or hits an assertion failure (LLVM is built with
-DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ABI_BREAKING_CHECKS=WITH_ASSERTS). - Miscompilation: the compiler generates incorrect program from a well-defined source code.
- Hang: the compiler runs into an infinite loop or fails to reach a fixpoint.
All bugs can be triggered with an opt command and a small piece of LLVM textual IR.
This dataset collects some fixed LLVM middle-end bugs from GitHub issues since 2024-01-01. Each issue contains issue description, test cases, a reference patch, and some hints. All issues are checked against the following criteria:
- At least one of the given test cases can be used to reproduce the bug at a specific commit (
base_commit). For most of the miscompilation bugs, thesrcandtgtfunctions will be checked with alive2, an automatic refinement verification tool for LLVM. If miscompilation happens,alive-tvwill provide a counterexample. The remaining miscompilation bugs will be checked bylli. optpasses all the given tests after fixing the bug with the given reference patch (patch).optpasses all regression tests at a specific commit (hints.fix_commit).
Take Issue121459 as an example:
{
// Identifier of the bug. It can be an issue number, a pull request number,
// or a commit hash.
"bug_id": "121459",
// Points to issue/PR/commit url
"issue_url": "https://github.com/llvm/llvm-project/issues/121459",
// Bug type: crash/miscompilation/hang
"bug_type": "miscompilation",
// Fixes should be applied at the base commit
"base_commit": "68d265666e708bad1c63b419b6275aaba1a7dcd2",
// Knowledge cutoff date. It is not allowed to use the web knowledge base
// after this date or use a large language model trained with newer
// information. Please check the "Rules" section for exemptions.
"knowledge_cutoff": "2025-01-02T09:03:32Z",
// Regression test directories
"lit_test_dir": [
"llvm/test/Transforms/InstCombine"
],
// Bug localization hints at different granularity levels.
// Note that this information is provided in a best-effort way.
// They are not guaranteed to be available or accurate.
"hints": {
"fix_commit": "a4d92400a6db9566d84cb4b900149e36e117f452",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
[
2782,
2787
],
[
2838,
2843
],
[
2847,
2852
]
]
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
"foldGEPOfPhi"
]
}
},
// A reference patch extracted from hints.fix_commit
"patch": "<omitted>",
// Minimal reproducible tests
"tests": [
{
"file": "llvm/test/Transforms/InstCombine/opaque-ptr.ll",
"commands": [
"opt -S -passes='instcombine<no-verify-fixpoint>' < %s"
],
"tests": [
{
"test_name": "gep_of_phi_of_gep_different_type",
"test_body": "<omitted>"
},
{
"test_name": "gep_of_phi_of_gep_flags2",
"test_body": "<omitted>"
},
{
"test_name": "gep_of_phi_of_gep_flags1",
"test_body": "<omitted>"
}
]
}
],
// Issue description
"issue": {
"title": "[InstCombine] GEPNoWrapFlags is propagated incorrectly",
"body": "<omitted>",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
},
"verified": true,
// You are allowed to choose a subset of issues to fix.
// Althrough these properties are obtained from the golden patch,
// using properties is not treated as using hints.
"properties": {
"is_single_file_fix": true,
"is_single_func_fix": true
}
}
As of May 19, 2025, this benchmark contains 295 issues. You can run python3 scripts/dataset_summary.py locally to obtain the latest statistics.
Total issues: 295
Verified issues: 295 (100.00%)
Bug type summary:
miscompilation: 106
crash: 181
hang: 8
Bug component summary (Total = 50):
SLPVectorizer: 73
LoopVectorize: 71
InstCombine: 54
ScalarEvolution: 15
VectorCombine: 11
ValueTracking: 8
IR: 6
ConstraintElimination: 5
InstructionSimplify: 5
SimplifyIndVar: 4
Local: 4
LoopAccessAnalysis: 3
LoopPeel: 3
MemCpyOptimizer: 3
DeadStoreElimination: 3
MemorySSAUpdater: 3
...
Label summary:
crash: 111
miscompilation: 108
vectorizers: 81
llvm:SLPVectorizer: 73
crash-on-valid: 61
llvm:instcombine: 57
llvm:transforms: 40
llvm:analysis: 22
release:backport: 16
llvm:SCEV: 16
generated by fuzzer: 13
confirmed: 9
llvm:crash: 8
regression: 7
llvm:hang: 6
...
Changed files count summary:
Average: 1.17
Max: 5
Min: 1
Median: 1
Inserted lines summary:
Average: 10.71
Max: 164
Min: 0
Median: 6
Deleted lines summary:
Average: 5.55
Max: 169
Min: 0
Median: 2
Test count summary:
Average: 3.59
Max: 107
Min: 1
Median: 1
Patch summary:
Single file fix: 264 (89.49%)
Single func fix: 227 (76.95%)
Single hunk fix: 168 (56.95%)
You can see from the statistics that more than half of the bugs can be fixed with a single hunk. So I believe most of bugs can be fixed with the aid of LLM-based APR techniques :)
Getting Started
Prerequisites
- A C++17 compatible compiler
- ninja
- ccache
- Pre-built LLVM core libraries
- alive-tv
You can follow the Dockerfile to setup the environment.
Installation
git clone https://github.com/dtcxzyw/llvm-apr-benchmark.git
cd llvm-apr-benchmark
pip3 install -r requirements.txt
mkdir -p work && cd work
git clone https://github.com/llvm/llvm-project.git
Please set the following environment variables:
export LAB_LLVM_DIR=<path-to-llvm-src>
export LAB_LLVM_BUILD_DIR=<path-to-llvm-build-dir>
export LAB_LLVM_ALIVE_TV=<path-to-alive-tv>
export LAB_DATASET_DIR=<path-to-llvm-apr-benchmark>/dataset
export LAB_FIX_DIR=<path-to-llvm-apr-benchmark>/examples/fixes
Usage
This benchmark provides two helper modules to allow researchers to easily interact with LLVM and this benchmark.
To use these two helpers:
sys.path.append(os.path.join(os.path.dirname(os.environ["LAB_DATASET_DIR"]), "scripts"))
import llvm_helper
from lab_env import Environment as Env
# Environment variables
llvm_helper.llvm_dir # os.environ["LAB_LLVM_DIR"]
llvm_helper.llvm_build_dir # os.environ["LAB_LLVM_BUILD_DIR"]
llvm_helper.llvm_alive_tv # os.environ["LAB_LLVM_ALIVE_TV"]
llvm_helper.dataset_dir # os.environ["LAB_DATASET_DIR"]
# Execute git commands on the llvm source tree
source_code = llvm_helper.git_execute(['show', f'{commit}:{file_path}'])
# Get information of first failed test from the result of Environment.check_fast/check_full
res, log = env.check_fast()
if isinstance(log, list):
test = llvm_helper.get_first_failed_test(log)
env = Env(
# Load an issue from dataset/{issue_id}.json
issue_id,
# The knowledge cutoff date of LLM
base_model_knowledge_cutoff = "2024-01-01Z",
# Max concurrent jobs for build/test
max_build_jobs=None,
max_test_jobs=None,
)
# If any external knowledge is used, please call this function.
env.use_knowledge(url = "<url>", date = "<date>")
# Reset the source tree to the base commit. Please call it before each attempt.
env.reset()
# Build llvm
res, log = env.build()
# Provide a certificate with the patch and verification result
certificate = env.dump()
# Perform build + test
res, log = env.check_fast()
# Perform build + test + lit regression test
res, log = env.check_full()
# Issue information (always available)
bug_type = env.get_bug_type()
base_commit = env.get_base_commit()
tests = env.get_tests()
# Hints (optional)
fix_commit = env.get_hint_fix_commit()
components = env.get_hint_components()
files = env.get_hint_files()
functions = env.get_hint_bug_functions()
linenos = env.get_hint_line_level_bug_locations()
# Bisection result (optional)
# It is collected in a best-effort way and not always precise.
bisect_commit = env.get_bisect_commit()
# Issue description (optional)
issue = env.get_hint_issue()
# Collect instructions and intrinsics from the given LLVM IR.
# Then it will retrieve descriptions from llvm/docs/LangRef.dst.
# It is useful for LLMs to understand new flags/attributes/metadata.
keywords = env.get_ir_keywords(llvm_ir)
desc = env.get_langref_desc(keywords)
# Properties
is_single_func_fix = env.is_single_func_fix()
is_single_file_fix = env.is_single_file_fix()
Here is a simple repair loop:
env = Env(...)
# System prompts and user prompts
messages = []
while True:
# Reset the LLVM source code tree
env.reset()
# Get information from env
...
# Chat with LLM
...
# Modify the source code in place
...
res, log = env.check_full()
if res:
# The bug is fixed successfully
cert = json.dumps(env.dump(log = messages), indent=2)
print(cert)
break
# Append the feedback into user prompts for the next iteration
messages.append(construct_user_prompt_from_feedback(log))
I have drafted a poor baseline which is powered by DeepSeek-R1. This baseline implementation is only for reference purposes since I am neither an expert in LLM nor APR.
Rules
To claim that your APR tool successfully fixes a bug, please obey the following rules:
- Knowledge allowed to use:
- Any static content/ dynamic feedback provided by
lab_env.Environment - Any content in the LLVM source tree before the base commit
- Large language model trained with dataset before the knowledge cutoff date
- Any other content on the web created before the knowledge cutoff date
- Any static content/ dynamic feedback provided by
optwith this patch passes both the given tests and the regression testsuite.
License
This project is licensed under the Apache License 2.0. Please see the LICENSE for details.
Please cite this work with the following BibTex entry:
@misc{llvm-apr-benchmark,
title = {LLVM APR Benchmark: A Large-Scale Automated Program Repair Benchmark of Real-World LLVM Middle-End Bugs},
url = {https://github.com/dtcxzyw/llvm-apr-benchmark},
author = {Yingwei Zheng},
year = {2025},
}
- Downloads last month
- 24