Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
763adc5
commit 6252389
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# This patch is required to fix the crash referenced to in #1767. | ||
# It is a port of the following llvm 11.0 commit : https://reviews.llvm.org/D76994. | ||
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | ||
index 63ddb59fce6..822da218326 100644 | ||
--- lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | ||
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | ||
@@ -173,7 +173,7 @@ void DAGTypeLegalizer::PerformExpensiveChecks() { | ||
} | ||
} | ||
} | ||
- | ||
+#ifndef NDEBUG | ||
// Checked that NewNodes are only used by other NewNodes. | ||
for (unsigned i = 0, e = NewNodes.size(); i != e; ++i) { | ||
SDNode *N = NewNodes[i]; | ||
@@ -181,6 +181,7 @@ void DAGTypeLegalizer::PerformExpensiveChecks() { | ||
UI != UE; ++UI) | ||
assert(UI->getNodeId() == NewNode && "NewNode used by non-NewNode!"); | ||
} | ||
+#endif | ||
} | ||
|
||
/// This is the main entry point for the type legalizer. This does a top-down | ||
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h | ||
index faae14444d5..b908c5c58e9 100644 | ||
--- lib/CodeGen/SelectionDAG/LegalizeTypes.h | ||
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.h | ||
@@ -155,7 +155,9 @@ private: | ||
const SDValue &getSDValue(TableId &Id) { | ||
RemapId(Id); | ||
assert(Id && "TableId should be non-zero"); | ||
- return IdToValueMap[Id]; | ||
+ auto I = IdToValueMap.find(Id); | ||
+ assert(I != IdToValueMap.end() && "cannot find Id in map"); | ||
+ return I->second; | ||
} | ||
|
||
public: | ||
@@ -172,24 +174,29 @@ public: | ||
bool run(); | ||
|
||
void NoteDeletion(SDNode *Old, SDNode *New) { | ||
+ assert(Old != New && "node replaced with self"); | ||
for (unsigned i = 0, e = Old->getNumValues(); i != e; ++i) { | ||
TableId NewId = getTableId(SDValue(New, i)); | ||
TableId OldId = getTableId(SDValue(Old, i)); | ||
|
||
- if (OldId != NewId) | ||
+ if (OldId != NewId) { | ||
ReplacedValues[OldId] = NewId; | ||
|
||
- // Delete Node from tables. | ||
+ // Delete Node from tables. We cannot do this when OldId == NewId, | ||
+ // because NewId can still have table references to it in | ||
+ // ReplacedValues. | ||
+ IdToValueMap.erase(OldId); | ||
+ PromotedIntegers.erase(OldId); | ||
+ ExpandedIntegers.erase(OldId); | ||
+ SoftenedFloats.erase(OldId); | ||
+ PromotedFloats.erase(OldId); | ||
+ ExpandedFloats.erase(OldId); | ||
+ ScalarizedVectors.erase(OldId); | ||
+ SplitVectors.erase(OldId); | ||
+ WidenedVectors.erase(OldId); | ||
+ } | ||
+ | ||
ValueToIdMap.erase(SDValue(Old, i)); | ||
- IdToValueMap.erase(OldId); | ||
- PromotedIntegers.erase(OldId); | ||
- ExpandedIntegers.erase(OldId); | ||
- SoftenedFloats.erase(OldId); | ||
- PromotedFloats.erase(OldId); | ||
- ExpandedFloats.erase(OldId); | ||
- ScalarizedVectors.erase(OldId); | ||
- SplitVectors.erase(OldId); | ||
- WidenedVectors.erase(OldId); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// RUN: %{ispc} --target=avx2-i32x16 %s -o %t.o | ||
// REQUIRES: X86_ENABLED | ||
extern uniform bool arr_4[17]; | ||
export void test(uniform int64 var_1, uniform bool var_15) { | ||
foreach (i_0 = var_1... 16U) | ||
arr_4[i_0] = !(varying bool)reduce_min(180) ? 5923697687793782713ULL : (varying bool)var_15; | ||
} |