1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

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

Prior to this patch we could have read uninitialized memory.

llvm-svn: 270303
This commit is contained in:
Quentin Colombet 2016-05-21 01:41:17 +00:00
parent d7d0f71629
commit a48386a2aa

View File

@ -272,9 +272,12 @@ protected:
/// \post if Force == true then getRegBankForType(SVT) == &RegBank /// \post if Force == true then getRegBankForType(SVT) == &RegBank
void recordRegBankForType(const RegisterBank &RegBank, void recordRegBankForType(const RegisterBank &RegBank,
MVT::SimpleValueType SVT, bool Force = false) { MVT::SimpleValueType SVT, bool Force = false) {
if (!VTToRegBank) if (!VTToRegBank) {
VTToRegBank.reset( VTToRegBank.reset(
new const RegisterBank *[MVT::SimpleValueType::LAST_VALUETYPE]); 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"); assert(SVT < MVT::SimpleValueType::LAST_VALUETYPE && "Out-of-bound access");
// If we want to override the mapping or the mapping does not exits yet, // If we want to override the mapping or the mapping does not exits yet,
// set the register bank for SVT. // set the register bank for SVT.