Datasets:

Modalities:
Text
Formats:
json
Size:
< 1K
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
dtcxzyw commited on
Commit
8a23f90
·
1 Parent(s): 527a9bc
dataset.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
dataset/119665.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "119665",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/119665",
4
+ "bug_type": "crash",
5
+ "base_commit": "7ae78a6cdb6ce9ad1534ed10519649fb3d47aca9",
6
+ "knowledge_cutoff": "2024-12-12T07:13:14Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "3706dfef660097f24fb5efbac0d7f14b424492ed",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 2937,
19
+ 2946
20
+ ],
21
+ [
22
+ 2950,
23
+ 2955
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
29
+ "InnerLoopVectorizer::fixVectorizedLoop"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 3706dfef660097f24fb5efbac0d7f14b424492ed\nAuthor: Florian Hahn <[email protected]>\nDate: Mon Feb 10 16:29:42 2025 +0000\n\n [LV] Forget LCSSA phi with new pred before other SCEV invalidation. (#119897)\n \n `forgetLcssaPhiWithNewPredecessor` performs additional invalidation if\n there is an existing SCEV for the phi, but earlier\n `forgetBlockAndLoopDispositions` or `forgetLoop` may already invalidate\n the SCEV for the phi.\n \n Change the order to first call `forgetLcssaPhiWithNewPredecessor` to\n ensure it runs before its SCEV gets invalidated too eagerly.\n \n Fixes https://github.com/llvm/llvm-project/issues/119665.\n \n PR: https://github.com/llvm/llvm-project/pull/119897\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 610e4904a80a..f2241be60ce0 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -2937,10 +2937,6 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {\n if (EnableVPlanNativePath)\n fixNonInductionPHIs(State);\n \n- // Forget the original basic block.\n- PSE.getSE()->forgetLoop(OrigLoop);\n- PSE.getSE()->forgetBlockAndLoopDispositions();\n-\n // After vectorization, the exit blocks of the original loop will have\n // additional predecessors. Invalidate SCEVs for the exit phis in case SE\n // looked through single-entry phis.\n@@ -2950,6 +2946,10 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {\n for (PHINode &PN : Exit->phis())\n PSE.getSE()->forgetLcssaPhiWithNewPredecessor(OrigLoop, &PN);\n \n+ // Forget the original basic block.\n+ PSE.getSE()->forgetLoop(OrigLoop);\n+ PSE.getSE()->forgetBlockAndLoopDispositions();\n+\n // Don't apply optimizations below when no vector region remains, as they all\n // require a vector loop at the moment.\n if (!State.Plan->getVectorLoopRegion())\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/LoopVectorize/invalidate-scev-at-scope-after-vectorization.ll",
37
+ "commands": [
38
+ "opt -passes='print<scalar-evolution>,loop-vectorize' -force-vector-width=4 -scalar-evolution-classify-expressions=false -S %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "<module>",
43
+ "test_body": "\n; Test case for https://github.com/llvm/llvm-project/issues/119665.\n\n; %loop.2's backedge-taken-count depends on %add.1 from %loop.1 via its\n; corresponding SCEV at the scope of %loop.2. After vectorizing %loop.1, %add.1\n; isn't available at the entry of %loop.2 anymore and %add.1 at %loop.2's scope\n; must be invalidated, as well as %loop.2's backedge-taken count.\ndefine void @test_invalidate_scevs_at_scope(ptr %p) {\n;\nentry:\n br label %loop.1\n\nloop.1:\n %iv.1 = phi i32 [ 0, %entry ], [ %iv.1.next, %loop.1 ]\n %1 = load i32, ptr %p, align 4\n %add.1 = add i32 %1, %iv.1\n %iv.1.next = add i32 %iv.1, 1\n %c.1 = icmp eq i32 %iv.1, 100\n br i1 %c.1, label %exit.1, label %loop.1\n\nexit.1:\n %add.lcssa = phi i32 [ %add.1, %loop.1 ]\n br label %loop.2\n\nloop.2:\n %iv.2 = phi i64 [ 0, %exit.1 ], [ %iv.2.next, %loop.2 ]\n %iv.2.trunc = trunc i64 %iv.2 to i32\n %iv.2.next = add i64 %iv.2, 1\n %gep = getelementptr inbounds i64, ptr %p, i64 %iv.2\n store i64 %iv.2, ptr %gep\n %add.2 = add i32 %add.lcssa, %iv.2.trunc\n %c.2 = icmp slt i32 %add.2, 100\n br i1 %c.2, label %loop.2, label %exit.2\n\nexit.2:\n ret void\n}\n\n;.\n;."
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[clang] Crash at -O2: Assertion `isAvailableAtLoopEntry(LHS, L) && \"LHS is not available at Loop Entry\"' failed.",
50
+ "body": "This code crashes at `-O2`: \n```c\nint a, e;\nint *b;\nshort c[];\nshort d;\nvoid f() {\n int g;\n for (;;)\n for (; a - 3 + g < 6; g = g + 1)\n c[g] = d;\n}\nvoid h();\nvoid i() {\n h();\n f();\n}\nvoid h() {\n e = 0;\n for (; e <= 50; ++e) {\n int *j = &a;\n *j = *b + e;\n }\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/jfo65eK9x\n\nCrash:\n```console\nclang: /root/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:11744: bool llvm::ScalarEvolution::isLoopEntryGuardedByCond(const llvm::Loop*, llvm::CmpInst::Predicate, const llvm::SCEV*, const llvm::SCEV*): Assertion `isAvailableAtLoopEntry(LHS, L) && \"LHS is not available at Loop Entry\"' failed.\n```\nBacktrace:\n```console\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 -Wall -Wextra -fno-strict-aliasing <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"<source>\"\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"i\"\n #0 0x0000000003c19758 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c19758)\n #1 0x0000000003c17464 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c17464)\n #2 0x0000000003b649c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x000079aa17242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x000079aa172969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x000079aa17242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x000079aa172287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x000079aa1722871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x000079aa17239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000000002c90a7b llvm::ScalarEvolution::isLoopEntryGuardedByCond(llvm::Loop const*, llvm::CmpInst::Predicate, llvm::SCEV const*, llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2c90a7b)\n#10 0x0000000002ca6d97 llvm::ScalarEvolution::getTripCountFromExitCount(llvm::SCEV const*, llvm::Type*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2ca6d97)\n#11 0x00000000058449e4 llvm::VPlan::createInitialVPlan(llvm::Type*, llvm::PredicatedScalarEvolution&, bool, bool, llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x58449e4)\n#12 0x000000000572a8ce llvm::LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(llvm::VFRange&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x572a8ce)\n#13 0x000000000572dd5a llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x572dd5a)\n#14 0x000000000572e24f llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x572e24f)\n#15 0x000000000573044f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x573044f)\n#16 0x0000000005732a89 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5732a89)\n#17 0x00000000057330c3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x57330c3)\n#18 0x0000000005283abe 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/clang+0x5283abe)\n#19 0x00000000035c8550 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35c8550)\n#20 0x00000000010fa0ee 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/clang+0x10fa0ee)\n#21 0x00000000035c6e6b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35c6e6b)\n#22 0x00000000010f977e 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/clang+0x10f977e)\n#23 0x00000000035c6870 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35c6870)\n#24 0x0000000003eca382 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#25 0x0000000003ecdbfd clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ecdbfd)\n#26 0x000000000459e07e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x459e07e)\n#27 0x000000000655704c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x655704c)\n#28 0x000000000459e458 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x459e458)\n#29 0x0000000004856fc9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4856fc9)\n#30 0x00000000047d989e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47d989e)\n#31 0x000000000494267e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x494267e)\n#32 0x0000000000cb92df cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcb92df)\n#33 0x0000000000cb0d7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#34 0x00000000045e2229 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#35 0x0000000003b64e74 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b64e74)\n#36 0x00000000045e281f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#37 0x00000000045a7f3d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45a7f3d)\n#38 0x00000000045a902d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45a902d)\n#39 0x00000000045b0565 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45b0565)\n#40 0x0000000000cb6123 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcb6123)\n#41 0x0000000000b84564 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xb84564)\n#42 0x000079aa17229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#43 0x000079aa17229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#44 0x0000000000cb0825 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcb0825)\n```\n",
51
+ "author": "cardigan1008",
52
+ "labels": [
53
+ "release:backport",
54
+ "vectorizers",
55
+ "crash",
56
+ "regression:18"
57
+ ],
58
+ "comments": [
59
+ {
60
+ "author": "shafik",
61
+ "body": "Looks like a clang-18 regression: https://godbolt.org/z/K7MMKxjzb"
62
+ },
63
+ {
64
+ "author": "dtcxzyw",
65
+ "body": "Reduced reproducer: https://godbolt.org/z/s4G9Yb1vG\n```\n; bin/opt -passes=\"print<scalar-evolution>,loop-vectorize\" test.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 void @i(ptr %p) {\nentry:\n br label %for.body.i\n\nfor.body.i: ; preds = %for.body.i, %entry\n %0 = phi i32 [ 0, %entry ], [ %inc.i, %for.body.i ]\n %1 = load i32, ptr %p, align 4\n %add.i = add i32 %1, %0\n %inc.i = add i32 %0, 1\n %exitcond.not.i = icmp eq i32 %0, 1\n br i1 %exitcond.not.i, label %for.cond.i.preheader, label %for.body.i\n\nfor.cond.i.preheader: ; preds = %for.body.i\n br label %for.cond.i\n\nfor.cond.i.loopexit: ; preds = %for.body.i1\n br label %for.cond.i\n\nfor.cond.i: ; preds = %for.cond.i.loopexit, %for.cond.i.preheader\n br label %for.body.i1\n\nfor.body.i1: ; preds = %for.body.i1, %for.cond.i\n %indvars.iv.i = phi i64 [ %indvars.iv.next.i, %for.body.i1 ], [ 0, %for.cond.i ]\n %indvars4.i = trunc i64 %indvars.iv.i to i32\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\n %add.reass.i = add i32 %add.i, %indvars4.i\n %cmp.i = icmp slt i32 %add.reass.i, 0\n br i1 %cmp.i, label %for.body.i1, label %for.cond.i.loopexit\n}\n\n```"
66
+ },
67
+ {
68
+ "author": "fhahn",
69
+ "body": "Thanks, let me take a look"
70
+ }
71
+ ]
72
+ },
73
+ "verified": true
74
+ }
dataset/126012.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "126012",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/126012",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "52a02b6d1e0c6b492495ff79a3a06ce93e6180b8",
6
+ "knowledge_cutoff": "2025-02-06T05:45:23Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/IndVarSimplify"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "7aed53eb1982113e825534f0f66d0a0e46e7a5ed",
12
+ "components": [
13
+ "ScalarEvolution"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Analysis/ScalarEvolution.cpp": [
17
+ [
18
+ 12400,
19
+ 12405
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Analysis/ScalarEvolution.cpp": [
25
+ "ScalarEvolution::isImpliedViaMerge"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 7aed53eb1982113e825534f0f66d0a0e46e7a5ed\nAuthor: Nikita Popov <[email protected]>\nDate: Mon Feb 10 10:07:21 2025 +0100\n\n [ScalarEvolution] Handle addrec incoming value in isImpliedViaMerge() (#126236)\n \n The code already guards against values coming from a previous iteration\n using properlyDominates(). However, addrecs are considered to properly\n dominate the loop they are defined in.\n \n Handle this special case separately, by checking for expressions that\n have computable loop evolution (this should cover cases like a zext of\n an addrec as well).\n \n I considered changing the definition of properlyDominates() instead, but\n decided against it. The current definition is useful in other context,\n e.g. when deciding whether an expression is safe to expand in a given\n block.\n \n Fixes https://github.com/llvm/llvm-project/issues/126012.\n\ndiff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp\nindex f89887118d8d..46a5c44f4e41 100644\n--- a/llvm/lib/Analysis/ScalarEvolution.cpp\n+++ b/llvm/lib/Analysis/ScalarEvolution.cpp\n@@ -12400,6 +12400,12 @@ bool ScalarEvolution::isImpliedViaMerge(CmpPredicate Pred, const SCEV *LHS,\n // iteration of a loop.\n if (!properlyDominates(L, LBB))\n return false;\n+ // Addrecs are considered to properly dominate their loop, so are missed\n+ // by the previous check. Discard any values that have computable\n+ // evolution in this loop.\n+ if (auto *Loop = LI.getLoopFor(LBB))\n+ if (hasComputableLoopEvolution(L, Loop))\n+ return false;\n if (!ProvedEasily(L, RHS))\n return false;\n }\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/IndVarSimplify/pr126012.ll",
33
+ "commands": [
34
+ "opt -S -passes=indvars < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define i32 @test() {\nentry:\n br label %for.preheader\n\nfor.preheader: ; preds = %for.inc, %entry\n %indvar1 = phi i32 [ 0, %entry ], [ %phi, %for.inc ]\n %indvar2 = phi i32 [ 1, %entry ], [ %indvar3, %for.inc ]\n %indvar3 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %cond1 = icmp eq i32 %indvar3, 0\n br i1 %cond1, label %for.inc, label %for.end\n\nfor.end: ; preds = %for.preheader\n %cmp = icmp sgt i32 %indvar2, 0\n %ext = zext i1 %cmp to i32\n br label %for.inc\n\nfor.inc: ; preds = %for.end, %for.preheader\n %phi = phi i32 [ %ext, %for.end ], [ 0, %for.preheader ]\n %inc = add i32 %indvar3, 1\n %exitcond = icmp eq i32 %indvar3, 2\n br i1 %exitcond, label %for.exit, label %for.preheader\n\nfor.exit: ; preds = %for.inc\n ret i32 %indvar1\n}\n",
40
+ "additional_args": "-src-unroll=4 -tgt-unroll=4"
41
+ }
42
+ ]
43
+ }
44
+ ],
45
+ "issue": {
46
+ "title": "[IndVarSimplify] Miscompilation at O2",
47
+ "body": "Reproducer: https://alive2.llvm.org/ce/z/UTnMBe\n```\n; bin/opt -passes=indvars 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\[email protected] = constant [4 x i8] c\"%d\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond1.preheader.i.i\n\nfor.cond1.preheader.i.i: ; preds = %for.inc18.i.i, %entry\n %.pre.i.i = phi i64 [ 0, %entry ], [ %1, %for.inc18.i.i ]\n %j.sroa.0.043.i.i = phi i64 [ 1, %entry ], [ %storemerge42.i.i, %for.inc18.i.i ]\n %storemerge42.i.i = phi i64 [ 0, %entry ], [ %inc22.i.i, %for.inc18.i.i ]\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i\n\nfor.end.i.i: ; preds = %for.cond1.preheader.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0\n %dec.348.i.i = add i64 %.pre.i.i, 1\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0\n br label %for.inc18.i.i\n\nfor.inc18.i.i: ; preds = %for.end.i.i, %for.cond1.preheader.i.i\n %1 = phi i64 [ %spec.select.i.i, %for.end.i.i ], [ 0, %for.cond1.preheader.i.i ]\n %inc22.i.i = add i64 %storemerge42.i.i, 1\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i\n\ng.exit: ; preds = %for.inc18.i.i\n %conv = trunc i64 %.pre.i.i to i32\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n```\nBefore:\n```\nEntering function main\n br label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %j.sroa.0.043.i.i -> i64 1\n phi i64 %storemerge42.i.i -> i64 0\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> T\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 0\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 1\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %j.sroa.0.043.i.i -> i64 0\n phi i64 %storemerge42.i.i -> i64 1\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> F\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 1\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 0\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 0\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 2\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %j.sroa.0.043.i.i -> i64 1\n phi i64 %storemerge42.i.i -> i64 2\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 1\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 1\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 1\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 3\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 1\n phi i64 %j.sroa.0.043.i.i -> i64 2\n phi i64 %storemerge42.i.i -> i64 3\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 2\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 2\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 2\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 4\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 2\n phi i64 %j.sroa.0.043.i.i -> i64 3\n phi i64 %storemerge42.i.i -> i64 4\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 3\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 3\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 3\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 5\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 3\n phi i64 %j.sroa.0.043.i.i -> i64 4\n phi i64 %storemerge42.i.i -> i64 5\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 4\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 4\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 4\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 6\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 4\n phi i64 %j.sroa.0.043.i.i -> i64 5\n phi i64 %storemerge42.i.i -> i64 6\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 5\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 5\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 5\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 7\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 5\n phi i64 %j.sroa.0.043.i.i -> i64 6\n phi i64 %storemerge42.i.i -> i64 7\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 6\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 6\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 6\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 8\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 6\n phi i64 %j.sroa.0.043.i.i -> i64 7\n phi i64 %storemerge42.i.i -> i64 8\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 7\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 7\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 7\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 9\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 7\n phi i64 %j.sroa.0.043.i.i -> i64 8\n phi i64 %storemerge42.i.i -> i64 9\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 8\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 8\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 8\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 10\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> T\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %g.exit\n %conv = trunc i64 %.pre.i.i to i32 -> i32 7\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n Printf: 7\n -> i32 2\n ret i32 0\nExiting function main\n```\nAfter:\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\[email protected] = constant [4 x i8] c\"%d\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond1.preheader.i.i\n\nfor.cond1.preheader.i.i: ; preds = %for.inc18.i.i, %entry\n %.pre.i.i = phi i64 [ 0, %entry ], [ %0, %for.inc18.i.i ]\n %storemerge42.i.i = phi i64 [ 0, %entry ], [ %inc22.i.i, %for.inc18.i.i ]\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i\n\nfor.end.i.i: ; preds = %for.cond1.preheader.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0\n br label %for.inc18.i.i\n\nfor.inc18.i.i: ; preds = %for.end.i.i, %for.cond1.preheader.i.i\n %0 = phi i64 [ %spec.select.i.i, %for.end.i.i ], [ 0, %for.cond1.preheader.i.i ]\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i\n\ng.exit: ; preds = %for.inc18.i.i\n %.pre.i.i.lcssa = phi i64 [ %.pre.i.i, %for.inc18.i.i ]\n %conv = trunc i64 %.pre.i.i.lcssa to i32\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n```\n```\nEntering function main\n br label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %storemerge42.i.i -> i64 0\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> T\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 0\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 1\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %storemerge42.i.i -> i64 1\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 1\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 1\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 1\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 2\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 1\n phi i64 %storemerge42.i.i -> i64 2\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 2\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 2\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 2\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 3\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 2\n phi i64 %storemerge42.i.i -> i64 3\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 3\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 3\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 3\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 4\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 3\n phi i64 %storemerge42.i.i -> i64 4\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 4\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 4\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 4\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 5\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 4\n phi i64 %storemerge42.i.i -> i64 5\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 5\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 5\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 5\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 6\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 5\n phi i64 %storemerge42.i.i -> i64 6\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 6\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 6\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 6\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 7\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 6\n phi i64 %storemerge42.i.i -> i64 7\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 7\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 7\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 7\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 8\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 7\n phi i64 %storemerge42.i.i -> i64 8\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 8\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 8\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 8\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 9\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 8\n phi i64 %storemerge42.i.i -> i64 9\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 9\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 9\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 9\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 10\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> T\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %g.exit\n phi i64 %.pre.i.i.lcssa -> i64 8\n %conv = trunc i64 %.pre.i.i.lcssa to i32 -> i32 8\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n Printf: 8\n -> i32 2\n ret i32 0\nExiting function main\n```\nllvm version: 52fc6ffcda0895c0c7b976ad1f5cb5a282b571d2",
48
+ "author": "dtcxzyw",
49
+ "labels": [
50
+ "miscompilation",
51
+ "llvm:SCEV"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "dtcxzyw",
56
+ "body": "Reduced reproducer: https://alive2.llvm.org/ce/z/_x96gs\n```\n; bin/opt -passes=indvars reduced.ll -S --debug\ndefine i32 @src() {\nentry:\n br label %for.preheader\n\nfor.preheader:\n %indvar1 = phi i32 [ 0, %entry ], [ %phi, %for.inc ]\n %indvar2 = phi i32 [ 1, %entry ], [ %indvar3, %for.inc ]\n %indvar3 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %cond1 = icmp eq i32 %indvar3, 0\n br i1 %cond1, label %for.inc, label %for.end\n\nfor.end:\n %cmp = icmp sgt i32 %indvar2, 0\n %ext = zext i1 %cmp to i32\n br label %for.inc\n\nfor.inc:\n %phi = phi i32 [ %ext, %for.end ], [ 0, %for.preheader ]\n %inc = add i32 %indvar3, 1\n %exitcond = icmp eq i32 %indvar3, 2\n br i1 %exitcond, label %for.exit, label %for.preheader\n\nfor.exit:\n ret i32 %indvar1\n}\n\n```\n```\nINDVARS: Eliminated comparison: %cmp = icmp sgt i32 %indvar2, 0\n\ndefine i32 @src() {\nentry:\n br label %for.preheader\n\nfor.preheader: ; preds = %for.inc, %entry\n %indvar1 = phi i32 [ 0, %entry ], [ %phi, %for.inc ]\n %indvar3 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %cond1 = icmp eq i32 %indvar3, 0\n br i1 %cond1, label %for.inc, label %for.end\n\nfor.end: ; preds = %for.preheader\n %ext = zext i1 true to i32\n br label %for.inc\n\nfor.inc: ; preds = %for.end, %for.preheader\n %phi = phi i32 [ %ext, %for.end ], [ 0, %for.preheader ]\n %inc = add nuw nsw i32 %indvar3, 1\n %exitcond = icmp eq i32 %indvar3, 2\n br i1 %exitcond, label %for.exit, label %for.preheader\n\nfor.exit: ; preds = %for.inc\n %indvar1.lcssa = phi i32 [ %indvar1, %for.inc ]\n ret i32 %indvar1.lcssa\n}\n```\n`ScalarEvolution::isImpliedViaMerge(sgt, %indvar2, 0, {0,+,1}<nuw><nsw><%for.preheader>(= %indvar3), 0)` wrongly returns true.\nI can't quite understand why `%indvar3` properly dominates `%for.preheader`: https://github.com/llvm/llvm-project/blob/26ecddb05d13c101ccd840a6710eb5f8b82de841/llvm/lib/Analysis/ScalarEvolution.cpp#L14131-L14141\n\n@nikic @fhahn Can you help fix this issue?\n\n\n"
57
+ },
58
+ {
59
+ "author": "nikic",
60
+ "body": "Related previous fix: https://reviews.llvm.org/D101829"
61
+ }
62
+ ]
63
+ },
64
+ "verified": true
65
+ }
dataset/126181.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "126181",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/126181",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "317a644ae6d501f1a1ec54d17ea8559bcdea35c0",
6
+ "knowledge_cutoff": "2025-02-07T05:51:32Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/DeadStoreElimination"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "2d31a12dbe2339d20844ede70cbb54dbaf4ceea9",
12
+ "components": [
13
+ "DeadStoreElimination"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
17
+ [
18
+ 2283,
19
+ 2289
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
25
+ "DSEState::getInitializesArgMemLoc"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 2d31a12dbe2339d20844ede70cbb54dbaf4ceea9\nAuthor: Nikita Popov <[email protected]>\nDate: Mon Feb 10 10:34:03 2025 +0100\n\n [DSE] Don't use initializes on byval argument (#126259)\n \n There are two ways we can fix this problem, depending on how the\n semantics of byval and initializes should interact:\n \n * Don't infer initializes on byval arguments. initializes on byval\n refers to the original caller memory (or having both attributes is made\n a verifier error).\n * Infer initializes on byval, but don't use it in DSE. initializes on\n byval refers to the callee copy. This matches the semantics of readonly\n on byval. This is slightly more powerful, for example, we could do a\n backend optimization where byval + initializes will allocate the full\n size of byval on the stack but not copy over the parts covered by\n initializes.\n \n I went with the second variant here, skipping byval + initializes in DSE\n (FunctionAttrs already doesn't propagate initializes past byval). I'm\n open to going in the other direction though.\n \n Fixes https://github.com/llvm/llvm-project/issues/126181.\n\ndiff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\nindex 05b4f176bfc3..38454053b039 100644\n--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\n+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\n@@ -2283,7 +2283,9 @@ DSEState::getInitializesArgMemLoc(const Instruction *I) {\n for (unsigned Idx = 0, Count = CB->arg_size(); Idx < Count; ++Idx) {\n ConstantRangeList Inits;\n Attribute InitializesAttr = CB->getParamAttr(Idx, Attribute::Initializes);\n- if (InitializesAttr.isValid())\n+ // initializes on byval arguments refers to the callee copy, not the\n+ // original memory the caller passed in.\n+ if (InitializesAttr.isValid() && !CB->isByValArgument(Idx))\n Inits = InitializesAttr.getValueAsConstantRangeList();\n \n Value *CurArg = CB->getArgOperand(Idx);\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll",
33
+ "commands": [
34
+ "opt < %s -passes=dse -enable-dse-initializes-attr-improvement -S"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test_byval",
39
+ "test_body": "%struct.a = type { i32, i64, i32, i32 }\n\n@e = dso_local global { i32, [4 x i8], i64, i32, i32 } { i32 5, [4 x i8] zeroinitializer, i64 0, i32 1, i32 90986701 }, align 8\n\ndefine i8 @ad(ptr byval(%struct.a) %ah) {\nentry:\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine i64 @af(ptr byval(%struct.a) initializes((0, 24)) %am) {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n\ndefine i32 @main() {\n %res = call i8 @ad(ptr @e)\n %val = sext i8 %res to i32\n ret i32 %val\n}\n",
40
+ "lli_expected_out": ""
41
+ }
42
+ ]
43
+ }
44
+ ],
45
+ "issue": {
46
+ "title": "[FuncAttrs] `initializes` is incorrectly set on parameters with `byval`",
47
+ "body": "Reproducer: https://godbolt.org/z/Mcx1nY4E7\n```\n; bin/opt -passes=function-attrs reduced.ll -S\n%struct.a = type { i32, i64, i32, i32 }\n\n@e = dso_local global { i32, [4 x i8], i64, i32, i32 } { i32 5, [4 x i8] zeroinitializer, i64 0, i32 1, i32 90986701 }, align 8\n\ndefine i8 @ad(ptr byval(%struct.a) %ah) {\nentry:\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine i64 @af(ptr byval(%struct.a) %am) {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n\n```\n```\ndefine i8 @ad(ptr byval(%struct.a) captures(none) initializes((0, 4)) %ah) #0 {\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine noundef i64 @af(ptr writeonly byval(%struct.a) captures(none) initializes((0, 24)) %am) #0 {\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n```\nAfter DSE:\n```\ndefine i8 @ad(ptr byval(%struct.a) captures(none) initializes((0, 4)) %ah) #0 {\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine noundef i64 @af(ptr writeonly byval(%struct.a) captures(none) initializes((0, 24)) %am) #0 {\n ret i64 0\n}\n```\n\nllvm version: d21fc58aeeaa7f0369a24dbe70a0360e0edbf76f\n",
48
+ "author": "dtcxzyw",
49
+ "labels": [
50
+ "miscompilation",
51
+ "llvm:transforms"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "nikic",
56
+ "body": "> We should also emit the padding for %struct.a.\n\nWithout commenting on whether we should or shouldn't, why is not having the padding a miscompile? As this is not a packed struct, for a i64:64 target, LLVM will implicitly insert the padding and it should have the correct size."
57
+ },
58
+ {
59
+ "author": "dtcxzyw",
60
+ "body": "> As this is not a packed struct, for a i64:64 target, LLVM will implicitly insert the padding and it should have the correct size.\n\nSorry. It is a DSE bug.\n"
61
+ },
62
+ {
63
+ "author": "dtcxzyw",
64
+ "body": "cc @haopliu "
65
+ },
66
+ {
67
+ "author": "nikic",
68
+ "body": "@dtcxzyw I think your new IR is over-reduced. You have `initializes((0, 24)` on `@af`, so I think eliminating the store is correct."
69
+ },
70
+ {
71
+ "author": "dtcxzyw",
72
+ "body": "> [@dtcxzyw](https://github.com/dtcxzyw) I think your new IR is over-reduced. You have `initializes((0, 24)` on `@af`, so I think eliminating the store is correct.\n\nFixed."
73
+ },
74
+ {
75
+ "author": "nikic",
76
+ "body": "There are two ways we can fix this, depending on what we want the semantics to do:\n\n 1. Don't infer initializes on byval arguments. initializes on byval refers to the original caller memory (or having both attributes is made a verifier error).\n 2. Infer initializes on byval, but don't use it in DSE. initializes on byval refers to the callee copy. This matches the semantics of readonly on byval.\n\nI think variant 2 is marginally more powerful. For example, we could do a backend optimization where byval + initializes will allocate the full size of byval on the stack but not copy over the parts covered by initializes."
77
+ }
78
+ ]
79
+ },
80
+ "verified": true
81
+ }
scripts/postfix_extract.py CHANGED
@@ -117,6 +117,7 @@ fix_commit_map = {
117
  "125369": None, # Reverted
118
  "125374": None, # Duplicate of #119173
119
  "125400": None, # Reverted
 
120
  }
121
 
122
  if issue_id in fix_commit_map:
 
117
  "125369": None, # Reverted
118
  "125374": None, # Duplicate of #119173
119
  "125400": None, # Reverted
120
+ "126409": None, # Reverted
121
  }
122
 
123
  if issue_id in fix_commit_map: