[cfe-dev] MRV on x86_64

Eli Friedman eli.friedman at gmail.com
Wed Mar 16 23:29:36 PDT 2011


On Thu, Mar 10, 2011 at 2:18 PM, Arushi Aggarwal <arushi987 at gmail.com> wrote:
> Hi,
>
> Also, is there a specific flag that I can pass to clang, to make sure it
> does optimizations like these, as I am passing the -disable-llvm-optzns
> flag, in general, to disable any other optimizations.
>
> Regards,
> Arushi
>
> On Thu, Mar 10, 2011 at 4:14 PM, Arushi Aggarwal <arushi987 at gmail.com>
> wrote:
>>
>>
>> On Thu, Mar 10, 2011 at 3:40 PM, Eli Friedman <eli.friedman at gmail.com>
>> wrote:
>>>
>>> On Thu, Mar 10, 2011 at 1:09 PM, Arushi Aggarwal <arushi987 at gmail.com>
>>> wrote:
>>> > Hi,
>>> >
>>> > I am using clang on the following code,
>>> >
>>> > struct S {
>>> >   float a,b,c;
>>> > };
>>> >
>>> > void foo(struct S obj) {
>>> >   obj.a = 1.2;
>>> > }
>>> >
>>> > int main() {
>>> >   struct S s;
>>> >   s.a = 1.0;
>>> >   s.b = 1.0;
>>> >   s.c = 1.0;
>>> >   foo(s);
>>> >   return 0;
>>> > }
>>> >
>>> > The generated code for foo, changes the type of the argument to foo to
>>> > be
>>> > {double, double} .
>>> >
>>> > llvm-gcc was converting this to {double, float} which was an ABI
>>> > requirement, as par an older
>>> >
>>> > discussion(http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-January/028870.html)
>>> >
>>> > Why does clang change it to a struct with a different size?
>>>
>>> clang uses different code written from scratch, so there are
>>> differences in the output.  In this case, it's a missed optimization;
>>> ideally, I think the signature of foo would be @_Z3foo1S(<2 x float>,
>>> float).
>>
>> Is this something that I should maybe file a bug for?

Sorry, I was intending to reply to this earlier.  Yes, please file a
bug.  And no, it's not the sort of thing that would be affected by
disable-llvm-optzns; the solution involves changing the initial code
generated by clang for calls.

-Eli




More information about the cfe-dev mailing list