allocation_order_begin takes non-const reference for MachineFunction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

allocation_order_begin takes non-const reference for MachineFunction

Anton Vayvod
Hi!
 
Could someone tell me the reason why allocation_order_begin method of TargetRegisterClass class takes a non-const reference to MachineFunction? I can't imagine why this method will change function and didn't find any override within llvm source which uses non-const methods of the MF parameter.
 
Just run into compiler error because I passed a const reference to the method.
 
Best regards,
 
Tony.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Reid Spencer-2
Hi Tony,

It doesn't look right to me either. The "begin" and "end" methods which
allocation_order_begin should return a const_iterator instead of an
iterator. Those methods are "const".  And, yes, the MachineFunction
reference isn't even used so at the very least it could be const (if not
removed).  However, I'm not an expert in this area of the code. Chris or
someone else will have to look at this and provide a determination.

Reid.

On Wed, 2006-08-16 at 18:14 +0400, Anton Vayvod wrote:

> Hi!
>  
> Could someone tell me the reason why allocation_order_begin method of
> TargetRegisterClass class takes a non-const reference to
> MachineFunction? I can't imagine why this method will change function
> and didn't find any override within llvm source which uses non-const
> methods of the MF parameter.
>  
> Just run into compiler error because I passed a const reference to the
> method.
>  
> Best regards,
>  
> Tony.
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Anton Vayvod
Thanks, Reid.
 
I've found that some overrides of allocation_order_begin() calls MachineFunction getInfo method. this method is not const. However, I think there could be default const implementation (const_cast of non-const method) and then allocation_order_begin() could be const.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Chris Lattner
On Wed, 16 Aug 2006, Anton Vayvod wrote:
> Thanks, Reid.
> I've found that some overrides of allocation_order_begin() calls
> MachineFunction getInfo method. this method is not const. However, I think
> there could be default const implementation (const_cast of non-const method)
> and then allocation_order_begin() could be const.

That sounds reasonable to me.  There should probably also be a const
version of the getInfo method.  If you'd be willing to put together a
patch, we can get it fixed.

Thanks,

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Anton Vayvod
I'm willing :) I don't know how to do it.
What's "to put together a patch"? :)

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Chris Lattner
On Wed, 16 Aug 2006, Anton Vayvod wrote:
> I'm willing :) I don't know how to do it.
> What's "to put together a patch"? :)

In your local CVS tree, change the methods to be const, and adjust any
code that is neccesary for that to work.  Once that is done, from the top
level, type 'cvs diff -u >& patch.txt' and attach patch.txt to an email.

If you're using sh instead of csh, use 'cvs diff -u 2>&1 > patch.txt'.

Thanks,

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Anton Vayvod
Ok, I'm in process. Do I need to checkout the latest llvm source, first?
 
I updated last right after the 1.8 release.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Reid Spencer-2
That would be advisable, there have been many commits since then.

Reid.

On Wed, 2006-08-16 at 23:24 +0400, Anton Vayvod wrote:
> Ok, I'm in process. Do I need to checkout the latest llvm source,
> first?
>  
> I updated last right after the 1.8 release.
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Chris Lattner
In reply to this post by Anton Vayvod
On Wed, 16 Aug 2006, Anton Vayvod wrote:
> Ok, I'm in process. Do I need to checkout the latest llvm source, first?

yes, please check out cvs head.  See the getting started guide for info

-Chris


> I updated last right after the 1.8 release.
>

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Ralph Corderoy
In reply to this post by Chris Lattner

Hi Chris,

> On Wed, 16 Aug 2006, Anton Vayvod wrote:
> > I'm willing :) I don't know how to do it.  What's "to put together a
> > patch"? :)
>
> In your local CVS tree, change the methods to be const, and adjust any
> code that is neccesary for that to work.  Once that is done, from the
> top level, type 'cvs diff -u >& patch.txt' and attach patch.txt to an
> email.
>
> If you're using sh instead of csh, use 'cvs diff -u 2>&1 > patch.txt'.

The sh equivalent of that csh is

    cvs diff -u >patch.txt 2>&1

The first duplicates stderr onto stdout and then changes stdout to be
patch.txt leaving stderr to go to wherever stdout used to go.  The
second changes stdout to be patch.txt and then duplicates stderr to go
there too.  This flexibility is one of sh's advantages over csh.  ;-)

Cheers,


Ralph.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Anton Vayvod
Thanks, Ralph, this line worked well :)
 
Here it is, my first patch to LLVM :)
 
I've changed all allocation_order_begin() and allocation_order_end() methods to take const MachineFunction &MF as a parameter. I also added const version of MachineFunction::getInfo<Ty>() method. And I changed three static hasFP() functions to take const reference to MachineFunction.
 
While doing this I've found that some methods of MachineFunction are const but return non-const pointers to MachineFunction internal info. Is that all right?
 
Thanks,
 
Tony.
 
P.S. I've updated llvm from CVS about 20 hour ago.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

patch.zip (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Chris Lattner
On Thu, 17 Aug 2006, Anton Vayvod wrote:
> Thanks, Ralph, this line worked well :)
> Here it is, my first patch to LLVM :)

> I've changed all allocation_order_begin() and allocation_order_end() methods
> to take const MachineFunction &MF as a parameter. I also added const version
> of MachineFunction::getInfo<Ty>() method. And I changed three static hasFP()
> functions to take const reference to MachineFunction.

Looks great, applied:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20060814/036832.html
...
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20060814/036839.html

> While doing this I've found that some methods of MachineFunction are const
> but return non-const pointers to MachineFunction internal info. Is that all
> right?

Which ones specifically?

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: allocation_order_begin takes non-const reference for MachineFunction

Anton Vayvod
> While doing this I've found that some methods of MachineFunction are const
> but return non-const pointers to MachineFunction internal info. Is that all
> right?

Which ones specifically?

-Chris
 
Probable candidates are:
getSSARegMap, getFrameInfo, getJumpTableInfo, getConstantPool, isPhysRegUsed, getBlockNumbered.
 
They are const but return non-const pointers to object's internal data. Though I don't know if making two versions of each methods will be useful or it'll just make code bigger and compilation a bit longer :)
 
isPhysRegUsed should be constified I suppose.
 
And btw comment to addToMMBNumbering method is a bit old (refers to getNextMMBNumber, which doesn't exist already).

 

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

stdlib.h

Fernando Magno Quintao Pereira
In reply to this post by Chris Lattner

Dear guys,

    my llvm-gcc does not compile stdlib.h correctly. I found this
explanation
here: http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=567
    Indeed, I am running Mac OS 10.4. Do I have to rebuild my gcc
front-end from source, or there is a script in the LLVM website that could
help me?

Best regards,

Fernando
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: stdlib.h

Reid Spencer-2
Rebuilding llvm-gcc4 from source should work fine. Please see the
directions in the file README.LLVM at the top level src directory. You
can check llvm-gcc4 out from Subversion with the command:

svn co svn://anonsvn.opensource.apple.com/svn/llvm/trunk llvm-gcc4

Reid.

On Sat, 2006-08-19 at 20:15 -0700, Fernando Magno Quintao Pereira wrote:

> Dear guys,
>
>     my llvm-gcc does not compile stdlib.h correctly. I found this
> explanation
> here: http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=567
>     Indeed, I am running Mac OS 10.4. Do I have to rebuild my gcc
> front-end from source, or there is a script in the LLVM website that could
> help me?
>
> Best regards,
>
> Fernando
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: stdlib.h

Fernando Magno Quintao Pereira

> Rebuilding llvm-gcc4 from source should work fine. Please see the
> directions in the file README.LLVM at the top level src directory. You
> can check llvm-gcc4 out from Subversion with the command:

Dear guys,

    I've rebuild my llvm-gcc3 (not llvm-gcc4) from source, and now it can
find stdlib.c and all the other sources, but I am having some other
problems with the new libraries.
1) If I try: llvm-gcc source.c -o source; llc -f source.bc -o ch.s ;
 gcc ch.s -o exec,
    I end up getting this error from gcc:
/usr/bin/ld: Undefined symbols:
___main
collect2: ld returned 1 exit status
    If I fix this, by replacing ___main by main manually, the program
seg-faults.

It used to work fine with the cfrontend that came together with llvm. Do
you
guys know what can be happening?

2) If I try: llvm-g++ source.cpp -o source ; source
I get this error:
ERROR: Program used external function '__llvm_eh_add_uncaught_exception'
which could not be resolved!
Abort

Could some one help me fixing this? Do I have to use llvm-gcc4?

All the best,

Fernando
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: stdlib.h

Reid Spencer-2
Try adding -lcrtend to the gcc link line. You need to link in the LLVM
runtime stuff.

Reid.

On Sun, 2006-08-20 at 14:30 -0700, Fernando Magno Quintao Pereira wrote:

> > Rebuilding llvm-gcc4 from source should work fine. Please see the
> > directions in the file README.LLVM at the top level src directory. You
> > can check llvm-gcc4 out from Subversion with the command:
>
> Dear guys,
>
>     I've rebuild my llvm-gcc3 (not llvm-gcc4) from source, and now it can
> find stdlib.c and all the other sources, but I am having some other
> problems with the new libraries.
> 1) If I try: llvm-gcc source.c -o source; llc -f source.bc -o ch.s ;
>  gcc ch.s -o exec,
>     I end up getting this error from gcc:
> /usr/bin/ld: Undefined symbols:
> ___main
> collect2: ld returned 1 exit status
>     If I fix this, by replacing ___main by main manually, the program
> seg-faults.
>
> It used to work fine with the cfrontend that came together with llvm. Do
> you
> guys know what can be happening?
>
> 2) If I try: llvm-g++ source.cpp -o source ; source
> I get this error:
> ERROR: Program used external function '__llvm_eh_add_uncaught_exception'
> which could not be resolved!
> Abort
>
> Could some one help me fixing this? Do I have to use llvm-gcc4?
>
> All the best,
>
> Fernando
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: stdlib.h

Fernando Magno Quintao Pereira

Thank you, Reid,

    I tried llvm-gcc -lcrtend ary3.c -o ary3, but I get

gccld: warning: Cannot find library 'crtend'
gccld: warning: Cannot find library 'c'

I have the libraries in my llvm directory:
llvm/runtime/GCCLibraries/crtend

Well, how do I link this to the LLVM runtime stuff? Before building from
the source, I had copied all the .h from my old gcc 4.0 to
llvm/cfrontend/and_so_forth... and I was able to compile .c all right. The
problem was the .cpp.

Thanks a lot,

Fernando

> Try adding -lcrtend to the gcc link line. You need to link in the LLVM
> runtime stuff.
>
> Reid.
>
> >     I've rebuild my llvm-gcc3 (not llvm-gcc4) from source, and now it can
> > find stdlib.c and all the other sources, but I am having some other
> > problems with the new libraries.
> > 1) If I try: llvm-gcc source.c -o source; llc -f source.bc -o ch.s ;
> >  gcc ch.s -o exec,
> >     I end up getting this error from gcc:
> > /usr/bin/ld: Undefined symbols:
> > ___main
> > collect2: ld returned 1 exit status
> >     If I fix this, by replacing ___main by main manually, the program
> > seg-faults.
> >
> > It used to work fine with the cfrontend that came together with llvm. Do
> > you
> > guys know what can be happening?
> >
> > 2) If I try: llvm-g++ source.cpp -o source ; source
> > I get this error:
> > ERROR: Program used external function '__llvm_eh_add_uncaught_exception'
> > which could not be resolved!
> > Abort
> >
> > Could some one help me fixing this? Do I have to use llvm-gcc4?
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: stdlib.h

Chris Lattner
On Sun, 20 Aug 2006, Fernando Magno Quintao Pereira wrote:

> Thank you, Reid,
>    I tried llvm-gcc -lcrtend ary3.c -o ary3, but I get
> gccld: warning: Cannot find library 'crtend'
> gccld: warning: Cannot find library 'c'
>
> I have the libraries in my llvm directory:
> llvm/runtime/GCCLibraries/crtend
>
> Well, how do I link this to the LLVM runtime stuff? Before building from
> the source, I had copied all the .h from my old gcc 4.0 to
> llvm/cfrontend/and_so_forth... and I was able to compile .c all right. The
> problem was the .cpp.

You need to follow the directions here:
http://llvm.org/docs/CFEBuildInstrs.html#llvm-gcc3-instructions

In particular, you must run the install-bytecode target, as instructed.

-Chris

>> Try adding -lcrtend to the gcc link line. You need to link in the LLVM
>> runtime stuff.
>>
>> Reid.
>>
>>>     I've rebuild my llvm-gcc3 (not llvm-gcc4) from source, and now it can
>>> find stdlib.c and all the other sources, but I am having some other
>>> problems with the new libraries.
>>> 1) If I try: llvm-gcc source.c -o source; llc -f source.bc -o ch.s ;
>>>  gcc ch.s -o exec,
>>>     I end up getting this error from gcc:
>>> /usr/bin/ld: Undefined symbols:
>>> ___main
>>> collect2: ld returned 1 exit status
>>>     If I fix this, by replacing ___main by main manually, the program
>>> seg-faults.
>>>
>>> It used to work fine with the cfrontend that came together with llvm. Do
>>> you
>>> guys know what can be happening?
>>>
>>> 2) If I try: llvm-g++ source.cpp -o source ; source
>>> I get this error:
>>> ERROR: Program used external function '__llvm_eh_add_uncaught_exception'
>>> which could not be resolved!
>>> Abort
>>>
>>> Could some one help me fixing this? Do I have to use llvm-gcc4?
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev