Datasets:

Modalities:
Text
Formats:
json
Size:
< 1K
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
dtcxzyw commited on
Commit
9d4f4b0
·
1 Parent(s): b87b06a
README.md CHANGED
@@ -131,76 +131,81 @@ Take [Issue121459](https://github.com/llvm/llvm-project/issues/121459) as an exa
131
  }
132
  ```
133
 
134
- As of January 20, 2025, this benchmark contains 226 issues. You can run `python3 scripts/dataset_summary.py` locally to obtain the latest statistics.
135
  ```
136
- Total issues: 226
137
- Verified issues: 226 (100.00%)
138
 
139
  Bug type summary:
140
- miscompilation: 84
141
- crash: 135
142
- hang: 7
143
-
144
- Bug component summary (Total = 43):
145
- LoopVectorize: 60
146
- SLPVectorizer: 50
147
- InstCombine: 47
148
- ScalarEvolution: 10
149
- VectorCombine: 7
150
- ValueTracking: 5
151
- IR: 5
152
- ConstraintElimination: 4
153
- InstructionSimplify: 4
154
- Local: 3
 
 
 
155
  MemCpyOptimizer: 3
 
 
156
  ...
157
 
158
  Label summary:
159
- miscompilation: 86
160
- crash: 82
161
- vectorizers: 67
162
- llvm:instcombine: 50
163
- llvm:SLPVectorizer: 50
164
- crash-on-valid: 44
165
- llvm:transforms: 31
166
- llvm:analysis: 14
167
- llvm:SCEV: 11
168
- release:backport: 9
 
169
  confirmed: 9
170
  llvm:crash: 8
171
- regression: 6
172
  llvm:hang: 6
173
- floating-point: 4
174
  ...
175
 
176
  Changed files count summary:
177
- Average: 1.15
178
- Max: 4
179
  Min: 1
180
  Median: 1
181
 
182
  Inserted lines summary:
183
- Average: 11.04
184
  Max: 164
185
  Min: 0
186
  Median: 6
187
 
188
  Deleted lines summary:
189
- Average: 5.64
190
  Max: 169
191
  Min: 0
192
  Median: 2
193
 
194
  Test count summary:
195
- Average: 3.73
196
  Max: 107
197
  Min: 1
198
  Median: 1
199
 
200
  Patch summary:
201
- Single file fix: 201 (88.94%)
202
- Single func fix: 173 (76.55%)
203
- Single hunk fix: 129 (57.08%)
204
  ```
205
 
206
  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 :)
 
131
  }
132
  ```
133
 
134
+ As of May 19, 2025, this benchmark contains 295 issues. You can run `python3 scripts/dataset_summary.py` locally to obtain the latest statistics.
135
  ```
136
+ Total issues: 295
137
+ Verified issues: 295 (100.00%)
138
 
139
  Bug type summary:
140
+ miscompilation: 106
141
+ crash: 181
142
+ hang: 8
143
+
144
+ Bug component summary (Total = 50):
145
+ SLPVectorizer: 73
146
+ LoopVectorize: 71
147
+ InstCombine: 54
148
+ ScalarEvolution: 15
149
+ VectorCombine: 11
150
+ ValueTracking: 8
151
+ IR: 6
152
+ ConstraintElimination: 5
153
+ InstructionSimplify: 5
154
+ SimplifyIndVar: 4
155
+ Local: 4
156
+ LoopAccessAnalysis: 3
157
+ LoopPeel: 3
158
  MemCpyOptimizer: 3
159
+ DeadStoreElimination: 3
160
+ MemorySSAUpdater: 3
161
  ...
162
 
163
  Label summary:
164
+ crash: 111
165
+ miscompilation: 108
166
+ vectorizers: 81
167
+ llvm:SLPVectorizer: 73
168
+ crash-on-valid: 61
169
+ llvm:instcombine: 57
170
+ llvm:transforms: 40
171
+ llvm:analysis: 22
172
+ release:backport: 16
173
+ llvm:SCEV: 16
174
+ generated by fuzzer: 13
175
  confirmed: 9
176
  llvm:crash: 8
177
+ regression: 7
178
  llvm:hang: 6
 
179
  ...
180
 
181
  Changed files count summary:
182
+ Average: 1.17
183
+ Max: 5
184
  Min: 1
185
  Median: 1
186
 
187
  Inserted lines summary:
188
+ Average: 10.71
189
  Max: 164
190
  Min: 0
191
  Median: 6
192
 
193
  Deleted lines summary:
194
+ Average: 5.55
195
  Max: 169
196
  Min: 0
197
  Median: 2
198
 
199
  Test count summary:
200
+ Average: 3.59
201
  Max: 107
202
  Min: 1
203
  Median: 1
204
 
205
  Patch summary:
206
+ Single file fix: 264 (89.49%)
207
+ Single func fix: 227 (76.95%)
208
+ Single hunk fix: 168 (56.95%)
209
  ```
210
 
211
  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 :)
dataset.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
dataset/125278.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "125278",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/125278",
4
+ "bug_type": "crash",
5
+ "base_commit": "1484f82cbc62eab9c4c8f393b84c2f521bf882f6",
6
+ "knowledge_cutoff": "2025-01-31T20:00:27Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "c4f723a7c3bb12ce4e247bcaed755c8d927f73a4",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
17
+ [
18
+ 1632,
19
+ 1642
20
+ ],
21
+ [
22
+ 1659,
23
+ 1696
24
+ ],
25
+ [
26
+ 1749,
27
+ 1767
28
+ ]
29
+ ]
30
+ },
31
+ "bug_location_funcname": {
32
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
33
+ "VPlanTransforms::truncateToMinimalBitwidths"
34
+ ]
35
+ }
36
+ },
37
+ "patch": "commit c4f723a7c3bb12ce4e247bcaed755c8d927f73a4\nAuthor: Ramkumar Ramachandra <[email protected]>\nDate: Thu May 8 11:49:54 2025 +0100\n\n [LV] Strip unmaintainable MinBWs assert (#136858)\n \n tryToWiden attempts to replace an Instruction with a Constant from SCEV,\n but forgets to erase the Instruction from the MinBWs map, leading to an\n assert in VPlanTransforms::truncateToMinimalBitwidths. Going forward,\n the assertion in truncateToMinimalBitwidths is unmaintainable, as LV\n could simplify the expression at any point: fix the bug by stripping the\n unmaintable assertion.\n \n Fixes #125278.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\nindex 7943f58f0739..79ddb8bf0b09 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\n@@ -1632,11 +1632,6 @@ static void licm(VPlan &Plan) {\n \n void VPlanTransforms::truncateToMinimalBitwidths(\n VPlan &Plan, const MapVector<Instruction *, uint64_t> &MinBWs) {\n-#ifndef NDEBUG\n- // Count the processed recipes and cross check the count later with MinBWs\n- // size, to make sure all entries in MinBWs have been handled.\n- unsigned NumProcessedRecipes = 0;\n-#endif\n // Keep track of created truncates, so they can be re-used. Note that we\n // cannot use RAUW after creating a new truncate, as this would could make\n // other uses have different types for their operands, making them invalidly\n@@ -1659,38 +1654,12 @@ void VPlanTransforms::truncateToMinimalBitwidths(\n if (!NewResSizeInBits)\n continue;\n \n-#ifndef NDEBUG\n- NumProcessedRecipes++;\n-#endif\n // If the value wasn't vectorized, we must maintain the original scalar\n // type. Skip those here, after incrementing NumProcessedRecipes. Also\n // skip casts which do not need to be handled explicitly here, as\n // redundant casts will be removed during recipe simplification.\n- if (isa<VPReplicateRecipe, VPWidenCastRecipe>(&R)) {\n-#ifndef NDEBUG\n- // If any of the operands is a live-in and not used by VPWidenRecipe or\n- // VPWidenSelectRecipe, but in MinBWs, make sure it is counted as\n- // processed as well. When MinBWs is currently constructed, there is no\n- // information about whether recipes are widened or replicated and in\n- // case they are reciplicated the operands are not truncated. Counting\n- // them them here ensures we do not miss any recipes in MinBWs.\n- // TODO: Remove once the analysis is done on VPlan.\n- for (VPValue *Op : R.operands()) {\n- if (!Op->isLiveIn())\n- continue;\n- auto *UV = dyn_cast_or_null<Instruction>(Op->getUnderlyingValue());\n- if (UV && MinBWs.contains(UV) && !ProcessedTruncs.contains(Op) &&\n- none_of(Op->users(),\n- IsaPred<VPWidenRecipe, VPWidenSelectRecipe>)) {\n- // Add an entry to ProcessedTruncs to avoid counting the same\n- // operand multiple times.\n- ProcessedTruncs[Op] = nullptr;\n- NumProcessedRecipes += 1;\n- }\n- }\n-#endif\n+ if (isa<VPReplicateRecipe, VPWidenCastRecipe>(&R))\n continue;\n- }\n \n Type *OldResTy = TypeInfo.inferScalarType(ResultVPV);\n unsigned OldResSizeInBits = OldResTy->getScalarSizeInBits();\n@@ -1749,19 +1718,11 @@ void VPlanTransforms::truncateToMinimalBitwidths(\n NewOp->insertBefore(&R);\n } else {\n PH->appendRecipe(NewOp);\n-#ifndef NDEBUG\n- auto *OpInst = dyn_cast<Instruction>(Op->getLiveInIRValue());\n- bool IsContained = MinBWs.contains(OpInst);\n- NumProcessedRecipes += IsContained;\n-#endif\n }\n }\n \n }\n }\n-\n- assert(MinBWs.size() == NumProcessedRecipes &&\n- \"some entries in MinBWs haven't been processed\");\n }\n \n /// Remove BranchOnCond recipes with true conditions together with removing\n",
38
+ "tests": [
39
+ {
40
+ "file": "llvm/test/Transforms/LoopVectorize/pr125278.ll",
41
+ "commands": [
42
+ "opt -passes=loop-vectorize -force-vector-width=4 -S %s"
43
+ ],
44
+ "tests": [
45
+ {
46
+ "test_name": "<module>",
47
+ "test_body": "\ndefine void @pr125278(ptr %dst, i64 %n) {\n;\nentry:\n %true.ext = zext i1 true to i32\n br label %cond\n\ncond:\n br label %loop\n\nloop:\n %iv = phi i64 [ 0, %cond ], [ %iv.next, %loop ]\n %false.ext = zext i1 false to i32\n %xor = xor i32 %false.ext, %true.ext\n %xor.trunc = trunc i32 %xor to i8\n store i8 %xor.trunc, ptr %dst, align 1\n %iv.next = add i64 %iv, 1\n %cmp = icmp ult i64 %iv.next, %n\n br i1 %cmp, label %loop, label %cond\n}"
48
+ }
49
+ ]
50
+ }
51
+ ],
52
+ "issue": {
53
+ "title": "[LoopVectorize] Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.",
54
+ "body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @c() #0 {\nentry:\n %conv12 = zext i1 false to i32\n br label %for.cond1\n\nfor.cond1: ; preds = %for.body, %entry\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.cond1\n %indvars.iv1 = phi i64 [ 0, %for.cond1 ], [ %indvars.iv.next, %for.body ]\n %land.ext = zext i1 false to i32\n %xor = xor i32 0, %conv12\n %conv20 = trunc i32 %xor to i8\n store i8 %conv20, ptr null, align 1\n %indvars.iv.next = add i64 %indvars.iv1, 1\n %cmp = icmp ult i64 %indvars.iv1, 1\n br i1 %cmp, label %for.body, label %for.cond1\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-sdext,-experimental-sdtrig,-experimental-smctr,-experimental-ssctr,-experimental-svukte,-experimental-xqcia,-experimental-xqciac,-experimental-xqcicli,-experimental-xqcicm,-experimental-xqcics,-experimental-xqcicsr,-experimental-xqciint,-experimental-xqcilo,-experimental-xqcilsm,-experimental-xqcisls,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-sha,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smdbltrp,-smepmp,-smmpm,-smnpm,-smrnmi,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssdbltrp,-ssnpm,-sspm,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-supm,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-svvptc,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xmipscmove,-xmipslsp,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zabha,-zacas,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\n```\nCommand/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt reduced.ll --passes=loop-vectorize\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:1438: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, const llvm::MapVector<llvm::Instruction*, long unsigned int>&): Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt reduced.ll --passes=loop-vectorize\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"c\"\n #0 0x00005ac7451347e2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33f67e2)\n #1 0x00005ac74513182f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33f382f)\n #2 0x00005ac74513196c SignalHandler(int) Signals.cpp:0:0\n #3 0x00007f6297445320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)\n #4 0x00007f629749eb1c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007f629749eb1c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007f629749eb1c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007f629744526e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007f62974288ff abort ./stdlib/abort.c:81:7\n #9 0x00007f629742881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007f629743b507 (/lib/x86_64-linux-gnu/libc.so.6+0x3b507)\n#11 0x00005ac74415e85e llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, llvm::MapVector<llvm::Instruction*, unsigned long, llvm::DenseMap<llvm::Instruction*, unsigned int, llvm::DenseMapInfo<llvm::Instruction*, void>, llvm::detail::DenseMapPair<llvm::Instruction*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Instruction*, unsigned long>, 0u>> const&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x242085e)\n#12 0x00005ac743fd3d90 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x2295d90)\n#13 0x00005ac743fd42ee llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22962ee)\n#14 0x00005ac743fd6055 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x2298055)\n#15 0x00005ac743fd8fe1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x229afe1)\n#16 0x00005ac743fd95c7 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x229b5c7)\n#17 0x00005ac742ce28c5 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfa48c5)\n#18 0x00005ac744f21f0a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31e3f0a)\n#19 0x00005ac742ce5055 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfa7055)\n#20 0x00005ac744f2081c llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31e281c)\n#21 0x00005ac742ce1785 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfa3785)\n#22 0x00005ac744f20dfd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31e2dfd)\n#23 0x00005ac74248e195 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x750195)\n#24 0x00005ac74247e41e optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x74041e)\n#25 0x00007f629742a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#26 0x00007f629742a28b call_init ./csu/../csu/libc-start.c:128:20\n#27 0x00007f629742a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#28 0x00005ac742474c75 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x736c75)\nAborted (core dumped)\n```\n\nGodbolt: https://godbolt.org/z/YqE8f1PPz\n\nFound via fuzzer (C program before reduction)",
55
+ "author": "ewlu",
56
+ "labels": [
57
+ "vectorizers",
58
+ "crash",
59
+ "generated by fuzzer"
60
+ ],
61
+ "comments": [
62
+ {
63
+ "author": "patrick-rivos",
64
+ "body": "Some triaging for the same assert here: https://github.com/llvm/llvm-project/issues/87407"
65
+ },
66
+ {
67
+ "author": "cardigan1008",
68
+ "body": "There's a case that triggers the same crash at `-O2`:\n\n```c\nint a, h;\nstruct {\n char b;\n long c;\n char d\n} static e = {2, 2, 5};\nchar f, j, l;\nshort g;\nint *i;\nstatic short k;\nvoid m() {}\nvoid n() {\n m(e);\n for (; f; f++) {\n j ^= (a > (short)*i + k | e.d) <= 0;\n h = l;\n }\n}\nvoid o() {\n g = 1;\n for (; g;)\n k = 9;\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/EK3zbjPax\n\nBisected to https://github.com/llvm/llvm-project/commit/6d6eea92e36c301e34a7ec11b2a40e3080f79f53, which was committed by @fhahn \n\nHope it helps :)"
69
+ }
70
+ ]
71
+ },
72
+ "verified": true
73
+ }
dataset/137185.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "137185",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/137185",
4
+ "bug_type": "crash",
5
+ "base_commit": "6479e9bad371f19a36ed15c236defc301efc180f",
6
+ "knowledge_cutoff": "2025-04-24T14:36:28Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "a750893fea29f32e9bab2cd5176eec34e63b0898",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
17
+ [
18
+ 2127,
19
+ 2133
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
25
+ "VPScalarIVStepsRecipe::execute"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit a750893fea29f32e9bab2cd5176eec34e63b0898\nAuthor: Maryam Moghadas <[email protected]>\nDate: Tue May 6 12:48:21 2025 -0400\n\n [VPlan][LV] Fix invalid truncation in VPScalarIVStepsRecipe (#137832)\n \n Replace CreateTrunc with CreateSExtOrTrunc in VPScalarIVStepsRecipe to\n safely handle type conversion. This prevents assertion failures from\n invalid truncation when StartIdx0 has a smaller integer type than\n IntStepTy. The assertion was introduced by commit 783a846.\n Fixes https://github.com/llvm/llvm-project/issues/137185\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\nindex 6027572f1e84..c45c62e13d76 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n@@ -2127,7 +2127,7 @@ void VPScalarIVStepsRecipe::execute(VPTransformState &State) {\n Builder.CreateMul(StartIdx0, ConstantInt::get(StartIdx0->getType(),\n getUnrollPart(*this)));\n }\n- StartIdx0 = Builder.CreateTrunc(StartIdx0, IntStepTy);\n+ StartIdx0 = Builder.CreateSExtOrTrunc(StartIdx0, IntStepTy);\n }\n \n if (!FirstLaneOnly && State.VF.isScalable()) {\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/PowerPC/vplan-scalarivsext-crash.ll",
33
+ "commands": [
34
+ "opt -passes=loop-vectorize -S %s 2>&1"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\ntarget datalayout = \"E-m:a-p:32:32-Fi32-i64:64-n32\"\ntarget triple = \"powerpc-ibm-aix7.2.0.0\"\n\ndefine void @test_iv_trunc_crash(ptr %a, ptr %b, i32 %n) {\n;\nentry:\n %sum.0 = fadd reassoc double 0.0, 0.0\n %x = load double, ptr %a, align 8\n br label %loop_header\n\nloop_header: ; preds = %loop_body, %entry\n %sum.1 = phi double [ %sum.0, %entry ], [ %sum.next, %loop_body ]\n %i = phi i32 [ 0, %entry ], [ %i.next, %loop_body ]\n %cond = icmp sgt i32 %i, %n\n br i1 %cond, label %exit, label %loop_body\n\nloop_body: ; preds = %loop_header\n store double %sum.1, ptr %b, align 8\n %sum.next = fadd reassoc double %sum.1, %x\n %i.next = add i32 %i, 1\n br label %loop_header\n\nexit:\n ret void\n}\n;.\n;."
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[Loop Vectorize] Crash: Assertion `CastInst::castIsValid(opc, C, Ty) && \"Invalid constantexpr cast!\"'",
46
+ "body": "Here is the godbolt link to the reproducer: https://godbolt.org/z/354qYx43T\nFor the record here is the IR:\n```\nsource_filename = \"reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @widget() {\nbb:\n %sitofp = sitofp i32 0 to double\n br label %bb1\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %phi2 = phi double [ %fsub, %bb1 ], [ 0.000000e+00, %bb ]\n %fsub = fsub double %phi2, %sitofp\n %add = add i32 %phi, 1\n %icmp = icmp ult i32 %phi, 252\n br i1 %icmp, label %bb1, label %bb3\n\nbb3: ; preds = %bb1\n %phi4 = phi double [ %phi2, %bb1 ]\n %phi5 = phi double [ %fsub, %bb1 ]\n ret void\n}\n```\nwhich fails when running: `opt -passes=loop-vectorize -slp-threshold=-99999 -force-vector-width=4` with the backtrace:\n```\nopt: /root/llvm-project/llvm/lib/IR/Constants.cpp:2231: static llvm::Constant* llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool): Assertion `CastInst::castIsValid(opc, C, Ty) && \"Invalid constantexpr cast!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize -slp-threshold=-99999 -force-vector-width=4 <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"widget\"\n #0 0x00000000054eff68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54eff68)\n #1 0x00000000054ed8f4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007ccdb7442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007ccdb74969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007ccdb7442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007ccdb74287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007ccdb742871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007ccdb7439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000005166c4b llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5166c4b)\n #9 0x0000000000d41160 llvm::IRBuilderBase::CreateTrunc(llvm::Value*, llvm::Type*, llvm::Twine const&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd41160)\n#10 0x00000000045b9885 llvm::VPScalarIVStepsRecipe::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45b9885)\n#11 0x0000000004576263 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4576263)\n#12 0x000000000457e734 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x457e734)\n#13 0x000000000457f740 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x457f740)\n#14 0x000000000458abda llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x458abda)\n#15 0x000000000442b57c llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x442b57c)\n#16 0x0000000004443b38 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4443b38)\n#17 0x0000000004445ce0 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4445ce0)\n#18 0x0000000004446333 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4446333)\n#19 0x00000000031c103e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x31c103e)\n#20 0x00000000052e90a0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52e90a0)\n#21 0x0000000000e7bace llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe7bace)\n#22 0x00000000052e7973 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52e7973)\n#23 0x0000000000e7a98e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe7a98e)\n#24 0x00000000052e7380 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52e7380)\n#25 0x000000000094707a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94707a)\n#26 0x000000000093a84c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93a84c)\n#27 0x00007ccdb7429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#28 0x00007ccdb7429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#29 0x0000000000932485 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x932485)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
47
+ "author": "Nirhar",
48
+ "labels": [
49
+ "vectorizers",
50
+ "crash"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "Nirhar",
55
+ "body": "As far as I can see, we are trying to truncate an i32 value to i64 type, which is illegal, here:\nhttps://github.com/llvm/llvm-project/blob/72cc868c65b0641f23d1fb0518a8503c73ecdb5a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp#L2137\n\nMight be related to @fhahn 's commit here: 783a846507683c7b515473b833c9cf02cd2b1993"
56
+ },
57
+ {
58
+ "author": "maryammo",
59
+ "body": "I have also noticed the assertion as a result of commit 783a846507683c7b515473b833c9cf02cd2b1993 for invalid truncation. \n\n@fhahn , Does the following fix make sense? \n\n```\n--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n@@ -2124,7 +2124,7 @@ void VPScalarIVStepsRecipe::execute(VPTransformState &State) {\n Builder.CreateMul(StartIdx0, ConstantInt::get(StartIdx0->getType(),\n getUnrollPart(*this)));\n }\n- StartIdx0 = Builder.CreateTrunc(StartIdx0, IntStepTy);\n+ StartIdx0 = Builder.CreateSExtOrTrunc(StartIdx0, IntStepTy);\n }\n \n if (!FirstLaneOnly && State.VF.isScalable()) {\ndiff --git a/llvm/test/Transforms/LoopVectorize/PowerPC/regression-scalarivsext-crash.ll b/llvm/test/Transforms/LoopVectorize/PowerPC/regression-scalarivsext-crash.ll\nnew file mode 100644\nindex 000000000000..66b54a29b913\n--- /dev/null\n+++ b/llvm/test/Transforms/LoopVectorize/PowerPC/regression-scalarivsext-crash.ll\n@@ -0,0 +1,31 @@\n+; RUN: opt -passes=loop-vectorize -S < %s > /dev/null\n+; REQUIRES: asserts\n+\n+target datalayout = \"E-m:a-p:32:32-Fi32-i64:64-n32\"\n+target triple = \"powerpc-ibm-aix7.2.0.0\"\n+\n+define void @__power_mod_NMOD_power_init(ptr %a, ptr %b, i32 %n) {\n+entry:\n+ br label %loop_entry\n+\n+loop_exit: ; preds = %loop_header\n+ br label %loop_entry\n+\n+loop_entry: ; preds = %loop_exit, %entry\n+ %sum.0 = phi double [ 0.000000e+00, %entry ], [ %sum.1, %loop_exit ]\n+ %x = load double, ptr %a, align 8\n+ br label %loop_header\n+\n+loop_header: ; preds = %loop_body, %loop_entry\n+ %sum.1 = phi double [ %sum.0, %loop_entry ], [ %sum.next, %loop_body ]\n+ %i = phi i32 [ 0, %loop_entry ], [ %i.next, %loop_body ]\n+ %cond = icmp sgt i32 %i, %n\n+ br i1 %cond, label %loop_exit, label %loop_body\n+\n+loop_body: ; preds = %loop_header\n+ store double %sum.1, ptr %b, align 8\n+ %sum.next = fadd reassoc double %sum.1, %x\n+ %i.next = add i32 %i, 1\n+ br label %loop_header\n+}\n+\n```"
60
+ },
61
+ {
62
+ "author": "fhahn",
63
+ "body": "@maryammo thanks, could you create a PR? For the test case, does it require a target-triple or can the one provided by @Nirhar be used without a target triple?\n"
64
+ },
65
+ {
66
+ "author": "maryammo",
67
+ "body": "@fhahn , Sure I do. Both tests need target triple to fail. "
68
+ },
69
+ {
70
+ "author": "maryammo",
71
+ "body": "https://github.com/llvm/llvm-project/pull/137832"
72
+ }
73
+ ]
74
+ },
75
+ "verified": true
76
+ }
dataset/137797.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "137797",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/137797",
4
+ "bug_type": "crash",
5
+ "base_commit": "368fbc21631a16b66a2a5609271c467a025a08b9",
6
+ "knowledge_cutoff": "2025-04-29T12:24:21Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "3aecbbcbf675bc4472dafff18d29f21457323f28",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 15245,
19
+ 15250
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::isGatherShuffledSingleRegisterEntry"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 3aecbbcbf675bc4472dafff18d29f21457323f28\nAuthor: Alexey Bataev <[email protected]>\nDate: Tue May 6 06:40:54 2025 -0700\n\n [SLP]Do not match nodes if schedulability of parent nodes is different\n \n If one user node is non-schedulable and another one is schedulable, such\n nodes should be considered matched. The selection of the actual insert\n point in this case differs and the insert points may match, which may\n cause a compiler crash because of the broken def-use chain.\n \n Fixes #137797\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 4d183bb42f0e..a6ae26f2f0e1 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -15245,6 +15245,11 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n continue;\n }\n \n+ if (!TEUseEI.UserTE->isGather() && !UserPHI &&\n+ doesNotNeedToSchedule(TEUseEI.UserTE->Scalars) !=\n+ doesNotNeedToSchedule(UseEI.UserTE->Scalars) &&\n+ is_contained(UseEI.UserTE->Scalars, TEInsertPt))\n+ continue;\n // Check if the user node of the TE comes after user node of TEPtr,\n // otherwise TEPtr depends on TE.\n if ((TEInsertBlock != InsertPt->getParent() ||\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/matched-bv-schedulable.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-99999"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\ndefine void @test() {\n;\nbb:\n br i1 false, label %bb1, label %bb5\n\nbb1:\n %phi = phi i32 [ %or4, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %add = add i32 1, 0\n %or = or i32 0, %phi2\n %or3 = or i32 %or, 0\n %mul = mul i32 0, 0\n %or4 = or i32 %phi, %mul\n br i1 false, label %bb1, label %bb5\n\nbb5:\n %phi6 = phi i32 [ 0, %bb ], [ %or4, %bb1 ]\n %phi7 = phi i32 [ 0, %bb ], [ %or, %bb1 ]\n ret void\n}"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted!",
46
+ "body": "To reproduce run opt with the test below using -passes=slp-vectorizer -slp-threshold=-99999:\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat() #0 gc \"statepoint-example\" {\nbb:\n br i1 false, label %bb1, label %bb5\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ %or4, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %add = add i32 1, 0\n %or = or i32 0, %phi2\n %or3 = or i32 %or, 0\n %mul = mul i32 0, 0\n %or4 = or i32 %phi, %mul\n br i1 false, label %bb1, label %bb5\n\nbb5: ; preds = %bb1, %bb\n %phi6 = phi i32 [ 0, %bb ], [ %or4, %bb1 ]\n %phi7 = phi i32 [ 0, %bb ], [ %or, %bb1 ]\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,-amx-fp8,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,-movrs,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,-amx-tf32,-amx-avx512,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-amx-transpose,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-amx-movrs,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\n```\nReproducer: https://godbolt.org/z/YbPKn761h\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000055242e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55242e8)\n #1 0x0000000005521c74 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000073e542242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000073e5422969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000073e542242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000073e5422287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000080a091 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000054600e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54600e8)\n #8 0x000000000535c8d8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x535c8d8)\n #9 0x000000000093ee6e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93ee6e)\n#10 0x000000000531b5a0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x531b5a0)\n#11 0x00000000009492ba llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9492ba)\n#12 0x000000000093ca8c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93ca8c)\n#13 0x000073e542229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x000073e542229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x00000000009346c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9346c5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n",
47
+ "author": "TatyanaDoubts",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash"
51
+ ],
52
+ "comments": []
53
+ },
54
+ "verified": true
55
+ }
dataset/137937.json ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "137937",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/137937",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "eac7466448f920e733f12beca28ff848cfa4810d",
6
+ "knowledge_cutoff": "2025-04-30T08:55:06Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/ConstraintElimination"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "aa054c681059257d371857945c08840f69f68379",
12
+ "components": [
13
+ "ConstraintElimination"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": [
17
+ [
18
+ 1563,
19
+ 1570
20
+ ],
21
+ [
22
+ 1611,
23
+ 1625
24
+ ],
25
+ [
26
+ 1852,
27
+ 1860
28
+ ]
29
+ ]
30
+ },
31
+ "bug_location_funcname": {
32
+ "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": [
33
+ "checkOrAndOpImpliedByOther",
34
+ "eliminateConstraints"
35
+ ]
36
+ }
37
+ },
38
+ "patch": "commit aa054c681059257d371857945c08840f69f68379\nAuthor: Yingwei Zheng <[email protected]>\nDate: Wed May 14 23:37:41 2025 +0800\n\n [ConstraintElim] Simplify and/or instead of replacing its operand (#139874)\n \n In `checkOrAndOpImpliedByOther`, replacing an operand of a disjoint or\n is unsafe: https://alive2.llvm.org/ce/z/4R4hxN\n This patch performs the simplification directly, to avoid miscompilation\n and unnecessary canonicalization.\n \n Closes https://github.com/llvm/llvm-project/issues/137937.\n\ndiff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp\nindex f2d6e268743e..da5be383df15 100644\n--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp\n+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp\n@@ -1563,8 +1563,12 @@ removeEntryFromStack(const StackEntry &E, ConstraintInfo &Info,\n static bool checkOrAndOpImpliedByOther(\n FactOrCheck &CB, ConstraintInfo &Info, Module *ReproducerModule,\n SmallVectorImpl<ReproducerEntry> &ReproducerCondStack,\n- SmallVectorImpl<StackEntry> &DFSInStack) {\n+ SmallVectorImpl<StackEntry> &DFSInStack,\n+ SmallVectorImpl<Instruction *> &ToRemove) {\n Instruction *JoinOp = CB.getContextInst();\n+ if (JoinOp->use_empty())\n+ return false;\n+\n CmpInst *CmpToCheck = cast<CmpInst>(CB.getInstructionToSimplify());\n unsigned OtherOpIdx = JoinOp->getOperand(0) == CmpToCheck ? 1 : 0;\n \n@@ -1611,15 +1615,12 @@ static bool checkOrAndOpImpliedByOther(\n if (auto ImpliedCondition =\n checkCondition(CmpToCheck->getPredicate(), CmpToCheck->getOperand(0),\n CmpToCheck->getOperand(1), CmpToCheck, Info)) {\n- if (IsOr && isa<SelectInst>(JoinOp)) {\n- JoinOp->setOperand(\n- OtherOpIdx == 0 ? 2 : 0,\n+ if (IsOr == *ImpliedCondition)\n+ JoinOp->replaceAllUsesWith(\n ConstantInt::getBool(JoinOp->getType(), *ImpliedCondition));\n- } else\n- JoinOp->setOperand(\n- 1 - OtherOpIdx,\n- ConstantInt::getBool(JoinOp->getType(), *ImpliedCondition));\n-\n+ else\n+ JoinOp->replaceAllUsesWith(JoinOp->getOperand(OtherOpIdx));\n+ ToRemove.push_back(JoinOp);\n return true;\n }\n \n@@ -1852,9 +1853,9 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,\n ReproducerModule.get(), ReproducerCondStack, S.DT, ToRemove);\n if (!Simplified &&\n match(CB.getContextInst(), m_LogicalOp(m_Value(), m_Value()))) {\n- Simplified =\n- checkOrAndOpImpliedByOther(CB, Info, ReproducerModule.get(),\n- ReproducerCondStack, DFSInStack);\n+ Simplified = checkOrAndOpImpliedByOther(\n+ CB, Info, ReproducerModule.get(), ReproducerCondStack, DFSInStack,\n+ ToRemove);\n }\n Changed |= Simplified;\n } else if (auto *MinMax = dyn_cast<MinMaxIntrinsic>(Inst)) {\n",
39
+ "tests": [
40
+ {
41
+ "file": "llvm/test/Transforms/ConstraintElimination/and-implied-by-operands.ll",
42
+ "commands": [
43
+ "opt -passes=constraint-elimination -S %s"
44
+ ],
45
+ "tests": [
46
+ {
47
+ "test_name": "and_tree_second_implies_first_perm1",
48
+ "test_body": "define void @and_tree_second_implies_first_perm1(i32 noundef %v0, i32 noundef %v1, i32 noundef %v2) {\nentry:\n %cmp0 = icmp sge i32 %v0, %v1\n %cmp1 = icmp sge i32 %v1, %v2\n %cmp2 = icmp slt i32 %v0, %v2\n %and1 = and i1 %cmp2, %cmp1\n %and2 = and i1 %cmp0, %and1\n br i1 %and2, label %if.then, label %return\n\nif.then: ; preds = %entry\n call void @side_effect()\n br label %return\n\nreturn: ; preds = %if.then, %entry\n ret void\n}\n\ndeclare void @side_effect()\n"
49
+ },
50
+ {
51
+ "test_name": "test_second_and_condition_implied_by_first",
52
+ "test_body": "define i1 @test_second_and_condition_implied_by_first(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %t.1 = icmp ugt i8 %x, 5\n %and = and i1 %c.1, %t.1\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
53
+ },
54
+ {
55
+ "test_name": "test_or_used_in_false_branch2",
56
+ "test_body": "define i1 @test_or_used_in_false_branch2(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %t.1 = icmp ugt i8 %x, 5\n %and = or i1 %c.1, %t.1\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 %t.1\n\nelse: ; preds = %entry\n ret i1 %t.1\n}\n"
57
+ },
58
+ {
59
+ "test_name": "test_and_used_in_false_branch",
60
+ "test_body": "define i1 @test_and_used_in_false_branch(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %t.1 = icmp ugt i8 %x, 5\n %and = and i1 %c.1, %t.1\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 %t.1\n\nelse: ; preds = %entry\n ret i1 %t.1\n}\n"
61
+ },
62
+ {
63
+ "test_name": "and_tree_second_implies_first_perm2",
64
+ "test_body": "define void @and_tree_second_implies_first_perm2(i32 noundef %v0, i32 noundef %v1, i32 noundef %v2) {\nentry:\n %cmp0 = icmp sge i32 %v0, %v1\n %cmp1 = icmp sge i32 %v1, %v2\n %cmp2 = icmp slt i32 %v0, %v2\n %and1 = and i1 %cmp0, %cmp2\n %and2 = and i1 %cmp1, %and1\n br i1 %and2, label %if.then, label %return\n\nif.then: ; preds = %entry\n call void @side_effect()\n br label %return\n\nreturn: ; preds = %if.then, %entry\n ret void\n}\n\ndeclare void @side_effect()\n"
65
+ },
66
+ {
67
+ "test_name": "or_tree_second_implies_first_with_unknown_cond",
68
+ "test_body": "define void @or_tree_second_implies_first_with_unknown_cond(i64 %x, i1 %cond) {\nentry:\n %cmp1 = icmp ugt i64 %x, 1\n %or1 = select i1 %cmp1, i1 %cond, i1 false\n %cmp2 = icmp ult i64 %x, 2\n %or2 = select i1 %or1, i1 %cmp2, i1 false\n br i1 %or2, label %if.then, label %if.end\n\nif.then: ; preds = %entry\n call void @side_effect()\n br label %if.end\n\nif.end: ; preds = %if.then, %entry\n ret void\n}\n\ndeclare void @side_effect()\n"
69
+ },
70
+ {
71
+ "test_name": "test_or_used_in_false_branch",
72
+ "test_body": "define i1 @test_or_used_in_false_branch(i8 %x) {\nentry:\n %c.1 = icmp ule i8 %x, 10\n %t.1 = icmp ule i8 %x, 5\n %and = or i1 %c.1, %t.1\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 %t.1\n\nelse: ; preds = %entry\n ret i1 %t.1\n}\n"
73
+ },
74
+ {
75
+ "test_name": "or_tree_second_implies_first",
76
+ "test_body": "define void @or_tree_second_implies_first(i32 noundef %v0, i32 noundef %v1, i32 noundef %v2) {\nentry:\n %cmp0 = icmp sge i32 %v0, %v1\n %cmp1 = icmp sge i32 %v1, %v2\n %and1 = or i1 %cmp0, %cmp1\n %cmp2 = icmp slt i32 %v0, %v2\n %and2 = or i1 %cmp2, %and1\n br i1 %and2, label %if.then, label %return\n\nif.then: ; preds = %entry\n call void @side_effect()\n br label %return\n\nreturn: ; preds = %if.then, %entry\n ret void\n}\n\ndeclare void @side_effect()\n"
77
+ },
78
+ {
79
+ "test_name": "and_tree_second_implies_first",
80
+ "test_body": "define void @and_tree_second_implies_first(i32 noundef %v0, i32 noundef %v1, i32 noundef %v2) {\nentry:\n %cmp0 = icmp sge i32 %v0, %v1\n %cmp1 = icmp sge i32 %v1, %v2\n %and1 = and i1 %cmp0, %cmp1\n %cmp2 = icmp slt i32 %v0, %v2\n %and2 = and i1 %cmp2, %and1\n br i1 %and2, label %if.then, label %return\n\nif.then: ; preds = %entry\n call void @side_effect()\n br label %return\n\nreturn: ; preds = %if.then, %entry\n ret void\n}\n\ndeclare void @side_effect()\n"
81
+ },
82
+ {
83
+ "test_name": "and_select_first_implies_second_may_be_poison",
84
+ "test_body": "define i1 @and_select_first_implies_second_may_be_poison(ptr noundef %A, ptr noundef %B) {\nentry:\n %c.1 = icmp ne ptr %A, %B\n %gep = getelementptr inbounds ptr, ptr %B, i64 -1\n %c.2 = icmp ugt ptr %gep, %A\n %and = select i1 %c.2, i1 %c.1, i1 false\n ret i1 %and\n}\n"
85
+ },
86
+ {
87
+ "test_name": "test_second_and_condition_not_implied_by_first",
88
+ "test_body": "define i1 @test_second_and_condition_not_implied_by_first(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %c.2 = icmp ugt i8 %x, 5\n %and = and i1 %c.2, %c.1\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
89
+ },
90
+ {
91
+ "test_name": "test_same_cond_for_and",
92
+ "test_body": "define i1 @test_same_cond_for_and(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %and = and i1 %c.1, %c.1\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
93
+ },
94
+ {
95
+ "test_name": "test_second_and_condition_implied_by_first_select_form",
96
+ "test_body": "define i1 @test_second_and_condition_implied_by_first_select_form(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %t.1 = icmp ugt i8 %x, 5\n %and = select i1 %c.1, i1 %t.1, i1 false\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
97
+ },
98
+ {
99
+ "test_name": "test_first_and_condition_implied_by_second_ops",
100
+ "test_body": "define i1 @test_first_and_condition_implied_by_second_ops(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %t.1 = icmp ugt i8 %x, 5\n %and = and i1 %t.1, %c.1\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ "file": "llvm/test/Transforms/ConstraintElimination/eq.ll",
106
+ "commands": [
107
+ "opt -passes=constraint-elimination -S %s"
108
+ ],
109
+ "tests": [
110
+ {
111
+ "test_name": "test_eq_for_signed_cmp_with_decompsition",
112
+ "test_body": "define i1 @test_eq_for_signed_cmp_with_decompsition(i32 noundef %v0, i32 noundef %v1, i32 noundef %v2, i32 noundef %addend0, i32 noundef %addend1) {\nentry:\n %v0add = add nsw i32 %v0, %addend0\n %v1add = add nsw i32 %v1, %addend1\n %cmp = icmp eq i32 %v2, %v0add\n %cmp1 = icmp sge i32 %v0add, %v1add\n %cmp2 = icmp sge i32 %addend0, 0\n %cmp3 = icmp slt i32 %addend0, %addend1\n %and0 = and i1 %cmp1, %cmp\n %and1 = and i1 %and0, %cmp2\n %and2 = and i1 %and1, %cmp3\n %cmp4 = icmp sgt i32 %v1, %v2\n %and3 = and i1 %cmp4, %and2\n ret i1 %and3\n}\n"
113
+ },
114
+ {
115
+ "test_name": "test_eq_for_signed_cmp",
116
+ "test_body": "define i1 @test_eq_for_signed_cmp(i32 noundef %v0, i32 noundef %v1, i32 noundef %v2) {\nentry:\n %cmp = icmp eq i32 %v2, %v0\n %cmp1 = icmp sge i32 %v0, %v1\n %and0 = and i1 %cmp1, %cmp\n %cmp4 = icmp sgt i32 %v1, %v2\n %and1 = and i1 %cmp4, %and0\n ret i1 %and1\n}\n"
117
+ }
118
+ ]
119
+ },
120
+ {
121
+ "file": "llvm/test/Transforms/ConstraintElimination/gep-arithmetic-signed-predicates.ll",
122
+ "commands": [
123
+ "opt -passes=constraint-elimination -S %s"
124
+ ],
125
+ "tests": [
126
+ {
127
+ "test_name": "ptr_N_signed_positive_assume",
128
+ "test_body": "; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\ndefine i4 @ptr_N_signed_positive_assume(ptr %src, ptr %lower, ptr %upper, i16 %N, i16 %step) {\nentry:\n %src.end = getelementptr inbounds i8, ptr %src, i16 %N\n %cmp.src.start = icmp slt ptr %src, %lower\n %cmp.src.end = icmp sge ptr %src.end, %upper\n %N.neg = icmp slt i16 %N, 0\n call void @llvm.assume(i1 %N.neg)\n %or.precond.0 = or i1 %cmp.src.start, %cmp.src.end\n br i1 %or.precond.0, label %trap.bb, label %step.check\n\ntrap.bb: ; preds = %ptr.check, %entry\n ret i4 2\n\nstep.check: ; preds = %entry\n %step.pos = icmp sge i16 %step, 0\n %step.slt.N = icmp slt i16 %step, %N\n %and.step = and i1 %step.pos, %step.slt.N\n br i1 %and.step, label %ptr.check, label %exit\n\nptr.check: ; preds = %step.check\n %src.step = getelementptr inbounds i8, ptr %src, i16 %step\n %cmp.step.start = icmp slt ptr %src.step, %lower\n %cmp.step.end = icmp sge ptr %src.step, %upper\n %or.check = or i1 %cmp.step.start, %cmp.step.end\n br i1 %or.check, label %trap.bb, label %exit\n\nexit: ; preds = %ptr.check, %step.check\n ret i4 3\n}\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n"
129
+ }
130
+ ]
131
+ },
132
+ {
133
+ "file": "llvm/test/Transforms/ConstraintElimination/geps-precondition-overflow-check.ll",
134
+ "commands": [
135
+ "opt -passes=constraint-elimination -S %s"
136
+ ],
137
+ "tests": [
138
+ {
139
+ "test_name": "overflow_check_4_and",
140
+ "test_body": "define i1 @overflow_check_4_and(ptr %dst) {\nentry:\n %dst.5 = getelementptr i32, ptr %dst, i64 5\n %dst.5.uge = icmp uge ptr %dst.5, %dst\n %and = and i1 %dst.5.uge, %dst.5.uge\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n %dst.4 = getelementptr i32, ptr %dst, i64 4\n %true.dst.4.uge = icmp uge ptr %dst.4, %dst\n %dst.5.2 = getelementptr i32, ptr %dst, i64 5\n %true.dst.5.uge = icmp uge ptr %dst.5.2, %dst\n %res.0 = xor i1 %true.dst.4.uge, %true.dst.5.uge\n %dst.6 = getelementptr i32, ptr %dst, i64 6\n %c.dst.6.uge = icmp uge ptr %dst.6, %dst\n %res.1 = xor i1 %res.0, %c.dst.6.uge\n ret i1 %res.1\n\nelse: ; preds = %entry\n %else.dst.4 = getelementptr i32, ptr %dst, i64 4\n %else.dst.4.uge = icmp uge ptr %else.dst.4, %dst\n %else.dst.6 = getelementptr i32, ptr %dst, i64 6\n %else.dst.6.uge = icmp uge ptr %else.dst.6, %dst\n %else.res.0 = xor i1 %else.dst.4.uge, %else.dst.6.uge\n ret i1 %else.res.0\n}\n"
141
+ },
142
+ {
143
+ "test_name": "overflow_check_3_or",
144
+ "test_body": "define i1 @overflow_check_3_or(ptr %dst) {\nentry:\n %dst.5 = getelementptr i32, ptr %dst, i64 5\n %dst.5.uge = icmp uge ptr %dst.5, %dst\n %or = or i1 %dst.5.uge, %dst.5.uge\n br i1 %or, label %then, label %else\n\nthen: ; preds = %entry\n %dst.4 = getelementptr i32, ptr %dst, i64 4\n %true.dst.4.uge = icmp uge ptr %dst.4, %dst\n ret i1 %true.dst.4.uge\n\nelse: ; preds = %entry\n ret i1 false\n}\n"
145
+ },
146
+ {
147
+ "test_name": "overflow_check_3_and",
148
+ "test_body": "define i1 @overflow_check_3_and(ptr %dst) {\nentry:\n %dst.5 = getelementptr i32, ptr %dst, i64 5\n %dst.5.uge = icmp uge ptr %dst.5, %dst\n %and = and i1 %dst.5.uge, %dst.5.uge\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n %dst.4 = getelementptr i32, ptr %dst, i64 4\n %dst.4.uge = icmp uge ptr %dst.4, %dst\n ret i1 %dst.4.uge\n\nelse: ; preds = %entry\n %else.dst.4 = getelementptr i32, ptr %dst, i64 4\n %else.dst.4.uge = icmp uge ptr %else.dst.4, %dst\n ret i1 %else.dst.4.uge\n}\n"
149
+ },
150
+ {
151
+ "test_name": "overflow_check_2_and",
152
+ "test_body": "define i1 @overflow_check_2_and(ptr %dst) {\nentry:\n %dst.5 = getelementptr i32, ptr %dst, i64 5\n %dst.5.uge = icmp uge ptr %dst.5, %dst\n %and = and i1 %dst.5.uge, %dst.5.uge\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n %dst.4 = getelementptr i32, ptr %dst, i64 4\n %true.dst.4.uge = icmp uge ptr %dst.4, %dst\n ret i1 %true.dst.4.uge\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
153
+ }
154
+ ]
155
+ },
156
+ {
157
+ "file": "llvm/test/Transforms/ConstraintElimination/loops-bottom-tested-pointer-cmps.ll",
158
+ "commands": [
159
+ "opt -passes=constraint-elimination -S %s"
160
+ ],
161
+ "tests": [
162
+ {
163
+ "test_name": "checks_in_loops_removable",
164
+ "test_body": "define void @checks_in_loops_removable(ptr %ptr, ptr %lower, ptr %upper, i8 %n) {\nentry:\n %cmp.ptr.lower = icmp ult ptr %ptr, %lower\n br i1 %cmp.ptr.lower, label %trap, label %pre.1\n\npre.1: ; preds = %entry\n %idx.ext = zext i8 %n to i16\n %ptr.n = getelementptr inbounds i8, ptr %ptr, i16 %idx.ext\n %cmp.ptr.n.upper = icmp ult ptr %ptr.n, %upper\n br i1 %cmp.ptr.n.upper, label %pre.2, label %trap\n\npre.2: ; preds = %pre.1\n %cmp.n.not.zero = icmp eq i8 %n, 0\n br i1 %cmp.n.not.zero, label %exit, label %loop.header\n\ntrap: ; preds = %loop.header, %pre.1, %entry\n ret void\n\nloop.header: ; preds = %loop.latch, %pre.2\n %iv = phi i16 [ 0, %pre.2 ], [ %iv.next, %loop.latch ]\n %ptr.iv = getelementptr inbounds i8, ptr %ptr, i16 %iv\n %cmp.ptr.iv.lower = icmp ugt ptr %lower, %ptr.iv\n %cmp.ptr.iv.upper = icmp ule ptr %upper, %ptr.iv\n %or = or i1 %cmp.ptr.iv.lower, %cmp.ptr.iv.upper\n br i1 %or, label %trap, label %loop.latch\n\nloop.latch: ; preds = %loop.header\n store i8 0, ptr %ptr.iv, align 4\n %iv.next = add nuw nsw i16 %iv, 1\n %exitcond = icmp ne i16 %iv.next, %idx.ext\n br i1 %exitcond, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch, %pre.2\n ret void\n}\n"
165
+ },
166
+ {
167
+ "test_name": "some_checks_in_loops_removable",
168
+ "test_body": "define void @some_checks_in_loops_removable(ptr %ptr, ptr %lower, ptr %upper, i8 %n) {\nentry:\n %cmp.ptr.lower = icmp ult ptr %ptr, %lower\n br i1 %cmp.ptr.lower, label %trap, label %pre.1\n\npre.1: ; preds = %entry\n %idx.ext = zext i8 %n to i16\n %ptr.n = getelementptr inbounds i8, ptr %ptr, i16 %idx.ext\n %cmp.ptr.n.upper = icmp ult ptr %ptr.n, %upper\n br i1 %cmp.ptr.n.upper, label %pre.2, label %trap\n\npre.2: ; preds = %pre.1\n %cmp.n.not.zero = icmp eq i8 %n, 0\n br i1 %cmp.n.not.zero, label %exit, label %loop.header\n\ntrap: ; preds = %loop.body, %loop.header, %pre.1, %entry\n ret void\n\nloop.header: ; preds = %loop.latch, %pre.2\n %iv = phi i16 [ 0, %pre.2 ], [ %iv.next, %loop.latch ]\n %ptr.iv = getelementptr inbounds i8, ptr %ptr, i16 %iv\n %cmp.ptr.iv.lower = icmp ugt ptr %lower, %ptr.iv\n %cmp.ptr.iv.upper = icmp ule ptr %upper, %ptr.iv\n %or = or i1 %cmp.ptr.iv.lower, %cmp.ptr.iv.upper\n br i1 %or, label %trap, label %loop.body\n\nloop.body: ; preds = %loop.header\n %iv.1 = add nuw nsw i16 %iv, 1\n %ptr.iv.1 = getelementptr inbounds i8, ptr %ptr, i16 %iv.1\n %cmp.ptr.iv.1.lower = icmp ugt ptr %lower, %ptr.iv.1\n %cmp.ptr.iv.1.upper = icmp ule ptr %upper, %ptr.iv.1\n %or.1 = or i1 %cmp.ptr.iv.1.lower, %cmp.ptr.iv.1.upper\n br i1 %or, label %trap, label %loop.latch\n\nloop.latch: ; preds = %loop.body\n store i8 0, ptr %ptr.iv, align 4\n %iv.next = add nuw nsw i16 %iv, 1\n %exitcond = icmp ne i16 %iv.next, %idx.ext\n br i1 %exitcond, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch, %pre.2\n ret void\n}\n"
169
+ },
170
+ {
171
+ "test_name": "no_checks_in_loops_removable",
172
+ "test_body": "define void @no_checks_in_loops_removable(ptr %ptr, ptr %lower, ptr %upper, i8 %n) {\nentry:\n %cmp.ptr.lower = icmp ult ptr %ptr, %lower\n br i1 %cmp.ptr.lower, label %trap, label %pre.1\n\npre.1: ; preds = %entry\n %idx.ext = zext i8 %n to i16\n %ptr.n = getelementptr inbounds i8, ptr %ptr, i16 %idx.ext\n %cmp.ptr.n.upper = icmp ult ptr %ptr.n, %upper\n br i1 %cmp.ptr.n.upper, label %loop.header, label %trap\n\ntrap: ; preds = %loop.body, %loop.header, %pre.1, %entry\n ret void\n\nloop.header: ; preds = %loop.latch, %pre.1\n %iv = phi i16 [ 0, %pre.1 ], [ %iv.next, %loop.latch ]\n %ptr.iv = getelementptr inbounds i8, ptr %ptr, i16 %iv\n %cmp.ptr.iv.lower = icmp ugt ptr %lower, %ptr.iv\n %cmp.ptr.iv.upper = icmp ule ptr %upper, %ptr.iv\n %or = or i1 %cmp.ptr.iv.lower, %cmp.ptr.iv.upper\n br i1 %or, label %trap, label %loop.body\n\nloop.body: ; preds = %loop.header\n %iv.1 = add nuw nsw i16 %iv, 1\n %ptr.iv.1 = getelementptr inbounds i8, ptr %ptr, i16 %iv.1\n %cmp.ptr.iv.1.lower = icmp ugt ptr %lower, %ptr.iv.1\n %cmp.ptr.iv.1.upper = icmp ule ptr %upper, %ptr.iv.1\n %or.1 = or i1 %cmp.ptr.iv.1.lower, %cmp.ptr.iv.1.upper\n br i1 %or, label %trap, label %loop.latch\n\nloop.latch: ; preds = %loop.body\n store i8 0, ptr %ptr.iv, align 4\n %iv.next = add nuw nsw i16 %iv, 1\n %exitcond = icmp ne i16 %iv.next, %idx.ext\n br i1 %exitcond, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n"
173
+ }
174
+ ]
175
+ },
176
+ {
177
+ "file": "llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll",
178
+ "commands": [
179
+ "opt -passes=constraint-elimination -S %s"
180
+ ],
181
+ "tests": [
182
+ {
183
+ "test_name": "test3",
184
+ "test_body": "define void @test3(ptr %src, ptr %lower, ptr %upper, i8 %N) {\nentry:\n %src.end = getelementptr inbounds i8, ptr %src, i8 %N\n %cmp.src.start = icmp ult ptr %src, %lower\n %cmp.src.end = icmp uge ptr %src.end, %upper\n %cmp.overflow = icmp ugt ptr %src, %src.end\n %or.0 = or i1 %cmp.src.start, %cmp.src.end\n %or.11 = or i1 %or.0, %cmp.overflow\n br i1 %or.11, label %trap.bb, label %loop.header\n\ntrap.bb: ; preds = %loop.body.2, %loop.body.1, %loop.body, %entry\n ret void\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i8 [ %iv.next, %loop.latch ], [ 1, %entry ]\n %next = or i8 %iv, 1\n %ec = icmp ult i8 %next, %N\n br i1 %ec, label %loop.body, label %exit\n\nloop.body: ; preds = %loop.header\n %src.iv = getelementptr inbounds i8, ptr %src, i8 %iv\n %cmp.iv.start = icmp ult ptr %src.iv, %lower\n %cmp.iv.end = icmp uge ptr %src.iv, %upper\n %or.1 = or i1 %cmp.iv.start, %cmp.iv.end\n br i1 %or.1, label %trap.bb, label %loop.body.1\n\nloop.body.1: ; preds = %loop.body\n %src.iv.1 = getelementptr inbounds i8, ptr %src, i8 %next\n %cmp.iv.1.start = icmp ult ptr %src.iv.1, %lower\n %cmp.iv.1.end = icmp uge ptr %src.iv.1, %upper\n %or.2 = or i1 %cmp.iv.1.start, %cmp.iv.1.end\n br i1 %or.2, label %trap.bb, label %loop.body.2\n\nloop.body.2: ; preds = %loop.body.1\n %add.2 = add nuw nsw i8 %iv, 2\n %src.iv.2 = getelementptr inbounds i8, ptr %src, i8 %add.2\n %cmp.iv.2.start = icmp ult ptr %src.iv.2, %lower\n %cmp.iv.2.end = icmp uge ptr %src.iv.2, %upper\n %or.3 = or i1 %cmp.iv.2.start, %cmp.iv.2.end\n br i1 %or.3, label %trap.bb, label %loop.latch\n\nloop.latch: ; preds = %loop.body.2\n %ptr = bitcast ptr %src.iv to ptr\n store i32 0, ptr %ptr, align 4\n %iv.next = add nuw nsw i8 %iv, 1\n br label %loop.header\n\nexit: ; preds = %loop.header\n ret void\n}\n"
185
+ },
186
+ {
187
+ "test_name": "test2_with_ne",
188
+ "test_body": "define void @test2_with_ne(ptr %src, ptr %lower, ptr %upper, i8 %N) {\nentry:\n %src.end = getelementptr inbounds i8, ptr %src, i8 %N\n %cmp.src.start = icmp ult ptr %src, %lower\n %cmp.src.end = icmp uge ptr %src.end, %upper\n %cmp.overflow = icmp ugt ptr %src, %src.end\n %or.0 = or i1 %cmp.src.start, %cmp.src.end\n %or.11 = or i1 %or.0, %cmp.overflow\n br i1 %or.11, label %trap.bb, label %loop.header\n\ntrap.bb: ; preds = %loop.body.2, %loop.body.1, %loop.body, %entry\n ret void\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i8 [ %iv.next, %loop.latch ], [ 1, %entry ]\n %next = add nuw nsw i8 %iv, 1\n %ec = icmp eq i8 %next, %N\n br i1 %ec, label %exit, label %loop.body\n\nloop.body: ; preds = %loop.header\n %src.iv = getelementptr inbounds i8, ptr %src, i8 %iv\n %cmp.iv.start = icmp ult ptr %src.iv, %lower\n %cmp.iv.end = icmp uge ptr %src.iv, %upper\n %or.1 = or i1 %cmp.iv.start, %cmp.iv.end\n br i1 %or.1, label %trap.bb, label %loop.body.1\n\nloop.body.1: ; preds = %loop.body\n %add.1 = add nuw nsw i8 %iv, 1\n %src.iv.1 = getelementptr inbounds i8, ptr %src, i8 %add.1\n %cmp.iv.1.start = icmp ult ptr %src.iv.1, %lower\n %cmp.iv.1.end = icmp uge ptr %src.iv.1, %upper\n %or.2 = or i1 %cmp.iv.1.start, %cmp.iv.1.end\n br i1 %or.2, label %trap.bb, label %loop.body.2\n\nloop.body.2: ; preds = %loop.body.1\n %add.2 = add nuw nsw i8 %iv, 2\n %src.iv.2 = getelementptr inbounds i8, ptr %src, i8 %add.2\n %cmp.iv.2.start = icmp ult ptr %src.iv.2, %lower\n %cmp.iv.2.end = icmp uge ptr %src.iv.2, %upper\n %or.3 = or i1 %cmp.iv.2.start, %cmp.iv.2.end\n br i1 %or.3, label %trap.bb, label %loop.latch\n\nloop.latch: ; preds = %loop.body.2\n %ptr = bitcast ptr %src.iv to ptr\n store i32 0, ptr %ptr, align 4\n %iv.next = add nuw nsw i8 %iv, 1\n br label %loop.header\n\nexit: ; preds = %loop.header\n ret void\n}\n"
189
+ }
190
+ ]
191
+ },
192
+ {
193
+ "file": "llvm/test/Transforms/ConstraintElimination/or-implied-by-operands.ll",
194
+ "commands": [
195
+ "opt -passes=constraint-elimination -S %s"
196
+ ],
197
+ "tests": [
198
+ {
199
+ "test_name": "test_or_used_in_false_branch2",
200
+ "test_body": "define i1 @test_or_used_in_false_branch2(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %t.1 = icmp ugt i8 %x, 5\n %or = or i1 %c.1, %t.1\n br i1 %or, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 %t.1\n\nelse: ; preds = %entry\n ret i1 %t.1\n}\n"
201
+ },
202
+ {
203
+ "test_name": "test_same_cond_for_or",
204
+ "test_body": "define i1 @test_same_cond_for_or(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %or = or i1 %c.1, %c.1\n br i1 %or, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
205
+ },
206
+ {
207
+ "test_name": "test_or_disjoint_set_operand",
208
+ "test_body": "define i1 @test_or_disjoint_set_operand(i8 %x) {\nentry:\n %cmp1 = icmp slt i8 %x, 1\n %cmp2 = icmp ne i8 %x, 0\n %or = or disjoint i1 %cmp2, %cmp1\n ret i1 %or\n}\n"
209
+ },
210
+ {
211
+ "test_name": "test_or_used_in_false_branch",
212
+ "test_body": "define i1 @test_or_used_in_false_branch(i8 %x) {\nentry:\n %c.1 = icmp ule i8 %x, 10\n %t.1 = icmp ule i8 %x, 5\n %or = or i1 %c.1, %t.1\n br i1 %or, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 %t.1\n\nelse: ; preds = %entry\n ret i1 %t.1\n}\n"
213
+ },
214
+ {
215
+ "test_name": "test_first_or_condition_implied_by_second_ops",
216
+ "test_body": "define i1 @test_first_or_condition_implied_by_second_ops(i8 %x) {\nentry:\n %c.1 = icmp ule i8 %x, 10\n %t.1 = icmp ugt i8 %x, 5\n %or = or i1 %t.1, %c.1\n br i1 %or, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
217
+ },
218
+ {
219
+ "test_name": "test_second_or_condition_implied_by_first",
220
+ "test_body": "define i1 @test_second_or_condition_implied_by_first(i8 %x) {\nentry:\n %c.1 = icmp ule i8 %x, 10\n %t.1 = icmp ugt i8 %x, 5\n %or = or i1 %c.1, %t.1\n br i1 %or, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
221
+ },
222
+ {
223
+ "test_name": "test_second_or_condition_not_implied_by_first",
224
+ "test_body": "define i1 @test_second_or_condition_not_implied_by_first(i8 %x) {\nentry:\n %c.1 = icmp ugt i8 %x, 10\n %c.2 = icmp ugt i8 %x, 5\n %or = or i1 %c.2, %c.1\n br i1 %or, label %then, label %else\n\nthen: ; preds = %entry\n ret i1 false\n\nelse: ; preds = %entry\n ret i1 true\n}\n"
225
+ }
226
+ ]
227
+ },
228
+ {
229
+ "file": "llvm/test/Transforms/ConstraintElimination/or.ll",
230
+ "commands": [
231
+ "opt -passes=constraint-elimination -S %s"
232
+ ],
233
+ "tests": [
234
+ {
235
+ "test_name": "test_or_chain_ule_1",
236
+ "test_body": "define i1 @test_or_chain_ule_1(i4 %x, i4 %y, i4 %z, i4 %a, i4 %b) {\nentry:\n %c.1 = icmp ule i4 %x, %y\n %c.2 = icmp ule i4 %y, %z\n %c.3 = icmp ule i4 2, %x\n %c.4 = icmp ule i4 2, %a\n %or.1 = or i1 %c.1, %c.2\n %or.2 = or i1 %or.1, %c.3\n %or.3 = or i1 %c.4, %or.2\n br i1 %or.3, label %bb1, label %exit\n\nbb1: ; preds = %entry\n %c.5 = icmp ule i4 %x, %z\n %c.6 = icmp ule i4 %x, %a\n %res.1 = xor i1 %c.5, %c.6\n %c.7 = icmp ule i4 2, %x\n %res.2 = xor i1 %res.1, %c.7\n ret i1 %res.2\n\nexit: ; preds = %entry\n %f.1 = icmp ule i4 %x, %z\n %f.2 = icmp ule i4 2, %x\n %res.3 = xor i1 %f.1, %f.2\n %t.1 = icmp ugt i4 %y, %z\n %res.4 = xor i1 %res.3, %t.1\n %t.2 = icmp ugt i4 %x, %y\n %res.5 = xor i1 %res.4, %t.2\n %t.3 = icmp ugt i4 %x, %z\n %res.6 = xor i1 %res.5, %t.3\n %t.4 = icmp ugt i4 2, %a\n %res.7 = xor i1 %res.6, %t.4\n %c.8 = icmp ule i4 %x, %a\n %res.8 = xor i1 %res.7, %c.8\n %c.9 = icmp ule i4 %x, %b\n %res.9 = xor i1 %res.8, %c.9\n ret i1 %res.9\n}\n"
237
+ }
238
+ ]
239
+ }
240
+ ],
241
+ "issue": {
242
+ "title": "[ConstraintElim] `checkOrAndOpImpliedByOther` should drop `disjoint` flag",
243
+ "body": "Reproducer: https://alive2.llvm.org/ce/z/pUvC88\n```\n----------------------------------------\ndefine i1 @src(i8 %b) {\nentry:\n %c.1 = icmp slt i8 %b, 1\n %c.2 = icmp ne i8 %b, 0\n %or = or disjoint i1 %c.2, %c.1\n ret i1 %or\n}\n=>\ndefine i1 @src(i8 %b) {\nentry:\n %c.2 = icmp ne i8 %b, 0\n %or = or disjoint i1 %c.2, 1\n ret i1 %or\n}\nTransformation doesn't verify!\n\nERROR: Target is more poisonous than source\n\nExample:\ni8 %b = #x01 (1)\n\nSource:\ni1 %c.1 = #x0 (0)\ni1 %c.2 = #x1 (1)\ni1 %or = #x1 (1)\n\nTarget:\ni1 %c.2 = #x1 (1)\ni1 %or = poison\nSource value: #x1 (1)\nTarget value: poison\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```\nTriggered by pre-commit fuzzing for https://github.com/llvm/llvm-project/pull/135784.\n",
244
+ "author": "dtcxzyw",
245
+ "labels": [
246
+ "miscompilation",
247
+ "llvm:transforms"
248
+ ],
249
+ "comments": []
250
+ },
251
+ "verified": true
252
+ }
dataset/138345.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "138345",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/138345",
4
+ "bug_type": "crash",
5
+ "base_commit": "1c1238d3615a7e1a99570d1e02de3b538d2e0669",
6
+ "knowledge_cutoff": "2025-05-02T21:00:30Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/GVNSink"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "43eafc0c4aca0b2fd159c09d4b162c1941b4f4ed",
12
+ "components": [
13
+ "Local"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Utils/Local.cpp": [
17
+ [
18
+ 4225,
19
+ 4232
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Utils/Local.cpp": [
25
+ "llvm::canReplaceOperandWithVariable"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 43eafc0c4aca0b2fd159c09d4b162c1941b4f4ed\nAuthor: Paul Kirth <[email protected]>\nDate: Mon May 5 18:16:33 2025 -0700\n\n [llvm][gvn-sink] Don't try to sink inline asm (#138414)\n \n Fixes #138345. Before this patch, gvn-sink would try to sink inline\n assembly statements. Other GVN passes avoid them (see\n https://github.com/llvm/llvm-project/blob/b4fac94181c4cf17dbb7ecc2ae975712b0e4a6d1/llvm/lib/Transforms/Scalar/GVN.cpp#L2932\n Similarly, gvn-sink should skip these instructions, since they are not\n safe to move. To do this, we update the early exit in\n canReplaceOperandWithVariable, since it should have caught this case.\n It's more efficient to also skip numbering in GVNSink if the instruction\n is InlineAsm, but that should be infrequent.\n \n The test added is reduced from a failure when compiling Fuchsia with\n gvn-sink.\n\ndiff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp\nindex 809a0d7ebeea..ce03bc066c6e 100644\n--- a/llvm/lib/Transforms/Utils/Local.cpp\n+++ b/llvm/lib/Transforms/Utils/Local.cpp\n@@ -4225,8 +4225,9 @@ bool llvm::canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx) {\n return false;\n \n // Early exit.\n- if (!isa<Constant>(I->getOperand(OpIdx)))\n+ if (!isa<Constant, InlineAsm>(I->getOperand(OpIdx))) {\n return true;\n+ }\n \n switch (I->getOpcode()) {\n default:\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/GVNSink/pr138345.ll",
33
+ "commands": [
34
+ "opt -passes=\"gvn-sink\" -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\n;; See https://github.com/llvm/llvm-project/issues/138345 for details.\n;; The program below used to crash due to taking the address of the inline asm.\n;; gvn-sink shouldn't do anything in this case, so test that the pass no longer\n;; generates invalid IR and no longer crashes.\n\ndefine void @c(i64 %num, ptr %ptr) {\n;\nentry:\n switch i64 %num, label %sw.epilog [\n i64 1, label %sw.bb\n i64 0, label %sw.bb1\n ]\n\nsw.bb: ; preds = %entry\n %1 = load i8, ptr %ptr, align 1\n call void asm sideeffect \"\", \"r,r,~{dirflag},~{fpsr},~{flags}\"(i8 %1, ptr @c)\n br label %sw.epilog\n\nsw.bb1: ; preds = %entry\n %2 = load i8, ptr %ptr, align 1\n call void asm sideeffect \"movdqu 0 %xmm0 \\0A\\09\", \"r,r,~{dirflag},~{fpsr},~{flags}\"(i8 %2, ptr @c)\n br label %sw.epilog\n\nsw.epilog: ; preds = %sw.bb1, %sw.bb, %entry\n ret void\n}"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "Assertion failure with gvn-sink",
46
+ "body": "I tried to enable GVN hoist/sink when compiling Fuchsia at -Oz, since that should improve size slightly, and ran into this. I know those passes have had some issues, but I figured they had some attention a while back and we should try again. Probably some value as a regression test, if nothing else.\n\nAssertion:\n```console\n'llvm/lib/Analysis/LazyValueInfo.cpp:679: std::optional<ValueLatticeElement> llvm::LazyValueInfoImpl::solveBlockValueNonLocal(Value *, BasicBlock *): Assertion `isa<Argument>(Val) && \"Unknown live-in to the entry block\"' failed.\n```\n\nHere's a reduced test case where the assertion triggers.\n\n```LLVM\n; RUN: opt -passes=\"gvn-sink,correlated-propagation\" -disable-output %s\n\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @c(i64 %0) {\nentry:\n switch i64 %0, label %sw.epilog [\n i64 1, label %sw.bb\n i64 0, label %sw.bb1\n ]\n\nsw.bb: ; preds = %entry\n %1 = load i8, ptr null, align 1\n call void asm sideeffect \"\", \"r,r,~{dirflag},~{fpsr},~{flags}\"(i8 %1, ptr @c)\n br label %sw.epilog\n\nsw.bb1: ; preds = %entry\n %2 = load i8, ptr null, align 1\n call void asm sideeffect \"movdqu 0 %xmm0 \\0A\\09\", \"r,r,~{dirflag},~{fpsr},~{flags}\"(i8 %2, ptr @c)\n br label %sw.epilog\n\nsw.epilog: ; preds = %sw.bb1, %sw.bb, %entry\n ret void\n}\n```\n\nFrom Clang:\n\n```c++\n// RUN: clang -cc1 -Os -mllvm -enable-gvn-hoist -mllvm -enable-gvn-sink -mllvm -wholeprogramdevirt-branch-funnel-threshold=0 -emit-llvm %s\nlong a;\nchar b;\nvoid c() {\n switch (a) {\n case 8:\n __asm(\"\" : : \"r\"(b), \"r\"(c));\n break;\n case 6:\n __asm(\"movdqu 0 %%xmm0 \\n\\t\" : : \"r\"(b), \"r\"(c));\n }\n}\n```",
47
+ "author": "ilovepi",
48
+ "labels": [
49
+ "crash-on-valid",
50
+ "llvm:GVN"
51
+ ],
52
+ "comments": []
53
+ },
54
+ "verified": true
55
+ }
dataset/140442.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "140442",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/140442",
4
+ "bug_type": "crash",
5
+ "base_commit": "b18ebd17b82db0bdf5bb8cae59c3208288fbef93",
6
+ "knowledge_cutoff": "2025-05-18T08:07:12Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopUnroll"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "7e14161f49b32387988cf9d937bbfaa27d0fbdd5",
12
+ "components": [
13
+ "LoopPeel"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Utils/LoopPeel.cpp": [
17
+ [
18
+ 1214,
19
+ 1220
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Utils/LoopPeel.cpp": [
25
+ "llvm::peelLoop"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 7e14161f49b32387988cf9d937bbfaa27d0fbdd5\nAuthor: Florian Hahn <[email protected]>\nDate: Sun May 18 10:17:20 2025 +0100\n\n [LoopPeel] Handle constants when updating exit values when peeling last.\n \n Account for constant values when updating exit values after peeling an\n iteration from the end. This can happen if the inner loop gets unrolled\n and simplified.\n \n Fixes https://github.com/llvm/llvm-project/issues/140442.\n\ndiff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp\nindex c5c637ab6e20..646354bba9df 100644\n--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp\n+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp\n@@ -1214,7 +1214,7 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,\n // Now adjust users of the original exit values by replacing them with the\n // exit value from the peeled iteration.\n for (const auto &[P, E] : ExitValues)\n- P->replaceAllUsesWith(VMap.lookup(E));\n+ P->replaceAllUsesWith(isa<Constant>(E) ? E : &*VMap.lookup(E));\n formLCSSA(*L, DT, LI, SE);\n } else {\n // Now adjust the phi nodes in the loop header to get their initial values\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopUnroll/unroll-and-peel-last-iteration.ll",
33
+ "commands": [
34
+ "opt -p loop-unroll -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\n; Test case for https://github.com/llvm/llvm-project/issues/140442.\ndefine i32 @peel_last_iter_of_outer_lcssa_phi_with_constant_after_unrolling_inner() {\n;\nentry:\n br label %outer.header\n\nouter.header:\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %outer.latch ]\n %0 = icmp eq i16 %iv, 999\n br label %inner.header\n\ninner.header:\n %inner.iv = phi i32 [ 0, %outer.header ], [ %inner.iv.next, %inner.latch ]\n %1 = add i32 %inner.iv, 1\n br i1 %0, label %then, label %inner.latch\n\nthen:\n call void @foo(i32 %inner.iv)\n br label %inner.latch\n\ninner.latch:\n %inner.iv.next = add i32 %inner.iv, 1\n %inner.ec = icmp eq i32 %inner.iv.next, 1\n br i1 %inner.ec, label %outer.latch, label %inner.header\n\nouter.latch:\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 1000\n br i1 %ec, label %exit, label %outer.header\n\nexit:\n ret i32 %1\n}\n\ndeclare void @foo(i32)\n;.\n;."
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[LoopUnroll] Assertion `New && \"Value::replaceAllUsesWith(<null>) is invalid!\"' failed.",
46
+ "body": "Reproducer: https://godbolt.org/z/ahxqn68Mn\n```\n; bin/opt -passes=\"loop-unroll<O3>\" reduced.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond52.preheader.i.i\n\nfor.cond52.preheader.i.i: ; preds = %for.end213.i.i, %entry\n %p_158.addr.0380.i.i1 = phi i16 [ 0, %entry ], [ %inc215.i.i, %for.end213.i.i ]\n %0 = icmp eq i16 %p_158.addr.0380.i.i1, -1\n br label %for.body136.i.i\n\nfor.body136.i.i: ; preds = %for.end54.preheader.peel.i.i.i, %for.cond52.preheader.i.i\n %1 = add i32 0, 0\n br i1 %0, label %for.end54.preheader.peel.i.i.i, label %for.end54.preheader.peel.i.i.i\n\nfor.end54.preheader.peel.i.i.i: ; preds = %for.body136.i.i, %for.body136.i.i\n br i1 true, label %for.end213.i.i, label %for.body136.i.i\n\nfor.end213.i.i: ; preds = %for.end54.preheader.peel.i.i.i\n %inc215.i.i = add i16 %p_158.addr.0380.i.i1, 1\n %exitcond387.not.i.i = icmp eq i16 %inc215.i.i, 0\n br i1 %exitcond387.not.i.i, label %for.end141.peel.i.i, label %for.cond52.preheader.i.i\n\nfor.end141.peel.i.i: ; preds = %for.end213.i.i\n ret i32 %1\n}\n```\n```\nopt: /root/llvm-project/llvm/lib/IR/Value.cpp:516: void llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses): Assertion `New && \"Value::replaceAllUsesWith(<null>) is invalid!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-unroll<O3> <source>\n1.\tRunning pass \"function(loop-unroll<O3>)\" on module \"<source>\"\n2.\tRunning pass \"loop-unroll<O3>\" on function \"main\"\n #0 0x00000000055c5a48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55c5a48)\n #1 0x00000000055c33d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000078c7a1842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000078c7a18969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000078c7a1842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000078c7a18287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000078c7a182871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000078c7a1839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000053f248a (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53f248a)\n #9 0x0000000004830404 llvm::peelLoop(llvm::Loop*, unsigned int, bool, llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::DominatorTree&, llvm::AssumptionCache*, bool, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4830404)\n#10 0x0000000004424eb9 tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&, llvm::LoopInfo*, llvm::ScalarEvolution&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, bool, int, bool, bool, bool, std::optional<unsigned int>, std::optional<unsigned int>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<unsigned int>, llvm::AAResults*) LoopUnrollPass.cpp:0:0\n#11 0x0000000004427b27 llvm::LoopUnrollPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4427b27)\n#12 0x0000000002d6a54e llvm::detail::PassModel<llvm::Function, llvm::LoopUnrollPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2d6a54e)\n#13 0x00000000053bcd00 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bcd00)\n#14 0x0000000000e8bbee llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe8bbee)\n#15 0x00000000053bd213 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bd213)\n#16 0x0000000000e8aa3e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe8aa3e)\n#17 0x00000000053bae30 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bae30)\n#18 0x000000000094c2aa llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94c2aa)\n#19 0x000000000093fa7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93fa7c)\n#20 0x000078c7a1829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#21 0x000078c7a1829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#22 0x0000000000937695 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x937695)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\nllvm version: 3ccb15d6caf57f2a866d496ada2fb52d14b179d2",
47
+ "author": "dtcxzyw",
48
+ "labels": [
49
+ "crash-on-valid",
50
+ "llvm:transforms",
51
+ "generated by fuzzer"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "fhahn",
56
+ "body": "Probably related to 3fcfce4c5e5fd1c3072e8db1d692c93459e8cd74, taking a look"
57
+ }
58
+ ]
59
+ },
60
+ "verified": true
61
+ }
dataset/140444.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "140444",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/140444",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "0b553e055ad01ca6a2c88f7da92157df29e42fd0",
6
+ "knowledge_cutoff": "2025-05-18T09:13:07Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopUnroll"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "a0a2a1e095ddd092e668b0b3f9a7dfa9655255e1",
12
+ "components": [
13
+ "LoopPeel"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Utils/LoopPeel.cpp": [
17
+ [
18
+ 343,
19
+ 354
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Utils/LoopPeel.cpp": [
25
+ "llvm::canPeelLastIteration"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit a0a2a1e095ddd092e668b0b3f9a7dfa9655255e1\nAuthor: Florian Hahn <[email protected]>\nDate: Sun May 18 11:47:03 2025 +0100\n\n [LoopPeel] Make sure exit condition has a single use when peeling last.\n \n Update the check in canPeelLastIteration to make sure the exiting\n condition has a single use. When peeling the last iteration, we adjust\n the condition in the loop body to be true one iteration early, which\n would be incorrect for other users.\n \n Fixes https://github.com/llvm/llvm-project/issues/140444.\n\ndiff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp\nindex 646354bba9df..4eaa3c971437 100644\n--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp\n+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp\n@@ -343,12 +343,12 @@ bool llvm::canPeelLastIteration(const Loop &L, ScalarEvolution &SE) {\n // codegen. For now, it must\n // * exit via the latch,\n // * the exit condition must be a NE/EQ compare of an induction with step\n- // of 1.\n+ // of 1 and must only be used by the exiting branch.\n BasicBlock *Latch = L.getLoopLatch();\n return Latch && Latch == L.getExitingBlock() &&\n match(Latch->getTerminator(),\n- m_Br(m_ICmp(Pred, m_Value(Inc), m_Value()), m_BasicBlock(Succ1),\n- m_BasicBlock(Succ2))) &&\n+ m_Br(m_OneUse(m_ICmp(Pred, m_Value(Inc), m_Value())),\n+ m_BasicBlock(Succ1), m_BasicBlock(Succ2))) &&\n ((Pred == CmpInst::ICMP_EQ && Succ2 == L.getHeader()) ||\n (Pred == CmpInst::ICMP_NE && Succ1 == L.getHeader())) &&\n isa<SCEVAddRecExpr>(SE.getSCEV(Inc)) &&\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopUnroll/peel-last-iteration.ll",
33
+ "commands": [
34
+ "opt -p loop-unroll -unroll-full-max-count=0 -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "exit_condition_has_other_loop_users",
39
+ "test_body": "define void @exit_condition_has_other_loop_users() {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv, 100\n br i1 %ec, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n call void @foo(i32 10)\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n call void @foo(i32 20)\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\ndeclare void @foo(i32)\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[LoopFullUnroll] Miscompilation at O3",
46
+ "body": "Reproducer:\n```\n; bin/opt -passes=loop-unroll-full reduced.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@g_479 = global i8 -1\n@crc32_tab = global [256 x i32] zeroinitializer\[email protected] = constant [15 x i8] c\"checksum = %X\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond1.preheader.i\n\nfor.cond1.preheader.i: ; preds = %for.cond1.preheader.i, %entry\n %indvars.iv.i = phi i64 [ 0, %entry ], [ %indvars.iv.next.i, %for.cond1.preheader.i ]\n %0 = and i64 %indvars.iv.i, 20\n %tobool.not.4.not.i = icmp eq i64 %0, 16\n %xor.5.i = select i1 %tobool.not.4.not.i, i32 0, i32 1\n %arrayidx.i = getelementptr [256 x i32], ptr @crc32_tab, i64 0, i64 %indvars.iv.i\n store i32 %xor.5.i, ptr %arrayidx.i, align 4\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\n %exitcond.not.i = icmp eq i64 %indvars.iv.next.i, 256\n br i1 %exitcond.not.i, label %lbl_1516.us.us.i.i, label %for.cond1.preheader.i\n\nlbl_1516.us.us.i.i: ; preds = %lbl_1587.us.us.i.i, %for.cond1.preheader.i\n %conv134690.us.us.i.i = phi i8 [ %spec.select.i.i, %lbl_1587.us.us.i.i ], [ 0, %for.cond1.preheader.i ]\n %l_1485.0.us.us.i.i = phi i16 [ %inc130.us.us.i.i, %lbl_1587.us.us.i.i ], [ -14340, %for.cond1.preheader.i ]\n %inc130.us.us.i.i = add i16 %l_1485.0.us.us.i.i, 1\n %tobool132.not.us.us.i.i = icmp eq i8 %conv134690.us.us.i.i, 0\n br i1 %tobool132.not.us.us.i.i, label %lbl_1587.us.us.i.i, label %land.rhs133.us.us.i.i\n\nland.rhs133.us.us.i.i: ; preds = %lbl_1516.us.us.i.i\n store i8 25, ptr @g_479, align 1\n br label %lbl_1587.us.us.i.i\n\nlbl_1587.us.us.i.i: ; preds = %land.rhs133.us.us.i.i, %lbl_1516.us.us.i.i\n %tobool293.not.not.us.us.i.i = icmp eq i16 %l_1485.0.us.us.i.i, 0\n %spec.select.i.i = select i1 %tobool293.not.not.us.us.i.i, i8 1, i8 0\n br i1 %tobool293.not.not.us.us.i.i, label %func_134.exit, label %lbl_1516.us.us.i.i\n\nfunc_134.exit: ; preds = %lbl_1587.us.us.i.i\n %1 = load i8, ptr @g_479, align 1\n %idxprom.i.i.i = zext i8 %1 to i64\n %arrayidx.i.i.i = getelementptr [256 x i32], ptr @crc32_tab, i64 0, i64 %idxprom.i.i.i\n %2 = load i32, ptr %arrayidx.i.i.i, align 4\n %call.i = call i32 (ptr, ...) @printf(ptr @.str.8, i32 %2)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n```\n```\n; ModuleID = 'reduced.ll'\nsource_filename = \"reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@g_479 = global i8 -1\n@crc32_tab = global [256 x i32] zeroinitializer\[email protected] = constant [15 x i8] c\"checksum = %X\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond1.preheader.i\n\nfor.cond1.preheader.i: ; preds = %for.cond1.preheader.i, %entry\n %indvars.iv.i = phi i64 [ 0, %entry ], [ %indvars.iv.next.i, %for.cond1.preheader.i ]\n %0 = and i64 %indvars.iv.i, 20\n %tobool.not.4.not.i = icmp eq i64 %0, 16\n %xor.5.i = select i1 %tobool.not.4.not.i, i32 0, i32 1\n %arrayidx.i = getelementptr [256 x i32], ptr @crc32_tab, i64 0, i64 %indvars.iv.i\n store i32 %xor.5.i, ptr %arrayidx.i, align 4\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\n %exitcond.not.i = icmp eq i64 %indvars.iv.next.i, 256\n br i1 %exitcond.not.i, label %lbl_1516.us.us.i.i.preheader, label %for.cond1.preheader.i\n\nlbl_1516.us.us.i.i.preheader: ; preds = %for.cond1.preheader.i\n br label %lbl_1516.us.us.i.i\n\nlbl_1516.us.us.i.i: ; preds = %lbl_1516.us.us.i.i.preheader, %lbl_1587.us.us.i.i\n %conv134690.us.us.i.i = phi i8 [ %spec.select.i.i, %lbl_1587.us.us.i.i ], [ 0, %lbl_1516.us.us.i.i.preheader ]\n %l_1485.0.us.us.i.i = phi i16 [ %inc130.us.us.i.i, %lbl_1587.us.us.i.i ], [ -14340, %lbl_1516.us.us.i.i.preheader ]\n %inc130.us.us.i.i = add nsw i16 %l_1485.0.us.us.i.i, 1\n %tobool132.not.us.us.i.i = icmp eq i8 %conv134690.us.us.i.i, 0\n br i1 %tobool132.not.us.us.i.i, label %lbl_1587.us.us.i.i, label %land.rhs133.us.us.i.i\n\nland.rhs133.us.us.i.i: ; preds = %lbl_1516.us.us.i.i\n store i8 25, ptr @g_479, align 1\n br label %lbl_1587.us.us.i.i\n\nlbl_1587.us.us.i.i: ; preds = %land.rhs133.us.us.i.i, %lbl_1516.us.us.i.i\n %tobool293.not.not.us.us.i.i = icmp eq i16 %l_1485.0.us.us.i.i, -1\n %spec.select.i.i = select i1 %tobool293.not.not.us.us.i.i, i8 1, i8 0\n br i1 %tobool293.not.not.us.us.i.i, label %func_134.exit.peel.begin, label %lbl_1516.us.us.i.i, !llvm.loop !0\n\nfunc_134.exit.peel.begin: ; preds = %lbl_1587.us.us.i.i\n %spec.select.i.i.lcssa = phi i8 [ %spec.select.i.i, %lbl_1587.us.us.i.i ]\n %inc130.us.us.i.i.lcssa = phi i16 [ %inc130.us.us.i.i, %lbl_1587.us.us.i.i ]\n br label %lbl_1516.us.us.i.i.peel\n\nlbl_1516.us.us.i.i.peel: ; preds = %func_134.exit.peel.begin\n %inc130.us.us.i.i.peel = add i16 %inc130.us.us.i.i.lcssa, 1\n %tobool132.not.us.us.i.i.peel = icmp eq i8 %spec.select.i.i.lcssa, 0\n br i1 %tobool132.not.us.us.i.i.peel, label %lbl_1587.us.us.i.i.peel, label %land.rhs133.us.us.i.i.peel\n\nland.rhs133.us.us.i.i.peel: ; preds = %lbl_1516.us.us.i.i.peel\n store i8 25, ptr @g_479, align 1\n br label %lbl_1587.us.us.i.i.peel\n\nlbl_1587.us.us.i.i.peel: ; preds = %land.rhs133.us.us.i.i.peel, %lbl_1516.us.us.i.i.peel\n %tobool293.not.not.us.us.i.i.peel = icmp eq i16 %inc130.us.us.i.i.lcssa, 0\n %spec.select.i.i.peel = select i1 %tobool293.not.not.us.us.i.i.peel, i8 1, i8 0\n br i1 %tobool293.not.not.us.us.i.i.peel, label %func_134.exit.peel.next, label %func_134.exit.peel.next\n\nfunc_134.exit.peel.next: ; preds = %lbl_1587.us.us.i.i.peel, %lbl_1587.us.us.i.i.peel\n br label %lbl_1516.us.us.i.i.peel.next\n\nlbl_1516.us.us.i.i.peel.next: ; preds = %func_134.exit.peel.next\n br label %func_134.exit\n\nfunc_134.exit: ; preds = %lbl_1516.us.us.i.i.peel.next\n %1 = load i8, ptr @g_479, align 1\n %idxprom.i.i.i = zext i8 %1 to i64\n %arrayidx.i.i.i = getelementptr [256 x i32], ptr @crc32_tab, i64 0, i64 %idxprom.i.i.i\n %2 = load i32, ptr %arrayidx.i.i.i, align 4\n %call.i = call i32 (ptr, ...) @printf(ptr @.str.8, i32 %2)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.peeled.count\", i32 1}\n```\nBefore:\n```\nchecksum = 1\n```\nAfter:\n```\nchecksum = 0\n```\nllvm version: 3ccb15d6caf57f2a866d496ada2fb52d14b179d2\n",
47
+ "author": "dtcxzyw",
48
+ "labels": [
49
+ "miscompilation",
50
+ "llvm:transforms",
51
+ "generated by fuzzer"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "dtcxzyw",
56
+ "body": "Reverting https://github.com/llvm/llvm-project/commit/3fcfce4c5e5fd1c3072e8db1d692c93459e8cd74 fixes this miscompilation. And https://github.com/llvm/llvm-project/commit/7e14161f49b32387988cf9d937bbfaa27d0fbdd5 doesn't fix this problem. cc @fhahn \n\n"
57
+ },
58
+ {
59
+ "author": "fhahn",
60
+ "body": "Issue is that we modify the exit condition w/o checking for other users."
61
+ }
62
+ ]
63
+ },
64
+ "verified": true
65
+ }
dataset/76852.json ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "76852",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/76852",
4
+ "bug_type": "crash",
5
+ "base_commit": "4d11f04b20f0bd7488e19e8f178ba028412fa519",
6
+ "knowledge_cutoff": "2024-01-03T19:32:37Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopDeletion"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "a0b911745494e3c2f53a27f23c536314818ce0b1",
12
+ "components": [
13
+ "LoopDeletion"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": [
17
+ [
18
+ 452,
19
+ 457
20
+ ],
21
+ [
22
+ 487,
23
+ 499
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": [
29
+ "deleteLoopIfDead"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit a0b911745494e3c2f53a27f23c536314818ce0b1\nAuthor: Manish Kausik H <[email protected]>\nDate: Fri Jan 19 20:00:20 2024 +0530\n\n LoopDeletion: Move EH pad check before the isLoopNeverExecuted Check (#78189)\n \n This commit modifies `LoopDeletion::deleteLoopIfDead` to check if the\n exit block of a loop is an EH pad before checking if the loop gets\n executed. This handles the case where an unreachable loop has a\n landingpad as an Exit block, and the loop gets deleted, leaving leaving\n the landingpad without an edge from an unwind clause.\n \n Fixes #76852.\n\ndiff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp\nindex c041e3621a16..bfe9374cf2f8 100644\n--- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp\n+++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp\n@@ -452,6 +452,13 @@ static LoopDeletionResult deleteLoopIfDead(Loop *L, DominatorTree &DT,\n \n BasicBlock *ExitBlock = L->getUniqueExitBlock();\n \n+ // We can't directly branch to an EH pad. Don't bother handling this edge\n+ // case.\n+ if (ExitBlock && ExitBlock->isEHPad()) {\n+ LLVM_DEBUG(dbgs() << \"Cannot delete loop exiting to EH pad.\\n\");\n+ return LoopDeletionResult::Unmodified;\n+ }\n+\n if (ExitBlock && isLoopNeverExecuted(L)) {\n LLVM_DEBUG(dbgs() << \"Loop is proven to never execute, delete it!\\n\");\n // We need to forget the loop before setting the incoming values of the exit\n@@ -487,13 +494,6 @@ static LoopDeletionResult deleteLoopIfDead(Loop *L, DominatorTree &DT,\n return LoopDeletionResult::Unmodified;\n }\n \n- // We can't directly branch to an EH pad. Don't bother handling this edge\n- // case.\n- if (ExitBlock && ExitBlock->isEHPad()) {\n- LLVM_DEBUG(dbgs() << \"Cannot delete loop exiting to EH pad.\\n\");\n- return LoopDeletionResult::Unmodified;\n- }\n-\n // Finally, we have to check that the loop really is dead.\n bool Changed = false;\n if (!isLoopDead(L, SE, ExitingBlocks, ExitBlock, Changed, Preheader, LI)) {\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/LoopDeletion/loop-with-ehpad-not-executed.ll",
37
+ "commands": [
38
+ "opt %s -passes=loop-deletion -S"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "<module>",
43
+ "test_body": "\ndefine void @wombat() personality ptr null {\n;\nbb:\n br i1 false, label %bb1, label %bb4\n\nbb1: ; preds = %bb\n br label %bb2\n\nbb2: ; preds = %bb1, %bb2\n %invoke = invoke double null()\n to label %bb2 unwind label %bb3\n\nbb3: ; preds = %bb2\n %landingpad = landingpad { ptr, i32 }\n cleanup\n ret void\n\nbb4: ; preds = %bb\n ret void\n}"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": " LLVM ERROR: Broken module found, compilation aborted!",
50
+ "body": "The bug was found by FuzzGen IR test generator\r\n\r\nRun opt with -passes=loop-deletion \r\nhttps://godbolt.org/z/16zoTYEqx\r\n\r\nTest.ll\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() gc \"statepoint-example\" personality ptr null {\r\nbb:\r\n br i1 false, label %bb1, label %bb4\r\n\r\nbb1: ; preds = %bb\r\n br label %bb2\r\n\r\nbb2: ; preds = %bb1, %bb2\r\n %invoke = invoke double null(i64 0)\r\n to label %bb2 unwind label %bb3\r\n\r\nbb3: ; preds = %bb2\r\n %landingpad = landingpad { ptr, i32 }\r\n cleanup\r\n ret void\r\n\r\nbb4: ; preds = %bb\r\n ret void\r\n}\r\n```\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-deletion <source>\r\n #0 0x0000000003597b18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3597b18)\r\n #1 0x000000000359526c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fee38042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007fee380969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007fee38042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007fee380287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007905f3 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x00000000034dea68 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x34dea68)\r\n #8 0x0000000002f6f993 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f6f993)\r\n #9 0x000000000088bbae llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x88bbae)\r\n#10 0x0000000002f34d6c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f34d6c)\r\n#11 0x0000000000895cca llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x895cca)\r\n#12 0x000000000079c483 main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x79c483)\r\n#13 0x00007fee38029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x00007fee38029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x000000000088af1e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x88af1e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
51
+ "author": "TatyanaDoubts",
52
+ "labels": [
53
+ "loopoptim",
54
+ "crash"
55
+ ],
56
+ "comments": [
57
+ {
58
+ "author": "Nirhar",
59
+ "body": "Just looked at the IR after loop deletion and before the verify pass, and looks like loop-deletion incorrectly considered the block with the landingpad as the exit block of the loop:\r\n```\r\ndefine void @wombat() gc \"statepoint-example\" personality ptr null {\r\nbb:\r\n br i1 false, label %bb1, label %bb4\r\n\r\nbb1: ; preds = %bb\r\n br label %bb3\r\n\r\nbb3: ; preds = %bb1\r\n %landingpad = landingpad { ptr, i32 }\r\n cleanup\r\n ret void\r\n\r\nbb4: ; preds = %bb\r\n ret void\r\n}\r\n\r\n$28 = void\r\n```\r\nThe problem seems to be with `Loop::getUniqueExitBlock` from https://github.com/llvm/llvm-project/blob/b6fc463d4c0b00e0741776f9d41b47f532a80b9e/llvm/lib/Transforms/Scalar/LoopDeletion.cpp#L453\r\n\r\nwhich returns the landingpad as the exit block of the loop. Perhaps this must be altered to consider that unwind edges are not real edges in the DAG. \r\n\r\n\r\n"
60
+ },
61
+ {
62
+ "author": "Nirhar",
63
+ "body": "I'm not sure who are the right persons to consult on this. @EugeneZelenko I leave it to you for you to add them."
64
+ },
65
+ {
66
+ "author": "nikic",
67
+ "body": "@Nirhar Isn't this already guarded by https://github.com/llvm/llvm-project/blob/b6fc463d4c0b00e0741776f9d41b47f532a80b9e/llvm/lib/Transforms/Scalar/LoopDeletion.cpp#L492?"
68
+ },
69
+ {
70
+ "author": "nikic",
71
+ "body": "Ah, this case hits the isLoopNeverExecuted() branch. So that check should just get moved higher, so it covers that case as well."
72
+ },
73
+ {
74
+ "author": "Nirhar",
75
+ "body": "@nikic Ah yes that makes sense. I'll land a patch for this soon!\r\n"
76
+ },
77
+ {
78
+ "author": "Nirhar",
79
+ "body": "@nikic On second thought, moving the landing pad check higher will not delete the loop, given that this loop never gets executed as well. Isn't it a better solution to delete the loop as well as delete the landing pad instruction?\r\n\r\nEssentially I propose to first check if the loop never gets executed. If yes, delete the loop. Next check if the exit block is a landing pad used exclusively by the loop. If yes, delete the landing pad as well. Is this solution acceptable to you?\r\n\r\nAlso is it correct to call the landing pad as an `ExitBlock`? In my opinion, semantically the landingpad should not be the block that `L->getUniqueExitBlock` returns given that the landingpad is not a part of the loop's logic. Thus in this case according to me `L->getUniqueExitBlock` should have returned a nullptr, and we should have hit the branch https://github.com/llvm/llvm-project/blob/b6fc463d4c0b00e0741776f9d41b47f532a80b9e/llvm/lib/Transforms/Scalar/LoopDeletion.cpp#L485 "
80
+ },
81
+ {
82
+ "author": "nikic",
83
+ "body": "> On second thought, moving the landing pad check higher will not delete the loop, given that this loop never gets executed as well. Isn't it a better solution to delete the loop as well as delete the landing pad instruction?\r\n\r\nThis is a degenerate case, it is not worthwhile to try and optimize it. It's possible to handle this case, but it's much harder than you think. The current code will always replace a loop with a branch to the exit, even if the loop is known to never execute, because this preserves the outer loop structure. If we replaced the entire loop with unreachable (which is what would really be necessary to handle the landingpad case) we may also break an outer loop and would have to perform corresponding loop info updates.\r\n\r\n> Also is it correct to call the landing pad as an ExitBlock? \r\n\r\nNote that ExitBlock and ExitingBlock are different things. And ExitingBlock is part of the loop and branches to an ExitBlock not part of the loop. So yes, landingpad is a valid ExitBlock here."
84
+ },
85
+ {
86
+ "author": "Nirhar",
87
+ "body": "Understood, thanks for the clarification @nikic !"
88
+ }
89
+ ]
90
+ },
91
+ "verified": true
92
+ }
dataset/77118.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "77118",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/77118",
4
+ "bug_type": "crash",
5
+ "base_commit": "40fae67a50e08e6b5b5300210021218e404d63a7",
6
+ "knowledge_cutoff": "2024-01-05T16:53:32Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopUnroll"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "e209178d6402348414b69941c77d621919b3b7ab",
12
+ "components": [
13
+ "SimplifyIndVar"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": [
17
+ [
18
+ 25,
19
+ 30
20
+ ],
21
+ [
22
+ 643,
23
+ 652
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": [
29
+ "SimplifyIndvar::replaceIVUserWithLoopInvariant"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit e209178d6402348414b69941c77d621919b3b7ab\nAuthor: Vedant Paranjape <[email protected]>\nDate: Wed Feb 21 17:51:56 2024 +0530\n\n [SimplifyIndVar] LCSSA form is destroyed by simplifyLoopIVs, preserve it (#78696)\n \n In LoopUnroll, peelLoop is called on the loop. After the loop is peeled\n it calls simplifyLoopAfterUnroll on the loop. This call to\n simplifyLoopAfterUnroll doesn't preserve the LCSSA form of the parent\n loop and thus during the next call to peelLoop the LCSSA form is already\n broken.\n \n LoopPeel util takes in the PreserveLCSSA argument and it passes\n on the same argument to simplifyLoop which checks if the loop is in a\n valid LCSSA form, when (PreserveLCSSA = true).\n \n This causes an assert in simplifyLoop when (PreserveLCSSA = true), as\n during the last call LCSSA for the loop wasn't preserved, and thus\n crashes at the following assert.\n \n assert(L->isRecursivelyLCSSAForm(*DT, *LI) &&\n \"Requested to preserve LCSSA, but it's already broken.\");\n \n Upon debugging, it is evident that simplifyLoopIVs call inside\n simplifyLoopAfterUnroll breaks the LCSSA form. This patch fixes\n llvm#77118, it checks if the replacement of IV Users with Loop Invariant\n preserves the LCSSA form. If it does not, it emits the required LCSSA\n Phi instructions.\n\ndiff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp\nindex 66bba1ca2f1d..297cfe5124d8 100644\n--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp\n+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp\n@@ -25,6 +25,7 @@\n #include \"llvm/Support/Debug.h\"\n #include \"llvm/Support/raw_ostream.h\"\n #include \"llvm/Transforms/Utils/Local.h\"\n+#include \"llvm/Transforms/Utils/LoopUtils.h\"\n #include \"llvm/Transforms/Utils/ScalarEvolutionExpander.h\"\n \n using namespace llvm;\n@@ -643,10 +644,21 @@ bool SimplifyIndvar::replaceIVUserWithLoopInvariant(Instruction *I) {\n }\n \n auto *Invariant = Rewriter.expandCodeFor(S, I->getType(), IP);\n+ bool NeedToEmitLCSSAPhis = false;\n+ if (!LI->replacementPreservesLCSSAForm(I, Invariant))\n+ NeedToEmitLCSSAPhis = true;\n \n I->replaceAllUsesWith(Invariant);\n LLVM_DEBUG(dbgs() << \"INDVARS: Replace IV user: \" << *I\n << \" with loop invariant: \" << *S << '\\n');\n+\n+ if (NeedToEmitLCSSAPhis) {\n+ SmallVector<Instruction *, 1> NeedsLCSSAPhis;\n+ NeedsLCSSAPhis.push_back(cast<Instruction>(Invariant));\n+ formLCSSAForInstructions(NeedsLCSSAPhis, *DT, *LI, SE);\n+ LLVM_DEBUG(dbgs() << \" INDVARS: Replacement breaks LCSSA form\"\n+ << \" inserting LCSSA Phis\" << '\\n');\n+ }\n ++NumFoldedUser;\n Changed = true;\n DeadInsts.emplace_back(I);\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/LoopUnroll/gh-issue77118-broken-lcssa-form.ll",
37
+ "commands": [
38
+ "opt -passes=loop-unroll -unroll-peel-count=2 -S -disable-output -debug-only=loop-unroll < %s 2>&1"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "<module>",
43
+ "test_body": "; REQUIRES: asserts\n\ndefine void @test() {\nentry:\n br label %loop1\n\nloop1:\n %phi = phi i32 [ 1, %entry ], [ 0, %loop1.latch ]\n br label %loop2\n\nloop2:\n %phi3 = phi i64 [ 0, %loop1 ], [ %sext, %loop2.latch ]\n br label %loop3\n\nloop3:\n %phi5 = phi i64 [ %phi3, %loop2 ], [ %sext, %loop3.latch ]\n %phi6 = phi i32 [ 1, %loop2 ], [ %add10, %loop3.latch ]\n %trunc = trunc i64 %phi5 to i32\n br i1 true, label %loop3.latch, label %exit\n\nloop3.latch:\n %add = add i32 1, %phi\n %sext = sext i32 %add to i64\n %add10 = add i32 %phi6, 1\n %icmp = icmp ugt i32 %add10, 2\n br i1 %icmp, label %loop2.latch, label %loop3\n\nloop2.latch:\n br i1 false, label %loop4.preheader, label %loop2\n\nloop4.preheader:\n br label %loop4\n\nloop4:\n br i1 false, label %loop1.latch, label %loop4\n\nloop1.latch:\n br label %loop1\n\nexit:\n %phi8 = phi i32 [ %trunc, %loop3 ]\n ret void\n}"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "Assertion `L->isRecursivelyLCSSAForm(*DT, *LI) && \"Requested to preserve LCSSA, but it's already broken.\"' failed.",
50
+ "body": "Run opt with -passes=loop-unroll\r\n\r\nhttps://godbolt.org/z/GcEW4dhMh\r\n\r\nTest.ll\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() gc \"statepoint-example\" !prof !0 {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb12, %bb\r\n %phi = phi i32 [ 1, %bb ], [ 0, %bb12 ]\r\n br label %bb2\r\n\r\nbb2: ; preds = %bb11, %bb1\r\n %phi3 = phi i64 [ 0, %bb1 ], [ %sext, %bb11 ]\r\n br label %bb4\r\n\r\nbb4: ; preds = %bb9, %bb2\r\n %phi5 = phi i64 [ %phi3, %bb2 ], [ %sext, %bb9 ]\r\n %phi6 = phi i32 [ 1, %bb2 ], [ %add10, %bb9 ]\r\n %trunc = trunc i64 %phi5 to i32\r\n br i1 true, label %bb9, label %bb7\r\n\r\nbb7: ; preds = %bb4\r\n %phi8 = phi i32 [ %trunc, %bb4 ]\r\n ret void\r\n\r\nbb9: ; preds = %bb4\r\n %add = add i32 1, %phi\r\n %sext = sext i32 %add to i64\r\n %add10 = add i32 %phi6, 1\r\n %icmp = icmp ugt i32 %add10, 2\r\n br i1 %icmp, label %bb11, label %bb4\r\n\r\nbb11: ; preds = %bb9\r\n br i1 false, label %bb12, label %bb2\r\n\r\nbb12: ; preds = %bb12, %bb11\r\n br i1 false, label %bb1, label %bb12, !prof !1\r\n}\r\n\r\n!0 = !{!\"function_entry_count\", i64 32768}\r\n!1 = !{!\"branch_weights\", i32 11, i32 1}\r\n```\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -S -passes=loop-unroll <source>\r\n #0 0x000000000359f928 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x359f928)\r\n #1 0x000000000359d07c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fe5f8e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007fe5f8e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007fe5f8e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007fe5f8e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007fe5f8e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007fe5f8e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000036a9544 llvm::simplifyLoop(llvm::Loop*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::AssumptionCache*, llvm::MemorySSAUpdater*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36a9544)\r\n #9 0x000000000369b9d6 llvm::peelLoop(llvm::Loop*, unsigned int, llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::DominatorTree&, llvm::AssumptionCache*, bool, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x369b9d6)\r\n#10 0x00000000033f771b tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&, llvm::LoopInfo*, llvm::ScalarEvolution&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, bool, int, bool, bool, bool, std::optional<unsigned int>, std::optional<unsigned int>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<unsigned int>) LoopUnrollPass.cpp:0:0\r\n#11 0x00000000033fa420 llvm::LoopUnrollPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x33fa420)\r\n#12 0x00000000037a6b8e llvm::detail::PassModel<llvm::Function, llvm::LoopUnrollPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x37a6b8e)\r\n#13 0x0000000000d8693d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd8693d)\r\n#14 0x0000000002f3dfee llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f3dfee)\r\n#15 0x0000000000d6ac7e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd6ac7e)\r\n#16 0x0000000002f3bf9c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f3bf9c)\r\n#17 0x0000000000895e8a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x895e8a)\r\n#18 0x000000000079c6d3 main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x79c6d3)\r\n#19 0x00007fe5f8e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#20 0x00007fe5f8e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#21 0x000000000088b0de _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x88b0de)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
51
+ "author": "TatyanaDoubts",
52
+ "labels": [
53
+ "loopoptim",
54
+ "crash"
55
+ ],
56
+ "comments": [
57
+ {
58
+ "author": "vedantparanjape-amd",
59
+ "body": "I looked at this, it seems peelLoop call destroys the LCSSA form, and after that calls simplifyLoop with PreserveLCSSA = true. I did the following change to confirm it.\r\n\r\n```c\r\ndiff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp\r\nindex 7cfeb019af97..be73d58796be 100644\r\n--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp\r\n+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp\r\n@@ -1270,6 +1270,7 @@ tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI, ScalarEvolution &SE,\r\n });\r\n\r\n ValueToValueMapTy VMap;\r\n+ dbgs() << \"is lcssa form (before peel): \" << L->isRecursivelyLCSSAForm(DT, *LI) << \"\\n\";\r\n if (peelLoop(L, PP.PeelCount, LI, &SE, DT, &AC, PreserveLCSSA, VMap)) {\r\n simplifyLoopAfterUnroll(L, true, LI, &SE, &DT, &AC, &TTI);\r\n // If the loop was peeled, we already \"used up\" the profile information\r\ndiff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp\r\nindex f76fa3bb6c61..47775ef70dc0 100644\r\n--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp\r\n+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp\r\n@@ -1054,6 +1054,7 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI,\r\n assert(DT.verify(DominatorTree::VerificationLevel::Fast));\r\n #endif\r\n\r\n+ dbgs() << \"is lcssa form (after peel): \" << L->isRecursivelyLCSSAForm(DT, *LI) << \"\\n\";\r\n // FIXME: Incrementally update loop-simplify\r\n simplifyLoop(L, &DT, LI, SE, AC, nullptr, PreserveLCSSA);\r\n```\r\nThe output from it was as follows:\r\n```bash\r\nis lcssa form (before peel): 1\r\nis lcssa form (after peel): 0\r\n```\r\nAs for the fix, adding a simple check for LCSSA and if it's not in form, forming it helped solve this bug. Does this look like a correct fix ?\r\n\r\n```c\r\ndiff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp\r\nindex f76fa3bb6c61..3e0545656d49 100644\r\n--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp\r\n+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp\r\n@@ -1054,6 +1054,8 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI,\r\n assert(DT.verify(DominatorTree::VerificationLevel::Fast));\r\n #endif\r\n\r\n+ if (PreserveLCSSA && !L->isRecursivelyLCSSAForm(DT, *LI))\r\n+ formLCSSARecursively(*L, DT, LI, SE);\r\n // FIXME: Incrementally update loop-simplify\r\n simplifyLoop(L, &DT, LI, SE, AC, nullptr, PreserveLCSSA);\r\n```\r\nCC: @fhahn / @nikic "
60
+ },
61
+ {
62
+ "author": "vedantparanjape-amd",
63
+ "body": "@TatyanaDoubts thanks for the report, it is now fixed."
64
+ }
65
+ ]
66
+ },
67
+ "verified": true
68
+ }
dataset/80289.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "80289",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/80289",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "f7b05e055fa63e1c4b5ae5e391b654b57161a0e4",
6
+ "knowledge_cutoff": "2024-02-01T13:14:59Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopUnroll"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "62ae7d976f494f3dbd297331b19cd1204750de6f",
12
+ "components": [
13
+ "LoopUnrollRuntime"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": [
17
+ [
18
+ 776,
19
+ 782
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": [
25
+ "llvm::UnrollRuntimeLoopRemainder"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 62ae7d976f494f3dbd297331b19cd1204750de6f\nAuthor: Nikita Popov <[email protected]>\nDate: Thu Feb 1 16:06:58 2024 +0100\n\n [LoopUnroll] Fix missing sign extension\n \n For integers larger than 64-bit, this would zero-extend a -1\n value, instead of sign-extending it.\n \n Fixes https://github.com/llvm/llvm-project/issues/80289.\n\ndiff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp\nindex 612f69970881..650f055356c0 100644\n--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp\n+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp\n@@ -776,7 +776,7 @@ bool llvm::UnrollRuntimeLoopRemainder(\n !isGuaranteedNotToBeUndefOrPoison(TripCount, AC, PreHeaderBR, DT)) {\n TripCount = B.CreateFreeze(TripCount);\n BECount =\n- B.CreateAdd(TripCount, ConstantInt::get(TripCount->getType(), -1));\n+ B.CreateAdd(TripCount, Constant::getAllOnesValue(TripCount->getType()));\n } else {\n // If we don't need to freeze, use SCEVExpander for BECount as well, to\n // allow slightly better value reuse.\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopUnroll/runtime-i128.ll",
33
+ "commands": [
34
+ "opt -S -passes=loop-unroll -unroll-runtime < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "declare void @foo()\n\ndefine void @test(i128 %n, i128 %m) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i128 [ 0, %entry ], [ %iv.next, %loop ]\n call void @foo()\n %iv.next = add i128 %iv, 1\n %cmp = icmp ne i128 %iv.next, %n\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "WRONG code: LoopUnroll / SCEVExpander with i128 induction variable.",
46
+ "body": "This reduced (csmith) test case seems well-defined, and should print '6':\r\n\r\n```\r\nchar C = 0;\r\n__int128 IW = 0;\r\nint *IPtr1, *IPtr2;\r\n\r\nstruct S2 { int f3; };\r\nvolatile struct S2 g_1100;\r\n\r\nint main() {\r\n for (; C <= 5; C += 1)\r\n for (; IW <= 5; IW += 1) {\r\n IPtr1 = IPtr2;\r\n g_1100;\r\n }\r\n int crc = IW;\r\n printf(\"checksum = %d\\n\", crc);\r\n}\r\n```\r\n```\r\n\r\nclang -target s390x-linux-gnu -march=z16 -O3 -mllvm -enable-load-pre=false -o ./a.out -mllvm -unroll-max-count=3; ./a.out\r\nchecksum = 7\r\nclang -target s390x-linux-gnu -march=z16 -O3 -mllvm -enable-load-pre=false -o ./a.out -mllvm -unroll-max-count=2; ./a.out\r\nchecksum = 6\r\n```\r\n\r\nHowever, when unrolled 3 times (not 2 or 4), the LoopUnroller creates a prologue loop, which is supposed to run extra iterations, as computed in the preheader (LoopUnrollRuntime.cpp:766):\r\n\r\n```\r\nfor.body5.preheader: ; preds = %for.cond2thread-pre-split\r\n %2 = sub i128 6, %.pr121517\r\n %3 = freeze i128 %2\r\n %4 = add i128 %3, 18446744073709551615\r\n %5 = urem i128 %4, 3\r\n %6 = add i128 %5, 1\r\n %xtraiter = urem i128 %6, 3\r\n %lcmp.mod = icmp ne i128 %xtraiter, 0\r\n br i1 %lcmp.mod, label %for.body5.prol.preheader, label %for.body5.prol.loopexit\r\n```\r\n\r\nThe constant used for %4 is actually is supposed to be i128 '-1', so UINT64_MAX (i64 -1) doesn't make sense.\r\n\r\ni128 <> i64, after LoopUnroller:\r\n```\r\n\r\nfor.body5.preheader: for.body5.preheader: \r\n %2 = sub i128 6, %.pr121517 | %2 = sub i64 6, %.pr121517\r\n %3 = freeze i128 %2 | %3 = freeze i64 %2\r\n %4 = add i128 %3, 18446744073709551615 | %4 = add i64 %3, -1\r\n %5 = urem i128 %4, 3 | %5 = urem i64 %4, 3\r\n %6 = add i128 %5, 1 | %6 = add i64 %5, 1\r\n %xtraiter = urem i128 %6, 3 | %xtraiter = urem i64 %6, 3\r\n %lcmp.mod = icmp ne i128 %xtraiter, 0 | %lcmp.mod = icmp ne i64 %xtraiter, 0\r\n br i1 %lcmp.mod, label %for.body5.prol.preh br i1 %lcmp.mod, label %for.body5.prol.preh\r\n```\r\n\r\n%4 is later optimized to a sub i128 with a folded constant of 18446744073709551621, which really should be '5'.\r\n\r\n@nikic @boxu-zhang @xiangzh1 @preames @uweigand \r\n\r\n\r\n",
47
+ "author": "JonPsson1",
48
+ "labels": [
49
+ "miscompilation",
50
+ "loopoptim"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "nikic",
55
+ "body": "Classic mistake, https://github.com/llvm/llvm-project/blob/f956e7fbf161447b9236f7c4448a9d02d3564261/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp#L779 create an unsigned `-1` value."
56
+ },
57
+ {
58
+ "author": "nikic",
59
+ "body": "As this is a recurring problem, I've started working on some sanity checks for APInt to solve this once and for all: https://github.com/llvm/llvm-project/pull/80309"
60
+ }
61
+ ]
62
+ },
63
+ "verified": true
64
+ }
dataset/83404.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "83404",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/83404",
4
+ "bug_type": "crash",
5
+ "base_commit": "a41bcb3930534ef1525b4fc30e53e818b39e2b60",
6
+ "knowledge_cutoff": "2024-02-29T10:33:37Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopStrengthReduce"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "6409c21857373bbb5563b37c3bacc066ad633658",
12
+ "components": [],
13
+ "bug_location_lineno": {
14
+ "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": [
15
+ [
16
+ 85,
17
+ 91
18
+ ]
19
+ ]
20
+ },
21
+ "bug_location_funcname": {}
22
+ },
23
+ "patch": "commit 6409c21857373bbb5563b37c3bacc066ad633658\nAuthor: Nikita Popov <[email protected]>\nDate: Tue Mar 5 16:38:09 2024 +0100\n\n [SCEVExpander] Use PoisoningVH for OrigFlags\n \n It's common to delete some instructions after using SCEVExpander,\n while it is still live (but will not be used afterwards). In that\n case, the AssertingVH may trigger. Replace it with a PoisoningVH\n so that we only detect the case where the SCEVExpander actually is\n used in a problematic fashion after the instruction removal.\n \n The alternative would be to add clear() calls to more code paths.\n \n Fixes https://github.com/llvm/llvm-project/issues/83404.\n\ndiff --git a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h\nindex 9de0996fb1e3..62c1e15a9a60 100644\n--- a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h\n+++ b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h\n@@ -85,7 +85,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {\n \n /// Original flags of instructions for which they were modified. Used\n /// by SCEVExpanderCleaner to undo changes.\n- DenseMap<AssertingVH<Instruction>, PoisonFlags> OrigFlags;\n+ DenseMap<PoisoningVH<Instruction>, PoisonFlags> OrigFlags;\n \n // The induction variables generated.\n SmallVector<WeakVH, 2> InsertedIVs;\n",
24
+ "tests": [
25
+ {
26
+ "file": "llvm/test/Transforms/LoopStrengthReduce/X86/pr83404.ll",
27
+ "commands": [
28
+ "opt -S -passes=loop-reduce -mtriple=x86_64-unknown-linux-gnu < %s"
29
+ ],
30
+ "tests": [
31
+ {
32
+ "test_name": "<module>",
33
+ "test_body": "\n; Make sure this does not assert.\ndefine void @test() {\n;\nentry:\n br label %for.body\n\nfor.body:\n %0 = phi i64 [ %dec, %for.body ], [ 0, %entry ]\n %h.18 = phi i32 [ 1, %for.body ], [ 0, %entry ]\n %dec = add i64 %0, 1\n %rem = urem i64 %0, 5\n %1 = trunc i64 %rem to i32\n %tobool3.not = icmp eq i32 %h.18, %1\n br label %for.body\n}"
34
+ }
35
+ ]
36
+ }
37
+ ],
38
+ "issue": {
39
+ "title": "llc crash: An asserting value handle still pointed to this value!",
40
+ "body": "llc crashed on the test case.\r\n\r\nBisected to https://github.com/llvm/llvm-project/commit/07292b7203e31fb90d9180bfccde0d4e84be2245, which was committed by @nikic \r\n\r\nCompiler explorer: https://godbolt.org/z/noEEWf5MM\r\n\r\n```llvm\r\n% cat reduced.ll\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @f() {\r\nentry:\r\n br label %for.body\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %0 = phi i64 [ %dec, %for.body ], [ 0, %entry ]\r\n %h.18 = phi i32 [ 1, %for.body ], [ 0, %entry ]\r\n %dec = add i64 %0, 1\r\n %rem = urem i64 %0, 5\r\n %1 = trunc i64 %rem to i32\r\n %tobool3.not = icmp eq i32 %h.18, %1\r\n br label %for.body\r\n}\r\n%\r\n% llc reduced.ll\r\nWhile deleting: i64 %dec\r\nAn asserting value handle still pointed to this value!\r\nUNREACHABLE executed at /tmp/tmpi78wpw36/tmp3ncswa62/llvm/lib/IR/Value.cpp:1246!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/llc reduced.ll\r\n1.\tRunning pass 'Function Pass Manager' on module 'reduced.ll'.\r\n2.\tRunning pass 'Loop Pass Manager' on function '@f'\r\n3.\tRunning pass 'Loop Strength Reduction' on basic block '%for.body'\r\n #0 0x00007fdb13f166cf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0x9516cf)\r\n #1 0x00007fdb13f13bf4 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fdb131da090 (/lib/x86_64-linux-gnu/libc.so.6+0x43090)\r\n #3 0x00007fdb131da00b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fdb131b9859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fdb13e26cde (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0x861cde)\r\n #6 0x00007fdb1416ae87 llvm::ValueHandleBase::ValueIsDeleted(llvm::Value*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0xba5e87)\r\n #7 0x00007fdb1416b82d llvm::Value::~Value() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0xba682d)\r\n #8 0x00007fdb1416b9a2 llvm::Value::deleteValue() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0xba69a2)\r\n #9 0x00007fdb14096174 llvm::Instruction::eraseFromParent() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0xad1174)\r\n#10 0x00007fdb150ce4e3 llvm::RecursivelyDeleteTriviallyDeadInstructions(llvm::SmallVectorImpl<llvm::WeakTrackingVH>&, llvm::TargetLibraryInfo const*, llvm::MemorySSAUpdater*, std::function<void (llvm::Value*)>) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0x1b094e3)\r\n#11 0x00007fdb150ce929 llvm::RecursivelyDeleteTriviallyDeadInstructions(llvm::Value*, llvm::TargetLibraryInfo const*, llvm::MemorySSAUpdater*, std::function<void (llvm::Value*)>) (.part.0) Local.cpp:0:0\r\n#12 0x00007fdb150cece1 llvm::RecursivelyDeleteDeadPHINode(llvm::PHINode*, llvm::TargetLibraryInfo const*, llvm::MemorySSAUpdater*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0x1b09ce1)\r\n#13 0x00007fdb15001692 llvm::DeleteDeadPHIs(llvm::BasicBlock*, llvm::TargetLibraryInfo const*, llvm::MemorySSAUpdater*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0x1a3c692)\r\n#14 0x00007fdb15627243 ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSA*) LoopStrengthReduce.cpp:0:0\r\n#15 0x00007fdb15628b92 (anonymous namespace)::LoopStrengthReduce::runOnLoop(llvm::Loop*, llvm::LPPassManager&) LoopStrengthReduce.cpp:0:0\r\n#16 0x00007fdb15e40dbb llvm::LPPassManager::runOnFunction(llvm::Function&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0x287bdbb)\r\n#17 0x00007fdb140e9921 llvm::FPPassManager::runOnFunction(llvm::Function&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0xb24921)\r\n#18 0x00007fdb140e9b69 llvm::FPPassManager::runOnModule(llvm::Module&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0xb24b69)\r\n#19 0x00007fdb140ea412 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/../lib/libLLVM.so.19.0git+0xb25412)\r\n#20 0x0000562c805e44c9 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0\r\n#21 0x0000562c805da126 main (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/llc+0x11126)\r\n#22 0x00007fdb131bb083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#23 0x0000562c805dac6e _start (/zdata/shaoli/compilers/ccbuilder-compilers/clang-07292b7203e31fb90d9180bfccde0d4e84be2245/bin/llc+0x11c6e)\r\n[1] 2969443 abort reduced.ll\r\n```\r\n\r\nThis test case is reduced from the following C code:\r\n```c\r\nint a;\r\nlong b, c;\r\nstatic long *d = &b, *e = &d;\r\nvoid f() {\r\n long *g = &c;\r\n int h = {};\r\n int *i = &h;\r\n for (;;)\r\n for (; a;) {\r\n *i ^= --*d % (unsigned long)5;\r\n *i || (*g = 0);\r\n *i = 1;\r\n long *j = e;\r\n e == &j;\r\n }\r\n}\r\nint main() {}\r\n```",
41
+ "author": "shao-hua-li",
42
+ "labels": [
43
+ "loopoptim",
44
+ "crash-on-valid"
45
+ ],
46
+ "comments": []
47
+ },
48
+ "verified": true
49
+ }
scripts/dataset_postfix.py CHANGED
@@ -55,7 +55,7 @@ def verify_issue(issue):
55
  if len(modified_funcs_valid) != 0:
56
  bug_location_funcname[file.path] = sorted(list(modified_funcs_valid))
57
  if len(bug_location_funcname) == 0:
58
- if issue.removesuffix(".json") not in ["88297"]:
59
  print(f"{issue} Warning: bug_location_funcname is empty")
60
  data["hints"]["bug_location_funcname"] = bug_location_funcname
61
  # Migration
 
55
  if len(modified_funcs_valid) != 0:
56
  bug_location_funcname[file.path] = sorted(list(modified_funcs_valid))
57
  if len(bug_location_funcname) == 0:
58
+ if issue.removesuffix(".json") not in ["88297", "83404"]:
59
  print(f"{issue} Warning: bug_location_funcname is empty")
60
  data["hints"]["bug_location_funcname"] = bug_location_funcname
61
  # Migration
scripts/extract_from_issues.py CHANGED
@@ -34,7 +34,7 @@ session.headers.update(
34
  )
35
 
36
  issue_id_begin = 76663 # Since 2024-01-01
37
- issue_id_end = 140362
38
 
39
 
40
  def wait(progress):
@@ -75,7 +75,12 @@ def fetch(issue_id):
75
  has_valid_label = True
76
  if "hang" in label_name:
77
  has_valid_label = True
78
- if "llvm" in label_name or label_name == "vectorizers":
 
 
 
 
 
79
  is_llvm_middleend = True
80
  for key in [
81
  "backend",
 
34
  )
35
 
36
  issue_id_begin = 76663 # Since 2024-01-01
37
+ issue_id_end = 140445
38
 
39
 
40
  def wait(progress):
 
75
  has_valid_label = True
76
  if "hang" in label_name:
77
  has_valid_label = True
78
+ if "llvm" in label_name or label_name in [
79
+ "vectorizers",
80
+ "loopoptim",
81
+ "floating-point",
82
+ "vectorization",
83
+ ]:
84
  is_llvm_middleend = True
85
  for key in [
86
  "backend",
scripts/llvm_helper.py CHANGED
@@ -123,7 +123,7 @@ def build(max_build_jobs: int):
123
  "-DLLVM_ABI_BREAKING_CHECKS=WITH_ASSERTS",
124
  "-DLLVM_ENABLE_WARNINGS=OFF",
125
  "-DLLVM_APPEND_VC_REV=OFF",
126
- "-DLLVM_TARGETS_TO_BUILD='X86;RISCV;AArch64;SystemZ;Hexagon'",
127
  "-DLLVM_PARALLEL_LINK_JOBS=4",
128
  "-DLLVM_INCLUDE_EXAMPLES=OFF",
129
  ],
 
123
  "-DLLVM_ABI_BREAKING_CHECKS=WITH_ASSERTS",
124
  "-DLLVM_ENABLE_WARNINGS=OFF",
125
  "-DLLVM_APPEND_VC_REV=OFF",
126
+ "-DLLVM_TARGETS_TO_BUILD='X86;RISCV;AArch64;SystemZ;Hexagon;PowerPC;'",
127
  "-DLLVM_PARALLEL_LINK_JOBS=4",
128
  "-DLLVM_INCLUDE_EXAMPLES=OFF",
129
  ],
scripts/postfix_extract.py CHANGED
@@ -57,6 +57,7 @@ timeline = session.get(issue["timeline_url"]).json()
57
  fix_commit = None
58
  fix_commit_map = {
59
  "76789": None, # Cannot reproduce with alive2
 
60
  "78024": None, # Reverted
61
  "79137": None, # Cannot reproduce with alive2
62
  "80836": "1c10821022f1799452065fb57474e894e2562b7f",
 
57
  fix_commit = None
58
  fix_commit_map = {
59
  "76789": None, # Cannot reproduce with alive2
60
+ "77842": None, # Threshold problem
61
  "78024": None, # Reverted
62
  "79137": None, # Cannot reproduce with alive2
63
  "80836": "1c10821022f1799452065fb57474e894e2562b7f",