Datasets:

Modalities:
Text
Formats:
json
Size:
< 1K
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
dtcxzyw commited on
Commit
9d95ddd
·
1 Parent(s): d9acdca
dataset.jsonl CHANGED
@@ -111,6 +111,7 @@
111
  {"bug_id": "115465", "issue_url": "https://github.com/llvm/llvm-project/issues/115465", "bug_type": "miscompilation", "base_commit": "d822c099eeacc69f6bf834a6373a41d0c9f84a3e", "knowledge_cutoff": "2024-11-08T11:25:34Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "27bf45aa36386136db179c494358670a994a98a5", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": [[2904, 2910]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": ["InstCombinerImpl::visitShuffleVectorInst"]}}, "patch": "commit 27bf45aa36386136db179c494358670a994a98a5\nAuthor: Yingwei Zheng <[email protected]>\nDate: Sun Nov 10 17:07:25 2024 +0800\n\n [InstCombine] Fix poison safety of folding shufflevector into select (#115483)\n \n We are allowed to fold shufflevector into select iff the condition is\n guaranteed not to be poison or the RHS is a poison.\n Alive2: https://alive2.llvm.org/ce/z/28zEWR\n \n Closes https://github.com/llvm/llvm-project/issues/115465.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp\nindex 454fe5a91d37..ede89b099e8d 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp\n@@ -2904,7 +2904,9 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {\n if (auto *SI = dyn_cast<SelectInst>(LHS)) {\n // We cannot do this fold for elementwise select since ShuffleVector is\n // not elementwise.\n- if (SI->getCondition()->getType()->isIntegerTy()) {\n+ if (SI->getCondition()->getType()->isIntegerTy() &&\n+ (isa<PoisonValue>(RHS) ||\n+ isGuaranteedNotToBePoison(SI->getCondition()))) {\n if (Instruction *I = FoldOpIntoSelect(SVI, SI))\n return I;\n }\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/vec_shuffle.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "shuf_cmp_may_be_poison", "test_body": "define <4 x i8> @shuf_cmp_may_be_poison(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\n %sel = select i1 %cmp, <4 x i8> %y, <4 x i8> <i8 0, i8 poison, i8 0, i8 poison>\n %shuf = shufflevector <4 x i8> %sel, <4 x i8> <i8 poison, i8 1, i8 poison, i8 3>, <4 x i32> <i32 0, i32 5, i32 2, i32 7>\n ret <4 x i8> %shuf\n}\n"}, {"test_name": "shuf_same_length_vec_select", "test_body": "define <4 x i32> @shuf_same_length_vec_select(<4 x i1> %cond) {\n %sel = select <4 x i1> %cond, <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> <i32 4, i32 5, i32 6, i32 7>\n %shuf = shufflevector <4 x i32> %sel, <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32> <i32 2, i32 1, i32 3, i32 5>\n ret <4 x i32> %shuf\n}\n"}]}], "issue": {"title": "[InstCombine] folded select produces different result on a blended vector", "body": "Alive2 report: https://alive2.llvm.org/ce/z/73v-ug\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine <4 x i8> @sel_shuf_commute3.2(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\r\n#0:\r\n %blend = shufflevector <4 x i8> { 0, 0, 0, 0 }, <4 x i8> %y, 0, 5, 2, 3\r\n %r = select i1 %cmp, <4 x i8> %y, <4 x i8> %blend\r\n %#1 = select <4 x i1> { 0, 1, 0, 1 }, <4 x i8> { 0, 1, 2, 3 }, <4 x i8> %r\r\n ret <4 x i8> %#1\r\n}\r\n=>\r\ndefine <4 x i8> @sel_shuf_commute3.2(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\r\n#0:\r\n %#1 = shufflevector <4 x i8> %y, <4 x i8> { poison, 1, poison, 3 }, 0, 5, 2, 7\r\n %#2 = select i1 %cmp, <4 x i8> %#1, <4 x i8> { 0, 1, 0, 3 }\r\n ret <4 x i8> %#2\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\n<4 x i8> %x = < poison, poison, poison, poison >\r\n<4 x i8> %y = < poison, poison, poison, poison >\r\ni1 %cmp = poison\r\n\r\nSource:\r\n<4 x i8> %blend = < #x00 (0), poison, #x00 (0), #x00 (0) >\r\n<4 x i8> %r = < poison, poison, poison, poison >\r\n<4 x i8> %#1 = < poison, #x01 (1), poison, #x03 (3) >\r\n\r\nTarget:\r\n<4 x i8> %#1 = < poison, #x01 (1), poison, #x03 (3) >\r\n<4 x i8> %#2 = < poison, poison, poison, poison >\r\nSource value: < poison, #x01 (1), poison, #x03 (3) >\r\nTarget value: < poison, poison, poison, poison >\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```\r\n", "author": "bongjunj", "labels": ["miscompilation", "llvm:instcombine"], "comments": []}, "verified": true}
112
  {"bug_id": "112666", "issue_url": "https://github.com/llvm/llvm-project/issues/112666", "bug_type": "miscompilation", "base_commit": "d6d73ec89e493c69cf24dc3a710d861e2ce08acb", "knowledge_cutoff": "2024-10-17T06:28:53Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "ff07df6620c32571c7e13ff96ec7976c63ed0ab8", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": [[333, 338]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": ["Negator::visitImpl"]}}, "patch": "commit ff07df6620c32571c7e13ff96ec7976c63ed0ab8\nAuthor: Yingwei Zheng <[email protected]>\nDate: Fri Nov 8 16:20:04 2024 +0800\n\n [InstCombine] Drop nsw in negation of select (#112893)\n \n Closes https://github.com/llvm/llvm-project/issues/112666 and\n https://github.com/llvm/llvm-project/issues/114181.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp\nindex 9bd848552615..2210336d92bf 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp\n@@ -333,6 +333,17 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) {\n NewSelect->swapValues();\n // Don't swap prof metadata, we didn't change the branch behavior.\n NewSelect->setName(I->getName() + \".neg\");\n+ // Poison-generating flags should be dropped\n+ Value *TV = NewSelect->getTrueValue();\n+ Value *FV = NewSelect->getFalseValue();\n+ if (match(TV, m_Neg(m_Specific(FV))))\n+ cast<Instruction>(TV)->dropPoisonGeneratingFlags();\n+ else if (match(FV, m_Neg(m_Specific(TV))))\n+ cast<Instruction>(FV)->dropPoisonGeneratingFlags();\n+ else {\n+ cast<Instruction>(TV)->dropPoisonGeneratingFlags();\n+ cast<Instruction>(FV)->dropPoisonGeneratingFlags();\n+ }\n Builder.Insert(NewSelect);\n return NewSelect;\n }\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/sub-of-negatible.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "negate_select_of_op_vs_negated_op_nsw_commuted", "test_body": "define i8 @negate_select_of_op_vs_negated_op_nsw_commuted(i8 %x, i8 %y, i1 %c) {\n %t0 = sub nsw i8 0, %x\n %t1 = select i1 %c, i8 %x, i8 %t0\n %t2 = sub i8 %y, %t1\n ret i8 %t2\n}\n"}, {"test_name": "negate_select_of_op_vs_negated_op_nsw", "test_body": "define i8 @negate_select_of_op_vs_negated_op_nsw(i8 %x, i8 %y, i1 %c) {\n %t0 = sub nsw i8 0, %x\n %t1 = select i1 %c, i8 %t0, i8 %x\n %t2 = sub i8 %y, %t1\n ret i8 %t2\n}\n"}, {"test_name": "dont_negate_ordinary_select", "test_body": "define i8 @dont_negate_ordinary_select(i8 %x, i8 %y, i8 %z, i1 %c) {\n %t0 = select i1 %c, i8 %x, i8 %y\n %t1 = sub i8 %z, %t0\n ret i8 %t1\n}\n"}, {"test_name": "negate_select_of_op_vs_negated_op_nsw_xyyx", "test_body": "define i8 @negate_select_of_op_vs_negated_op_nsw_xyyx(i8 %x, i8 %y, i8 %z, i1 %c) {\n %sub1 = sub nsw i8 %x, %y\n %sub2 = sub nsw i8 %y, %x\n %t1 = select i1 %c, i8 %sub1, i8 %sub2\n %t2 = sub i8 %z, %t1\n ret i8 %t2\n}\n"}, {"test_name": "negate_select_of_op_vs_negated_op", "test_body": "declare void @use8(i8)\n\ndefine i8 @negate_select_of_op_vs_negated_op(i8 %x, i8 %y, i1 %c) {\n %t0 = sub i8 0, %x\n call void @use8(i8 %t0)\n %t1 = select i1 %c, i8 %t0, i8 %x, !prof !0\n %t2 = sub i8 %y, %t1\n ret i8 %t2\n}\n\n!0 = !{!\"branch_weights\", i32 40, i32 1}\n"}]}], "issue": {"title": "[InstCombine] `nsw` flag should be dropped in Negator", "body": "Reproducer: https://alive2.llvm.org/ce/z/ZFF_QK\r\n```\r\ndefine i8 @src(i8 %x, i8 %y, i1 %c) {\r\n %t0 = sub nsw i8 0, %x\r\n %t1 = select i1 %c, i8 %t0, i8 %x\r\n %t2 = sub i8 %y, %t1\r\n ret i8 %t2\r\n}\r\n\r\ndefine i8 @tgt(i8 %x, i8 %y, i1 %c) {\r\n %t0 = sub nsw i8 0, %x\r\n %1 = select i1 %c, i8 %x, i8 %t0\r\n %t2 = add i8 %1, %y\r\n ret i8 %t2\r\n}\r\n```\r\n```\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\ni8 %x = #x80 (128, -128)\r\ni8 %y = #x00 (0)\r\ni1 %c = #x0 (0)\r\n\r\nSource:\r\ni8 %t0 = poison\r\ni8 %t1 = #x80 (128, -128)\r\ni8 %t2 = #x80 (128, -128)\r\n\r\nTarget:\r\ni8 %t0 = poison\r\ni8 %#1 = poison\r\ni8 %t2 = poison\r\nSource value: #x80 (128, -128)\r\nTarget value: poison\r\n```", "author": "dtcxzyw", "labels": ["miscompilation", "llvm:instcombine"], "comments": [{"author": "AZero13", "body": "Is this an issue in 19.x or just main?"}, {"author": "AZero13", "body": "Confirmed this issue exists in 19.x"}]}, "verified": true}
113
  {"bug_id": "116775", "issue_url": "https://github.com/llvm/llvm-project/issues/116775", "bug_type": "crash", "base_commit": "bdf00e2216280edef1ec91ccc07987db92197b59", "knowledge_cutoff": "2024-11-19T09:53:12Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "03d8831fa8ef5b7e32172c718b550a454645faea", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [[997, 1003]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": ["InstCombinerImpl::SimplifyDemandedUseBits"]}}, "patch": "commit 03d8831fa8ef5b7e32172c718b550a454645faea\nAuthor: Yingwei Zheng <[email protected]>\nDate: Tue Nov 19 22:17:24 2024 +0800\n\n [InstCombine] Handle constant GEP expr in `SimplifyDemandedUseBits` (#116794)\n \n Closes https://github.com/llvm/llvm-project/issues/116775.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\nindex 5eb807dcb76c..392c5c78345c 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\n@@ -997,7 +997,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,\n uint64_t MaskedGEPIndex = HighBitsGEPIndex | MaskedLowBitsGEPIndex;\n \n if (MaskedGEPIndex != GEPIndex) {\n- auto *GEP = cast<GetElementPtrInst>(II->getArgOperand(0));\n+ auto *GEP = cast<GEPOperator>(II->getArgOperand(0));\n Builder.SetInsertPoint(I);\n Type *GEPIndexType =\n DL.getIndexType(GEP->getPointerOperand()->getType());\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/ptrmask.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "ptrmask_demandedbits_constantexpr", "test_body": "target datalayout = \"p1:64:64:64:32\"\n\n@GC_arrays = external global { i8, i8, i64 }\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare ptr @llvm.ptrmask.p0.i64(ptr, i64) #0\n\ndefine ptr @ptrmask_demandedbits_constantexpr() {\nentry:\n %aligned_result = call ptr @llvm.ptrmask.p0.i64(ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 1), i64 -8)\n ret ptr %aligned_result\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "ptrmask_is_useless_fail1", "test_body": "target datalayout = \"p1:64:64:64:32\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare ptr @llvm.ptrmask.p0.i64(ptr, i64) #0\n\ndefine ptr @ptrmask_is_useless_fail1(i64 %i, i64 %m) {\n %m0 = and i64 %m, 127\n %i0 = and i64 %i, 511\n %p0 = inttoptr i64 %i0 to ptr\n %r = call ptr @llvm.ptrmask.p0.i64(ptr %p0, i64 %m0)\n ret ptr %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}]}], "issue": {"title": "Segfault when building https://github.com/ivmai/bdwgc@4fe4238", "body": "Attempting to build [https://github.com/ivmai/bdwgc@4fe4238](https://github.com/ivmai/bdwgc/tree/4fe42389509ff059bad8d4c955a570b34a6bda4b) using\r\n```shell\r\n$ ./autogen.sh\r\n$ ./configure --with-libatomic-ops --enable-cplusplus --enable-large-config\r\n$ make\r\n```\r\nresults in\r\n```text\r\nlibtool: compile: clang -std=gnu23 -DHAVE_CONFIG_H -I./include -I./include -DNDEBUG -fexceptions -DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden -Wall -Wextra -Wpedantic -Wno-long-long -O2 -march=native -Wno-frame-address -MT extra/gc.lo -MD -MP -MF extra/.deps/gc.Tpo -c extra/gc.c -fno-common -DPIC -o extra/.libs/gc.o\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: clang -std=gnu23 -DHAVE_CONFIG_H -I./include -I./include -DNDEBUG -fexceptions -DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden -Wall -Wextra -Wpedantic -Wno-long-long -O2 -march=native -Wno-frame-address -MT extra/gc.lo -MD -MP -MF extra/.deps/gc.Tpo -c extra/gc.c -fno-common -DPIC -o extra/.libs/gc.o\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,simple-loop-unswitch<no-nontrivial;trivial>,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide)),function(invalidate<should-not-run-function-passes>),cgscc(devirt<4>())\" on module \"extra/gc.c\"\r\n4.\tRunning pass \"cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,simple-loop-unswitch<no-nontrivial;trivial>,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide))\" on module \"extra/gc.c\"\r\n5.\tRunning pass \"instcombine<max-iterations=1;no-verify-fixpoint>\" on function \"GC_push_finalizer_structures\"\r\n #0 0x0000000112ecda98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3299a98)\r\n #1 0x0000000112eccb47 llvm::sys::RunSignalHandlers() (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3298b47)\r\n #2 0x0000000112eccde1 llvm::sys::CleanupOnSignal(unsigned long) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3298de1)\r\n #3 0x0000000112df2644 CrashRecoverySignalHandler(int) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31be644)\r\n #4 0x00007ff81abe4fdd (/usr/lib/system/libsystem_platform.dylib+0x7ff80046afdd)\r\n #5 0x0000000112e1d131 computeForAddCarry(llvm::KnownBits const&, llvm::KnownBits const&, bool, bool) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31e9131)\r\n #6 0x0000000112318cdd llvm::TargetFolder::FoldGEP(llvm::Type*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::GEPNoWrapFlags) const (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26e4cdd)\r\n #7 0x00000001102d2177 llvm::IRBuilderBase::CreateGEP(llvm::Type*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::GEPNoWrapFlags) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x69e177)\r\n #8 0x000000011209545a llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Instruction*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x246145a)\r\n #9 0x0000000112097524 llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(llvm::Instruction&, llvm::KnownBits&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2463524)\r\n#10 0x0000000111ffc58b llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x23c858b)\r\n#11 0x0000000111f85788 llvm::InstCombinerImpl::run() (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2351788)\r\n#12 0x0000000111f765e2 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x23425e2)\r\n#13 0x0000000111fc1b85 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x238db85)\r\n#14 0x0000000110596272 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x962272)\r\n#15 0x0000000112b6736a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f3336a)\r\n#16 0x000000011003f522 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/llvm-project@HEAD/lib/libLLVM.dylib+0x40b522)\r\n#17 0x00000001122fe7db llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26ca7db)\r\n#18 0x0000000110b41712 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0d712)\r\n#19 0x00000001122fa573 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c6573)\r\n#20 0x0000000110b3e332 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0a332)\r\n#21 0x00000001122fcc0e llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c8c0e)\r\n#22 0x0000000110b413a2 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0d3a2)\r\n#23 0x00000001122fbe83 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c7e83)\r\n#24 0x0000000110b3e012 llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0a012)\r\n#25 0x0000000112b65a22 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f31a22)\r\n#26 0x0000000110d25d8b llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x10f1d8b)\r\n#27 0x0000000110594012 llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x960012)\r\n#28 0x0000000112b65a22 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f31a22)\r\n#29 0x000000010788b478 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>&, std::__1::unique_ptr<llvm::ToolOutputFile, std::__1::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x172d478)\r\n#30 0x0000000107883b08 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::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1725b08)\r\n#31 0x0000000107d037d3 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1ba57d3)\r\n#32 0x000000010635df1d clang::ParseAST(clang::Sema&, bool, bool) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1fff1d)\r\n#33 0x000000010877f3d7 clang::FrontendAction::Execute() (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x26213d7)\r\n#34 0x00000001086e0500 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2582500)\r\n#35 0x00000001087f60e9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x26980e9)\r\n#36 0x000000010128d4f9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/llvm-project@HEAD/bin/clang-20+0x1000084f9)\r\n#37 0x0000000101289f88 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/opt/llvm-project@HEAD/bin/clang-20+0x100004f88)\r\n#38 0x00000001082b552e void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x215752e)\r\n#39 0x0000000112df288c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31be88c)\r\n#40 0x00000001082b5431 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2157431)\r\n#41 0x0000000108262131 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2104131)\r\n#42 0x00000001082623bf clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x21043bf)\r\n#43 0x00000001082b00c0 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x21520c0)\r\n#44 0x00000001012892b3 clang_main(int, char**, llvm::ToolContext const&) (/opt/llvm-project@HEAD/bin/clang-20+0x1000042b3)\r\n#45 0x00000001012984cb main (/opt/llvm-project@HEAD/bin/clang-20+0x1000134cb)\r\n#46 0x00007ff81a82a345 \r\nclang: error: clang frontend command failed with exit code 139 (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git c25c6c32494c8d1038438b6208d42ba40f25270e)\r\nTarget: x86_64-apple-darwin23.6.0\r\nThread model: posix\r\nInstalledDir: /opt/llvm-project@HEAD/bin\r\nclang: note: diagnostic msg: \r\n********************\r\n```\r\n\r\nFind attached the preprocessed source code at [gc-add69e.c.gz](https://github.com/user-attachments/files/17813033/gc-add69e.c.gz).", "author": "d125q", "labels": ["llvm:instcombine", "crash-on-valid"], "comments": [{"author": "dtcxzyw", "body": "Reproducer: https://godbolt.org/z/Ts478aen6\r\n```\r\n; bin/opt -passes=instcombine test.ll -S\r\n@GC_arrays = external global { i8, i8, i64 }\r\n\r\ndefine ptr @GC_push_finalizer_structures() {\r\nentry:\r\n %aligned_result.i = call ptr @llvm.ptrmask.p0.i64(ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 1), i64 -8)\r\n ret ptr %aligned_result.i\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::GetElementPtrInst; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\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: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=instcombine <source>\r\n1.\tRunning pass \"function(instcombine<max-iterations=1;verify-fixpoint>)\" on module \"<source>\"\r\n2.\tRunning pass \"instcombine<max-iterations=1;verify-fixpoint>\" on function \"GC_push_finalizer_structures\"\r\n #0 0x0000000005194b38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5194b38)\r\n #1 0x000000000519252c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000074b7d8442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000074b7d84969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000074b7d8442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000074b7d84287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000074b7d842871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000074b7d8439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000040d9310 decltype(auto) llvm::cast<llvm::GetElementPtrInst, llvm::Value>(llvm::Value*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40d9310)\r\n #9 0x00000000040e2f9e llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Instruction*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40e2f9e)\r\n#10 0x00000000040e6082 llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(llvm::Instruction&, llvm::KnownBits&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40e6082)\r\n#11 0x00000000040355a6 llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40355a6)\r\n#12 0x0000000003fe2311 llvm::InstCombinerImpl::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe2311)\r\n#13 0x0000000003fe3cc6 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) (.isra.0) InstructionCombining.cpp:0:0\r\n#14 0x0000000003fe504e llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe504e)\r\n#15 0x0000000002c5c24e llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2c5c24e)\r\n#16 0x0000000004f949e8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f949e8)\r\n#17 0x0000000000e4027e 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+0xe4027e)\r\n#18 0x0000000004f9340e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f9340e)\r\n#19 0x0000000000e3f92e 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+0xe3f92e)\r\n#20 0x0000000004f92e40 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f92e40)\r\n#21 0x0000000000909fda 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+0x909fda)\r\n#22 0x00000000008fc70a optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fc70a)\r\n#23 0x000074b7d8429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#24 0x000074b7d8429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#25 0x00000000008f3e9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f3e9e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```"}]}, "verified": true}
 
114
  {"bug_id": "120433", "issue_url": "https://github.com/llvm/llvm-project/issues/120433", "bug_type": "crash", "base_commit": "ac8a9f8fffb605514056f53f12f1fba94ee933e9", "knowledge_cutoff": "2024-12-18T15:02:42Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "e7a4d78ad328d02bf515b2fa4af8b2c188a6a636", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[21148, 21155]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["SLPVectorizerPass::vectorizeCmpInsts"]}}, "patch": "commit e7a4d78ad328d02bf515b2fa4af8b2c188a6a636\nAuthor: DianQK <[email protected]>\nDate: Thu Dec 19 06:21:57 2024 +0800\n\n [SLP] Check if instructions exist after vectorization (#120434)\n \n Fixes #120433.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex d967813075bb..88049897b29a 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -21148,8 +21148,11 @@ bool SLPVectorizerPass::vectorizeCmpInsts(iterator_range<ItT> CmpInsts,\n if (R.isDeleted(I))\n continue;\n for (Value *Op : I->operands())\n- if (auto *RootOp = dyn_cast<Instruction>(Op))\n+ if (auto *RootOp = dyn_cast<Instruction>(Op)) {\n Changed |= vectorizeRootInstruction(nullptr, RootOp, BB, R);\n+ if (R.isDeleted(I))\n+ break;\n+ }\n }\n // Try to vectorize operands as vector bundles.\n for (CmpInst *I : CmpInsts) {\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/slp-deleted-inst.ll", "commands": ["opt -S -passes=slp-vectorizer < %s"], "tests": [{"test_name": "foo", "test_body": "define void @foo() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb3, %bb\n %i = phi i32 [ %i26, %bb3 ], [ 0, %bb ]\n %i2 = phi i32 [ %i24, %bb3 ], [ 0, %bb ]\n br label %bb3\n\nbb3: ; preds = %bb1\n %i4 = zext i32 %i2 to i64\n %i5 = mul i64 %i4, 0\n %i10 = or i64 0, %i5\n %i11 = trunc i64 %i10 to i32\n %i12 = and i32 %i11, 0\n %i13 = zext i32 %i to i64\n %i14 = mul i64 %i13, 0\n %i19 = or i64 0, %i14\n %i20 = trunc i64 %i19 to i32\n %i21 = and i32 %i20, 0\n %i22 = or i32 %i12, %i21\n %i23 = icmp ult i32 %i22, 0\n %i24 = select i1 %i23, i32 0, i32 0\n %i25 = icmp ult i32 0, 0\n %i26 = select i1 %i25, i32 0, i32 0\n br label %bb1\n}\n"}]}], "issue": {"title": "[SLP] Assertion `detail::isPresent(Val) && \"dyn_cast on a non-existent value\"' failed.", "body": "This IR crashes on SLP: https://llvm.godbolt.org/z/8oar4o4d1\n\n```llvm\ndefine void @foo() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb3, %bb\n %i = phi i32 [ %i26, %bb3 ], [ 0, %bb ]\n %i2 = phi i32 [ %i24, %bb3 ], [ 0, %bb ]\n br label %bb3\n\nbb3: ; preds = %bb1\n %i4 = zext i32 %i2 to i64\n %i5 = mul i64 %i4, 0\n %i10 = or i64 0, %i5\n %i11 = trunc i64 %i10 to i32\n %i12 = and i32 %i11, 0\n %i13 = zext i32 %i to i64\n %i14 = mul i64 %i13, 0\n %i19 = or i64 0, %i14\n %i20 = trunc i64 %i19 to i32\n %i21 = and i32 %i20, 0\n %i22 = or i32 %i12, %i21\n %i23 = icmp ult i32 %i22, 0\n %i24 = select i1 %i23, i32 0, i32 0\n %i25 = icmp ult i32 0, 0\n %i26 = select i1 %i25, i32 0, i32 0\n br label %bb1\n}\n```", "author": "DianQK", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": []}, "verified": true}
115
  {"bug_id": "87856", "issue_url": "https://github.com/llvm/llvm-project/issues/87856", "bug_type": "crash", "base_commit": "b17d44558ba4c30a3005089b334f68593d6a9c7c", "knowledge_cutoff": "2024-04-06T02:19:05Z", "lit_test_dir": ["llvm/test/Transforms/Attributor"], "hints": {"fix_commit": "2d61692d4b75b7d92b44bfafb1011c1723955151", "components": ["Attributor"], "bug_location_lineno": {"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": [[5899, 5908]]}, "bug_location_funcname": {"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": ["AANoCaptureImpl::updateImpl"]}}, "patch": "commit 2d61692d4b75b7d92b44bfafb1011c1723955151\nAuthor: Matt Arsenault <[email protected]>\nDate: Thu May 23 19:31:33 2024 +0200\n\n Attributor: Do not assume function context in AANoCapture (#91462)\n \n If the calling function has the null_pointer_is_valid attribute, somehow\n a null constant reaches here. I'm not sure why exactly, it doesn't\n happen for other types of constants.\n \n Fixes #87856\n\ndiff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp\nindex 41b66aafe7d3..1b3bf3c732ed 100644\n--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp\n+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp\n@@ -5690,6 +5690,9 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,\n return V.use_empty();\n \n // You cannot \"capture\" null in the default address space.\n+ //\n+ // FIXME: This should use NullPointerIsDefined to account for the function\n+ // attribute.\n if (isa<UndefValue>(V) || (isa<ConstantPointerNull>(V) &&\n V.getType()->getPointerAddressSpace() == 0)) {\n return true;\n@@ -5899,10 +5902,13 @@ ChangeStatus AANoCaptureImpl::updateImpl(Attributor &A) {\n \n const Function *F =\n isArgumentPosition() ? IRP.getAssociatedFunction() : IRP.getAnchorScope();\n- assert(F && \"Expected a function!\");\n- const IRPosition &FnPos = IRPosition::function(*F);\n+\n+ // TODO: Is the checkForAllUses below useful for constants?\n+ if (!F)\n+ return indicatePessimisticFixpoint();\n \n AANoCapture::StateType T;\n+ const IRPosition &FnPos = IRPosition::function(*F);\n \n // Readonly means we cannot capture through memory.\n bool IsKnown;\n", "tests": [{"file": "llvm/test/Transforms/Attributor/issue87856.ll", "commands": ["opt -S -passes=attributor < %s"], "tests": [{"test_name": "<module>", "test_body": "\ndefine void @null_ptr_is_valid_call_with_null() #0 {\n;\n call void @store_as0(ptr null)\n ret void\n}\n\ndefine void @null_ptr_is_valid_call_with_undef() #0 {\n;\n call void @store_as0(ptr undef)\n ret void\n}\n\ndefine void @store_as0(ptr %0) {\n;\n store i16 0, ptr %0, align 2\n ret void\n}\n\ndefine void @call_store_as1() {\n;\n call void @store_as1(ptr addrspace(1) null)\n ret void\n}\n\ndefine void @store_as1(ptr addrspace(1) %arg) {\n;\n store i16 0, ptr addrspace(1) %arg, align 2\n ret void\n}\n\nattributes #0 = { null_pointer_is_valid }\n;.\n;."}]}], "issue": {"title": "[attributor] Crash on `null_pointer_is_valid` function", "body": "With\r\n\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"aarch64-none-linux-android28\"\r\n\r\n; Function Attrs: null_pointer_is_valid\r\ndefine i64 @foo() #0 {\r\n call fastcc void @bar(ptr null)\r\n ret i64 0\r\n}\r\n\r\ndefine fastcc void @bar(ptr %0) {\r\n store i16 0, ptr %0, align 2\r\n ret void\r\n}\r\n\r\nattributes #0 = { null_pointer_is_valid }\r\n```\r\n\r\nand running\r\n\r\n```\r\nopt -passes=attributor file.ll\r\n```\r\n\r\nwe crash with\r\n\r\n```\r\nopt: llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:5901: virtual ChangeStatus (anonymous namespace)::AANoCaptureImpl::updateImpl(Attributor &): Assertion `F && \"Expected a function!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: opt -passes=attributor reduced.ll\r\n #0 0x000000000165bf38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project/build/Release/bin/opt+0x165bf38)\r\n #1 0x0000000001659a40 llvm::sys::RunSignalHandlers() (llvm-project/build/Release/bin/opt+0x1659a40)\r\n #2 0x000000000165c938 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f3ec923e6f0 __restore_rt (/lib64/libc.so.6+0x3e6f0)\r\n #4 0x00007f3ec928b94c __pthread_kill_implementation (/lib64/libc.so.6+0x8b94c)\r\n #5 0x00007f3ec923e646 gsignal (/lib64/libc.so.6+0x3e646)\r\n #6 0x00007f3ec92287f3 abort (/lib64/libc.so.6+0x287f3)\r\n #7 0x00007f3ec922871b _nl_load_domain.cold (/lib64/libc.so.6+0x2871b)\r\n #8 0x00007f3ec9237386 (/lib64/libc.so.6+0x37386)\r\n #9 0x0000000002f2a65b (anonymous namespace)::AANoCaptureImpl::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0\r\n#10 0x0000000002ec8492 llvm::AbstractAttribute::update(llvm::Attributor&) (llvm-project/build/Release/bin/opt+0x2ec8492)\r\n#11 0x0000000002ed3b83 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (llvm-project/build/Release/bin/opt+0x2ed3b83)\r\n#12 0x0000000002eec289 llvm::AANoCapture const* llvm::Attributor::getOrCreateAAFor<llvm::AANoCapture>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) Attributor.cpp:0:0\r\n#13 0x0000000002f1ab57 (anonymous namespace)::AANoAliasCallSiteArgument::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0\r\n#14 0x0000000002ec8492 llvm::AbstractAttribute::update(llvm::Attributor&) (llvm-project/build/Release/bin/opt+0x2ec8492)\r\n#15 0x0000000002ed3b83 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (llvm-project/build/Release/bin/opt+0x2ed3b83)\r\n#16 0x0000000002efba19 llvm::AANoAlias const* llvm::Attributor::getOrCreateAAFor<llvm::AANoAlias>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) Attributor.cpp:0:0\r\n#17 0x0000000002ede880 void llvm::Attributor::checkAndQueryIRAttr<(llvm::Attribute::AttrKind)20, llvm::AANoAlias>(llvm::IRPosition const&, llvm::AttributeSet) (llvm-project/build/Release/bin/opt+0x2ede880)\r\n#18 0x0000000002edd545 llvm::Attributor::identifyDefaultAbstractAttributes(llvm::Function&) (llvm-project/build/Release/bin/opt+0x2edd545)\r\n#19 0x0000000002ee0800 runAttributorOnFunctions(llvm::InformationCache&, llvm::SetVector<llvm::Function*, llvm::SmallVector<llvm::Function*, 0u>, llvm::DenseSet<llvm::Function*, llvm::DenseMapInfo<llvm::Function*, void>>, 0u>&, llvm::AnalysisGetter&, llvm::CallGraphUpdater&, bool, bool) Attributor.cpp:0:0\r\n#20 0x0000000002edfc41 llvm::AttributorPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/Release/bin/opt+0x2edfc41)\r\n#21 0x0000000002b6fcdd llvm::detail::PassModel<llvm::Module, llvm::AttributorPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0\r\n#22 0x0000000001853e56 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/Release/bin/opt+0x1853e56)\r\n#23 0x0000000002afaa4b 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) (llvm-project/build/Release/bin/opt+0x2afaa4b)\r\n#24 0x0000000001622f36 optMain (llvm-project/build/Release/bin/opt+0x1622f36)\r\n```", "author": "lanza", "labels": ["crash-on-valid", "llvm::Attributor"], "comments": [{"author": "lanza", "body": "https://github.com/llvm/llvm-project/blob/0f52f4ddd909eb38f2a691ffed8469263fe5f635/llvm/lib/Transforms/IPO/AttributorAttributes.cpp#L5901"}, {"author": "dtcxzyw", "body": "cc @arsenm "}, {"author": "arsenm", "body": "Just returning on the null function seems to work, but I don't understand exactly why it reaches here. AANoCapture::isImpliedByIR is incorrectly reimplementing NullPointerIsDefined but fixing that doesn't seem to help any "}]}, "verified": true}
116
  {"bug_id": "119173", "issue_url": "https://github.com/llvm/llvm-project/issues/119173", "bug_type": "miscompilation", "base_commit": "ab77db03ce28e86a61010e51ea13796ea09efc46", "knowledge_cutoff": "2024-12-09T07:19:06Z", "lit_test_dir": ["llvm/test/Transforms/LoopVectorize"], "hints": {"fix_commit": "30f3752e54fa7cd595a434a985efbe9a7abe9b65", "components": ["LoopVectorize"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [[6637, 6644], [8588, 8593]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": ["LoopVectorizationCostModel::getInstructionCost", "VPRecipeBuilder::tryToWiden"]}}, "patch": "commit 30f3752e54fa7cd595a434a985efbe9a7abe9b65\nAuthor: Florian Hahn <[email protected]>\nDate: Mon Feb 3 17:01:02 2025 +0000\n\n [VPlan] Only use SCEV for live-ins in tryToWiden. (#125436)\n \n Replacing a recipe with a live-in may not be correct in all cases,\n e.g. when replacing recipes involving header-phi recipes, like\n reductions.\n \n For now, only use SCEV to simplify live-ins.\n \n More powerful input simplification can be built in top of\n https://github.com/llvm/llvm-project/pull/124432 in the future.\n \n \n Fixes https://github.com/llvm/llvm-project/issues/119173.\n Fixes https://github.com/llvm/llvm-project/issues/125374.\n \n PR: https://github.com/llvm/llvm-project/pull/125436\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex cbb9960959f2..ce66350669d5 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6637,8 +6637,10 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,\n // fold away. We can generalize this for all operations using the notion\n // of neutral elements. (TODO)\n if (I->getOpcode() == Instruction::Mul &&\n- (PSE.getSCEV(I->getOperand(0))->isOne() ||\n- PSE.getSCEV(I->getOperand(1))->isOne()))\n+ ((TheLoop->isLoopInvariant(I->getOperand(0)) &&\n+ PSE.getSCEV(I->getOperand(0))->isOne()) ||\n+ (TheLoop->isLoopInvariant(I->getOperand(1)) &&\n+ PSE.getSCEV(I->getOperand(1))->isOne())))\n return 0;\n \n // Detect reduction patterns\n@@ -8588,6 +8590,8 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I,\n // to replace operands with constants.\n ScalarEvolution &SE = *PSE.getSE();\n auto GetConstantViaSCEV = [this, &SE](VPValue *Op) {\n+ if (!Op->isLiveIn())\n+ return Op;\n Value *V = Op->getUnderlyingValue();\n if (isa<Constant>(V) || !SE.isSCEVable(V->getType()))\n return Op;\n", "tests": [{"file": "llvm/test/Transforms/LoopVectorize/AArch64/mul-simplification.ll", "commands": ["opt -p loop-vectorize -S %s"], "tests": [{"test_name": "mul_select_operand_known_1_via_scev", "test_body": "target triple = \"arm64-apple-macosx\"\n\ndefine i64 @mul_select_operand_known_1_via_scev() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i64 [ 12, %entry ], [ %red.next, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = and i32 %iv, 1\n %cmp1.i = icmp eq i32 %0, 0\n %narrow.i = select i1 %cmp1.i, i32 1, i32 %iv\n %mul = zext nneg i32 %narrow.i to i64\n %red.next = mul nsw i64 %red, %mul\n %iv.next = add nuw nsw i32 %iv, 1\n %ec = icmp eq i32 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %res = phi i64 [ %red.next, %loop ]\n ret i64 %res\n}\n", "additional_args": "-src-unroll=4 -tgt-unroll=4"}, {"test_name": "pr125374", "test_body": "target 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.body.i.i\n\nfor.body.i.i: ; preds = %for.body.i.i, %entry\n %indvars.iv.i.i = phi i64 [ 0, %entry ], [ %indvars.iv.next.i.i, %for.body.i.i ]\n %conv678.i.i = phi i8 [ 1, %entry ], [ %add.i.i.i, %for.body.i.i ]\n %add.i.i.i = add i8 0, %conv678.i.i\n %indvars.iv.next.i.i = add i64 %indvars.iv.i.i, 1\n %exitcond.not.i.i = icmp eq i64 %indvars.iv.i.i, 1\n br i1 %exitcond.not.i.i, label %o.exit, label %for.body.i.i\n\no.exit: ; preds = %for.body.i.i\n %conv6.i.i = zext i8 %add.i.i.i to i32\n ret i32 %conv6.i.i\n}\n", "additional_args": "-src-unroll=2 -tgt-unroll=2"}]}], "issue": {"title": "[clang] Miscompilation at -O3", "body": "This code prints 15 at -O3, but prints 5 at -O0/1/2:\n```c\nint printf(const char *, ...);\nstatic int a[] = {4294967295, 5};\nint b, c;\nint main() {\n a[1] = b = 5;\n unsigned d = -13;\n for (; d >= 8; d = a[0] + d + 6) {\n int *e = &b;\n *e = a[0] - -1 + b;\n }\n a[c];\n printf(\"%d\\n\", b);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/4xdPqcjPb\n\nBisected to https://github.com/llvm/llvm-project/commit/6d6eea92e36c301e34a7ec11b2a40e3080f79f53, which was committed by @fhahn ", "author": "cardigan1008", "labels": ["miscompilation", "vectorizers"], "comments": [{"author": "hstk30-hw", "body": "Don't ignore the warning.\n\n```\n<source>:2:19: warning: implicit conversion from 'long' to 'int' changes value from 4294967294 to -2 [-Wconstant-conversion]\n 2 | static int a[] = {4294967294, 5};\n | ~^~~~~~~~~~\n```"}, {"author": "antoniofrighetto", "body": "Please leave the issue opened, as it's implementation-defined behaviour, not undefined behaviour."}, {"author": "antoniofrighetto", "body": "Reduced to:\n```llvm\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine noundef i32 @src() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %entry, %for.body\n %d.06 = phi i32 [ -13, %entry ], [ %add2.reass, %for.body ]\n %add45 = phi i32 [ 5, %entry ], [ %add, %for.body ]\n %add = add i32 0, %add45\n %add2.reass = add i32 %d.06, 5\n %cmp = icmp ugt i32 %add2.reass, 7\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret i32 %add\n}\n```\n\n@fhahn I think the issue fundamentally here lies in the fact that we are incorrectly widening the constant 5 (retrieved from SCEV) to `<5, 5, 5, 5>`, when in fact it should be `<5, 0, 0, 0>` (VPlan value: `WIDEN-REDUCTION-PHI ir<%add45> = phi ir<5>`). The VPBasicBlock for the miscompiled basic block is the following one:\n```\nvector.body:\n EMIT vp<%4> = CANONICAL-INDUCTION ir<0>, vp<%7>\n WIDEN-INDUCTION %d.06 = phi -13, %add2.reass, ir<5>, vp<%0>\n WIDEN-REDUCTION-PHI ir<%add45> = phi ir<5>\n EMIT vp<%5> = WIDEN-CANONICAL-INDUCTION vp<%4>\n EMIT vp<%6> = icmp ule vp<%5>, vp<%3>\n```\nI'm not that familiar with VPlan, though I feel like that either we are not taking into account the active lane, or we should have not emitted a widen instruction in the first place.\n\n(Godbolt: https://llvm.godbolt.org/z/4Wz46ceh1)"}, {"author": "antoniofrighetto", "body": "@fhahn Would you be willing to have a look at it? Happy to help with any additional triage, if needed."}, {"author": "fhahn", "body": "Yep let me take a look!"}]}, "verified": true}
 
111
  {"bug_id": "115465", "issue_url": "https://github.com/llvm/llvm-project/issues/115465", "bug_type": "miscompilation", "base_commit": "d822c099eeacc69f6bf834a6373a41d0c9f84a3e", "knowledge_cutoff": "2024-11-08T11:25:34Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "27bf45aa36386136db179c494358670a994a98a5", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": [[2904, 2910]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": ["InstCombinerImpl::visitShuffleVectorInst"]}}, "patch": "commit 27bf45aa36386136db179c494358670a994a98a5\nAuthor: Yingwei Zheng <[email protected]>\nDate: Sun Nov 10 17:07:25 2024 +0800\n\n [InstCombine] Fix poison safety of folding shufflevector into select (#115483)\n \n We are allowed to fold shufflevector into select iff the condition is\n guaranteed not to be poison or the RHS is a poison.\n Alive2: https://alive2.llvm.org/ce/z/28zEWR\n \n Closes https://github.com/llvm/llvm-project/issues/115465.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp\nindex 454fe5a91d37..ede89b099e8d 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp\n@@ -2904,7 +2904,9 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {\n if (auto *SI = dyn_cast<SelectInst>(LHS)) {\n // We cannot do this fold for elementwise select since ShuffleVector is\n // not elementwise.\n- if (SI->getCondition()->getType()->isIntegerTy()) {\n+ if (SI->getCondition()->getType()->isIntegerTy() &&\n+ (isa<PoisonValue>(RHS) ||\n+ isGuaranteedNotToBePoison(SI->getCondition()))) {\n if (Instruction *I = FoldOpIntoSelect(SVI, SI))\n return I;\n }\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/vec_shuffle.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "shuf_cmp_may_be_poison", "test_body": "define <4 x i8> @shuf_cmp_may_be_poison(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\n %sel = select i1 %cmp, <4 x i8> %y, <4 x i8> <i8 0, i8 poison, i8 0, i8 poison>\n %shuf = shufflevector <4 x i8> %sel, <4 x i8> <i8 poison, i8 1, i8 poison, i8 3>, <4 x i32> <i32 0, i32 5, i32 2, i32 7>\n ret <4 x i8> %shuf\n}\n"}, {"test_name": "shuf_same_length_vec_select", "test_body": "define <4 x i32> @shuf_same_length_vec_select(<4 x i1> %cond) {\n %sel = select <4 x i1> %cond, <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> <i32 4, i32 5, i32 6, i32 7>\n %shuf = shufflevector <4 x i32> %sel, <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32> <i32 2, i32 1, i32 3, i32 5>\n ret <4 x i32> %shuf\n}\n"}]}], "issue": {"title": "[InstCombine] folded select produces different result on a blended vector", "body": "Alive2 report: https://alive2.llvm.org/ce/z/73v-ug\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine <4 x i8> @sel_shuf_commute3.2(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\r\n#0:\r\n %blend = shufflevector <4 x i8> { 0, 0, 0, 0 }, <4 x i8> %y, 0, 5, 2, 3\r\n %r = select i1 %cmp, <4 x i8> %y, <4 x i8> %blend\r\n %#1 = select <4 x i1> { 0, 1, 0, 1 }, <4 x i8> { 0, 1, 2, 3 }, <4 x i8> %r\r\n ret <4 x i8> %#1\r\n}\r\n=>\r\ndefine <4 x i8> @sel_shuf_commute3.2(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\r\n#0:\r\n %#1 = shufflevector <4 x i8> %y, <4 x i8> { poison, 1, poison, 3 }, 0, 5, 2, 7\r\n %#2 = select i1 %cmp, <4 x i8> %#1, <4 x i8> { 0, 1, 0, 3 }\r\n ret <4 x i8> %#2\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\n<4 x i8> %x = < poison, poison, poison, poison >\r\n<4 x i8> %y = < poison, poison, poison, poison >\r\ni1 %cmp = poison\r\n\r\nSource:\r\n<4 x i8> %blend = < #x00 (0), poison, #x00 (0), #x00 (0) >\r\n<4 x i8> %r = < poison, poison, poison, poison >\r\n<4 x i8> %#1 = < poison, #x01 (1), poison, #x03 (3) >\r\n\r\nTarget:\r\n<4 x i8> %#1 = < poison, #x01 (1), poison, #x03 (3) >\r\n<4 x i8> %#2 = < poison, poison, poison, poison >\r\nSource value: < poison, #x01 (1), poison, #x03 (3) >\r\nTarget value: < poison, poison, poison, poison >\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```\r\n", "author": "bongjunj", "labels": ["miscompilation", "llvm:instcombine"], "comments": []}, "verified": true}
112
  {"bug_id": "112666", "issue_url": "https://github.com/llvm/llvm-project/issues/112666", "bug_type": "miscompilation", "base_commit": "d6d73ec89e493c69cf24dc3a710d861e2ce08acb", "knowledge_cutoff": "2024-10-17T06:28:53Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "ff07df6620c32571c7e13ff96ec7976c63ed0ab8", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": [[333, 338]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": ["Negator::visitImpl"]}}, "patch": "commit ff07df6620c32571c7e13ff96ec7976c63ed0ab8\nAuthor: Yingwei Zheng <[email protected]>\nDate: Fri Nov 8 16:20:04 2024 +0800\n\n [InstCombine] Drop nsw in negation of select (#112893)\n \n Closes https://github.com/llvm/llvm-project/issues/112666 and\n https://github.com/llvm/llvm-project/issues/114181.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp\nindex 9bd848552615..2210336d92bf 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp\n@@ -333,6 +333,17 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) {\n NewSelect->swapValues();\n // Don't swap prof metadata, we didn't change the branch behavior.\n NewSelect->setName(I->getName() + \".neg\");\n+ // Poison-generating flags should be dropped\n+ Value *TV = NewSelect->getTrueValue();\n+ Value *FV = NewSelect->getFalseValue();\n+ if (match(TV, m_Neg(m_Specific(FV))))\n+ cast<Instruction>(TV)->dropPoisonGeneratingFlags();\n+ else if (match(FV, m_Neg(m_Specific(TV))))\n+ cast<Instruction>(FV)->dropPoisonGeneratingFlags();\n+ else {\n+ cast<Instruction>(TV)->dropPoisonGeneratingFlags();\n+ cast<Instruction>(FV)->dropPoisonGeneratingFlags();\n+ }\n Builder.Insert(NewSelect);\n return NewSelect;\n }\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/sub-of-negatible.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "negate_select_of_op_vs_negated_op_nsw_commuted", "test_body": "define i8 @negate_select_of_op_vs_negated_op_nsw_commuted(i8 %x, i8 %y, i1 %c) {\n %t0 = sub nsw i8 0, %x\n %t1 = select i1 %c, i8 %x, i8 %t0\n %t2 = sub i8 %y, %t1\n ret i8 %t2\n}\n"}, {"test_name": "negate_select_of_op_vs_negated_op_nsw", "test_body": "define i8 @negate_select_of_op_vs_negated_op_nsw(i8 %x, i8 %y, i1 %c) {\n %t0 = sub nsw i8 0, %x\n %t1 = select i1 %c, i8 %t0, i8 %x\n %t2 = sub i8 %y, %t1\n ret i8 %t2\n}\n"}, {"test_name": "dont_negate_ordinary_select", "test_body": "define i8 @dont_negate_ordinary_select(i8 %x, i8 %y, i8 %z, i1 %c) {\n %t0 = select i1 %c, i8 %x, i8 %y\n %t1 = sub i8 %z, %t0\n ret i8 %t1\n}\n"}, {"test_name": "negate_select_of_op_vs_negated_op_nsw_xyyx", "test_body": "define i8 @negate_select_of_op_vs_negated_op_nsw_xyyx(i8 %x, i8 %y, i8 %z, i1 %c) {\n %sub1 = sub nsw i8 %x, %y\n %sub2 = sub nsw i8 %y, %x\n %t1 = select i1 %c, i8 %sub1, i8 %sub2\n %t2 = sub i8 %z, %t1\n ret i8 %t2\n}\n"}, {"test_name": "negate_select_of_op_vs_negated_op", "test_body": "declare void @use8(i8)\n\ndefine i8 @negate_select_of_op_vs_negated_op(i8 %x, i8 %y, i1 %c) {\n %t0 = sub i8 0, %x\n call void @use8(i8 %t0)\n %t1 = select i1 %c, i8 %t0, i8 %x, !prof !0\n %t2 = sub i8 %y, %t1\n ret i8 %t2\n}\n\n!0 = !{!\"branch_weights\", i32 40, i32 1}\n"}]}], "issue": {"title": "[InstCombine] `nsw` flag should be dropped in Negator", "body": "Reproducer: https://alive2.llvm.org/ce/z/ZFF_QK\r\n```\r\ndefine i8 @src(i8 %x, i8 %y, i1 %c) {\r\n %t0 = sub nsw i8 0, %x\r\n %t1 = select i1 %c, i8 %t0, i8 %x\r\n %t2 = sub i8 %y, %t1\r\n ret i8 %t2\r\n}\r\n\r\ndefine i8 @tgt(i8 %x, i8 %y, i1 %c) {\r\n %t0 = sub nsw i8 0, %x\r\n %1 = select i1 %c, i8 %x, i8 %t0\r\n %t2 = add i8 %1, %y\r\n ret i8 %t2\r\n}\r\n```\r\n```\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\ni8 %x = #x80 (128, -128)\r\ni8 %y = #x00 (0)\r\ni1 %c = #x0 (0)\r\n\r\nSource:\r\ni8 %t0 = poison\r\ni8 %t1 = #x80 (128, -128)\r\ni8 %t2 = #x80 (128, -128)\r\n\r\nTarget:\r\ni8 %t0 = poison\r\ni8 %#1 = poison\r\ni8 %t2 = poison\r\nSource value: #x80 (128, -128)\r\nTarget value: poison\r\n```", "author": "dtcxzyw", "labels": ["miscompilation", "llvm:instcombine"], "comments": [{"author": "AZero13", "body": "Is this an issue in 19.x or just main?"}, {"author": "AZero13", "body": "Confirmed this issue exists in 19.x"}]}, "verified": true}
113
  {"bug_id": "116775", "issue_url": "https://github.com/llvm/llvm-project/issues/116775", "bug_type": "crash", "base_commit": "bdf00e2216280edef1ec91ccc07987db92197b59", "knowledge_cutoff": "2024-11-19T09:53:12Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "03d8831fa8ef5b7e32172c718b550a454645faea", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [[997, 1003]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": ["InstCombinerImpl::SimplifyDemandedUseBits"]}}, "patch": "commit 03d8831fa8ef5b7e32172c718b550a454645faea\nAuthor: Yingwei Zheng <[email protected]>\nDate: Tue Nov 19 22:17:24 2024 +0800\n\n [InstCombine] Handle constant GEP expr in `SimplifyDemandedUseBits` (#116794)\n \n Closes https://github.com/llvm/llvm-project/issues/116775.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\nindex 5eb807dcb76c..392c5c78345c 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\n@@ -997,7 +997,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,\n uint64_t MaskedGEPIndex = HighBitsGEPIndex | MaskedLowBitsGEPIndex;\n \n if (MaskedGEPIndex != GEPIndex) {\n- auto *GEP = cast<GetElementPtrInst>(II->getArgOperand(0));\n+ auto *GEP = cast<GEPOperator>(II->getArgOperand(0));\n Builder.SetInsertPoint(I);\n Type *GEPIndexType =\n DL.getIndexType(GEP->getPointerOperand()->getType());\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/ptrmask.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "ptrmask_demandedbits_constantexpr", "test_body": "target datalayout = \"p1:64:64:64:32\"\n\n@GC_arrays = external global { i8, i8, i64 }\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare ptr @llvm.ptrmask.p0.i64(ptr, i64) #0\n\ndefine ptr @ptrmask_demandedbits_constantexpr() {\nentry:\n %aligned_result = call ptr @llvm.ptrmask.p0.i64(ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 1), i64 -8)\n ret ptr %aligned_result\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "ptrmask_is_useless_fail1", "test_body": "target datalayout = \"p1:64:64:64:32\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare ptr @llvm.ptrmask.p0.i64(ptr, i64) #0\n\ndefine ptr @ptrmask_is_useless_fail1(i64 %i, i64 %m) {\n %m0 = and i64 %m, 127\n %i0 = and i64 %i, 511\n %p0 = inttoptr i64 %i0 to ptr\n %r = call ptr @llvm.ptrmask.p0.i64(ptr %p0, i64 %m0)\n ret ptr %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}]}], "issue": {"title": "Segfault when building https://github.com/ivmai/bdwgc@4fe4238", "body": "Attempting to build [https://github.com/ivmai/bdwgc@4fe4238](https://github.com/ivmai/bdwgc/tree/4fe42389509ff059bad8d4c955a570b34a6bda4b) using\r\n```shell\r\n$ ./autogen.sh\r\n$ ./configure --with-libatomic-ops --enable-cplusplus --enable-large-config\r\n$ make\r\n```\r\nresults in\r\n```text\r\nlibtool: compile: clang -std=gnu23 -DHAVE_CONFIG_H -I./include -I./include -DNDEBUG -fexceptions -DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden -Wall -Wextra -Wpedantic -Wno-long-long -O2 -march=native -Wno-frame-address -MT extra/gc.lo -MD -MP -MF extra/.deps/gc.Tpo -c extra/gc.c -fno-common -DPIC -o extra/.libs/gc.o\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: clang -std=gnu23 -DHAVE_CONFIG_H -I./include -I./include -DNDEBUG -fexceptions -DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden -Wall -Wextra -Wpedantic -Wno-long-long -O2 -march=native -Wno-frame-address -MT extra/gc.lo -MD -MP -MF extra/.deps/gc.Tpo -c extra/gc.c -fno-common -DPIC -o extra/.libs/gc.o\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,simple-loop-unswitch<no-nontrivial;trivial>,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide)),function(invalidate<should-not-run-function-passes>),cgscc(devirt<4>())\" on module \"extra/gc.c\"\r\n4.\tRunning pass \"cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,simple-loop-unswitch<no-nontrivial;trivial>,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide))\" on module \"extra/gc.c\"\r\n5.\tRunning pass \"instcombine<max-iterations=1;no-verify-fixpoint>\" on function \"GC_push_finalizer_structures\"\r\n #0 0x0000000112ecda98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3299a98)\r\n #1 0x0000000112eccb47 llvm::sys::RunSignalHandlers() (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3298b47)\r\n #2 0x0000000112eccde1 llvm::sys::CleanupOnSignal(unsigned long) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3298de1)\r\n #3 0x0000000112df2644 CrashRecoverySignalHandler(int) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31be644)\r\n #4 0x00007ff81abe4fdd (/usr/lib/system/libsystem_platform.dylib+0x7ff80046afdd)\r\n #5 0x0000000112e1d131 computeForAddCarry(llvm::KnownBits const&, llvm::KnownBits const&, bool, bool) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31e9131)\r\n #6 0x0000000112318cdd llvm::TargetFolder::FoldGEP(llvm::Type*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::GEPNoWrapFlags) const (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26e4cdd)\r\n #7 0x00000001102d2177 llvm::IRBuilderBase::CreateGEP(llvm::Type*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::GEPNoWrapFlags) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x69e177)\r\n #8 0x000000011209545a llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Instruction*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x246145a)\r\n #9 0x0000000112097524 llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(llvm::Instruction&, llvm::KnownBits&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2463524)\r\n#10 0x0000000111ffc58b llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x23c858b)\r\n#11 0x0000000111f85788 llvm::InstCombinerImpl::run() (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2351788)\r\n#12 0x0000000111f765e2 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x23425e2)\r\n#13 0x0000000111fc1b85 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x238db85)\r\n#14 0x0000000110596272 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x962272)\r\n#15 0x0000000112b6736a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f3336a)\r\n#16 0x000000011003f522 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/llvm-project@HEAD/lib/libLLVM.dylib+0x40b522)\r\n#17 0x00000001122fe7db llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26ca7db)\r\n#18 0x0000000110b41712 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0d712)\r\n#19 0x00000001122fa573 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c6573)\r\n#20 0x0000000110b3e332 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0a332)\r\n#21 0x00000001122fcc0e llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c8c0e)\r\n#22 0x0000000110b413a2 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0d3a2)\r\n#23 0x00000001122fbe83 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c7e83)\r\n#24 0x0000000110b3e012 llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0a012)\r\n#25 0x0000000112b65a22 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f31a22)\r\n#26 0x0000000110d25d8b llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x10f1d8b)\r\n#27 0x0000000110594012 llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x960012)\r\n#28 0x0000000112b65a22 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f31a22)\r\n#29 0x000000010788b478 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>&, std::__1::unique_ptr<llvm::ToolOutputFile, std::__1::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x172d478)\r\n#30 0x0000000107883b08 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::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1725b08)\r\n#31 0x0000000107d037d3 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1ba57d3)\r\n#32 0x000000010635df1d clang::ParseAST(clang::Sema&, bool, bool) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1fff1d)\r\n#33 0x000000010877f3d7 clang::FrontendAction::Execute() (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x26213d7)\r\n#34 0x00000001086e0500 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2582500)\r\n#35 0x00000001087f60e9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x26980e9)\r\n#36 0x000000010128d4f9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/llvm-project@HEAD/bin/clang-20+0x1000084f9)\r\n#37 0x0000000101289f88 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/opt/llvm-project@HEAD/bin/clang-20+0x100004f88)\r\n#38 0x00000001082b552e void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x215752e)\r\n#39 0x0000000112df288c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31be88c)\r\n#40 0x00000001082b5431 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2157431)\r\n#41 0x0000000108262131 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2104131)\r\n#42 0x00000001082623bf clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x21043bf)\r\n#43 0x00000001082b00c0 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x21520c0)\r\n#44 0x00000001012892b3 clang_main(int, char**, llvm::ToolContext const&) (/opt/llvm-project@HEAD/bin/clang-20+0x1000042b3)\r\n#45 0x00000001012984cb main (/opt/llvm-project@HEAD/bin/clang-20+0x1000134cb)\r\n#46 0x00007ff81a82a345 \r\nclang: error: clang frontend command failed with exit code 139 (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git c25c6c32494c8d1038438b6208d42ba40f25270e)\r\nTarget: x86_64-apple-darwin23.6.0\r\nThread model: posix\r\nInstalledDir: /opt/llvm-project@HEAD/bin\r\nclang: note: diagnostic msg: \r\n********************\r\n```\r\n\r\nFind attached the preprocessed source code at [gc-add69e.c.gz](https://github.com/user-attachments/files/17813033/gc-add69e.c.gz).", "author": "d125q", "labels": ["llvm:instcombine", "crash-on-valid"], "comments": [{"author": "dtcxzyw", "body": "Reproducer: https://godbolt.org/z/Ts478aen6\r\n```\r\n; bin/opt -passes=instcombine test.ll -S\r\n@GC_arrays = external global { i8, i8, i64 }\r\n\r\ndefine ptr @GC_push_finalizer_structures() {\r\nentry:\r\n %aligned_result.i = call ptr @llvm.ptrmask.p0.i64(ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 1), i64 -8)\r\n ret ptr %aligned_result.i\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::GetElementPtrInst; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\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: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=instcombine <source>\r\n1.\tRunning pass \"function(instcombine<max-iterations=1;verify-fixpoint>)\" on module \"<source>\"\r\n2.\tRunning pass \"instcombine<max-iterations=1;verify-fixpoint>\" on function \"GC_push_finalizer_structures\"\r\n #0 0x0000000005194b38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5194b38)\r\n #1 0x000000000519252c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000074b7d8442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000074b7d84969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000074b7d8442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000074b7d84287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000074b7d842871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000074b7d8439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000040d9310 decltype(auto) llvm::cast<llvm::GetElementPtrInst, llvm::Value>(llvm::Value*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40d9310)\r\n #9 0x00000000040e2f9e llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Instruction*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40e2f9e)\r\n#10 0x00000000040e6082 llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(llvm::Instruction&, llvm::KnownBits&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40e6082)\r\n#11 0x00000000040355a6 llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40355a6)\r\n#12 0x0000000003fe2311 llvm::InstCombinerImpl::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe2311)\r\n#13 0x0000000003fe3cc6 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) (.isra.0) InstructionCombining.cpp:0:0\r\n#14 0x0000000003fe504e llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe504e)\r\n#15 0x0000000002c5c24e llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2c5c24e)\r\n#16 0x0000000004f949e8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f949e8)\r\n#17 0x0000000000e4027e 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+0xe4027e)\r\n#18 0x0000000004f9340e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f9340e)\r\n#19 0x0000000000e3f92e 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+0xe3f92e)\r\n#20 0x0000000004f92e40 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f92e40)\r\n#21 0x0000000000909fda 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+0x909fda)\r\n#22 0x00000000008fc70a optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fc70a)\r\n#23 0x000074b7d8429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#24 0x000074b7d8429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#25 0x00000000008f3e9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f3e9e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```"}]}, "verified": true}
114
+ {"bug_id": "126085", "issue_url": "https://github.com/llvm/llvm-project/issues/126085", "bug_type": "crash", "base_commit": "6575154b6eca80097d77db69ce1ee60c72854ee6", "knowledge_cutoff": "2025-02-06T15:41:55Z", "lit_test_dir": ["llvm/test/Transforms/VectorCombine"], "hints": {"fix_commit": "eb2b453eb73dfe0b8cf516dfb4d568c0b858d1fa", "components": ["VectorCombine"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [[3210, 3216]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": ["VectorCombine::foldInsExtVectorToShuffle"]}}, "patch": "commit eb2b453eb73dfe0b8cf516dfb4d568c0b858d1fa\nAuthor: Simon Pilgrim <[email protected]>\nDate: Thu Feb 6 16:40:48 2025 +0000\n\n [VectorCombine] foldInsExtVectorToShuffle - ensure we call getShuffleCost with the input operand type, not the result\n \n Typo in #121216\n \n Fixes #126085\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\nindex 4f46b621c8a7..746742e14d08 100644\n--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n@@ -3210,7 +3210,7 @@ bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {\n ExtToVecMask[0] = ExtIdx;\n // Add cost for expanding or narrowing\n NewCost = TTI.getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc,\n- DstVecTy, ExtToVecMask, CostKind);\n+ SrcVecTy, ExtToVecMask, CostKind);\n NewCost += TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind);\n }\n \n", "tests": [{"file": "llvm/test/Transforms/VectorCombine/X86/pr126085.ll", "commands": ["opt < %s -passes=vector-combine -S -mtriple=x86_64--"], "tests": [{"test_name": "<module>", "test_body": "\ndefine i32 @test(ptr %a0) {\n;\n %load = load <16 x i8>, ptr %a0, align 1\n %shuf = shufflevector <16 x i8> %load, <16 x i8> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>\n %elt = extractelement <16 x i8> %load, i64 11\n %ins = insertelement <4 x i8> %shuf, i8 %elt, i64 1\n %res = bitcast <4 x i8> %ins to i32\n ret i32 %res\n}"}]}], "issue": {"title": "[VectorCombine] Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.", "body": "Reproducer:\n```\n; bin/opt -passes=vector-combine 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 @test(ptr readonly captures(none) dereferenceable(16) %0) {\n %2 = load <16 x i8>, ptr %0, align 1\n %.sroa.01.2.vec.insert = shufflevector <16 x i8> %2, <16 x i8> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>\n %3 = extractelement <16 x i8> %2, i64 11\n %.sroa.01.3.vec.insert = insertelement <4 x i8> %.sroa.01.2.vec.insert, i8 %3, i64 1\n %4 = bitcast <4 x i8> %.sroa.01.3.vec.insert to i32\n ret i32 %4\n}\n```\n```\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/IR/Instructions.cpp:1890: bool isSingleSourceMaskImpl(llvm::ArrayRef<int>, int): Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: bin/opt -passes=vector-combine reduced.ll -S\n1. Running pass \"function(vector-combine)\" on module \"reduced.ll\"\n2. Running pass \"vector-combine\" on function \"test\"\n #0 0x00007f4379a17152 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x217152)\n #1 0x00007f4379a1403f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x21403f)\n #2 0x00007f4379a1417c SignalHandler(int) Signals.cpp:0:0\n #3 0x00007f4379442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007f43794969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007f43794969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007f43794969fc pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007f4379442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007f43794287f3 abort ./stdlib/abort.c:81:7\n #9 0x00007f437942871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007f4379439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x00007f4370e71a16 isSingleSourceMaskImpl(llvm::ArrayRef<int>, int) Instructions.cpp:0:0\n#12 0x00007f4370e7c3dc llvm::ShuffleVectorInst::isReverseMask(llvm::ArrayRef<int>, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x27c3dc)\n#13 0x00007f43788933f2 llvm::X86TTIImpl::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0x4933f2)\n#14 0x00007f43716ddf0c llvm::TargetTransformInfo::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x4ddf0c)\n#15 0x00007f437224f6e7 (anonymous namespace)::VectorCombine::foldInsExtVectorToShuffle(llvm::Instruction&) VectorCombine.cpp:0:0\n#16 0x00007f4372256116 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const VectorCombine.cpp:0:0\n#17 0x00007f437225787f llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x25787f)\n#18 0x00007f4373f225c5 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.21.0git+0x1225c5)\n#19 0x00007f4370f10cad llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x310cad)\n#20 0x00007f43784dc235 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdc235)\n#21 0x00007f4370f0ee75 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x30ee75)\n#22 0x00007f43784dcbf5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdcbf5)\n#23 0x00007f4370f0fb2a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x30fb2a)\n#24 0x00007f4379ba3dc6 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) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x2fdc6)\n#25 0x00007f4379baf5c2 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x3b5c2)\n#26 0x00007f4379429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#27 0x00007f4379429e40 call_init ./csu/../csu/libc-start.c:128:20\n#28 0x00007f4379429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#29 0x00006293bc5a5095 _start (bin/opt+0x1095)\nAborted (core dumped)\n```\n\nTriggered by https://github.com/llvm/llvm-project/pull/121216. cc @ParkHanbum @RKSimon \nReported by https://github.com/dtcxzyw/llvm-opt-benchmark/issues/2093\n\n", "author": "dtcxzyw", "labels": ["crash-on-valid", "llvm:transforms"], "comments": [{"author": "RKSimon", "body": "Found the problem - fix incoming"}]}, "verified": true}
115
  {"bug_id": "120433", "issue_url": "https://github.com/llvm/llvm-project/issues/120433", "bug_type": "crash", "base_commit": "ac8a9f8fffb605514056f53f12f1fba94ee933e9", "knowledge_cutoff": "2024-12-18T15:02:42Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "e7a4d78ad328d02bf515b2fa4af8b2c188a6a636", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[21148, 21155]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["SLPVectorizerPass::vectorizeCmpInsts"]}}, "patch": "commit e7a4d78ad328d02bf515b2fa4af8b2c188a6a636\nAuthor: DianQK <[email protected]>\nDate: Thu Dec 19 06:21:57 2024 +0800\n\n [SLP] Check if instructions exist after vectorization (#120434)\n \n Fixes #120433.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex d967813075bb..88049897b29a 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -21148,8 +21148,11 @@ bool SLPVectorizerPass::vectorizeCmpInsts(iterator_range<ItT> CmpInsts,\n if (R.isDeleted(I))\n continue;\n for (Value *Op : I->operands())\n- if (auto *RootOp = dyn_cast<Instruction>(Op))\n+ if (auto *RootOp = dyn_cast<Instruction>(Op)) {\n Changed |= vectorizeRootInstruction(nullptr, RootOp, BB, R);\n+ if (R.isDeleted(I))\n+ break;\n+ }\n }\n // Try to vectorize operands as vector bundles.\n for (CmpInst *I : CmpInsts) {\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/slp-deleted-inst.ll", "commands": ["opt -S -passes=slp-vectorizer < %s"], "tests": [{"test_name": "foo", "test_body": "define void @foo() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb3, %bb\n %i = phi i32 [ %i26, %bb3 ], [ 0, %bb ]\n %i2 = phi i32 [ %i24, %bb3 ], [ 0, %bb ]\n br label %bb3\n\nbb3: ; preds = %bb1\n %i4 = zext i32 %i2 to i64\n %i5 = mul i64 %i4, 0\n %i10 = or i64 0, %i5\n %i11 = trunc i64 %i10 to i32\n %i12 = and i32 %i11, 0\n %i13 = zext i32 %i to i64\n %i14 = mul i64 %i13, 0\n %i19 = or i64 0, %i14\n %i20 = trunc i64 %i19 to i32\n %i21 = and i32 %i20, 0\n %i22 = or i32 %i12, %i21\n %i23 = icmp ult i32 %i22, 0\n %i24 = select i1 %i23, i32 0, i32 0\n %i25 = icmp ult i32 0, 0\n %i26 = select i1 %i25, i32 0, i32 0\n br label %bb1\n}\n"}]}], "issue": {"title": "[SLP] Assertion `detail::isPresent(Val) && \"dyn_cast on a non-existent value\"' failed.", "body": "This IR crashes on SLP: https://llvm.godbolt.org/z/8oar4o4d1\n\n```llvm\ndefine void @foo() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb3, %bb\n %i = phi i32 [ %i26, %bb3 ], [ 0, %bb ]\n %i2 = phi i32 [ %i24, %bb3 ], [ 0, %bb ]\n br label %bb3\n\nbb3: ; preds = %bb1\n %i4 = zext i32 %i2 to i64\n %i5 = mul i64 %i4, 0\n %i10 = or i64 0, %i5\n %i11 = trunc i64 %i10 to i32\n %i12 = and i32 %i11, 0\n %i13 = zext i32 %i to i64\n %i14 = mul i64 %i13, 0\n %i19 = or i64 0, %i14\n %i20 = trunc i64 %i19 to i32\n %i21 = and i32 %i20, 0\n %i22 = or i32 %i12, %i21\n %i23 = icmp ult i32 %i22, 0\n %i24 = select i1 %i23, i32 0, i32 0\n %i25 = icmp ult i32 0, 0\n %i26 = select i1 %i25, i32 0, i32 0\n br label %bb1\n}\n```", "author": "DianQK", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": []}, "verified": true}
116
  {"bug_id": "87856", "issue_url": "https://github.com/llvm/llvm-project/issues/87856", "bug_type": "crash", "base_commit": "b17d44558ba4c30a3005089b334f68593d6a9c7c", "knowledge_cutoff": "2024-04-06T02:19:05Z", "lit_test_dir": ["llvm/test/Transforms/Attributor"], "hints": {"fix_commit": "2d61692d4b75b7d92b44bfafb1011c1723955151", "components": ["Attributor"], "bug_location_lineno": {"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": [[5899, 5908]]}, "bug_location_funcname": {"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": ["AANoCaptureImpl::updateImpl"]}}, "patch": "commit 2d61692d4b75b7d92b44bfafb1011c1723955151\nAuthor: Matt Arsenault <[email protected]>\nDate: Thu May 23 19:31:33 2024 +0200\n\n Attributor: Do not assume function context in AANoCapture (#91462)\n \n If the calling function has the null_pointer_is_valid attribute, somehow\n a null constant reaches here. I'm not sure why exactly, it doesn't\n happen for other types of constants.\n \n Fixes #87856\n\ndiff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp\nindex 41b66aafe7d3..1b3bf3c732ed 100644\n--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp\n+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp\n@@ -5690,6 +5690,9 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,\n return V.use_empty();\n \n // You cannot \"capture\" null in the default address space.\n+ //\n+ // FIXME: This should use NullPointerIsDefined to account for the function\n+ // attribute.\n if (isa<UndefValue>(V) || (isa<ConstantPointerNull>(V) &&\n V.getType()->getPointerAddressSpace() == 0)) {\n return true;\n@@ -5899,10 +5902,13 @@ ChangeStatus AANoCaptureImpl::updateImpl(Attributor &A) {\n \n const Function *F =\n isArgumentPosition() ? IRP.getAssociatedFunction() : IRP.getAnchorScope();\n- assert(F && \"Expected a function!\");\n- const IRPosition &FnPos = IRPosition::function(*F);\n+\n+ // TODO: Is the checkForAllUses below useful for constants?\n+ if (!F)\n+ return indicatePessimisticFixpoint();\n \n AANoCapture::StateType T;\n+ const IRPosition &FnPos = IRPosition::function(*F);\n \n // Readonly means we cannot capture through memory.\n bool IsKnown;\n", "tests": [{"file": "llvm/test/Transforms/Attributor/issue87856.ll", "commands": ["opt -S -passes=attributor < %s"], "tests": [{"test_name": "<module>", "test_body": "\ndefine void @null_ptr_is_valid_call_with_null() #0 {\n;\n call void @store_as0(ptr null)\n ret void\n}\n\ndefine void @null_ptr_is_valid_call_with_undef() #0 {\n;\n call void @store_as0(ptr undef)\n ret void\n}\n\ndefine void @store_as0(ptr %0) {\n;\n store i16 0, ptr %0, align 2\n ret void\n}\n\ndefine void @call_store_as1() {\n;\n call void @store_as1(ptr addrspace(1) null)\n ret void\n}\n\ndefine void @store_as1(ptr addrspace(1) %arg) {\n;\n store i16 0, ptr addrspace(1) %arg, align 2\n ret void\n}\n\nattributes #0 = { null_pointer_is_valid }\n;.\n;."}]}], "issue": {"title": "[attributor] Crash on `null_pointer_is_valid` function", "body": "With\r\n\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"aarch64-none-linux-android28\"\r\n\r\n; Function Attrs: null_pointer_is_valid\r\ndefine i64 @foo() #0 {\r\n call fastcc void @bar(ptr null)\r\n ret i64 0\r\n}\r\n\r\ndefine fastcc void @bar(ptr %0) {\r\n store i16 0, ptr %0, align 2\r\n ret void\r\n}\r\n\r\nattributes #0 = { null_pointer_is_valid }\r\n```\r\n\r\nand running\r\n\r\n```\r\nopt -passes=attributor file.ll\r\n```\r\n\r\nwe crash with\r\n\r\n```\r\nopt: llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:5901: virtual ChangeStatus (anonymous namespace)::AANoCaptureImpl::updateImpl(Attributor &): Assertion `F && \"Expected a function!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: opt -passes=attributor reduced.ll\r\n #0 0x000000000165bf38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project/build/Release/bin/opt+0x165bf38)\r\n #1 0x0000000001659a40 llvm::sys::RunSignalHandlers() (llvm-project/build/Release/bin/opt+0x1659a40)\r\n #2 0x000000000165c938 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f3ec923e6f0 __restore_rt (/lib64/libc.so.6+0x3e6f0)\r\n #4 0x00007f3ec928b94c __pthread_kill_implementation (/lib64/libc.so.6+0x8b94c)\r\n #5 0x00007f3ec923e646 gsignal (/lib64/libc.so.6+0x3e646)\r\n #6 0x00007f3ec92287f3 abort (/lib64/libc.so.6+0x287f3)\r\n #7 0x00007f3ec922871b _nl_load_domain.cold (/lib64/libc.so.6+0x2871b)\r\n #8 0x00007f3ec9237386 (/lib64/libc.so.6+0x37386)\r\n #9 0x0000000002f2a65b (anonymous namespace)::AANoCaptureImpl::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0\r\n#10 0x0000000002ec8492 llvm::AbstractAttribute::update(llvm::Attributor&) (llvm-project/build/Release/bin/opt+0x2ec8492)\r\n#11 0x0000000002ed3b83 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (llvm-project/build/Release/bin/opt+0x2ed3b83)\r\n#12 0x0000000002eec289 llvm::AANoCapture const* llvm::Attributor::getOrCreateAAFor<llvm::AANoCapture>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) Attributor.cpp:0:0\r\n#13 0x0000000002f1ab57 (anonymous namespace)::AANoAliasCallSiteArgument::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0\r\n#14 0x0000000002ec8492 llvm::AbstractAttribute::update(llvm::Attributor&) (llvm-project/build/Release/bin/opt+0x2ec8492)\r\n#15 0x0000000002ed3b83 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (llvm-project/build/Release/bin/opt+0x2ed3b83)\r\n#16 0x0000000002efba19 llvm::AANoAlias const* llvm::Attributor::getOrCreateAAFor<llvm::AANoAlias>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) Attributor.cpp:0:0\r\n#17 0x0000000002ede880 void llvm::Attributor::checkAndQueryIRAttr<(llvm::Attribute::AttrKind)20, llvm::AANoAlias>(llvm::IRPosition const&, llvm::AttributeSet) (llvm-project/build/Release/bin/opt+0x2ede880)\r\n#18 0x0000000002edd545 llvm::Attributor::identifyDefaultAbstractAttributes(llvm::Function&) (llvm-project/build/Release/bin/opt+0x2edd545)\r\n#19 0x0000000002ee0800 runAttributorOnFunctions(llvm::InformationCache&, llvm::SetVector<llvm::Function*, llvm::SmallVector<llvm::Function*, 0u>, llvm::DenseSet<llvm::Function*, llvm::DenseMapInfo<llvm::Function*, void>>, 0u>&, llvm::AnalysisGetter&, llvm::CallGraphUpdater&, bool, bool) Attributor.cpp:0:0\r\n#20 0x0000000002edfc41 llvm::AttributorPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/Release/bin/opt+0x2edfc41)\r\n#21 0x0000000002b6fcdd llvm::detail::PassModel<llvm::Module, llvm::AttributorPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0\r\n#22 0x0000000001853e56 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/Release/bin/opt+0x1853e56)\r\n#23 0x0000000002afaa4b 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) (llvm-project/build/Release/bin/opt+0x2afaa4b)\r\n#24 0x0000000001622f36 optMain (llvm-project/build/Release/bin/opt+0x1622f36)\r\n```", "author": "lanza", "labels": ["crash-on-valid", "llvm::Attributor"], "comments": [{"author": "lanza", "body": "https://github.com/llvm/llvm-project/blob/0f52f4ddd909eb38f2a691ffed8469263fe5f635/llvm/lib/Transforms/IPO/AttributorAttributes.cpp#L5901"}, {"author": "dtcxzyw", "body": "cc @arsenm "}, {"author": "arsenm", "body": "Just returning on the null function seems to work, but I don't understand exactly why it reaches here. AANoCapture::isImpliedByIR is incorrectly reimplementing NullPointerIsDefined but fixing that doesn't seem to help any "}]}, "verified": true}
117
  {"bug_id": "119173", "issue_url": "https://github.com/llvm/llvm-project/issues/119173", "bug_type": "miscompilation", "base_commit": "ab77db03ce28e86a61010e51ea13796ea09efc46", "knowledge_cutoff": "2024-12-09T07:19:06Z", "lit_test_dir": ["llvm/test/Transforms/LoopVectorize"], "hints": {"fix_commit": "30f3752e54fa7cd595a434a985efbe9a7abe9b65", "components": ["LoopVectorize"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [[6637, 6644], [8588, 8593]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": ["LoopVectorizationCostModel::getInstructionCost", "VPRecipeBuilder::tryToWiden"]}}, "patch": "commit 30f3752e54fa7cd595a434a985efbe9a7abe9b65\nAuthor: Florian Hahn <[email protected]>\nDate: Mon Feb 3 17:01:02 2025 +0000\n\n [VPlan] Only use SCEV for live-ins in tryToWiden. (#125436)\n \n Replacing a recipe with a live-in may not be correct in all cases,\n e.g. when replacing recipes involving header-phi recipes, like\n reductions.\n \n For now, only use SCEV to simplify live-ins.\n \n More powerful input simplification can be built in top of\n https://github.com/llvm/llvm-project/pull/124432 in the future.\n \n \n Fixes https://github.com/llvm/llvm-project/issues/119173.\n Fixes https://github.com/llvm/llvm-project/issues/125374.\n \n PR: https://github.com/llvm/llvm-project/pull/125436\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex cbb9960959f2..ce66350669d5 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6637,8 +6637,10 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,\n // fold away. We can generalize this for all operations using the notion\n // of neutral elements. (TODO)\n if (I->getOpcode() == Instruction::Mul &&\n- (PSE.getSCEV(I->getOperand(0))->isOne() ||\n- PSE.getSCEV(I->getOperand(1))->isOne()))\n+ ((TheLoop->isLoopInvariant(I->getOperand(0)) &&\n+ PSE.getSCEV(I->getOperand(0))->isOne()) ||\n+ (TheLoop->isLoopInvariant(I->getOperand(1)) &&\n+ PSE.getSCEV(I->getOperand(1))->isOne())))\n return 0;\n \n // Detect reduction patterns\n@@ -8588,6 +8590,8 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I,\n // to replace operands with constants.\n ScalarEvolution &SE = *PSE.getSE();\n auto GetConstantViaSCEV = [this, &SE](VPValue *Op) {\n+ if (!Op->isLiveIn())\n+ return Op;\n Value *V = Op->getUnderlyingValue();\n if (isa<Constant>(V) || !SE.isSCEVable(V->getType()))\n return Op;\n", "tests": [{"file": "llvm/test/Transforms/LoopVectorize/AArch64/mul-simplification.ll", "commands": ["opt -p loop-vectorize -S %s"], "tests": [{"test_name": "mul_select_operand_known_1_via_scev", "test_body": "target triple = \"arm64-apple-macosx\"\n\ndefine i64 @mul_select_operand_known_1_via_scev() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i64 [ 12, %entry ], [ %red.next, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = and i32 %iv, 1\n %cmp1.i = icmp eq i32 %0, 0\n %narrow.i = select i1 %cmp1.i, i32 1, i32 %iv\n %mul = zext nneg i32 %narrow.i to i64\n %red.next = mul nsw i64 %red, %mul\n %iv.next = add nuw nsw i32 %iv, 1\n %ec = icmp eq i32 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %res = phi i64 [ %red.next, %loop ]\n ret i64 %res\n}\n", "additional_args": "-src-unroll=4 -tgt-unroll=4"}, {"test_name": "pr125374", "test_body": "target 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.body.i.i\n\nfor.body.i.i: ; preds = %for.body.i.i, %entry\n %indvars.iv.i.i = phi i64 [ 0, %entry ], [ %indvars.iv.next.i.i, %for.body.i.i ]\n %conv678.i.i = phi i8 [ 1, %entry ], [ %add.i.i.i, %for.body.i.i ]\n %add.i.i.i = add i8 0, %conv678.i.i\n %indvars.iv.next.i.i = add i64 %indvars.iv.i.i, 1\n %exitcond.not.i.i = icmp eq i64 %indvars.iv.i.i, 1\n br i1 %exitcond.not.i.i, label %o.exit, label %for.body.i.i\n\no.exit: ; preds = %for.body.i.i\n %conv6.i.i = zext i8 %add.i.i.i to i32\n ret i32 %conv6.i.i\n}\n", "additional_args": "-src-unroll=2 -tgt-unroll=2"}]}], "issue": {"title": "[clang] Miscompilation at -O3", "body": "This code prints 15 at -O3, but prints 5 at -O0/1/2:\n```c\nint printf(const char *, ...);\nstatic int a[] = {4294967295, 5};\nint b, c;\nint main() {\n a[1] = b = 5;\n unsigned d = -13;\n for (; d >= 8; d = a[0] + d + 6) {\n int *e = &b;\n *e = a[0] - -1 + b;\n }\n a[c];\n printf(\"%d\\n\", b);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/4xdPqcjPb\n\nBisected to https://github.com/llvm/llvm-project/commit/6d6eea92e36c301e34a7ec11b2a40e3080f79f53, which was committed by @fhahn ", "author": "cardigan1008", "labels": ["miscompilation", "vectorizers"], "comments": [{"author": "hstk30-hw", "body": "Don't ignore the warning.\n\n```\n<source>:2:19: warning: implicit conversion from 'long' to 'int' changes value from 4294967294 to -2 [-Wconstant-conversion]\n 2 | static int a[] = {4294967294, 5};\n | ~^~~~~~~~~~\n```"}, {"author": "antoniofrighetto", "body": "Please leave the issue opened, as it's implementation-defined behaviour, not undefined behaviour."}, {"author": "antoniofrighetto", "body": "Reduced to:\n```llvm\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine noundef i32 @src() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %entry, %for.body\n %d.06 = phi i32 [ -13, %entry ], [ %add2.reass, %for.body ]\n %add45 = phi i32 [ 5, %entry ], [ %add, %for.body ]\n %add = add i32 0, %add45\n %add2.reass = add i32 %d.06, 5\n %cmp = icmp ugt i32 %add2.reass, 7\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret i32 %add\n}\n```\n\n@fhahn I think the issue fundamentally here lies in the fact that we are incorrectly widening the constant 5 (retrieved from SCEV) to `<5, 5, 5, 5>`, when in fact it should be `<5, 0, 0, 0>` (VPlan value: `WIDEN-REDUCTION-PHI ir<%add45> = phi ir<5>`). The VPBasicBlock for the miscompiled basic block is the following one:\n```\nvector.body:\n EMIT vp<%4> = CANONICAL-INDUCTION ir<0>, vp<%7>\n WIDEN-INDUCTION %d.06 = phi -13, %add2.reass, ir<5>, vp<%0>\n WIDEN-REDUCTION-PHI ir<%add45> = phi ir<5>\n EMIT vp<%5> = WIDEN-CANONICAL-INDUCTION vp<%4>\n EMIT vp<%6> = icmp ule vp<%5>, vp<%3>\n```\nI'm not that familiar with VPlan, though I feel like that either we are not taking into account the active lane, or we should have not emitted a widen instruction in the first place.\n\n(Godbolt: https://llvm.godbolt.org/z/4Wz46ceh1)"}, {"author": "antoniofrighetto", "body": "@fhahn Would you be willing to have a look at it? Happy to help with any additional triage, if needed."}, {"author": "fhahn", "body": "Yep let me take a look!"}]}, "verified": true}
dataset/126085.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "126085",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/126085",
4
+ "bug_type": "crash",
5
+ "base_commit": "6575154b6eca80097d77db69ce1ee60c72854ee6",
6
+ "knowledge_cutoff": "2025-02-06T15:41:55Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/VectorCombine"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "eb2b453eb73dfe0b8cf516dfb4d568c0b858d1fa",
12
+ "components": [
13
+ "VectorCombine"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
17
+ [
18
+ 3210,
19
+ 3216
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
25
+ "VectorCombine::foldInsExtVectorToShuffle"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit eb2b453eb73dfe0b8cf516dfb4d568c0b858d1fa\nAuthor: Simon Pilgrim <[email protected]>\nDate: Thu Feb 6 16:40:48 2025 +0000\n\n [VectorCombine] foldInsExtVectorToShuffle - ensure we call getShuffleCost with the input operand type, not the result\n \n Typo in #121216\n \n Fixes #126085\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\nindex 4f46b621c8a7..746742e14d08 100644\n--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n@@ -3210,7 +3210,7 @@ bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {\n ExtToVecMask[0] = ExtIdx;\n // Add cost for expanding or narrowing\n NewCost = TTI.getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc,\n- DstVecTy, ExtToVecMask, CostKind);\n+ SrcVecTy, ExtToVecMask, CostKind);\n NewCost += TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind);\n }\n \n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/VectorCombine/X86/pr126085.ll",
33
+ "commands": [
34
+ "opt < %s -passes=vector-combine -S -mtriple=x86_64--"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\ndefine i32 @test(ptr %a0) {\n;\n %load = load <16 x i8>, ptr %a0, align 1\n %shuf = shufflevector <16 x i8> %load, <16 x i8> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>\n %elt = extractelement <16 x i8> %load, i64 11\n %ins = insertelement <4 x i8> %shuf, i8 %elt, i64 1\n %res = bitcast <4 x i8> %ins to i32\n ret i32 %res\n}"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[VectorCombine] Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.",
46
+ "body": "Reproducer:\n```\n; bin/opt -passes=vector-combine 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 @test(ptr readonly captures(none) dereferenceable(16) %0) {\n %2 = load <16 x i8>, ptr %0, align 1\n %.sroa.01.2.vec.insert = shufflevector <16 x i8> %2, <16 x i8> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>\n %3 = extractelement <16 x i8> %2, i64 11\n %.sroa.01.3.vec.insert = insertelement <4 x i8> %.sroa.01.2.vec.insert, i8 %3, i64 1\n %4 = bitcast <4 x i8> %.sroa.01.3.vec.insert to i32\n ret i32 %4\n}\n```\n```\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/IR/Instructions.cpp:1890: bool isSingleSourceMaskImpl(llvm::ArrayRef<int>, int): Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: bin/opt -passes=vector-combine reduced.ll -S\n1. Running pass \"function(vector-combine)\" on module \"reduced.ll\"\n2. Running pass \"vector-combine\" on function \"test\"\n #0 0x00007f4379a17152 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x217152)\n #1 0x00007f4379a1403f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x21403f)\n #2 0x00007f4379a1417c SignalHandler(int) Signals.cpp:0:0\n #3 0x00007f4379442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007f43794969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007f43794969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007f43794969fc pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007f4379442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007f43794287f3 abort ./stdlib/abort.c:81:7\n #9 0x00007f437942871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007f4379439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x00007f4370e71a16 isSingleSourceMaskImpl(llvm::ArrayRef<int>, int) Instructions.cpp:0:0\n#12 0x00007f4370e7c3dc llvm::ShuffleVectorInst::isReverseMask(llvm::ArrayRef<int>, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x27c3dc)\n#13 0x00007f43788933f2 llvm::X86TTIImpl::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0x4933f2)\n#14 0x00007f43716ddf0c llvm::TargetTransformInfo::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x4ddf0c)\n#15 0x00007f437224f6e7 (anonymous namespace)::VectorCombine::foldInsExtVectorToShuffle(llvm::Instruction&) VectorCombine.cpp:0:0\n#16 0x00007f4372256116 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const VectorCombine.cpp:0:0\n#17 0x00007f437225787f llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x25787f)\n#18 0x00007f4373f225c5 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.21.0git+0x1225c5)\n#19 0x00007f4370f10cad llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x310cad)\n#20 0x00007f43784dc235 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdc235)\n#21 0x00007f4370f0ee75 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x30ee75)\n#22 0x00007f43784dcbf5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdcbf5)\n#23 0x00007f4370f0fb2a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x30fb2a)\n#24 0x00007f4379ba3dc6 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) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x2fdc6)\n#25 0x00007f4379baf5c2 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x3b5c2)\n#26 0x00007f4379429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#27 0x00007f4379429e40 call_init ./csu/../csu/libc-start.c:128:20\n#28 0x00007f4379429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#29 0x00006293bc5a5095 _start (bin/opt+0x1095)\nAborted (core dumped)\n```\n\nTriggered by https://github.com/llvm/llvm-project/pull/121216. cc @ParkHanbum @RKSimon \nReported by https://github.com/dtcxzyw/llvm-opt-benchmark/issues/2093\n\n",
47
+ "author": "dtcxzyw",
48
+ "labels": [
49
+ "crash-on-valid",
50
+ "llvm:transforms"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "RKSimon",
55
+ "body": "Found the problem - fix incoming"
56
+ }
57
+ ]
58
+ },
59
+ "verified": true
60
+ }
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 = 125512
38
 
39
 
40
  def wait(progress):
 
34
  )
35
 
36
  issue_id_begin = 76663 # Since 2024-01-01
37
+ issue_id_end = 126174
38
 
39
 
40
  def wait(progress):
scripts/postfix_extract.py CHANGED
@@ -104,6 +104,7 @@ fix_commit_map = {
104
  "119173": "30f3752e54fa7cd595a434a985efbe9a7abe9b65",
105
  "119646": None, # Cannot reproduce with alive2
106
  "121430": None, # Alive2 bug https://github.com/AliveToolkit/alive2/pull/1155
 
107
  "122166": None, # Duplicate of #117308
108
  "122324": None, # Cannot confirm fix with alive2
109
  "122430": None, # Cannot confirm fix with alive2
 
104
  "119173": "30f3752e54fa7cd595a434a985efbe9a7abe9b65",
105
  "119646": None, # Cannot reproduce with alive2
106
  "121430": None, # Alive2 bug https://github.com/AliveToolkit/alive2/pull/1155
107
+ "121583": None, # Removed fold
108
  "122166": None, # Duplicate of #117308
109
  "122324": None, # Cannot confirm fix with alive2
110
  "122430": None, # Cannot confirm fix with alive2