From a48386a2aaad9c294f9794577337e31283138b18 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Sat, 21 May 2016 01:41:17 +0000 Subject: [PATCH] [RegisterBankInfo] Fix the initialization of the map VT to RegBank. Prior to this patch we could have read uninitialized memory. llvm-svn: 270303 --- include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index b640637cdee..8f7042655cb 100644 --- a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h +++ b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -272,9 +272,12 @@ protected: /// \post if Force == true then getRegBankForType(SVT) == &RegBank void recordRegBankForType(const RegisterBank &RegBank, MVT::SimpleValueType SVT, bool Force = false) { - if (!VTToRegBank) + if (!VTToRegBank) { VTToRegBank.reset( new const RegisterBank *[MVT::SimpleValueType::LAST_VALUETYPE]); + std::fill(&VTToRegBank[0], + &VTToRegBank[MVT::SimpleValueType::LAST_VALUETYPE], nullptr); + } assert(SVT < MVT::SimpleValueType::LAST_VALUETYPE && "Out-of-bound access"); // If we want to override the mapping or the mapping does not exits yet, // set the register bank for SVT.