/*========================== begin_copyright_notice ============================ Copyright (C) 2026 Intel Corporation SPDX-License-Identifier: MIT ============================= end_copyright_notice ===========================*/ /*========================== begin_copyright_notice ============================ Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. See https://llvm.org/LICENSE.txt for license information. SPDX-License-Identifier: Apache-2.0 with LLVM-exception ============================= end_copyright_notice ===========================*/ We've observed that in some cases (e.g this test: https://github.com/intel/intel-graphics-compiler/blob/master/IGC/ocloc_tests/retry/final_test_pytorch3.ll) whole function's body is removed when it shouldn't. This patch makes InstructionCombiner behaviour consistent with LLVM 16 by disabling part of removal logic. In upstream it was handled/fixed like this: https://github.com/llvm/llvm-project/commit/70aca7b12220971dcc54ec6431813665eac5856e I think this patch can be removed once we switch to LLVM 18 or later. diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 6aa20ee26..5d0e5d00b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -1559,14 +1559,14 @@ Instruction *InstCombinerImpl::visitStoreInst(StoreInst &SI) { } // This is a non-terminator unreachable marker. Don't remove it. - if (isa(Ptr)) { - // Remove all instructions after the marker and guaranteed-to-transfer - // instructions before the marker. - if (handleUnreachableFrom(SI.getNextNode()) || - removeInstructionsBeforeUnreachable(SI)) - return &SI; - return nullptr; - } + // if (isa(Ptr)) { + // // Remove all instructions after the marker and guaranteed-to-transfer + // // instructions before the marker. + // if (handleUnreachableFrom(SI.getNextNode()) || + // removeInstructionsBeforeUnreachable(SI)) + // return &SI; + // return nullptr; + // } // store undef, Ptr -> noop // FIXME: This is technically incorrect because it might overwrite a poison