[llvm-dev] Conditional jump or move depends on uninitialised value(s)

regehr via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 21 15:38:22 PST 2016

I spent some time digging into a Valgrind report of uninitialized values 
in LLVM r287520 built using itself.  (One of quite a few such reports 
that comes up during a "make check".)

I could use another set of eyes on the issue if someone has time.

This command gives me an error:

valgrind -q ./bin/llc < 
/home/regehr/llvm/test/CodeGen/Hexagon/hwloop-dbg.ll -march=hexagon 

The error is at this line:


Here I've refactored the code into a minimal (noinline) function that 
still triggers the problem.  xfunc2() and xfunc3() are also noinline. 
The problem goes away if either isReg() or isDef() is marked noinline.

void xfuncx(const MachineOperand &MO,
	    const TargetRegisterInfo *TRI,
	   BitVector &LivePhysRegs)  {
   if (MO.isReg() &&  // <<<<------ problem reported here
       MO.isDef()) {
     xfunc2(MO, TRI, LivePhysRegs);
   } else {
     xfunc3(MO, LivePhysRegs);

The asm is below.  Maybe I've been staring too long but I don't see the 
problem Valgrind is talking about.


.text._Z6xfuncxRKN4llvm14MachineOperandEPKNS_18TargetRegisterInfoERNS_9BitVectorE,"ax", at progbits
	.p2align	4, 0x90
_Z6xfuncxRKN4llvm14MachineOperandEPKNS_18TargetRegisterInfoERNS_9BitVectorE, at function
	.loc	2 126 0                 # 
# BB#0:                                 # %entry
	#DEBUG_VALUE: xfuncx:MO <- %RDI
	#DEBUG_VALUE: xfuncx:TRI <- %RSI
	#DEBUG_VALUE: xfuncx:LivePhysRegs <- %RDX
	#DEBUG_VALUE: isReg:this <- %RDI
	.loc	2 127 18 prologue_end   # 
	movl	$16777471, %eax         # imm = 0x10000FF
	andl	(%rdi), %eax
	#DEBUG_VALUE: isReg:this <- %RDI
	cmpl	$16777216, %eax         # imm = 0x1000000
	jne	.LBB4_2
# BB#1:                                 # %if.then
	#DEBUG_VALUE: xfuncx:LivePhysRegs <- %RDX
	#DEBUG_VALUE: xfuncx:TRI <- %RSI
	#DEBUG_VALUE: xfuncx:MO <- %RDI
	.loc	2 129 5                 # 
_Z6xfunc2RKN4llvm14MachineOperandEPKNS_18TargetRegisterInfoERNS_9BitVectorE at PLT 
.LBB4_2:                                # %if.else
	#DEBUG_VALUE: xfuncx:LivePhysRegs <- %RDX
	#DEBUG_VALUE: xfuncx:TRI <- %RSI
	#DEBUG_VALUE: xfuncx:MO <- %RDI
	.loc	2 131 5                 # 
	movq	%rdx, %rsi
	jmp	_Z6xfunc3RKN4llvm14MachineOperandERNS_9BitVectorE at PLT # TAILCALL

More information about the llvm-dev mailing list