git: 514c98ba14a0 - main - Merge commit 37b7207651b4 from llvm-project (by zhongyunde@huawei.com):
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 15 Apr 2024 16:30:56 UTC
The branch main has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=514c98ba14a0f590891844d1a6bec0ac4de54489
commit 514c98ba14a0f590891844d1a6bec0ac4de54489
Author: Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-04-15 16:24:39 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-04-15 16:30:29 +0000
Merge commit 37b7207651b4 from llvm-project (by zhongyunde@huawei.com):
[SimplifyCFG] Fix crash when there is unreachable large index (#88616)
The large case index out of scope is dead code, but it is still be
created for TableContents in SwitchLookupTable::SwitchLookupTable,
so make sure the table size after growing should not get smaller.
Fix https://github.com/llvm/llvm-project/issues/88607
This should fix "Assertion failed: (idx < size()), function operator[]"
when building the science/dynare port.
PR: 276104, 278320
Reported by: yuri
MFC after: 1 month
---
contrib/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/contrib/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 13eae549b2ce..f95dae1842fe 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6710,9 +6710,11 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
return SwitchLookupTable::WouldFitInRegister(
DL, UpperBound, KV.second /* ResultType */);
})) {
+ // There may be some case index larger than the UpperBound (unreachable
+ // case), so make sure the table size does not get smaller.
+ TableSize = std::max(UpperBound, TableSize);
// The default branch is unreachable after we enlarge the lookup table.
// Adjust DefaultIsReachable to reuse code path.
- TableSize = UpperBound;
DefaultIsReachable = false;
}
}