From 20a4b1461bab25af48d73b07ca5bafafc397eb2e Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 6 Apr 2020 14:08:39 +0100 Subject: [PATCH] aco: zero-initialize Temp MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes dEQP-VK.transform_feedback.* crashes from accesses garbage temporaries in emit_extract_vector(). Fixes: 85521061 ("aco: prepare helper functions for subdword handling") Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Tested-by: Marge Bot Part-of: --- src/amd/compiler/aco_instruction_selection.cpp | 1 - src/amd/compiler/aco_ir.h | 2 +- src/amd/compiler/aco_optimizer.cpp | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 2d9b78792f3..6a63d5d8718 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -274,7 +274,6 @@ Temp emit_extract_vector(isel_context* ctx, Temp src, uint32_t idx, RegClass dst assert(src.bytes() > (idx * dst_rc.bytes())); Builder bld(ctx->program, ctx->block); auto it = ctx->allocated_vec.find(src.id()); - /* the size check needs to be early because elements other than 0 may be garbage */ if (it != ctx->allocated_vec.end() && dst_rc.bytes() == it->second[idx].regClass().bytes()) { if (it->second[idx].regClass() == dst_rc) { return it->second[idx]; diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index b05f809d21f..17ce7e39f1b 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -262,7 +262,7 @@ static constexpr RegClass v8b{RegClass::v8b}; * and SSA id. */ struct Temp { - Temp() = default; + Temp() noexcept : id_(0), reg_class(RegType::sgpr, 0) {} constexpr Temp(uint32_t id, RegClass cls) noexcept : id_(id), reg_class(cls) {} diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index 7a5b8f9d756..72ae710f838 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -103,6 +103,8 @@ struct ssa_info { }; uint32_t label; + ssa_info() : label(0) {} + void add_label(Label new_label) { /* Since all labels which use "instr" use it for the same thing -- 2.30.2