[cfe-commits] [PATCH] Add -fobjc-direct-class-refs
rjmccall at apple.com
Mon May 14 12:12:24 PDT 2012
On May 14, 2012, at 11:44 AM, Jonathan Schleifer wrote:
> Am 14.05.2012 um 20:34 schrieb John McCall:
>> If the GNU runtime supports emitting direct references to the class, why is a command-line option necessary?
> The GNU runtime does not. The GNUstep runtime does and mine does.
> It needs to be an option as this is not even part of the new, non-fragile ABI. So when compiling against the GNUstep or my runtime, this flag can be used to directly reference classes - this makes for more than a 2x speedup in real world application. This also means this is independent on whether you use the fragile or non-fragile ABI. You might want to use the fragile ABI with -fobjc-direct-class-refs for maximum performance.
I agree that this is at least theoretically independent of the fragile ABI vs. the nonfragile ABI, although I suspect that you'd need to check both implementations to verify that they do, in fact, guarantee the correctness of this. In Darwin's runtime, at least, the nonfragile ABI reserves the right to make class references "forward", so that the address of the global symbol is not necessarily the address of the class.
>> I am opposed to providing an ever-expanding spectrum of command line flags — particularly driver flags! — to slightly tweak the ABI.
> Then we need a module for each runtime so we have multiple -f*-runtime. CGObjCGNU.cpp would need to be splitted into CGObjCGNU.cpp, CGObjCGNUstep.cpp and CGObjCObjFW.cpp for -fgnu-runtime, -fgnustep-runtime and -fobjfw-runtime - for just a few lines of differences. Is this really better?
Or, you know, it could be a subclass that just implements GetClass differently, or even just sets a flag in the common GNU implementation that is honored by GetClass. There is no need to leap to the most absurd possible implementation.
The right thing to do is to propagate information down like "please optimize for this specific runtime". Whether that means "-fgnustep-runtime" or "-fgnu-runtime=gnustep" or "-foptimize-runtime=gnustep" is a separable choice.
>> Even if we supported this, it would be an IR-gen option, not a language option.
> Can you elaborate, please? I'm new to Clang's code.
There is a separate structure called the CodeGenOptions which carries options which don't alter the language dialect but which do impact how code is emitted to implement it.
More information about the cfe-commits