Skip to content

Commit 8634635

Browse files
committed
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
1 parent 4277c21 commit 8634635

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/CodeGen/RegAllocFast.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ void RegAllocFastImpl::allocVirtRegUndef(MachineOperand &MO) {
982982
if (!shouldAllocateRegister(VirtReg))
983983
return;
984984

985+
MO.setIsRenamable();
985986
LiveRegMap::iterator LRI = findLiveVirtReg(VirtReg);
986987
MCPhysReg PhysReg;
987988
if (LRI != LiveVirtRegs.end() && LRI->PhysReg) {
@@ -997,6 +998,7 @@ void RegAllocFastImpl::allocVirtRegUndef(MachineOperand &MO) {
997998
// basic.
998999
PhysReg = getErrorAssignment(*LRI, *MO.getParent(), RC);
9991000
LRI->Error = true;
1001+
MO.setIsRenamable(false);
10001002
} else
10011003
PhysReg = AllocationOrder.front();
10021004
}
@@ -1007,7 +1009,6 @@ void RegAllocFastImpl::allocVirtRegUndef(MachineOperand &MO) {
10071009
MO.setSubReg(0);
10081010
}
10091011
MO.setReg(PhysReg);
1010-
MO.setIsRenamable(!LRI->Error);
10111012
}
10121013

10131014
/// Variation of defineVirtReg() with special handling for livethrough regs

0 commit comments

Comments
 (0)