[LLVMdev] Question about llvm::dbg()

Jean-Daniel Dupas devlists at shadowlab.org
Tue Jan 19 14:18:12 PST 2010


Maybe I miss something but I think there is a problem with this code in Support/Debug.cpp when compiling in Release build (NDEBUG defined):

namespace llvm {
  /// dbgs - Return dbgs().
  raw_ostream &dbgs() {
    return dbgs();
  }
}

I though it would crash with a stack overflow due to infinite recursion, but llvm-gcc is smart enough to compile it as a jmp and create an infinite loop instead 

otool -tv Debug.o

llvm::dbgs():
0000000000000000	pushq	%rbp
0000000000000001	movq	%rsp,%rbp
0000000000000004	jmp	0x00000004

Anyway, I think neither crash nor infinite loop is the expected behavior, isn't it ? 

-- Jean-Daniel








More information about the llvm-dev mailing list