diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2025-02-26 15:25:55 +0100 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2025-02-26 15:25:55 +0100 |
commit | 8634635d689c5a7adfb19cde4a313d7c02e95194 (patch) | |
tree | f5186ae93953875e610cca4816cd20ec00a45747 /llvm/lib/CodeGen/RegAllocFast.cpp | |
parent | 4277c21059a80fdd915aef9abd7be3d2b161f1b0 (diff) | |
download | llvm-8634635d689c5a7adfb19cde4a313d7c02e95194.zip llvm-8634635d689c5a7adfb19cde4a313d7c02e95194.tar.gz llvm-8634635d689c5a7adfb19cde4a313d7c02e95194.tar.bz2 |
RegAllocFast: Stop reading uninitalized memory
Found by msan.
==8138==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x559016395beb in allocVirtRegUndef llvm/lib/CodeGen/RegAllocFast.cpp:1010:6
Diffstat (limited to 'llvm/lib/CodeGen/RegAllocFast.cpp')
-rw-r--r-- | llvm/lib/CodeGen/RegAllocFast.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/RegAllocFast.cpp b/llvm/lib/CodeGen/RegAllocFast.cpp index 0f44f6d..3627bbb 100644 --- a/llvm/lib/CodeGen/RegAllocFast.cpp +++ b/llvm/lib/CodeGen/RegAllocFast.cpp @@ -982,6 +982,7 @@ void RegAllocFastImpl::allocVirtRegUndef(MachineOperand &MO) { if (!shouldAllocateRegister(VirtReg)) return; + MO.setIsRenamable(); LiveRegMap::iterator LRI = findLiveVirtReg(VirtReg); MCPhysReg PhysReg; if (LRI != LiveVirtRegs.end() && LRI->PhysReg) { @@ -997,6 +998,7 @@ void RegAllocFastImpl::allocVirtRegUndef(MachineOperand &MO) { // basic. PhysReg = getErrorAssignment(*LRI, *MO.getParent(), RC); LRI->Error = true; + MO.setIsRenamable(false); } else PhysReg = AllocationOrder.front(); } @@ -1007,7 +1009,6 @@ void RegAllocFastImpl::allocVirtRegUndef(MachineOperand &MO) { MO.setSubReg(0); } MO.setReg(PhysReg); - MO.setIsRenamable(!LRI->Error); } /// Variation of defineVirtReg() with special handling for livethrough regs |