mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-27 05:40:06 +00:00
Fix folding of volatile store. (#2048)
When looking for the Volatile mask on a store, the instruction folder accesses an out-of-bounds element. We fix that up. Fixes crbug.com/903530.
This commit is contained in:
parent
a6150a3fe7
commit
dc9d155d62
@ -2025,7 +2025,7 @@ FoldingRule StoringUndef() {
|
||||
|
||||
// If this is a volatile store, the store cannot be removed.
|
||||
if (inst->NumInOperands() == 3) {
|
||||
if (inst->GetSingleWordInOperand(3) & SpvMemoryAccessVolatileMask) {
|
||||
if (inst->GetSingleWordInOperand(2) & SpvMemoryAccessVolatileMask) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -5821,7 +5821,7 @@ TEST_P(MatchingInstructionWithNoResultFoldingTest, Case) {
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(StoreMatchingTest, MatchingInstructionWithNoResultFoldingTest,
|
||||
::testing::Values(
|
||||
// Test case 0: Using OpDot to extract last element.
|
||||
// Test case 0: Remove store of undef.
|
||||
InstructionFoldingCase<bool>(
|
||||
Header() +
|
||||
"; CHECK: OpLabel\n" +
|
||||
@ -5834,7 +5834,18 @@ INSTANTIATE_TEST_CASE_P(StoreMatchingTest, MatchingInstructionWithNoResultFoldin
|
||||
"OpStore %n %undef\n" +
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
0 /* OpStore */, true)
|
||||
0 /* OpStore */, true),
|
||||
// Test case 1: Keep volatile store.
|
||||
InstructionFoldingCase<bool>(
|
||||
Header() +
|
||||
"%main = OpFunction %void None %void_func\n" +
|
||||
"%main_lab = OpLabel\n" +
|
||||
"%n = OpVariable %_ptr_v4double Function\n" +
|
||||
"%undef = OpUndef %v4double\n" +
|
||||
"OpStore %n %undef Volatile\n" +
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
0 /* OpStore */, false)
|
||||
));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(VectorShuffleMatchingTest, MatchingInstructionWithNoResultFoldingTest,
|
||||
|
Loading…
Reference in New Issue
Block a user