Debian Codegraph @

external/llvm/releases/14.0.0/patches_external/LowerSwitch-RemoveUnreachableBBs.patch

raw
1 /*========================== begin_copyright_notice ============================
2
3 Copyright (C) 2024 Intel Corporation
4
5 SPDX-License-Identifier: MIT
6
7 ============================= end_copyright_notice ===========================*/
8 /*========================== begin_copyright_notice ============================
9
10 Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
11 See https://llvm.org/LICENSE.txt for license information.
12 SPDX-License-Identifier: Apache-2.0 with LLVM-exception
13
14 ============================= end_copyright_notice ===========================*/
15 The reason for removing unreachable blocks is this change in the LLVM repo:
16 https://github.com/llvm/llvm-project/commit/1065f3439bad59323f16e7c8ee568c7d94dcd952
17 LowerSwitchPass can leave phi instructions with nodes from unreachable basic blocks
18 which is a disallowed state for DomTree.
19
20 diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
21 index aff9d1311..b38de0a7a 100644
22 --- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp
23 +++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
24 @@ -38,6 +38,7 @@
25 #include "llvm/Support/raw_ostream.h"
26 #include "llvm/Transforms/Utils.h"
27 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
28 +#include "llvm/Transforms/Utils/Local.h"
29 #include <algorithm>
30 #include <cassert>
31 #include <cstdint>
32 @@ -542,6 +543,10 @@ bool LowerSwitch(Function &F, LazyValueInfo *LVI, AssumptionCache *AC) {
33 DeleteDeadBlock(BB);
34 }
35
36 + if (!DeleteList.empty()) {
37 + removeUnreachableBlocks(F);
38 + }
39 +
40 return Changed;
41 }
42