[llvm] r270303 - [RegisterBankInfo] Fix the initialization of the map VT to RegBank.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Fri May 20 18:41:17 PDT 2016


Author: qcolombet
Date: Fri May 20 20:41:17 2016
New Revision: 270303

URL: http://llvm.org/viewvc/llvm-project?rev=270303&view=rev
Log:
[RegisterBankInfo] Fix the initialization of the map VT to RegBank.

Prior to this patch we could have read uninitialized memory.

Modified:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h

Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h?rev=270303&r1=270302&r2=270303&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h Fri May 20 20:41:17 2016
@@ -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.




More information about the llvm-commits mailing list