From 9e57bf586ce72e30039a8b226ef1aa6c310d25b5 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Sat, 21 May 2016 01:41:17 +0000 Subject: [RegisterBankInfo] Fix the initialization of the map VT to RegBank. Prior to this patch we could have read uninitialized memory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270303 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') 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. -- cgit v1.2.3