calling convention optimisation & const/immutable ref
Matthias Bentrup via Digitalmars-d
digitalmars-d at puremagic.com
Tue Nov 8 05:21:47 PST 2016
On Tuesday, 8 November 2016 at 12:56:10 UTC, Johan Engelen wrote:
> On Monday, 7 November 2016 at 16:48:55 UTC, John Colvin wrote:
>> [...]
>
> This reminds me of an LLVM presentation by Chandler, mentioning
> that passing by reference may hamper the optimization of code
> (because memory becomes involved). I don't think he gave a
> clear example, but one thing I can think of is potential
> aliasing:
> void foo(ref LargeThing a, ref LargeThing b), where a and b may
> alias partly.
> To do the "ref" optimization for _all_ large function
> parameters per default sounds like a bad idea.
>
> Also, how would I turn the optimization off (I guess
> extern(C++) would do that?)? What if my function needs a local
> copy (say, in multithreaded stuff), and I want that copy to be
> const?
>
> -Johan
Aliasing is not an issue when LargeThing is immutable, is it ?
More information about the Digitalmars-d
mailing list