[PATCH] Standardize usage of CodeGenModule::getContext().getTargetInfo()

Stephen Lin swlin at post.harvard.edu
Wed Apr 10 06:49:10 PDT 2013


Ok, this revised patch standardizes it the other way, wherever the
getContext().getTargetInfo() pattern is used (not just CodeGenModule).
A lot of lines are different length now now so I reformatted the
containing statements to standard line wrap style.

I decided to go ahead and cache Target everywhere this pattern is
used; it was already being cached at CodeGenFunction and CodeGenTypes,
but the cache was not being used consistently (sometimes the cache
would be used directly, sometimes it would be be used through an
accessor  and sometimes it wouldn't be used at all). I standardized
all usage to use the accessor, since Target was being shadowed by
local variables sometimes, and to make the code more grepable.

Also, I noticed that TargetOptions is not being used by CodeGenModule
(it seems like all the information it could be used for is
encapsulated in ASTContext already), so I removed it from its
constructor's parameters as well as the parameters of its callers,
recursively, that were defined within the "lib" tree. I didn't remove
it from CreateLLVMCodeGen in "include/clang/CodeGen/ModuleBuilder.h",
since that's apparently part of the public interface of the CodeGen
library. I also put this in an separate patch in case there's some
reason it shouldn't be removed, but this patch should only be applied
on top of the previous one.

Let me know if this looks OK.

On Tue, Apr 9, 2013 at 5:12 PM, Stephen Lin <swlin at post.harvard.edu> wrote:
> OK, I'll go the other way.
>
> On Tue, Apr 9, 2013 at 4:54 PM, John McCall <rjmccall at apple.com> wrote:
>> On Apr 8, 2013, at 9:09 PM, Stephen Lin <swlin at post.harvard.edu> wrote:
>>> CodeGenModule::getTarget() is implemented as a trivial call to
>>> CodeGenModule::getContext().getTargetInfo(), however, the two are
>>> called interchangeably from other functions without any apparent
>>> semantic distinction between the two.
>>>
>>> Since the latter usage is more prevalent and is more fundamental
>>> anyway, I've eliminated the former and converted all usages to the
>>> latter.
>>
>> I'd go the other way, actually:  it's shorter, and we can cache it easily
>> if we decide it's important.
>>
>>> Also, I've removed CodeGenTypes::getTarget(), since it wasn't
>>> being used.
>>
>> This seems fine.
>>
>> John.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: standardize-target-info.patch
Type: application/octet-stream
Size: 40866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130410/beddc9c5/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: remove-target-options.patch
Type: application/octet-stream
Size: 3974 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130410/beddc9c5/attachment-0001.obj>


More information about the cfe-commits mailing list