Re: malloc was optimized out
Re: malloc was optimized out
- Subject: Re: malloc was optimized out
- From: Chris Cleeland <email@hidden>
- Date: Mon, 04 Jul 2016 22:27:34 -0500
Whether you agree or disagree with what clang does, it doesn't matter. clang is doing what it is doing; *YOU* have to deal with it in your code.
Your contrived example is not at all like the example you provided where the pointers in a struct-returned-by-value are assigned to the return value of malloc(). In the contrived example clang is well within its rights to optimize out the call to malloc as has been explained well by others (yes, I know you don't agree but that honestly doesn't matter because, frankly, you're wrong in that regard).
I think that if you want to report a bug, you need to model things after your more complicated example because based solely on what you show it seems less likely that the optimizer has enough information to optimize out a malloc.
If you really want to know how much space is available for heap allocation, you're going to have to try to touch every page in your requested set. Even then there would be cases you can't accommodate such as when memory gets freed up you wouldn't know about it.
To really do this correctly, you are going to have to dive down and get intimate with the VM subsystem of each OS on which you run, and hopefully create an abstraction over it that permits you to do what you feel you need.
But, at this point, based on the evidence, clang is not your problem.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden