[LLVMdev] Allocate memory for a class

B B blackbox.dev.ml at gmail.com
Thu Apr 25 05:13:07 PDT 2013


Hi!

When I allocate memory for a structure, in _Znwm (operator new) function I
need to specify size. How can I determine this information dynamically?

; ModuleID = '/tmp/webcompile/_12211_0.bc'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.A = type { i32, float }

define i32 @main() uwtable {
entry:
%a = alloca %class.A*, align 8
%call = call noalias i8* @_Znwm(i64 8)  ; << how can I determine this value?
%0 = bitcast i8* %call to %class.A*
store %class.A* %0, %class.A** %a, align 8
ret i32 0
}

declare noalias i8* @_Znwm(i64)

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130425/5074e736/attachment.html>


More information about the llvm-dev mailing list