-O4 with #include <iostream>

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

-O4 with #include <iostream>

Toralf Niebuhr
I recently asked why something doesn't compile. With the latest trunk it compiles fine under some conditions.

//  ---- Out.h
class Out {
public:
  void out();
};

//  ---- Out.cpp
#include "Out.h"
#include <iostream>

void Out::out() {
  std::cout << "Hello World" << std::endl;
}

// ---- main.cpp
#include "Out.h"

int main() {
  Out o;
        o.out();
        return 0;
}

compiling this with
clang++ -O4 -o main main.cpp Out.cpp
gives the following error

Alloca array size must be i32
  %o = alloca %class.Out, void (%class.Out*)* @_ZN3Out3outEv, align 2 ; <%class.Out*> [#uses=1]
Instruction does not dominate all uses!
  %o = alloca %class.Out, void (%class.Out*)* @_ZN3Out3outEv, align 2 ; <%class.Out*> [#uses=1]
  call void @_ZN3Out3outEv(%class.Out* %o)
Broken module found, compilation aborted!
Stack dump:
0. Running pass 'Function Pass Manager' on module 'ld-temp.o'.
1. Running pass 'Module Verifier' on function '@main'


The interesting thing is the following

if I modify main.cpp to

// ---- main.cpp
#include "Out.h"
#include <iostream>

int main() {
  Out o;
        o.out();
        return 0;
}

It compiles fine and the binary runes fine too.

This makes me think that there was to much optimization done during compile time when compiling Out.cpp

Any ideas?


Toralf


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: -O4 with #include <iostream>

Chris Lattner
On Jul 4, 2010, at 2:47 AM, Toralf Niebuhr wrote:

> I recently asked why something doesn't compile. With the latest trunk it compiles fine under some conditions.

What version of clang are you using?  The code that is causing the error has been completely removed.  Can you try with mainline?

-Chris

>
> //  ---- Out.h
> class Out {
> public:
>  void out();
> };
>
> //  ---- Out.cpp
> #include "Out.h"
> #include <iostream>
>
> void Out::out() {
>  std::cout << "Hello World" << std::endl;
> }
>
> // ---- main.cpp
> #include "Out.h"
>
> int main() {
>  Out o;
> o.out();
> return 0;
> }
>
> compiling this with
> clang++ -O4 -o main main.cpp Out.cpp
> gives the following error
>
> Alloca array size must be i32
>  %o = alloca %class.Out, void (%class.Out*)* @_ZN3Out3outEv, align 2 ; <%class.Out*> [#uses=1]
> Instruction does not dominate all uses!
>  %o = alloca %class.Out, void (%class.Out*)* @_ZN3Out3outEv, align 2 ; <%class.Out*> [#uses=1]
>  call void @_ZN3Out3outEv(%class.Out* %o)
> Broken module found, compilation aborted!
> Stack dump:
> 0. Running pass 'Function Pass Manager' on module 'ld-temp.o'.
> 1. Running pass 'Module Verifier' on function '@main'
>
>
> The interesting thing is the following
>
> if I modify main.cpp to
>
> // ---- main.cpp
> #include "Out.h"
> #include <iostream>
>
> int main() {
>  Out o;
> o.out();
> return 0;
> }
>
> It compiles fine and the binary runes fine too.
>
> This makes me think that there was to much optimization done during compile time when compiling Out.cpp
>
> Any ideas?
>
>
> Toralf
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: -O4 with #include <iostream>

Toralf Niebuhr
Am 04.07.2010 um 18:50 schrieb Chris Lattner:

> On Jul 4, 2010, at 2:47 AM, Toralf Niebuhr wrote:
>
>> I recently asked why something doesn't compile. With the latest trunk it compiles fine under some conditions.
>
> What version of clang are you using?  The code that is causing the error has been completely removed.  Can you try with mainline?
>
I am on the current llvm (r107591)/clang(r107591) trunk
Both repositories are up to date. I use the URLs to the svn from this site: http://clang.llvm.org/get_started.html
When compiling with  -v I get "clang -cc1 version 2.8 based upon llvm 2.8svn hosted on x86_64-apple-darwin10"

I attached the complete error log that I get with the -v option set.




> -Chris
>
>>
>> //  ---- Out.h
>> class Out {
>> public:
>> void out();
>> };
>>
>> //  ---- Out.cpp
>> #include "Out.h"
>> #include <iostream>
>>
>> void Out::out() {
>> std::cout << "Hello World" << std::endl;
>> }
>>
>> // ---- main.cpp
>> #include "Out.h"
>>
>> int main() {
>> Out o;
>> o.out();
>> return 0;
>> }
>>
>> compiling this with
>> clang++ -O4 -o main main.cpp Out.cpp
>> gives the following error
>>
>> Alloca array size must be i32
>> %o = alloca %class.Out, void (%class.Out*)* @_ZN3Out3outEv, align 2 ; <%class.Out*> [#uses=1]
>> Instruction does not dominate all uses!
>> %o = alloca %class.Out, void (%class.Out*)* @_ZN3Out3outEv, align 2 ; <%class.Out*> [#uses=1]
>> call void @_ZN3Out3outEv(%class.Out* %o)
>> Broken module found, compilation aborted!
>> Stack dump:
>> 0. Running pass 'Function Pass Manager' on module 'ld-temp.o'.
>> 1. Running pass 'Module Verifier' on function '@main'
>>
>>
>> The interesting thing is the following
>>
>> if I modify main.cpp to
>>
>> // ---- main.cpp
>> #include "Out.h"
>> #include <iostream>
>>
>> int main() {
>> Out o;
>> o.out();
>> return 0;
>> }
>>
>> It compiles fine and the binary runes fine too.
>>
>> This makes me think that there was to much optimization done during compile time when compiling Out.cpp
>>
>> Any ideas?
>>
>>
>> Toralf
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

error.log (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: -O4 with #include <iostream>

Chris Lattner

On Jul 4, 2010, at 12:24 PM, Toralf Niebuhr wrote:

> Am 04.07.2010 um 18:50 schrieb Chris Lattner:
>
>> On Jul 4, 2010, at 2:47 AM, Toralf Niebuhr wrote:
>>
>>> I recently asked why something doesn't compile. With the latest trunk it compiles fine under some conditions.
>>
>> What version of clang are you using?  The code that is causing the error has been completely removed.  Can you try with mainline?
>>
> I am on the current llvm (r107591)/clang(r107591) trunk
> Both repositories are up to date. I use the URLs to the svn from this site: http://clang.llvm.org/get_started.html
> When compiling with  -v I get "clang -cc1 version 2.8 based upon llvm 2.8svn hosted on x86_64-apple-darwin10"
>
> I attached the complete error log that I get with the -v option set.

Aha, thanks for the log.  The issue here is that you're using ToT clang with an old version of the linker support library "liblto".  Please copy over /usr/lib/libLTO.dylib (and /Developer/usr/lib/libLTO.dylib) with the libLTO built with your ToT checkout of LLVM.

-Chris


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: -O4 with #include <iostream>

Toralf Niebuhr

Am 05.07.2010 um 00:09 schrieb Chris Lattner:

>
> On Jul 4, 2010, at 12:24 PM, Toralf Niebuhr wrote:
>
>> Am 04.07.2010 um 18:50 schrieb Chris Lattner:
>>
>>> On Jul 4, 2010, at 2:47 AM, Toralf Niebuhr wrote:
>>>
>>>> I recently asked why something doesn't compile. With the latest trunk it compiles fine under some conditions.
>>>
>>> What version of clang are you using?  The code that is causing the error has been completely removed.  Can you try with mainline?
>>>
>> I am on the current llvm (r107591)/clang(r107591) trunk
>> Both repositories are up to date. I use the URLs to the svn from this site: http://clang.llvm.org/get_started.html
>> When compiling with  -v I get "clang -cc1 version 2.8 based upon llvm 2.8svn hosted on x86_64-apple-darwin10"
>>
>> I attached the complete error log that I get with the -v option set.
>
> Aha, thanks for the log.  The issue here is that you're using ToT clang with an old version of the linker support library "liblto".  Please copy over /usr/lib/libLTO.dylib (and /Developer/usr/lib/libLTO.dylib) with the libLTO built with your ToT checkout of LLVM.
>
> -Chris
>
Thanks

Is there actually an option in the configure script such that everything is correctly installed?


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: -O4 with #include <iostream>

Chris Lattner

On Jul 4, 2010, at 11:36 PM, Toralf Niebuhr wrote:

>>>
>>> I attached the complete error log that I get with the -v option set.
>>
>> Aha, thanks for the log.  The issue here is that you're using ToT clang with an old version of the linker support library "liblto".  Please copy over /usr/lib/libLTO.dylib (and /Developer/usr/lib/libLTO.dylib) with the libLTO built with your ToT checkout of LLVM.
>>
>> -Chris
>>
> Thanks
>
> Is there actually an option in the configure script such that everything is correctly installed?

Not that I know of.  Devang, is there a makefile target that installs liblto?

-Chris
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: -O4 with #include <iostream>

Devang Patel

On Jul 5, 2010, at 9:25 AM, Chris Lattner wrote:

>
> On Jul 4, 2010, at 11:36 PM, Toralf Niebuhr wrote:
>
>>>>
>>>> I attached the complete error log that I get with the -v option set.
>>>
>>> Aha, thanks for the log.  The issue here is that you're using ToT clang with an old version of the linker support library "liblto".  Please copy over /usr/lib/libLTO.dylib (and /Developer/usr/lib/libLTO.dylib) with the libLTO built with your ToT checkout of LLVM.
>>>
>>> -Chris
>>>
>> Thanks
>>
>> Is there actually an option in the configure script such that everything is correctly installed?
>
> Not that I know of.  Devang, is there a makefile target that installs liblto?

There is int any LTO specific install target. Usual 'make install' installs liblto in destination directory.
-
Devang


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev