Vikram S. Adve
2002-Sep-11 10:08 UTC
[LLVMdev] FW: question about malloc call vs. instruction
I'm forwarding this question to llvmdev: -----Original Message----- From: lee white baugh [mailto:leebaugh at students.uiuc.edu] Sent: Wednesday, September 11, 2002 1:27 AM To: Vikram S. Adve Subject: RE: mp1 i'll attempt to address the issues i raised in my long email as i am able. as i said i have figured out the worklist thing, and am happy to report that i've negotiated lots of troubles compiling and so on and am actually printing out a bunch of instructions. which reveals my new problem: when i attempt a malloc in my own, it comes out like this: %reg216 = call int (...)* %malloc( ulong 8 ) ; <int> [#uses=1] a call to malloc, not a malloc instruction. i don't know how to get the information i need out of a call to malloc. when i replace 'malloc' in the code with 'alloca', i get %reg107 = alloca ubyte, uint 8 ; <ubyte*> [#uses=1] so everything is fine for alloca. i thought if i ran the inline pass it might change a malloc call to a malloc instruction, but it didn't. can you tell me what's up here? i'm really sorry to constantly bug you. if you hate it let me know. my motivation in doing so is to get through this as quickly as i can so i can return to qual studying! lee <pre> +------+ +-+ o+---\ / +--+ The *- ++ Hamster +--/ \ >-------------< this living hand, now warm and capable of earnest grasping, would, if it were cold and in the icy silence of the tomb, so haunt thy days and chill thy dreaming nights that thou wouldst wish thine own heart dry of blood so in my veins red life might stream again, and thou be conscience-calmed -- see here it is -- i hold it towards you. : john keats </pre>
Chris Lattner
2002-Sep-11 13:45 UTC
[LLVMdev] FW: question about malloc call vs. instruction
> printing out a bunch of instructions. which reveals my new problem: when > i attempt a malloc in my own, it comes out like this: > > %reg216 = call int (...)* %malloc( ulong 8 ) ; <int> [#uses=1] > a call to malloc, not a malloc instruction. i don't know how to get the > information i need out of a call to malloc.You need to #include <stdlib.h>. Try compiling with warnings on (-Wall -W), and you should get diagnostics for problems like this.> when i replace 'malloc' in the code with 'alloca', i get > %reg107 = alloca ubyte, uint 8 ; <ubyte*> [#uses=1] > so everything is fine for alloca.alloca doesn't require a prototype.> i thought if i ran the inline pass it might change a malloc call to a > malloc instruction, but it didn't. can you tell me what's up here?No prototype = Not a known function... The inlining pass shouldn't touch malloc instructions/calls. The malloc calls should be eliminated by a pass "built into" the GCC frontend: http://llvm.cs.uiuc.edu/doxygen/RaiseAllocations_8cpp-source.html ... but this only will work if there is a prototype for the function. -Chris