[LLVMdev] Another two questions on LLVM

Duncan Sands baldrick at free.fr
Mon Jun 7 12:52:18 PDT 2010

Hi Xiaolong,

> First, how does LLVM handle the "new statement" of C++? Could any one
> give me any hint?

LLVM doesn't have special support for "new".  It's up to the C++ front-ends
(clang++, llvm-g++, g++-4.5+dragonegg) to lower "new" to LLVM IR.  You can
find out how by pasting C++ code into http://llvm.org/demo
For example, "int *n(void) { return new int; }" ->

define i32* @_Z1nv() {
   %0 = tail call i8* @_Znwm(i64 4)                ; <i8*> [#uses=1]
   %1 = bitcast i8* %0 to i32*                     ; <i32*> [#uses=1]
   ret i32* %1

declare i8* @_Znwm(i64)

> Second, what properties does the callgraph generated by LLVM has? One
> property I am interesting in is whether the callgraph is a safe
> approximation of its corresponding run-time callgraph.

It is, otherwise it would be useless.

> Third, does LLVM provide any strategy to resolve function calls? If
> yes, what strategies does it employ?

This is mostly done by the the inline and instcombine passes.



More information about the llvm-dev mailing list