[llvm-commits] [llvm] r45774 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson
Author: resistor
Date: Wed Jan  9 04:32:30 2008
New Revision: 45774

URL: http://llvm.org/viewvc/llvm-project?rev=45774&view=rev
Log:
Fix an infinite recursion bug in InsertCopies.

Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=45774&r1=45773&r2=45774&view=diff

==
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9 04:32:30 2008
@@ -101,7 +101,7 @@
  std::vector& DF,
  std::vector >& locals);
 void ScheduleCopies(MachineBasicBlock* MBB, std::set& pushed);
-void InsertCopies(MachineBasicBlock* MBB);
+void InsertCopies(MachineBasicBlock* MBB, std::set& v);
   };
 
   char StrongPHIElimination::ID = 0;
@@ -610,7 +610,10 @@
 }
 
 /// InsertCopies - insert copies into MBB and all of its successors
-void StrongPHIElimination::InsertCopies(MachineBasicBlock* MBB) {
+void StrongPHIElimination::InsertCopies(MachineBasicBlock* MBB,
+std::set& visited) 
{
+  visited.insert(MBB);
+  
   std::set pushed;
   
   // Rewrite register uses from Stacks
@@ -629,7 +632,8 @@
   for (GraphTraits::ChildIteratorType I = 
GraphTraits::child_begin(MBB), E =
GraphTraits::child_end(MBB); I != E; ++I)
-InsertCopies(*I);
+if (!visited.count(*I))
+  InsertCopies(*I, visited);
   
   // As we exit this block, pop the names we pushed while processing it
   for (std::set::iterator I = pushed.begin(), 
@@ -649,7 +653,8 @@
   
   // Insert copies
   // FIXME: This process should probably preserve LiveVariables
-  InsertCopies(Fn.begin());
+  std::set visited;
+  InsertCopies(Fn.begin(), visited);
   
   // Perform renaming
   typedef std::map > RenameSetType;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45775 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson
Author: resistor
Date: Wed Jan  9 04:41:39 2008
New Revision: 45775

URL: http://llvm.org/viewvc/llvm-project?rev=45775&view=rev
Log:
StrongPHIElim: Now with even fewer trivial bugs!

Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=45775&r1=45774&r2=45775&view=diff

==
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9 04:41:39 2008
@@ -215,7 +215,9 @@
   stack.pop_back();
   CurrentParent = stack.back();
   
-  parentBlock = 
LV.getVarInfo(CurrentParent->getReg()).DefInst->getParent();
+  parentBlock = CurrentParent->getReg() ?
+   LV.getVarInfo(CurrentParent->getReg()).DefInst->getParent() 
:
+   0;
 }
 
 DomForestNode* child = new DomForestNode(*I, CurrentParent);
@@ -361,7 +363,7 @@
   std::set ProcessedNames;
   
   MachineBasicBlock::iterator P = MBB->begin();
-  while (P->getOpcode() == TargetInstrInfo::PHI) {
+  while (P != MBB->end() && P->getOpcode() == TargetInstrInfo::PHI) {
 LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand(0).getReg());
 
 unsigned DestReg = P->getOperand(0).getReg();


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CommandLine.html patch

2008-01-09 Thread Sam Bishop
I've attached a patch which fixes a few punctuation errors and typos in the
CommandLine class documentation.  (Thanks for the documentation, by the
way!)

Also, I was confused by one of the examples regarding the handling of
program-wide global options such as a debug flag.  "DebugFlag" is the global
variable set by the parser; the following is given as an example of how you
would use it:

// DEBUG macro - This macro should be used by code to emit debug information.
// In the '-debug' option is specified on the command line, and if this is a
// debug build, then the code specified as the option to the macro will be
// executed.  Otherwise it will not be.  Example:
//
// DOUT << "Bitset contains: " << Bitset << "\n";
//
#ifdef NDEBUG
#define DEBUG(X)
#else
#define DEBUG(X) do { if (DebugFlag) { X; } } while (0)
#endif

I'm very new to LLVM, so I can only guess at how DOUT is related to DEBUG().
 Is there another example that would be more straightforward?

Thanks,
Sam Bishop

CommandLine.html.patch
Description: Binary data
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CommandLine.html patch

2008-01-09 Thread Sam Bishop
On Wed, January 9, 2008 10:34 am, Sam Bishop wrote:
> Also, I was confused by one of the examples regarding the handling of
> program-wide global options such as a debug flag
> ...
> I'm very new to LLVM, so I can only guess at how DOUT is related to DEBUG().
> Is there another example that would be more straightforward?

On second thought, I'd recommend simply removing the DOUT example from the
comment.  I have attached an updated patch.

Sam

CommandLine.html.patch
Description: Binary data
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-www/devmtg/current/index.html

2008-01-09 Thread Jonathan Johnson


Changes in directory llvm-www/devmtg/current:

index.html updated: 1.2 -> 1.3
---
Log message:

Updated list of attendees, added link from dev. meeting sidebar entry and 
frontpage entry below the 2.2 release schedule.

---
Diffs of the changes:  (+2 -1)

 index.html |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm-www/devmtg/current/index.html
diff -u llvm-www/devmtg/current/index.html:1.2 
llvm-www/devmtg/current/index.html:1.3
--- llvm-www/devmtg/current/index.html:1.2  Tue Jan  8 22:49:01 2008
+++ llvm-www/devmtg/current/index.html  Wed Jan  9 12:37:54 2008
@@ -36,6 +36,7 @@

Unconfirmed Attendees
NameOrganization
+   Owen AndersonApple, Inc.
Robert HundtGoogle
Jonathan JohnsonAlacatia Labs, Inc.
Chris LattnerApple, Inc.
@@ -43,7 +44,7 @@
Chuck RoseAdobe Systems Incorporated
Mike StumpApple, Inc.

-   Total unconfirmed: 6
+   Total unconfirmed: 7
 
 
 
\ No newline at end of file



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-www/header.incl www-index.html

2008-01-09 Thread Jonathan Johnson


Changes in directory llvm-www:

header.incl updated: 1.63 -> 1.64
www-index.html updated: 1.149 -> 1.150
---
Log message:

Updated list of attendees, added link from dev. meeting sidebar entry and 
frontpage entry below the 2.2 release schedule.

---
Diffs of the changes:  (+9 -0)

 header.incl|1 +
 www-index.html |8 
 2 files changed, 9 insertions(+)


Index: llvm-www/header.incl
diff -u llvm-www/header.incl:1.63 llvm-www/header.incl:1.64
--- llvm-www/header.incl:1.63   Thu Sep 27 01:27:42 2007
+++ llvm-www/header.inclWed Jan  9 12:37:54 2008
@@ -91,6 +91,7 @@
 DeveloperĀ Mtgs
 
   
+  http://llvm.org/devmtg/current/";>Upcoming
   http://llvm.org/devmtg/2007-05/";>May 25, 2007
   
 


Index: llvm-www/www-index.html
diff -u llvm-www/www-index.html:1.149 llvm-www/www-index.html:1.150
--- llvm-www/www-index.html:1.149   Fri Sep 28 18:23:11 2007
+++ llvm-www/www-index.html Wed Jan  9 12:37:54 2008
@@ -129,6 +129,14 @@
 
 
 
+Upcoming Meeting
+
+
+   We are planning this year's developer 
meeting. Please provide input and let us know if you are interested in 
attending.
+
+
+
+
 Try out LLVM in your browser
 
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CommandLine.html patch

2008-01-09 Thread Bill Wendling
On Jan 9, 2008 9:34 AM, Sam Bishop <[EMAIL PROTECTED]> wrote:
> Also, I was confused by one of the examples regarding the handling of
> program-wide global options such as a debug flag.  "DebugFlag" is the global
> variable set by the parser; the following is given as an example of how you
> would use it:
>
> // DEBUG macro - This macro should be used by code to emit debug information.
> // In the '-debug' option is specified on the command line, and if this is a
> // debug build, then the code specified as the option to the macro will be
> // executed.  Otherwise it will not be.  Example:
> //
> // DOUT << "Bitset contains: " << Bitset << "\n";
> //
> #ifdef NDEBUG
> #define DEBUG(X)
> #else
> #define DEBUG(X) do { if (DebugFlag) { X; } } while (0)
> #endif
>
> I'm very new to LLVM, so I can only guess at how DOUT is related to DEBUG().
>  Is there another example that would be more straightforward?
>
DOUT is documented here:

  http://llvm.org/docs/CodingStandards.html#ll_iostream

Though you're right that this example is misplaced.

-bw
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45780 - /llvm/trunk/docs/CommandLine.html

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 13:28:50 2008
New Revision: 45780

URL: http://llvm.org/viewvc/llvm-project?rev=45780&view=rev
Log:
many cleanups and fixed, contributed by Sam Bishop

Modified:
llvm/trunk/docs/CommandLine.html

Modified: llvm/trunk/docs/CommandLine.html
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandLine.html?rev=45780&r1=45779&r2=45780&view=diff

==
--- llvm/trunk/docs/CommandLine.html (original)
+++ llvm/trunk/docs/CommandLine.html Wed Jan  9 13:28:50 2008
@@ -138,7 +138,7 @@
 
 Globally accessible: Libraries can specify command line arguments that are
 automatically enabled in any tool that links to the library.  This is possible
-because the application doesn't have to keep a "list" of arguments to pass to
+because the application doesn't have to keep a list of arguments to pass to
 the parser.  This also makes supporting dynamically
 loaded options trivial.
 
@@ -216,12 +216,12 @@
 declarations.
 
 Now that you are ready to support command line arguments, we need to tell 
the
-system which ones we want, and what type of argument they are.  The CommandLine
+system which ones we want, and what type of arguments they are.  The 
CommandLine
 library uses a declarative syntax to model command line arguments with the
 global variable declarations that capture the parsed values.  This means that
 for every command line option that you would like to support, there should be a
 global variable declaration to capture the result.  For example, in a compiler,
-we would like to support the unix standard '-o ' 
option
+we would like to support the Unix-standard '-o ' 
option
 to specify where to put the output.  With the CommandLine library, this is
 represented like this:
 
@@ -383,7 +383,7 @@
   -help  - display available options (--help-hidden for more)
 
 
-and "opt --help-hidden" prints this:
+and "compiler --help-hidden" prints this:
 
 
 USAGE: compiler [options] 
@@ -432,7 +432,7 @@
 
 
 The third line (which is the only one we modified from above) defines a
-"-q alias that updates the "Quiet" variable (as specified by
+"-q" alias that updates the "Quiet" variable (as specified by
 the cl::aliasopt modifier) whenever it is
 specified.  Because aliases do not hold state, the only thing the program has 
to
 query is the Quiet variable now.  Another nice feature of aliases is
@@ -462,24 +462,24 @@
 
 
 
-So far, we have seen how the CommandLine library handles builtin types like
+So far we have seen how the CommandLine library handles builtin types like
 std::string, bool and int, but how does it handle
 things it doesn't know about, like enums or 'int*'s?
 
-The answer is that it uses a table driven generic parser (unless you specify
+The answer is that it uses a table-driven generic parser (unless you specify
 your own parser, as described in the Extension
 Guide).  This parser maps literal strings to whatever type is required, and
 requires you to tell it what this mapping should be.
 
-Lets say that we would like to add four optimization levels to our
+Let's say that we would like to add four optimization levels to our
 optimizer, using the standard flags "-g", "-O0",
 "-O1", and "-O2".  We could easily implement this with 
boolean
 options like above, but there are several problems with this strategy:
 
 
 A user could specify more than one of the options at a time, for example,
-"opt -O3 -O2".  The CommandLine library would not be able to catch 
this
-erroneous input for us.
+"compiler -O3 -O2".  The CommandLine library would not be able to
+catch this erroneous input for us.
 
 We would have to test 4 different variables to see which ones are set.
 
@@ -634,7 +634,7 @@
 
 
 
-Now that we have the standard run of the mill argument types out of the way,
+Now that we have the standard run-of-the-mill argument types out of the way,
 lets get a little wild and crazy.  Lets say that we want our optimizer to 
accept
 a list of optimizations to perform, allowing duplicates.  For example, 
we
 might want to run: "compiler -dce -constprop -inline -dce -strip".  In
@@ -750,7 +750,7 @@
 
 Finally, if external storage is used, then the location specified must be of
 type unsigned. In all other ways a cl::bits option is morally equivalent to a cl::bits option is equivalent to a  cl::list option.
 
 
@@ -916,7 +916,7 @@
   
   
   static cl::list Files(cl::Positional, cl::OneOrMore);
-  static cl::listlt;std::string> Libraries("l", cl::ZeroOrMore);
+  static cl::list Libraries("l", cl::ZeroOrMore);
 
   int main(int argc, char**argv) {
 // ...
@@ -969,7 +969,7 @@
 standard Unix Bourne shell (/bin/sh).  To run /bin/sh, first
 you specify options to the shell itself (like -x which turns on trace
 output), then you specify the name of the script to run, then you specify
-arguments to the script.  These arguments to the script are parsed by the 
b

Re: [llvm-commits] CommandLine.html patch

2008-01-09 Thread Chris Lattner

On Jan 9, 2008, at 9:54 AM, Sam Bishop wrote:

> On Wed, January 9, 2008 10:34 am, Sam Bishop wrote:
>> Also, I was confused by one of the examples regarding the handling of
>> program-wide global options such as a debug flag
>> ...
>> I'm very new to LLVM, so I can only guess at how DOUT is related to  
>> DEBUG().
>> Is there another example that would be more straightforward?
>
> On second thought, I'd recommend simply removing the DOUT example  
> from the
> comment.  I have attached an updated patch.

Very nice, applied, thanks!
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080107/056997.html

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45781 - in /llvm/trunk/lib/System: DynamicLibrary.cpp Path.cpp

2008-01-09 Thread Duncan Sands
Author: baldrick
Date: Wed Jan  9 13:42:09 2008
New Revision: 45781

URL: http://llvm.org/viewvc/llvm-project?rev=45781&view=rev
Log:
Fix compile failures with g++-4.3.

Modified:
llvm/trunk/lib/System/DynamicLibrary.cpp
llvm/trunk/lib/System/Path.cpp

Modified: llvm/trunk/lib/System/DynamicLibrary.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=45781&r1=45780&r2=45781&view=diff

==
--- llvm/trunk/lib/System/DynamicLibrary.cpp (original)
+++ llvm/trunk/lib/System/DynamicLibrary.cpp Wed Jan  9 13:42:09 2008
@@ -13,6 +13,7 @@
 
 #include "llvm/System/DynamicLibrary.h"
 #include "llvm/Config/config.h"
+#include 
 #include 
 
 // Collection of symbol name/value pairs to be searched prior to any libraries.

Modified: llvm/trunk/lib/System/Path.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Path.cpp?rev=45781&r1=45780&r2=45781&view=diff

==
--- llvm/trunk/lib/System/Path.cpp (original)
+++ llvm/trunk/lib/System/Path.cpp Wed Jan  9 13:42:09 2008
@@ -14,6 +14,7 @@
 #include "llvm/System/Path.h"
 #include "llvm/Config/config.h"
 #include 
+#include 
 #include 
 using namespace llvm;
 using namespace sys;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc-4.2] r45757 - in /llvm-gcc-4.2/trunk/gcc: llvm-types.cpp tree.c tree.h

2008-01-09 Thread Duncan Sands
Hi Dale, thanks for fixing this.

> +/// FixBaseClassFields - alter the types referred to by Field nodes that

Do you really have to modify the fields of the record?  Instead, you could
have a map in ConvertRECORD (possibly in StructTypeConversionInfo) that gives
the type to use for each field [currently you use the record as the map, 
stashing
the new type there] or just calculate the type in ConvertRECORD and pass the 
type
as an extra parameter to all subroutines or somesuch.

Alternatively, couldn't you just convert the original field type to LLVM then 
drop
fields off the end of the LLVM type if they go over the DECL_SIZE, or something
along those lines?

> +TREE_INT_CST_LOW(DECL_SIZE(Field)) < 
> +  TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(Field

This probably kills Ada (testing now), since the size doesn't have to be
a constant in general (likewise in RestoreBaseClassFields).

Ciao,

Duncan.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc-4.2] r45757 - in /llvm-gcc-4.2/trunk/gcc: llvm-types.cpp tree.c tree.h

2008-01-09 Thread Dale Johannesen

On Jan 9, 2008, at 12:43 PM, Duncan Sands wrote:

> Hi Dale, thanks for fixing this.
>
>> +/// FixBaseClassFields - alter the types referred to by Field  
>> nodes that
>
> Do you really have to modify the fields of the record?  Instead, you  
> could
> have a map in ConvertRECORD (possibly in StructTypeConversionInfo)  
> that gives
> the type to use for each field [currently you use the record as the  
> map, stashing
> the new type there] or just calculate the type in ConvertRECORD and  
> pass the type
> as an extra parameter to all subroutines or somesuch.
>
> Alternatively, couldn't you just convert the original field type to  
> LLVM then drop
> fields off the end of the LLVM type if they go over the DECL_SIZE,  
> or something
> along those lines?

Other implementations may be possible.   This approach (which I agree  
has unaesthetic aspects) makes minimal changes to existing logic; I  
think that's a fairly important virtue.

The idea I liked best was to get the C++ FE to generate the right  
fields in the first place, but couldn't get it to work.

>> +TREE_INT_CST_LOW(DECL_SIZE(Field)) <
>> +  TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(Field
>
> This probably kills Ada (testing now), since the size doesn't have  
> to be
> a constant in general (likewise in RestoreBaseClassFields).

OK, didn't know that.  That's an easy fix.  I figured if I broke Ada  
somebody would tell me :)

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc-4.2] r45757 - in /llvm-gcc-4.2/trunk/gcc: llvm-types.cpp tree.c tree.h

2008-01-09 Thread Dale Johannesen
The patch below should address this problem, let me know.

On Jan 9, 2008, at 12:43 PM, Duncan Sands wrote:
>> +TREE_INT_CST_LOW(DECL_SIZE(Field)) <
>> +  TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(Field
>
> This probably kills Ada (testing now), since the size doesn't have  
> to be
> a constant in general (likewise in RestoreBaseClassFields).

Index: llvm-types.cpp
===
--- llvm-types.cpp  (revision 45777)
+++ llvm-types.cpp  (working copy)
@@ -1696,6 +1696,8 @@
  TREE_CODE(TREE_TYPE(Field))==RECORD_TYPE &&
  TYPE_SIZE(TREE_TYPE(Field)) &&
  DECL_SIZE(Field) &&
+TREE_CODE(DECL_SIZE(Field))==INTEGER_CST &&
+TREE_CODE(TYPE_SIZE(TREE_TYPE(Field)))==INTEGER_CST &&
  TREE_INT_CST_LOW(DECL_SIZE(Field)) <
TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(Field
TREE_TYPE(Field) = FixBaseClassField(Field);

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r45775 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Tanya Lattner
Just glancing at this briefly for the first time. I really think that  
runOnMachineFunction could benefit from comments that give an  
overview of the algorithm. Secondly, the classes/structs and member  
variables could also use some comments.
You should also explain what a dominance forest/node is and maybe  
some more comments on its construction. I'd also more closely  
document the trivial interferences. I know this stuff is in the  
paper, but it makes your code easier to understand for people who  
haven't read it. Yes, I'm a comment freak.

Is the DFS numbering of the MachineFunction something that would be  
useful for other optimizations? Maybe it could be pulled out and used  
as an analysis?

-Tanya



On Jan 9, 2008, at 2:41 AM, Owen Anderson wrote:

> Author: resistor
> Date: Wed Jan  9 04:41:39 2008
> New Revision: 45775
>
> URL: http://llvm.org/viewvc/llvm-project?rev=45775&view=rev
> Log:
> StrongPHIElim: Now with even fewer trivial bugs!
>
> Modified:
> llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
>
> Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ 
> StrongPHIElimination.cpp?rev=45775&r1=45774&r2=45775&view=diff
>
> == 
> 
> --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
> +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9  
> 04:41:39 2008
> @@ -215,7 +215,9 @@
>stack.pop_back();
>CurrentParent = stack.back();
>
> -  parentBlock = LV.getVarInfo(CurrentParent->getReg()).DefInst- 
> >getParent();
> +  parentBlock = CurrentParent->getReg() ?
> +   LV.getVarInfo(CurrentParent->getReg()).DefInst- 
> >getParent() :
> +   0;
>  }
>
>  DomForestNode* child = new DomForestNode(*I, CurrentParent);
> @@ -361,7 +363,7 @@
>std::set ProcessedNames;
>
>MachineBasicBlock::iterator P = MBB->begin();
> -  while (P->getOpcode() == TargetInstrInfo::PHI) {
> +  while (P != MBB->end() && P->getOpcode() == TargetInstrInfo::PHI) {
>  LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand 
> (0).getReg());
>
>  unsigned DestReg = P->getOperand(0).getReg();
>
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45783 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson
Author: resistor
Date: Wed Jan  9 16:40:54 2008
New Revision: 45783

URL: http://llvm.org/viewvc/llvm-project?rev=45783&view=rev
Log:
Clean up StrongPHIElimination a bit, and add some more comments to the internal 
structures.  There's
still more work to do on this front.

Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=45783&r1=45782&r2=45783&view=diff

==
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9 16:40:54 2008
@@ -39,13 +39,28 @@
 static char ID; // Pass identification, replacement for typeid
 StrongPHIElimination() : MachineFunctionPass((intptr_t)&ID) {}
 
+// Waiting stores, for each MBB, the set of copies that need to
+// be inserted into that MBB
 DenseMap > Waiting;
 
+// Stacks holds the renaming stack for each register
 std::map > Stacks;
+
+// Registers in UsedByAnother are PHI nodes that are themselves
+// used as operands to another another PHI node
 std::set UsedByAnother;
+
+// RenameSets are the sets of operands to a PHI (the defining instruction
+// of the key) that can be renamed without copies
 std::map > RenameSets;
 
+// Store the DFS-in number of each block
+DenseMap preorder;
+
+// Store the DFS-out number of each block
+DenseMap maxpreorder;
+
 bool runOnMachineFunction(MachineFunction &Fn);
 
 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@@ -59,19 +74,32 @@
   maxpreorder.clear();
   
   Waiting.clear();
+  Stacks.clear();
+  UsedByAnother.clear();
+  RenameSets.clear();
 }
 
   private:
+
+/// DomForestNode - Represents a node in the "dominator forest".  This is
+/// a forest in which the nodes represent registers and the edges
+/// represent a dominance relation in the block defining those registers.
 struct DomForestNode {
 private:
+  // Store references to our children
   std::vector children;
+  // The register we represent
   unsigned reg;
   
+  // Add another node as our child
   void addChild(DomForestNode* DFN) { children.push_back(DFN); }
   
 public:
   typedef std::vector::iterator iterator;
   
+  // Create a DomForestNode by providing the register it represents, and
+  // the node to be its parent.  The virtual root node has register 0
+  // and a null parent.
   DomForestNode(unsigned r, DomForestNode* parent) : reg(r) {
 if (parent)
   parent->addChild(this);
@@ -82,16 +110,14 @@
   delete *I;
   }
   
+  /// getReg - Return the regiser that this node represents
   inline unsigned getReg() { return reg; }
   
+  // Provide iterator access to our children
   inline DomForestNode::iterator begin() { return children.begin(); }
   inline DomForestNode::iterator end() { return children.end(); }
 };
 
-DenseMap preorder;
-DenseMap maxpreorder;
-
-
 void computeDFS(MachineFunction& MF);
 void processBlock(MachineBasicBlock* MBB);
 
@@ -188,22 +214,28 @@
 StrongPHIElimination::computeDomForest(std::set& regs) {
   LiveVariables& LV = getAnalysis();
   
+  // Begin by creating a virtual root node, since the actual results
+  // may well be a forest.  Assume this node has maximum DFS-out number.
   DomForestNode* VirtualRoot = new DomForestNode(0, 0);
   maxpreorder.insert(std::make_pair((MachineBasicBlock*)0, ~0UL));
   
+  // Populate a worklist with the registers
   std::vector worklist;
   worklist.reserve(regs.size());
   for (std::set::iterator I = regs.begin(), E = regs.end();
I != E; ++I)
 worklist.push_back(*I);
   
+  // Sort the registers by the DFS-in number of their defining block
   PreorderSorter PS(preorder, LV);
   std::sort(worklist.begin(), worklist.end(), PS);
   
+  // Create a "current parent" stack, and put the virtual root on top of it
   DomForestNode* CurrentParent = VirtualRoot;
   std::vector stack;
   stack.push_back(VirtualRoot);
   
+  // Iterate over all the registers in the previously computed order
   for (std::vector::iterator I = worklist.begin(), E = 
worklist.end();
I != E; ++I) {
 unsigned pre = preorder[LV.getVarInfo(*I).DefInst->getParent()];
@@ -211,6 +243,8 @@
  LV.getVarInfo(CurrentParent->getReg()).DefInst->getParent() :
  0;
 
+// If the DFS-in number of the register is greater than the DFS-out number
+// of the current parent, repeatedly pop the parent stack until it isn't.
 while (pre > maxpreorder[parentBlock]) {
   stack.pop_back();
   CurrentParent = stack.back();
@@ -220,11 +254,16 @@
0;
 }

[llvm-commits] [llvm] r45787 - in /llvm/trunk: lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp test/CodeGen/X86/2008-01-08-SchedulerCrash.ll

2008-01-09 Thread Evan Cheng
Author: evancheng
Date: Wed Jan  9 17:01:55 2008
New Revision: 45787

URL: http://llvm.org/viewvc/llvm-project?rev=45787&view=rev
Log:
Special copy SUnit's do not have SDNode's.

Added:
llvm/trunk/test/CodeGen/X86/2008-01-08-SchedulerCrash.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=45787&r1=45786&r2=45787&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Wed Jan  9 
17:01:55 2008
@@ -1208,13 +1208,13 @@
   for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
I != E; ++I) {
 if (I->isCtrl) continue;  // ignore chain preds
-if (I->Dep->Node->getOpcode() != ISD::CopyFromReg)
+if (!I->Dep->Node || I->Dep->Node->getOpcode() != ISD::CopyFromReg)
   Scratches++;
   }
   for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
I != E; ++I) {
 if (I->isCtrl) continue;  // ignore chain succs
-if (I->Dep->Node->getOpcode() != ISD::CopyToReg)
+if (!I->Dep->Node || I->Dep->Node->getOpcode() != ISD::CopyToReg)
   Scratches += 10;
   }
   return Scratches;

Added: llvm/trunk/test/CodeGen/X86/2008-01-08-SchedulerCrash.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-01-08-SchedulerCrash.ll?rev=45787&view=auto

==
--- llvm/trunk/test/CodeGen/X86/2008-01-08-SchedulerCrash.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2008-01-08-SchedulerCrash.ll Wed Jan  9 
17:01:55 2008
@@ -0,0 +1,32 @@
+; RUN: llvm-as < %s | llc -march=x86
+
+   %struct.indexentry = type { i32, i8*, i8*, i8*, i8*, i8* }
+
+define i32 @_bfd_stab_section_find_nearest_line(i32 %offset) nounwind  {
+entry:
+   %tmp910 = add i32 0, %offset;  [#uses=1]
+   br i1 true, label %bb951, label %bb917
+
+bb917: ; preds = %entry
+   ret i32 0
+
+bb951: ; preds = %bb986, %entry
+   %tmp955 = sdiv i32 0, 2 ;  [#uses=3]
+   %tmp961 = getelementptr %struct.indexentry* null, i32 %tmp955, i32 0
;  [#uses=1]
+   br i1 true, label %bb986, label %bb967
+
+bb967: ; preds = %bb951
+   ret i32 0
+
+bb986: ; preds = %bb951
+   %tmp993 = load i32* %tmp961, align 4;  [#uses=1]
+   %tmp995 = icmp ugt i32 %tmp993, %tmp910 ;  [#uses=2]
+   %tmp1002 = add i32 %tmp955, 1   ;  [#uses=1]
+   %low.0 = select i1 %tmp995, i32 0, i32 %tmp1002 ;  
[#uses=1]
+   %high.0 = select i1 %tmp995, i32 %tmp955, i32 0 ;  
[#uses=1]
+   %tmp1006 = icmp eq i32 %low.0, %high.0  ;  [#uses=1]
+   br i1 %tmp1006, label %UnifiedReturnBlock, label %bb951
+
+UnifiedReturnBlock:; preds = %bb986
+   ret i32 1
+}


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45791 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson
Author: resistor
Date: Wed Jan  9 18:01:41 2008
New Revision: 45791

URL: http://llvm.org/viewvc/llvm-project?rev=45791&view=rev
Log:
Copies need to be inserted before the first terminator, not at the end of the 
block.

Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=45791&r1=45790&r2=45791&view=diff

==
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9 18:01:41 2008
@@ -613,7 +613,7 @@
   }
   
   // Insert copy from map[curr.first] to curr.second
-  TII->copyRegToReg(*MBB, MBB->end(), curr.second,
+  TII->copyRegToReg(*MBB, MBB->getFirstTerminator(), curr.second,
 map[curr.first], RC, RC);
   map[curr.first] = curr.second;
   
@@ -642,7 +642,7 @@
   
   // Insert a copy from dest to a new temporary t at the end of b
   unsigned t = MF->getRegInfo().createVirtualRegister(RC);
-  TII->copyRegToReg(*MBB, MBB->end(), t,
+  TII->copyRegToReg(*MBB, MBB->getFirstTerminator(), t,
 curr.second, RC, RC);
   map[curr.second] = t;
   


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45792 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

2008-01-09 Thread Evan Cheng
Author: evancheng
Date: Wed Jan  9 18:09:10 2008
New Revision: 45792

URL: http://llvm.org/viewvc/llvm-project?rev=45792&view=rev
Log:
Remove comments that do not correspond to anything after recent refactoring.

Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=45792&r1=45791&r2=45792&view=diff

==
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jan  9 18:09:10 2008
@@ -1209,6 +1209,34 @@
  &ArgValues[0], ArgValues.size()).getValue(Op.ResNo);
 }
 
+SDOperand
+X86TargetLowering::LowerMemOpCallTo(SDOperand Op, SelectionDAG &DAG,
+const SDOperand &StackPtr,
+const CCValAssign &VA,
+SDOperand Chain,
+SDOperand Arg) {
+  SDOperand PtrOff = DAG.getConstant(VA.getLocMemOffset(), getPointerTy());
+  PtrOff = DAG.getNode(ISD::ADD, getPointerTy(), StackPtr, PtrOff);
+  SDOperand FlagsOp = Op.getOperand(6+2*VA.getValNo());
+  unsigned Flags= cast(FlagsOp)->getValue();
+  if (Flags & ISD::ParamFlags::ByVal) {
+unsigned Align = 1 << ((Flags & ISD::ParamFlags::ByValAlign) >>
+   ISD::ParamFlags::ByValAlignOffs);
+
+unsigned  Size = (Flags & ISD::ParamFlags::ByValSize) >>
+ISD::ParamFlags::ByValSizeOffs;
+
+SDOperand AlignNode = DAG.getConstant(Align, MVT::i32);
+SDOperand  SizeNode = DAG.getConstant(Size, MVT::i32);
+SDOperand AlwaysInline = DAG.getConstant(1, MVT::i32);
+
+return DAG.getMemcpy(Chain, PtrOff, Arg, SizeNode, AlignNode,
+ AlwaysInline);
+  } else {
+return DAG.getStore(Chain, Arg, PtrOff, NULL, 0);
+  }
+}
+
 SDOperand X86TargetLowering::LowerCALL(SDOperand Op, SelectionDAG &DAG) {
   MachineFunction &MF = DAG.getMachineFunction();
   SDOperand Chain = Op.getOperand(0);
@@ -1524,47 +1552,6 @@
 
 
 
//===--===//
-//   FastCall Calling Convention implementation
-//===--===//
-//
-// The X86 'fastcall' calling convention passes up to two integer arguments in
-// registers (an appropriate portion of ECX/EDX), passes arguments in C order,
-// and requires that the callee pop its arguments off the stack (allowing 
proper
-// tail calls), and has the same return value conventions as C calling convs.
-//
-// This calling convention always arranges for the callee pop value to be 8n+4
-// bytes, which is needed for tail recursion elimination and stack alignment
-// reasons.
-
-SDOperand
-X86TargetLowering::LowerMemOpCallTo(SDOperand Op, SelectionDAG &DAG,
-const SDOperand &StackPtr,
-const CCValAssign &VA,
-SDOperand Chain,
-SDOperand Arg) {
-  SDOperand PtrOff = DAG.getConstant(VA.getLocMemOffset(), getPointerTy());
-  PtrOff = DAG.getNode(ISD::ADD, getPointerTy(), StackPtr, PtrOff);
-  SDOperand FlagsOp = Op.getOperand(6+2*VA.getValNo());
-  unsigned Flags= cast(FlagsOp)->getValue();
-  if (Flags & ISD::ParamFlags::ByVal) {
-unsigned Align = 1 << ((Flags & ISD::ParamFlags::ByValAlign) >>
-   ISD::ParamFlags::ByValAlignOffs);
-
-unsigned  Size = (Flags & ISD::ParamFlags::ByValSize) >>
-ISD::ParamFlags::ByValSizeOffs;
-
-SDOperand AlignNode = DAG.getConstant(Align, MVT::i32);
-SDOperand  SizeNode = DAG.getConstant(Size, MVT::i32);
-SDOperand AlwaysInline = DAG.getConstant(1, MVT::i32);
-
-return DAG.getMemcpy(Chain, PtrOff, Arg, SizeNode, AlignNode,
- AlwaysInline);
-  } else {
-return DAG.getStore(Chain, Arg, PtrOff, NULL, 0);
-  }
-}
-
-//===--===//
 //Fast Calling Convention (tail call) implementation
 
//===--===//
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45795 - /llvm/trunk/test/CodeGen/Generic/bool-vector.ll

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 18:30:38 2008
New Revision: 45795

URL: http://llvm.org/viewvc/llvm-project?rev=45795&view=rev
Log:
new testcase for PR1845

Added:
llvm/trunk/test/CodeGen/Generic/bool-vector.ll

Added: llvm/trunk/test/CodeGen/Generic/bool-vector.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/bool-vector.ll?rev=45795&view=auto

==
--- llvm/trunk/test/CodeGen/Generic/bool-vector.ll (added)
+++ llvm/trunk/test/CodeGen/Generic/bool-vector.ll Wed Jan  9 18:30:38 2008
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | llc
+; PR1845
+
+define void @boolVectorSelect(<4 x i1>* %boolVectorPtr) {
+Body:
+%castPtr = bitcast <4 x i1>* %boolVectorPtr to <4 x i1>*
+%someBools = load <4 x i1>* %castPtr, align 1   ; <<4 x i1>>
+%internal = alloca <4 x i1>, align 16   ; <<4 x i1>*> [#uses=1]
+store <4 x i1> %someBools, <4 x i1>* %internal, align 1
+ret void
+}


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45796 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 18:30:57 2008
New Revision: 45796

URL: http://llvm.org/viewvc/llvm-project?rev=45796&view=rev
Log:
Fix PR1845 and rdar://5676945.  Generic vectors smaller
than hardware supported type will be scalarized, so we
can infer their alignment from that info.

We now codegen pr1845 into:

_boolVectorSelect:
lbz r2, 0(r3)
stb r2, -16(r1)
blr 


Modified:
llvm/trunk/include/llvm/Target/TargetData.h
llvm/trunk/lib/Target/TargetData.cpp

Modified: llvm/trunk/include/llvm/Target/TargetData.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=45796&r1=45795&r2=45796&view=diff

==
--- llvm/trunk/include/llvm/Target/TargetData.h (original)
+++ llvm/trunk/include/llvm/Target/TargetData.h Wed Jan  9 18:30:57 2008
@@ -92,7 +92,7 @@
   void setAlignment(AlignTypeEnum align_type, unsigned char abi_align,
 unsigned char pref_align, uint32_t bit_width);
   unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width,
-bool ABIAlign) const;
+bool ABIAlign, const Type *Ty) const;
   //! Internal helper method that returns requested alignment for type.
   unsigned char getAlignment(const Type *Ty, bool abi_or_pref) const;
 

Modified: llvm/trunk/lib/Target/TargetData.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=45796&r1=45795&r2=45796&view=diff

==
--- llvm/trunk/lib/Target/TargetData.cpp (original)
+++ llvm/trunk/lib/Target/TargetData.cpp Wed Jan  9 18:30:57 2008
@@ -154,7 +154,8 @@
  p:@verbatim::@endverbatim: Pointer size, 
  ABI and preferred alignment.
  
- @verbatim::@endverbatim: Numeric 
type alignment. Type is
+ @verbatim::@endverbatim: Numeric 
type
+ alignment. Type is
  one of i|f|v|a, corresponding to integer, floating point, vector (aka
  packed) or aggregate.  Size indicates the size, e.g., 32 or 64 bits.
  \p
@@ -258,7 +259,8 @@
 /// getAlignmentInfo - Return the alignment (either ABI if ABIInfo = true or 
 /// preferred if ABIInfo = false) the target wants for the specified datatype.
 unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType, 
-  uint32_t BitWidth, bool ABIInfo) const {
+  uint32_t BitWidth, bool ABIInfo,
+  const Type *Ty) const {
   // Check to see if we have an exact match and remember the best match we see.
   int BestMatchIdx = -1;
   int LargestInt = -1;
@@ -293,14 +295,22 @@
 }
   }
 
-  // For integers, if we didn't find a best match, use the largest one found.
-  if (BestMatchIdx == -1)
-BestMatchIdx = LargestInt;
-
   // Okay, we didn't find an exact solution.  Fall back here depending on what
   // is being looked for.
-  assert(BestMatchIdx != -1 && "Didn't find alignment info for this 
datatype!");
-
+  if (BestMatchIdx == -1) {
+// If we didn't find an integer alignment, fall back on most conservative.
+if (AlignType == INTEGER_ALIGN) {
+  BestMatchIdx = LargestInt;
+} else {
+  assert(AlignType == VECTOR_ALIGN && "Unknown alignment type!");
+  
+  // If we didn't find a vector size that is smaller or equal to this type,
+  // then we will end up scalarizing this to its element type.  Just return
+  // the alignment of the element.
+  return getAlignment(cast(Ty)->getElementType(), ABIInfo);
+}
+  }
+
   // Since we got a "best match" index, just return it.
   return ABIInfo ? Alignments[BestMatchIdx].ABIAlign
  : Alignments[BestMatchIdx].PrefAlign;
@@ -474,7 +484,7 @@
 
 // Get the layout annotation... which is lazily created on demand.
 const StructLayout *Layout = getStructLayout(cast(Ty));
-unsigned Align = getAlignmentInfo(AGGREGATE_ALIGN, 0, abi_or_pref);
+unsigned Align = getAlignmentInfo(AGGREGATE_ALIGN, 0, abi_or_pref, Ty);
 return std::max(Align, (unsigned)Layout->getAlignment());
   }
   case Type::IntegerTyID:
@@ -490,22 +500,16 @@
   case Type::X86_FP80TyID:
 AlignType = FLOAT_ALIGN;
 break;
-  case Type::VectorTyID: {
-const VectorType *VTy = cast(Ty);
-// Degenerate vectors are assumed to be scalar-ized
-if (VTy->getNumElements() == 1)
-  return getAlignment(VTy->getElementType(), abi_or_pref);
-else
-  AlignType = VECTOR_ALIGN;
+  case Type::VectorTyID:
+AlignType = VECTOR_ALIGN;
 break;
-  }
   default:
 assert(0 && "Bad type for getAlignment!!!");
 break;
   }
 
   return getAlignmentInfo((AlignTypeEnum)AlignType, getTypeSizeInBits(Ty),
-  abi_or_pref);
+  abi_or_pref, Ty);
 }
 
 unsigned char TargetData::getABITypeAlignment(const Type *Ty) const {


_

[llvm-commits] [llvm] r45797 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson
Author: resistor
Date: Wed Jan  9 18:33:11 2008
New Revision: 45797

URL: http://llvm.org/viewvc/llvm-project?rev=45797&view=rev
Log:
Get rid of the isKillInst predicate.  LiveVariables already provides this 
information.

Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=45797&r1=45796&r2=45797&view=diff

==
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9 18:33:11 2008
@@ -298,22 +298,18 @@
   return false;
 }
 
-/// isKillInst - helper method that determines, from a VarInfo, if an 
-/// instruction kills a given register
-static bool isKillInst(LiveVariables::VarInfo& V, MachineInstr* MI) {
-  return std::find(V.Kills.begin(), V.Kills.end(), MI) != V.Kills.end();
-}
-
 /// interferes - checks for local interferences by scanning a block.  The only
 /// trick parameter is 'mode' which tells it the relationship of the two
 /// registers. 0 - defined in the same block, 1 - first properly dominates
 /// second, 2 - second properly dominates first 
-static bool interferes(LiveVariables::VarInfo& First,
-   LiveVariables::VarInfo& Second,
-   MachineBasicBlock* scan, unsigned mode) {
+static bool interferes(unsigned a, unsigned b, MachineBasicBlock* scan,
+   LiveVariables& LV, unsigned mode) {
   MachineInstr* def = 0;
   MachineInstr* kill = 0;
   
+  LiveVariables::VarInfo& First = LV.getVarInfo(a);
+  LiveVariables::VarInfo& Second = LV.getVarInfo(b);
+  
   bool interference = false;
   
   // Wallk the block, checking for interferences
@@ -350,10 +346,10 @@
   break;
 }
   // Store KillInsts if they match up with the DefInst
-  } else if (isKillInst(First, curr)) {
+  } else if (LV.KillsRegister(curr, a)) {
 if (def == First.DefInst) {
   kill = curr;
-} else if (isKillInst(Second, curr)) {
+} else if (LV.KillsRegister(curr, b)) {
   if (def == Second.DefInst) {
 kill = curr;
   }
@@ -372,7 +368,7 @@
   break;
 }
   // Save KillInsts of First
-  } else if (isKillInst(First, curr)) {
+  } else if (LV.KillsRegister(curr, a)) {
 kill = curr;
   }
 // Symmetric with the above
@@ -385,7 +381,7 @@
   interference = false;
   break;
 }
-  } else if (isKillInst(Second, curr)) {
+  } else if (LV.KillsRegister(curr, b)) {
 kill = curr;
   }
 }
@@ -468,7 +464,7 @@
   }
   
   // If there's an interference, we need to insert  copies
-  if (interferes(FirstInfo, SecondInfo, scan, mode)) {
+  if (interferes(p.first, p.second, scan, LV, mode)) {
 // Insert copies for First
 for (int i = P->getNumOperands() - 1; i >= 2; i-=2) {
   if (P->getOperand(i-1).getReg() == p.first) {


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45798 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

2008-01-09 Thread Evan Cheng
Author: evancheng
Date: Wed Jan  9 18:37:26 2008
New Revision: 45798

URL: http://llvm.org/viewvc/llvm-project?rev=45798&view=rev
Log:
Do not use the stack pointer directly, issue a copyfromreg instead. Otherwise 
we can end up with something like ADD32ri %esp, x which two-address pass won't 
like.

Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=45798&r1=45797&r2=45798&view=diff

==
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jan  9 18:37:26 2008
@@ -1332,7 +1332,7 @@
 } else {
   assert(VA.isMemLoc());
   if (StackPtr.Val == 0)
-StackPtr = DAG.getRegister(getStackPtrReg(), getPointerTy());
+StackPtr = DAG.getCopyFromReg(Chain, X86StackPtr, getPointerTy());
 
   MemOpChains.push_back(LowerMemOpCallTo(Op, DAG, StackPtr, VA, Chain,
  Arg));


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45799 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson
Author: resistor
Date: Wed Jan  9 18:47:01 2008
New Revision: 45799

URL: http://llvm.org/viewvc/llvm-project?rev=45799&view=rev
Log:
Add more comments explaining the basics of how the decision of when to rename 
and when to insert
copies is made.

Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=45799&r1=45798&r2=45799&view=diff

==
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9 18:47:01 2008
@@ -390,7 +390,10 @@
   return interference;
 }
 
-/// processBlock - Eliminate PHIs in the given block
+/// processBlock - Determine how to break up PHIs in the current block.  Each
+/// PHI is broken up by some combination of renaming its operands and inserting
+/// copies.  This method is responsible for determining which operands receive
+/// which treatment.
 void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
   LiveVariables& LV = getAnalysis();
   
@@ -398,21 +401,37 @@
   // before the current one.
   std::set ProcessedNames;
   
+  // Iterate over all the PHI nodes in this block
   MachineBasicBlock::iterator P = MBB->begin();
   while (P != MBB->end() && P->getOpcode() == TargetInstrInfo::PHI) {
 LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand(0).getReg());
 
 unsigned DestReg = P->getOperand(0).getReg();
 
-// Hold the names that are currently in the candidate set.
+// PHIUnion is the set of incoming registers to the PHI node that
+// are going to be renames rather than having copies inserted.  This set
+// is refinded over the course of this function.  UnionedBlocks is the set
+// of corresponding MBBs.
 std::set PHIUnion;
 std::set UnionedBlocks;
   
+// Iterate over the operands of the PHI node
 for (int i = P->getNumOperands() - 1; i >= 2; i-=2) {
   unsigned SrcReg = P->getOperand(i-1).getReg();
   LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg);
 
-  // Check for trivial interferences
+  // Check for trivial interferences via liveness information, allowing us
+  // to avoid extra work later.  Any registers that interfere cannot both
+  // be in the renaming set, so choose one and add copies for it instead.
+  // The conditions are:
+  //   1) if the operand is live into the PHI node's block OR
+  //   2) if the PHI node is live out of the operand's defining block OR
+  //   3) if the operand is itself a PHI node and the original PHI is
+  //  live into the operand's defining block OR
+  //   4) if the operand is already being renamed for another PHI node
+  //  in this block OR
+  //   5) if any two operands are defined in the same block, insert copies
+  //  for one of them
   if (isLiveIn(SrcInfo, P->getParent()) ||
   isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) ||
   ( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
@@ -420,24 +439,32 @@
   ProcessedNames.count(SrcReg) ||
   UnionedBlocks.count(SrcInfo.DefInst->getParent())) {
 
-// add a copy from a_i to p in Waiting[From[a_i]]
+// Add a copy for the selected register
 MachineBasicBlock* From = P->getOperand(i).getMBB();
 Waiting[From].insert(std::make_pair(SrcReg, DestReg));
 UsedByAnother.insert(SrcReg);
   } else {
+// Otherwise, add it to the renaming set
 PHIUnion.insert(SrcReg);
 UnionedBlocks.insert(SrcInfo.DefInst->getParent());
   }
 }
 
+// Compute the dominator forest for the renaming set.  This is a forest
+// where the nodes are the registers and the edges represent dominance 
+// relations between the defining blocks of the registers
 std::vector DF = 
  
computeDomForest(PHIUnion);
 
-// Walk DomForest to resolve interferences
+// Walk DomForest to resolve interferences at an inter-block level.  This
+// will remove registers from the renaming set (and insert copies for them)
+// if interferences are found.
 std::vector > localInterferences;
 processPHIUnion(P, PHIUnion, DF, localInterferences);
 
-// Check for local interferences
+// The dominator forest walk may have returned some register pairs whose
+// interference cannot be determines from dominator analysis.  We now 
+// examine these pairs for local interferences.
 for (std::vector >::iterator I =
 localInterferences.begin(), E = localInterferences.end(); I != E; ++I) 
{
   std::pair p = *I;
@@ -481,10 +508,13 @@
   }
 }
 
-// Cache renaming information
+// Add the renaming set for this PHI node to our overal renaming 
in

[llvm-commits] [llvm-gcc-4.2] r45800 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 18:48:14 2008
New Revision: 45800

URL: http://llvm.org/viewvc/llvm-project?rev=45800&view=rev
Log:
Fix a "bug" introduced by attribute(annotate).  Before this patch it 
would always call " ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));"
even if there are no annotate attributes on a global, causing the string
to be emitted and unused.

Modified:
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=45800&r1=45799&r2=45800&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jan  9 18:48:14 2008
@@ -754,12 +754,14 @@
   
   // Handle annotate attribute on global.
   tree annotateAttr = lookup_attribute("annotate", DECL_ATTRIBUTES (decl));
+  if (annotateAttr == 0)
+return;
   
   // Get file and line number
- Constant *lineNo = ConstantInt::get(Type::Int32Ty, DECL_SOURCE_LINE(decl));
- Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));
- const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
- file = ConstantExpr::getBitCast(file, SBP);
+  Constant *lineNo = ConstantInt::get(Type::Int32Ty, DECL_SOURCE_LINE(decl));
+  Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));
+  const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
+  file = ConstantExpr::getBitCast(file, SBP);
  
   // There may be multiple annotate attributes. Pass return of lookup_attr 
   //  to successive lookups.
@@ -779,10 +781,12 @@
   assert(TREE_CODE(val) == STRING_CST && 
  "Annotate attribute arg should always be a string");
   Constant *strGV = TreeConstantToLLVM::EmitLV_STRING_CST(val);
-  Constant *Element[4] = {ConstantExpr::getBitCast(GV,SBP),
+  Constant *Element[4] = {
+ConstantExpr::getBitCast(GV,SBP),
 ConstantExpr::getBitCast(strGV,SBP),
 file,
-lineNo};
+lineNo
+  };
  
   AttributeAnnotateGlobals.push_back(ConstantStruct::get(Element, 4, 
false));
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.0] r45801 - /llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 18:48:43 2008
New Revision: 45801

URL: http://llvm.org/viewvc/llvm-project?rev=45801&view=rev
Log:
Fix a "bug" introduced by attribute(annotate).  Before this patch it 
would always call " ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));"
even if there are no annotate attributes on a global, causing the string
to be emitted and unused.



Modified:
llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp

Modified: llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp?rev=45801&r1=45800&r2=45801&view=diff

==
--- llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp Wed Jan  9 18:48:43 2008
@@ -714,12 +714,14 @@
   
   // Handle annotate attribute on global.
   tree annotateAttr = lookup_attribute("annotate", DECL_ATTRIBUTES (decl));
+  if (annotateAttr == 0)
+return;
   
   // Get file and line number
- Constant *lineNo = ConstantInt::get(Type::Int32Ty, DECL_SOURCE_LINE(decl));
- Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));
- const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
- file = ConstantExpr::getBitCast(file, SBP);
+  Constant *lineNo = ConstantInt::get(Type::Int32Ty, DECL_SOURCE_LINE(decl));
+  Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));
+  const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
+  file = ConstantExpr::getBitCast(file, SBP);
  
   // There may be multiple annotate attributes. Pass return of lookup_attr 
   //  to successive lookups.
@@ -739,10 +741,12 @@
   assert(TREE_CODE(val) == STRING_CST && 
  "Annotate attribute arg should always be a string");
   Constant *strGV = TreeConstantToLLVM::EmitLV_STRING_CST(val);
-  Constant *Element[4] = {ConstantExpr::getBitCast(GV,SBP),
+  Constant *Element[4] = {
+ConstantExpr::getBitCast(GV,SBP),
 ConstantExpr::getBitCast(strGV,SBP),
 file,
-lineNo};
+lineNo
+  };
  
   AttributeAnnotateGlobals.push_back(ConstantStruct::get(Element, 4, 
false));
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45803 - /llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 19:01:27 2008
New Revision: 45803

URL: http://llvm.org/viewvc/llvm-project?rev=45803&view=rev
Log:
provide def_* and use_* iterators in addition to reg_* iterators.
The first only returns definitions of a register, the second only
returns uses, the third returns both.

Modified:
llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h

Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=45803&r1=45802&r2=45803&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Wed Jan  9 19:01:27 
2008
@@ -64,11 +64,31 @@
   /// reg_begin/reg_end - Provide iteration support to walk over all 
definitions
   /// and uses of a register within the MachineFunction that corresponds to 
this
   /// MachineRegisterInfo object.
-  class reg_iterator;
+  template
+  class defusechain_iterator;
+
+  /// reg_iterator/reg_begin/reg_end - Walk all defs and uses of the specified
+  /// register.
+  typedef defusechain_iterator reg_iterator;
   reg_iterator reg_begin(unsigned RegNo) const {
 return reg_iterator(getRegUseDefListHead(RegNo));
   }
   static reg_iterator reg_end() { return reg_iterator(0); }
+
+  /// def_iterator/def_begin/def_end - Walk all defs of the specified register.
+  typedef defusechain_iterator def_iterator;
+  def_iterator def_begin(unsigned RegNo) const {
+return def_iterator(getRegUseDefListHead(RegNo));
+  }
+  static def_iterator def_end() { return def_iterator(0); }
+
+  /// use_iterator/use_begin/use_end - Walk all uses of the specified register.
+  typedef defusechain_iterator use_iterator;
+  use_iterator use_begin(unsigned RegNo) const {
+return use_iterator(getRegUseDefListHead(RegNo));
+  }
+  static use_iterator use_end() { return use_iterator(0); }
+  
   
   /// replaceRegWith - Replace all instances of FromReg with ToReg in the
   /// machine function.  This is like llvm-level X->replaceAllUsesWith(Y),
@@ -174,23 +194,36 @@
   void HandleVRegListReallocation();
   
 public:
-  /// reg_iterator - This class provides iterator support for machine
-  /// operands in the function that use or define a specific register.
-  class reg_iterator : public forward_iterator {
+  /// defusechain_iterator - This class provides iterator support for machine
+  /// operands in the function that use or define a specific register.  If
+  /// ReturnUses is true it returns uses of registers, if ReturnDefs is true it
+  /// returns defs.  If neither are true then you are silly and it always
+  /// returns end().
+  template
+  class defusechain_iterator
+: public forward_iterator {
 MachineOperand *Op;
-reg_iterator(MachineOperand *op) : Op(op) {}
+defusechain_iterator(MachineOperand *op) : Op(op) {
+  // If the first node isn't one we're interested in, advance to one that
+  // we are interested in.
+  if (op) {
+if (!ReturnUses && op->isUse() || 
+!ReturnDefs && op->isDef())
+  ++*this;
+  }
+}
 friend class MachineRegisterInfo;
   public:
 typedef forward_iterator::reference reference;
 typedef forward_iterator::pointer pointer;
 
-reg_iterator(const reg_iterator &I) : Op(I.Op) {}
-reg_iterator() : Op(0) {}
+defusechain_iterator(const defusechain_iterator &I) : Op(I.Op) {}
+defusechain_iterator() : Op(0) {}
 
-bool operator==(const reg_iterator &x) const {
+bool operator==(const defusechain_iterator &x) const {
   return Op == x.Op;
 }
-bool operator!=(const reg_iterator &x) const {
+bool operator!=(const defusechain_iterator &x) const {
   return !operator==(x);
 }
 
@@ -198,13 +231,19 @@
 bool atEnd() const { return Op == 0; }
 
 // Iterator traversal: forward iteration only
-reg_iterator &operator++() {  // Preincrement
+defusechain_iterator &operator++() {  // Preincrement
   assert(Op && "Cannot increment end iterator!");
   Op = Op->getNextOperandForReg();
+  
+  // If this is an operand we don't care about, skip it.
+  while (Op && (!ReturnUses && Op->isUse() || 
+!ReturnDefs && Op->isDef()))
+Op = Op->getNextOperandForReg();
+  
   return *this;
 }
-reg_iterator operator++(int) {// Postincrement
-  reg_iterator tmp = *this; ++*this; return tmp;
+defusechain_iterator operator++(int) {// Postincrement
+  defusechain_iterator tmp = *this; ++*this; return tmp;
 }
 
 MachineOperand &getOperand() const {


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r45799 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Tanya Lattner
Nice!

On Jan 9, 2008, at 4:47 PM, Owen Anderson wrote:

> Author: resistor
> Date: Wed Jan  9 18:47:01 2008
> New Revision: 45799
>
> URL: http://llvm.org/viewvc/llvm-project?rev=45799&view=rev
> Log:
> Add more comments explaining the basics of how the decision of when  
> to rename and when to insert
> copies is made.
>
> Modified:
> llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
>
> Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ 
> StrongPHIElimination.cpp?rev=45799&r1=45798&r2=45799&view=diff
>
> == 
> 
> --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
> +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9  
> 18:47:01 2008
> @@ -390,7 +390,10 @@
>return interference;
>  }
>
> -/// processBlock - Eliminate PHIs in the given block
> +/// processBlock - Determine how to break up PHIs in the current  
> block.  Each
> +/// PHI is broken up by some combination of renaming its operands  
> and inserting
> +/// copies.  This method is responsible for determining which  
> operands receive
> +/// which treatment.
>  void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
>LiveVariables& LV = getAnalysis();
>
> @@ -398,21 +401,37 @@
>// before the current one.
>std::set ProcessedNames;
>
> +  // Iterate over all the PHI nodes in this block
>MachineBasicBlock::iterator P = MBB->begin();
>while (P != MBB->end() && P->getOpcode() == TargetInstrInfo::PHI) {
>  LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand 
> (0).getReg());
>
>  unsigned DestReg = P->getOperand(0).getReg();
>
> -// Hold the names that are currently in the candidate set.
> +// PHIUnion is the set of incoming registers to the PHI node that
> +// are going to be renames rather than having copies  
> inserted.  This set
> +// is refinded over the course of this function.   
> UnionedBlocks is the set
> +// of corresponding MBBs.
>  std::set PHIUnion;
>  std::set UnionedBlocks;
>
> +// Iterate over the operands of the PHI node
>  for (int i = P->getNumOperands() - 1; i >= 2; i-=2) {
>unsigned SrcReg = P->getOperand(i-1).getReg();
>LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg);
>
> -  // Check for trivial interferences
> +  // Check for trivial interferences via liveness information,  
> allowing us
> +  // to avoid extra work later.  Any registers that interfere  
> cannot both
> +  // be in the renaming set, so choose one and add copies for  
> it instead.
> +  // The conditions are:
> +  //   1) if the operand is live into the PHI node's block OR
> +  //   2) if the PHI node is live out of the operand's  
> defining block OR
> +  //   3) if the operand is itself a PHI node and the original  
> PHI is
> +  //  live into the operand's defining block OR
> +  //   4) if the operand is already being renamed for another  
> PHI node
> +  //  in this block OR
> +  //   5) if any two operands are defined in the same block,  
> insert copies
> +  //  for one of them
>if (isLiveIn(SrcInfo, P->getParent()) ||
>isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) ||
>( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
> @@ -420,24 +439,32 @@
>ProcessedNames.count(SrcReg) ||
>UnionedBlocks.count(SrcInfo.DefInst->getParent())) {
>
> -// add a copy from a_i to p in Waiting[From[a_i]]
> +// Add a copy for the selected register
>  MachineBasicBlock* From = P->getOperand(i).getMBB();
>  Waiting[From].insert(std::make_pair(SrcReg, DestReg));
>  UsedByAnother.insert(SrcReg);
>} else {
> +// Otherwise, add it to the renaming set
>  PHIUnion.insert(SrcReg);
>  UnionedBlocks.insert(SrcInfo.DefInst->getParent());
>}
>  }
>
> +// Compute the dominator forest for the renaming set.  This is  
> a forest
> +// where the nodes are the registers and the edges represent  
> dominance
> +// relations between the defining blocks of the registers
>  std::vector DF =
>
> computeDomForest(PHIUnion);
>
> -// Walk DomForest to resolve interferences
> +// Walk DomForest to resolve interferences at an inter-block  
> level.  This
> +// will remove registers from the renaming set (and insert  
> copies for them)
> +// if interferences are found.
>  std::vector > localInterferences;
>  processPHIUnion(P, PHIUnion, DF, localInterferences);
>
> -// Check for local interferences
> +// The dominator forest walk may have returned some register  
> pairs whose
> +// interference cannot be determines from dominator analysis.   
> We now
> +// examine these pairs for local interferences.
>

[llvm-commits] [llvm-gcc-4.2] r45804 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm.h objc/objc-act.c

2008-01-09 Thread Bill Wendling
Author: void
Date: Wed Jan  9 19:28:25 2008
New Revision: 45804

URL: http://llvm.org/viewvc/llvm-project?rev=45804&view=rev
Log:
We're creating incorrect metadata. LLVM gives this for class references:

L_OBJC_CLASS_REFERENCES_0:
  .space 4
..
L_OBJC_CLASS_NAME_0:
  ...

while GCC gives:

L_OBJC_CLASS_REFERENCES_0:
  .long L_OBJC_CLASS_NAME_0
..
L_OBJC_CLASS_NAME_0:
  ...

which is correct. What's happening is that the reference is being created and
LLVM is setting it's initializer to "null" because it's not pointing to
something at that time. But then reference is modified to point to some
object. However, LLVM wasn't updating its initializer information at that point.


Modified:
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
llvm-gcc-4.2/trunk/gcc/llvm.h
llvm-gcc-4.2/trunk/gcc/objc/objc-act.c

Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=45804&r1=45803&r2=45804&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jan  9 19:28:25 2008
@@ -798,6 +798,17 @@
   }
 }
 
+/// reset_initializer_llvm - Change the initializer for a global variable.
+void reset_initializer_llvm(tree decl) {
+  // Get or create the global variable now.
+  GlobalVariable *GV = cast(DECL_LLVM(decl));
+  
+  // Convert the initializer over.
+  Constant *Init = TreeConstantToLLVM::Convert(DECL_INITIAL(decl));
+
+  // Set the initializer.
+  GV->setInitializer(Init);
+}
   
 /// emit_global_to_llvm - Emit the specified VAR_DECL or aggregate CONST_DECL 
to
 /// LLVM as a global variable.  This function implements the end of

Modified: llvm-gcc-4.2/trunk/gcc/llvm.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm.h?rev=45804&r1=45803&r2=45804&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm.h Wed Jan  9 19:28:25 2008
@@ -44,12 +44,15 @@
 /* make_decl_llvm - This is also defined in tree.h and used by macros there. */
 void make_decl_llvm(union tree_node*);
 
+/* reset_initializer_llvm - Change the initializer for a global variable. */
+void reset_initializer_llvm(union tree_node*);
+
 /* emit_global_to_llvm - Emit the specified VAR_DECL to LLVM as a global
  * variable.
  */
 void emit_global_to_llvm(union tree_node*);
 
-/* emit_global_to_llvm - Emit the specified alias to LLVM
+/* emit_alias_to_llvm - Emit the specified alias to LLVM
  */
 void emit_alias_to_llvm(union tree_node*, union tree_node*, union tree_node*);
 

Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=45804&r1=45803&r2=45804&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original)
+++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Wed Jan  9 19:28:25 2008
@@ -76,6 +76,9 @@
 #include "langhooks-def.h"
 /* APPLE LOCAL optimization pragmas 3124235/3420242 */
 #include "opts.h"
+#ifdef ENABLE_LLVM
+#include "llvm.h"   /* for reset_initializer_llvm */
+#endif
 
 #define OBJC_VOID_AT_END   void_list_node
 
@@ -5541,6 +5544,13 @@
{
  decl = TREE_PURPOSE (chain);
  finish_var_decl (decl, expr);
+  /* APPLE LOCAL LLVM begin - radar 5676233 */
+#ifdef ENABLE_LLVM
+  /* Reset the initializer for this reference as it most likely
+ changed.  */
+  reset_initializer_llvm(decl);
+#endif
+  /* APPLE LOCAL LLVM end - radar 5676233 */
}
   else
{
@@ -18172,8 +18182,16 @@
   for (chain = cls_ref_chain; chain; chain = TREE_CHAIN (chain))
 {
   handle_class_ref (chain);
-  if (TREE_PURPOSE (chain))
+  /* APPLE LOCAL LLVM begin - radar 5676233 */
+  if (TREE_PURPOSE (chain)) {
generate_classref_translation_entry (chain);
+#ifdef ENABLE_LLVM
+/* Reset the initializer for this reference as it most likely
+   changed.  */
+reset_initializer_llvm(TREE_PURPOSE (chain));
+#endif
+  }
+  /* APPLE LOCAL LLVM end - radar 5676233 */
 }
 
   for (impent = imp_list; impent; impent = impent->next)


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45805 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson
Author: resistor
Date: Wed Jan  9 19:36:43 2008
New Revision: 45805

URL: http://llvm.org/viewvc/llvm-project?rev=45805&view=rev
Log:
Get rid of all uses of LiveVariables::VarInfo::DefInst in favor of the 
equivalent API from
MachineRegisterInfo.  Once all clients are switched over, the former will be 
going away.

Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=45805&r1=45804&r2=45805&view=diff

==
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9 19:36:43 2008
@@ -121,7 +121,8 @@
 void computeDFS(MachineFunction& MF);
 void processBlock(MachineBasicBlock* MBB);
 
-std::vector computeDomForest(std::set& instrs);
+std::vector computeDomForest(std::set& instrs,
+ MachineRegisterInfo& MRI);
 void processPHIUnion(MachineInstr* Inst,
  std::set& PHIUnion,
  std::vector& DF,
@@ -186,18 +187,18 @@
 class PreorderSorter {
 private:
   DenseMap& preorder;
-  LiveVariables& LV;
+  MachineRegisterInfo& MRI;
   
 public:
   PreorderSorter(DenseMap& p,
-LiveVariables& L) : preorder(p), LV(L) { }
+MachineRegisterInfo& M) : preorder(p), MRI(M) { }
   
   bool operator()(unsigned A, unsigned B) {
 if (A == B)
   return false;
 
-MachineBasicBlock* ABlock = LV.getVarInfo(A).DefInst->getParent();
-MachineBasicBlock* BBlock = LV.getVarInfo(A).DefInst->getParent();
+MachineBasicBlock* ABlock = MRI.getVRegDef(A)->getParent();
+MachineBasicBlock* BBlock = MRI.getVRegDef(B)->getParent();
 
 if (preorder[ABlock] < preorder[BBlock])
   return true;
@@ -211,9 +212,8 @@
 /// computeDomForest - compute the subforest of the DomTree corresponding
 /// to the defining blocks of the registers in question
 std::vector
-StrongPHIElimination::computeDomForest(std::set& regs) {
-  LiveVariables& LV = getAnalysis();
-  
+StrongPHIElimination::computeDomForest(std::set& regs, 
+   MachineRegisterInfo& MRI) {
   // Begin by creating a virtual root node, since the actual results
   // may well be a forest.  Assume this node has maximum DFS-out number.
   DomForestNode* VirtualRoot = new DomForestNode(0, 0);
@@ -227,7 +227,7 @@
 worklist.push_back(*I);
   
   // Sort the registers by the DFS-in number of their defining block
-  PreorderSorter PS(preorder, LV);
+  PreorderSorter PS(preorder, MRI);
   std::sort(worklist.begin(), worklist.end(), PS);
   
   // Create a "current parent" stack, and put the virtual root on top of it
@@ -238,9 +238,9 @@
   // Iterate over all the registers in the previously computed order
   for (std::vector::iterator I = worklist.begin(), E = 
worklist.end();
I != E; ++I) {
-unsigned pre = preorder[LV.getVarInfo(*I).DefInst->getParent()];
+unsigned pre = preorder[MRI.getVRegDef(*I)->getParent()];
 MachineBasicBlock* parentBlock = CurrentParent->getReg() ?
- LV.getVarInfo(CurrentParent->getReg()).DefInst->getParent() :
+ MRI.getVRegDef(CurrentParent->getReg())->getParent() :
  0;
 
 // If the DFS-in number of the register is greater than the DFS-out number
@@ -250,7 +250,7 @@
   CurrentParent = stack.back();
   
   parentBlock = CurrentParent->getReg() ?
-   LV.getVarInfo(CurrentParent->getReg()).DefInst->getParent() 
:
+   MRI.getVRegDef(CurrentParent->getReg())->getParent() :
0;
 }
 
@@ -271,11 +271,13 @@
 
 /// isLiveIn - helper method that determines, from a VarInfo, if a register
 /// is live into a block
-static bool isLiveIn(LiveVariables::VarInfo& V, MachineBasicBlock* MBB) {
+static bool isLiveIn(unsigned r, MachineBasicBlock* MBB,
+ MachineRegisterInfo& MRI, LiveVariables& LV) {
+  LiveVariables::VarInfo V = LV.getVarInfo(r);
   if (V.AliveBlocks.test(MBB->getNumber()))
 return true;
   
-  if (V.DefInst->getParent() != MBB &&
+  if (MRI.getVRegDef(r)->getParent() != MBB &&
   V.UsedBlocks.test(MBB->getNumber()))
 return true;
   
@@ -284,8 +286,10 @@
 
 /// isLiveOut - help method that determines, from a VarInfo, if a register is
 /// live out of a block.
-static bool isLiveOut(LiveVariables::VarInfo& V, MachineBasicBlock* MBB) {
-  if (MBB == V.DefInst->getParent() ||
+static bool isLiveOut(unsigned r, MachineBasicBlock* MBB,
+  MachineRegisterInfo& MRI, LiveVariables& LV) {
+  LiveVariables::VarInfo& V = LV.getVarInfo(r);
+  if (MBB == MRI.getVRegDef(r)->getParent() ||
   V.UsedBlocks.test(MBB->getNumber())) {
 for (std::vector::iterator I = V.Kills.begin(), 
  

Re: [llvm-commits] [llvm] r45799 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson

There's more in the pipeline too.

--Owen

On Jan 9, 2008, at 7:15 PM, Tanya Lattner wrote:


Nice!

On Jan 9, 2008, at 4:47 PM, Owen Anderson wrote:


Author: resistor
Date: Wed Jan  9 18:47:01 2008
New Revision: 45799

URL: http://llvm.org/viewvc/llvm-project?rev=45799&view=rev
Log:
Add more comments explaining the basics of how the decision of when
to rename and when to insert
copies is made.

Modified:
   llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/
StrongPHIElimination.cpp?rev=45799&r1=45798&r2=45799&view=diff

=
=

--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9
18:47:01 2008
@@ -390,7 +390,10 @@
  return interference;
}

-/// processBlock - Eliminate PHIs in the given block
+/// processBlock - Determine how to break up PHIs in the current
block.  Each
+/// PHI is broken up by some combination of renaming its operands
and inserting
+/// copies.  This method is responsible for determining which
operands receive
+/// which treatment.
void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
  LiveVariables& LV = getAnalysis();

@@ -398,21 +401,37 @@
  // before the current one.
  std::set ProcessedNames;

+  // Iterate over all the PHI nodes in this block
  MachineBasicBlock::iterator P = MBB->begin();
  while (P != MBB->end() && P->getOpcode() == TargetInstrInfo::PHI) {
LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand
(0).getReg());

unsigned DestReg = P->getOperand(0).getReg();

-// Hold the names that are currently in the candidate set.
+// PHIUnion is the set of incoming registers to the PHI node  
that

+// are going to be renames rather than having copies
inserted.  This set
+// is refinded over the course of this function.
UnionedBlocks is the set
+// of corresponding MBBs.
std::set PHIUnion;
std::set UnionedBlocks;

+// Iterate over the operands of the PHI node
for (int i = P->getNumOperands() - 1; i >= 2; i-=2) {
  unsigned SrcReg = P->getOperand(i-1).getReg();
  LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg);

-  // Check for trivial interferences
+  // Check for trivial interferences via liveness information,
allowing us
+  // to avoid extra work later.  Any registers that interfere
cannot both
+  // be in the renaming set, so choose one and add copies for
it instead.
+  // The conditions are:
+  //   1) if the operand is live into the PHI node's block OR
+  //   2) if the PHI node is live out of the operand's
defining block OR
+  //   3) if the operand is itself a PHI node and the original
PHI is
+  //  live into the operand's defining block OR
+  //   4) if the operand is already being renamed for another
PHI node
+  //  in this block OR
+  //   5) if any two operands are defined in the same block,
insert copies
+  //  for one of them
  if (isLiveIn(SrcInfo, P->getParent()) ||
  isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) ||
  ( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
@@ -420,24 +439,32 @@
  ProcessedNames.count(SrcReg) ||
  UnionedBlocks.count(SrcInfo.DefInst->getParent())) {

-// add a copy from a_i to p in Waiting[From[a_i]]
+// Add a copy for the selected register
MachineBasicBlock* From = P->getOperand(i).getMBB();
Waiting[From].insert(std::make_pair(SrcReg, DestReg));
UsedByAnother.insert(SrcReg);
  } else {
+// Otherwise, add it to the renaming set
PHIUnion.insert(SrcReg);
UnionedBlocks.insert(SrcInfo.DefInst->getParent());
  }
}

+// Compute the dominator forest for the renaming set.  This is
a forest
+// where the nodes are the registers and the edges represent
dominance
+// relations between the defining blocks of the registers
std::vector DF =

computeDomForest(PHIUnion);

-// Walk DomForest to resolve interferences
+// Walk DomForest to resolve interferences at an inter-block
level.  This
+// will remove registers from the renaming set (and insert
copies for them)
+// if interferences are found.
std::vector > localInterferences;
processPHIUnion(P, PHIUnion, DF, localInterferences);

-// Check for local interferences
+// The dominator forest walk may have returned some register
pairs whose
+// interference cannot be determines from dominator analysis.
We now
+// examine these pairs for local interferences.
for (std::vector >::iterator I =
localInterferences.begin(), E = localInterferences.end();
I != E; ++I) {
  std::pair p = *I;
@@ -481,10 +508,13 @@
  }
}

-// Cache renaming information
+// Add the renaming set for this PHI node to our over

Re: [llvm-commits] [llvm] r45799 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Evan Cheng
Geeze. I asked for comments and was ignored. Tanya asks for it and  
she gets it right away. :-)

Evan
On Jan 9, 2008, at 5:15 PM, Tanya Lattner wrote:

> Nice!
>
> On Jan 9, 2008, at 4:47 PM, Owen Anderson wrote:
>
>> Author: resistor
>> Date: Wed Jan  9 18:47:01 2008
>> New Revision: 45799
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=45799&view=rev
>> Log:
>> Add more comments explaining the basics of how the decision of when
>> to rename and when to insert
>> copies is made.
>>
>> Modified:
>> llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
>>
>> Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/
>> StrongPHIElimination.cpp?rev=45799&r1=45798&r2=45799&view=diff
>>
>> = 
>> =
>> 
>> --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9
>> 18:47:01 2008
>> @@ -390,7 +390,10 @@
>>return interference;
>>  }
>>
>> -/// processBlock - Eliminate PHIs in the given block
>> +/// processBlock - Determine how to break up PHIs in the current
>> block.  Each
>> +/// PHI is broken up by some combination of renaming its operands
>> and inserting
>> +/// copies.  This method is responsible for determining which
>> operands receive
>> +/// which treatment.
>>  void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
>>LiveVariables& LV = getAnalysis();
>>
>> @@ -398,21 +401,37 @@
>>// before the current one.
>>std::set ProcessedNames;
>>
>> +  // Iterate over all the PHI nodes in this block
>>MachineBasicBlock::iterator P = MBB->begin();
>>while (P != MBB->end() && P->getOpcode() ==  
>> TargetInstrInfo::PHI) {
>>  LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand
>> (0).getReg());
>>
>>  unsigned DestReg = P->getOperand(0).getReg();
>>
>> -// Hold the names that are currently in the candidate set.
>> +// PHIUnion is the set of incoming registers to the PHI node  
>> that
>> +// are going to be renames rather than having copies
>> inserted.  This set
>> +// is refinded over the course of this function.
>> UnionedBlocks is the set
>> +// of corresponding MBBs.
>>  std::set PHIUnion;
>>  std::set UnionedBlocks;
>>
>> +// Iterate over the operands of the PHI node
>>  for (int i = P->getNumOperands() - 1; i >= 2; i-=2) {
>>unsigned SrcReg = P->getOperand(i-1).getReg();
>>LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg);
>>
>> -  // Check for trivial interferences
>> +  // Check for trivial interferences via liveness information,
>> allowing us
>> +  // to avoid extra work later.  Any registers that interfere
>> cannot both
>> +  // be in the renaming set, so choose one and add copies for
>> it instead.
>> +  // The conditions are:
>> +  //   1) if the operand is live into the PHI node's block OR
>> +  //   2) if the PHI node is live out of the operand's
>> defining block OR
>> +  //   3) if the operand is itself a PHI node and the original
>> PHI is
>> +  //  live into the operand's defining block OR
>> +  //   4) if the operand is already being renamed for another
>> PHI node
>> +  //  in this block OR
>> +  //   5) if any two operands are defined in the same block,
>> insert copies
>> +  //  for one of them
>>if (isLiveIn(SrcInfo, P->getParent()) ||
>>isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) ||
>>( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
>> @@ -420,24 +439,32 @@
>>ProcessedNames.count(SrcReg) ||
>>UnionedBlocks.count(SrcInfo.DefInst->getParent())) {
>>
>> -// add a copy from a_i to p in Waiting[From[a_i]]
>> +// Add a copy for the selected register
>>  MachineBasicBlock* From = P->getOperand(i).getMBB();
>>  Waiting[From].insert(std::make_pair(SrcReg, DestReg));
>>  UsedByAnother.insert(SrcReg);
>>} else {
>> +// Otherwise, add it to the renaming set
>>  PHIUnion.insert(SrcReg);
>>  UnionedBlocks.insert(SrcInfo.DefInst->getParent());
>>}
>>  }
>>
>> +// Compute the dominator forest for the renaming set.  This is
>> a forest
>> +// where the nodes are the registers and the edges represent
>> dominance
>> +// relations between the defining blocks of the registers
>>  std::vector DF =
>>
>> computeDomForest(PHIUnion);
>>
>> -// Walk DomForest to resolve interferences
>> +// Walk DomForest to resolve interferences at an inter-block
>> level.  This
>> +// will remove registers from the renaming set (and insert
>> copies for them)
>> +// if interferences are found.
>>  std::vector > localInterferences;
>>  processPHIUnion(P, PHIUnion, DF, localInterferences);
>>
>> -// Check for local interferences
>> +// The domina

Re: [llvm-commits] [llvm-gcc-4.2] r45804 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm.h objc/objc-act.c

2008-01-09 Thread Chris Lattner

On Jan 9, 2008, at 5:28 PM, Bill Wendling wrote:

> Author: void
> Date: Wed Jan  9 19:28:25 2008
> New Revision: 45804
>
> URL: http://llvm.org/viewvc/llvm-project?rev=45804&view=rev
> Log:
> We're creating incorrect metadata. LLVM gives this for class  
> references:

Hey Bill,

Is it possible to avoid having the llvm-front-end called on the objc  
metadata before its fully formed?  Alternatively, perhaps the objc  
front-end should set the early version of the metadata as being an  
extern instead of definition?

-Chris

>
> L_OBJC_CLASS_REFERENCES_0:
>  .space 4
> ..
> L_OBJC_CLASS_NAME_0:
>  ...
>
> while GCC gives:
>
> L_OBJC_CLASS_REFERENCES_0:
>  .long L_OBJC_CLASS_NAME_0
> ..
> L_OBJC_CLASS_NAME_0:
>  ...
>
> which is correct. What's happening is that the reference is being  
> created and
> LLVM is setting it's initializer to "null" because it's not pointing  
> to
> something at that time. But then reference is modified to point to  
> some
> object. However, LLVM wasn't updating its initializer information at  
> that point.
>
>
> Modified:
>llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
>llvm-gcc-4.2/trunk/gcc/llvm.h
>llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=45804&r1=45803&r2=45804&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ==
> --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jan  9 19:28:25 2008
> @@ -798,6 +798,17 @@
>   }
> }
>
> +/// reset_initializer_llvm - Change the initializer for a global  
> variable.
> +void reset_initializer_llvm(tree decl) {
> +  // Get or create the global variable now.
> +  GlobalVariable *GV = cast(DECL_LLVM(decl));
> +
> +  // Convert the initializer over.
> +  Constant *Init = TreeConstantToLLVM::Convert(DECL_INITIAL(decl));
> +
> +  // Set the initializer.
> +  GV->setInitializer(Init);
> +}
>
> /// emit_global_to_llvm - Emit the specified VAR_DECL or aggregate  
> CONST_DECL to
> /// LLVM as a global variable.  This function implements the end of
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm.h
> URL: 
> http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm.h?rev=45804&r1=45803&r2=45804&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ==
> --- llvm-gcc-4.2/trunk/gcc/llvm.h (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm.h Wed Jan  9 19:28:25 2008
> @@ -44,12 +44,15 @@
> /* make_decl_llvm - This is also defined in tree.h and used by  
> macros there. */
> void make_decl_llvm(union tree_node*);
>
> +/* reset_initializer_llvm - Change the initializer for a global  
> variable. */
> +void reset_initializer_llvm(union tree_node*);
> +
> /* emit_global_to_llvm - Emit the specified VAR_DECL to LLVM as a  
> global
>  * variable.
>  */
> void emit_global_to_llvm(union tree_node*);
>
> -/* emit_global_to_llvm - Emit the specified alias to LLVM
> +/* emit_alias_to_llvm - Emit the specified alias to LLVM
>  */
> void emit_alias_to_llvm(union tree_node*, union tree_node*, union  
> tree_node*);
>
>
> Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
> URL: 
> http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=45804&r1=45803&r2=45804&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ==
> --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original)
> +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Wed Jan  9 19:28:25 2008
> @@ -76,6 +76,9 @@
> #include "langhooks-def.h"
> /* APPLE LOCAL optimization pragmas 3124235/3420242 */
> #include "opts.h"
> +#ifdef ENABLE_LLVM
> +#include "llvm.h"   /* for reset_initializer_llvm */
> +#endif
>
> #define OBJC_VOID_AT_END  void_list_node
>
> @@ -5541,6 +5544,13 @@
>   {
> decl = TREE_PURPOSE (chain);
> finish_var_decl (decl, expr);
> +  /* APPLE LOCAL LLVM begin - radar 5676233 */
> +#ifdef ENABLE_LLVM
> +  /* Reset the initializer for this reference as it most  
> likely
> + changed.  */
> +  reset_initializer_llvm(decl);
> +#endif
> +  /* APPLE LOCAL LLVM end - radar 5676233 */
>   }
>   else
>   {
> @@ -18172,8 +18182,16 @@
>   for (chain = cls_ref_chain; chain; chain = TREE_CHAIN (chain))
> {
>   handle_class_ref (chain);
> -  if (TREE_PURPOSE (chain))
> +  /* APPLE LOCAL LLVM begin - radar 5676233 */
> +  if (TREE_PURPOSE (chain)) {
>   generate_classref_translation_entry (chain);
> +#ifdef ENABLE_LLVM
> +/* Reset the initializer for this reference as it most likely
> +   changed.  */
> +reset_initializer_llvm(TREE_PURPOSE (chain));
> +#endif
> +  }
> +  /* APPLE LOCAL LLVM end - radar 5676233 */
> }
>
>   for (impent = imp_list; impent; imp

[llvm-commits] [llvm] r45811 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/DwarfWriter.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86Ta

2008-01-09 Thread Dale Johannesen
Author: johannes
Date: Wed Jan  9 20:03:30 2008
New Revision: 45811

URL: http://llvm.org/viewvc/llvm-project?rev=45811&view=rev
Log:
Emit unused EH frames for weak definitions on Darwin,
because assembler/linker can't cope with weak absolutes.
PR 1880.


Modified:
llvm/trunk/include/llvm/Target/TargetAsmInfo.h
llvm/trunk/lib/CodeGen/DwarfWriter.cpp
llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
llvm/trunk/lib/Target/TargetAsmInfo.cpp
llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp

Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=45811&r1=45810&r2=45811&view=diff

==
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Wed Jan  9 20:03:30 2008
@@ -309,6 +309,10 @@
 ///
 const char *GlobalEHDirective;  // Defaults to NULL.
 
+/// SupportsWeakEmptyEHFrame - True if target assembler and linker will
+/// handle a weak_definition of constant 0 for an omitted EH frame.
+bool SupportsWeakOmittedEHFrame;  // Defaults to true.
+
 /// DwarfSectionOffsetDirective - Special section offset directive.
 const char* DwarfSectionOffsetDirective; // Defaults to NULL
 
@@ -585,6 +589,9 @@
 const char *getGlobalEHDirective() const {
   return GlobalEHDirective;
 }
+bool getSupportsWeakOmittedEHFrame() const {
+  return SupportsWeakOmittedEHFrame;
+}
 const char *getDwarfSectionOffsetDirective() const {
   return DwarfSectionOffsetDirective;
 }

Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=45811&r1=45810&r2=45811&view=diff

==
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Wed Jan  9 20:03:30 2008
@@ -2877,18 +2877,25 @@
 O << GlobalEHDirective << EHFrameInfo.FnName << "\n";
 }
 
-// If there are no calls then you can't unwind.
-if (!EHFrameInfo.hasCalls) { 
+// If corresponding function is weak definition, this should be too.
+if ((EHFrameInfo.linkage == Function::WeakLinkage || 
+ EHFrameInfo.linkage == Function::LinkOnceLinkage) &&
+TAI->getWeakDefDirective())
+  O << TAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n";
+
+// If there are no calls then you can't unwind.  This may mean we can
+// omit the EH Frame, but some environments do not handle weak absolute
+// symbols.
+if (!EHFrameInfo.hasCalls &&
+((EHFrameInfo.linkage != Function::WeakLinkage && 
+  EHFrameInfo.linkage != Function::LinkOnceLinkage) ||
+ !TAI->getWeakDefDirective() ||
+ TAI->getSupportsWeakOmittedEHFrame()))
+{ 
   O << EHFrameInfo.FnName << " = 0\n";
 } else {
   O << EHFrameInfo.FnName << ":\n";
 
-  // If corresponding function is weak definition, this should be too.
-  if ((EHFrameInfo.linkage == Function::WeakLinkage || 
-   EHFrameInfo.linkage == Function::LinkOnceLinkage) &&
-  TAI->getWeakDefDirective())
-O << TAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n";
-
   // EH frame header.
   EmitDifference("eh_frame_end", EHFrameInfo.Number,
  "eh_frame_begin", EHFrameInfo.Number, true);

Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=45811&r1=45810&r2=45811&view=diff

==
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Wed Jan  9 20:03:30 2008
@@ -51,8 +51,8 @@
 StaticDtorsSection = ".mod_term_func";
   }
   UsedDirective = "\t.no_dead_strip\t";
-  WeakDefDirective = "\t.weak_definition\t";
-  WeakRefDirective = "\t.weak_reference\t";
+  WeakDefDirective = "\t.weak_definition ";
+  WeakRefDirective = "\t.weak_reference ";
   HiddenDirective = "\t.private_extern\t";
   SupportsExceptionHandling = true;
   NeedsIndirectEncoding = true;
@@ -62,12 +62,13 @@
   DwarfEHFrameSection =
   ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
   DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
+  GlobalEHDirective = "\t.globl\t";
+  SupportsWeakOmittedEHFrame = false;
 
   DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
   DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
   DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
   DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
-  GlobalEHDirective = "\t.globl\t";
   DwarfPubNamesSection = ".section __DWARF,__debug_

Re: [llvm-commits] [llvm] r45799 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

2008-01-09 Thread Owen Anderson

What can I say, she's scarier than you. :-p

--Owen

On Jan 9, 2008, at 7:55 PM, Evan Cheng wrote:


Geeze. I asked for comments and was ignored. Tanya asks for it and
she gets it right away. :-)

Evan
On Jan 9, 2008, at 5:15 PM, Tanya Lattner wrote:


Nice!

On Jan 9, 2008, at 4:47 PM, Owen Anderson wrote:


Author: resistor
Date: Wed Jan  9 18:47:01 2008
New Revision: 45799

URL: http://llvm.org/viewvc/llvm-project?rev=45799&view=rev
Log:
Add more comments explaining the basics of how the decision of when
to rename and when to insert
copies is made.

Modified:
   llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/
StrongPHIElimination.cpp?rev=45799&r1=45798&r2=45799&view=diff

=

=

--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jan  9
18:47:01 2008
@@ -390,7 +390,10 @@
  return interference;
}

-/// processBlock - Eliminate PHIs in the given block
+/// processBlock - Determine how to break up PHIs in the current
block.  Each
+/// PHI is broken up by some combination of renaming its operands
and inserting
+/// copies.  This method is responsible for determining which
operands receive
+/// which treatment.
void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
  LiveVariables& LV = getAnalysis();

@@ -398,21 +401,37 @@
  // before the current one.
  std::set ProcessedNames;

+  // Iterate over all the PHI nodes in this block
  MachineBasicBlock::iterator P = MBB->begin();
  while (P != MBB->end() && P->getOpcode() ==
TargetInstrInfo::PHI) {
LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand
(0).getReg());

unsigned DestReg = P->getOperand(0).getReg();

-// Hold the names that are currently in the candidate set.
+// PHIUnion is the set of incoming registers to the PHI node
that
+// are going to be renames rather than having copies
inserted.  This set
+// is refinded over the course of this function.
UnionedBlocks is the set
+// of corresponding MBBs.
std::set PHIUnion;
std::set UnionedBlocks;

+// Iterate over the operands of the PHI node
for (int i = P->getNumOperands() - 1; i >= 2; i-=2) {
  unsigned SrcReg = P->getOperand(i-1).getReg();
  LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg);

-  // Check for trivial interferences
+  // Check for trivial interferences via liveness information,
allowing us
+  // to avoid extra work later.  Any registers that interfere
cannot both
+  // be in the renaming set, so choose one and add copies for
it instead.
+  // The conditions are:
+  //   1) if the operand is live into the PHI node's block OR
+  //   2) if the PHI node is live out of the operand's
defining block OR
+  //   3) if the operand is itself a PHI node and the original
PHI is
+  //  live into the operand's defining block OR
+  //   4) if the operand is already being renamed for another
PHI node
+  //  in this block OR
+  //   5) if any two operands are defined in the same block,
insert copies
+  //  for one of them
  if (isLiveIn(SrcInfo, P->getParent()) ||
  isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) ||
  ( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
@@ -420,24 +439,32 @@
  ProcessedNames.count(SrcReg) ||
  UnionedBlocks.count(SrcInfo.DefInst->getParent())) {

-// add a copy from a_i to p in Waiting[From[a_i]]
+// Add a copy for the selected register
MachineBasicBlock* From = P->getOperand(i).getMBB();
Waiting[From].insert(std::make_pair(SrcReg, DestReg));
UsedByAnother.insert(SrcReg);
  } else {
+// Otherwise, add it to the renaming set
PHIUnion.insert(SrcReg);
UnionedBlocks.insert(SrcInfo.DefInst->getParent());
  }
}

+// Compute the dominator forest for the renaming set.  This is
a forest
+// where the nodes are the registers and the edges represent
dominance
+// relations between the defining blocks of the registers
std::vector DF =

computeDomForest(PHIUnion);

-// Walk DomForest to resolve interferences
+// Walk DomForest to resolve interferences at an inter-block
level.  This
+// will remove registers from the renaming set (and insert
copies for them)
+// if interferences are found.
std::vector > localInterferences;
processPHIUnion(P, PHIUnion, DF, localInterferences);

-// Check for local interferences
+// The dominator forest walk may have returned some register
pairs whose
+// interference cannot be determines from dominator analysis.
We now
+// examine these pairs for local interferences.
for (std::vector >::iterator I =
localInterferences.begin(), E = localInterferences.end();
I != E; ++I)

[llvm-commits] [llvm] r45812 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

2008-01-09 Thread Evan Cheng
Author: evancheng
Date: Wed Jan  9 20:18:37 2008
New Revision: 45812

URL: http://llvm.org/viewvc/llvm-project?rev=45812&view=rev
Log:
Add a isImmutable bit to StackObject. Fixed stack objects are immutable (in the 
function) unless specified otherwise.

Modified:
llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=45812&r1=45811&r2=45812&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Wed Jan  9 20:18:37 2008
@@ -86,8 +86,13 @@
 // the function.  This field has no meaning for a variable sized element.
 int64_t SPOffset;
 
-StackObject(uint64_t Sz, unsigned Al, int64_t SP)
-  : Size(Sz), Alignment(Al), SPOffset(SP) {}
+// isImmutable - If true, the value of the stack object does not change
+// in this function. By default, fixed objects are immutable unless marked
+// otherwise.
+bool isImmutable;
+
+StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM = false)
+  : Size(Sz), Alignment(Al), SPOffset(SP), isImmutable(IM) {}
   };
 
   /// Objects - The list of stack objects allocated...
@@ -255,11 +260,13 @@
 
   /// CreateFixedObject - Create a new object at a fixed location on the stack.
   /// All fixed objects should be created before other objects are created for
-  /// efficiency.  This returns an index with a negative value.
+  /// efficiency. By default, fixed objects are immutable. This returns an
+  /// index with a negative value.
   ///
-  int CreateFixedObject(uint64_t Size, int64_t SPOffset) {
+  int CreateFixedObject(uint64_t Size, int64_t SPOffset,
+bool Immutable = true) {
 assert(Size != 0 && "Cannot allocate zero size fixed stack objects!");
-Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset));
+Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, Immutable));
 return -++NumFixedObjects;
   }
 
@@ -269,6 +276,12 @@
 return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects);
   }
 
+  /// isImmutableObjectIndex - Returns true if the specified index corresponds
+  /// to an immutable object.
+  bool isImmutableObjectIndex(int ObjectIdx) const {
+return Objects[ObjectIdx+NumFixedObjects].isImmutable;
+  }
+
   /// CreateStackObject - Create a new statically sized stack object, returning
   /// a postive identifier to represent it.
   ///


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45813 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

2008-01-09 Thread Evan Cheng
Author: evancheng
Date: Wed Jan  9 20:24:25 2008
New Revision: 45813

URL: http://llvm.org/viewvc/llvm-project?rev=45813&view=rev
Log:
Mark byval parameter stack objects mutable for now.

Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=45813&r1=45812&r2=45813&view=diff

==
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jan  9 20:24:25 2008
@@ -1012,16 +1012,17 @@
   MachineFrameInfo *MFI,
   SDOperand Root, unsigned i) {
   // Create the nodes corresponding to a load from this parameter slot.
+  unsigned Flags = cast(Op.getOperand(3 + i))->getValue();
+  bool isByVal = Flags & ISD::ParamFlags::ByVal;
+
+  // FIXME: For now, all byval parameter objects are marked mutable. This
+  // can be changed with more analysis.
   int FI = MFI->CreateFixedObject(MVT::getSizeInBits(VA.getValVT())/8,
-  VA.getLocMemOffset());
+  VA.getLocMemOffset(), !isByVal);
   SDOperand FIN = DAG.getFrameIndex(FI, getPointerTy());
-
-  unsigned Flags =  cast(Op.getOperand(3 + i))->getValue();
-
-  if (Flags & ISD::ParamFlags::ByVal)
+  if (isByVal)
 return FIN;
-  else
-return DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0);
+  return DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0);
 }
 
 SDOperand


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45814 - /llvm/trunk/test/CodeGen/X86/pr1505b.ll

2008-01-09 Thread Evan Cheng
Author: evancheng
Date: Wed Jan  9 20:54:40 2008
New Revision: 45814

URL: http://llvm.org/viewvc/llvm-project?rev=45814&view=rev
Log:
Codegen improvement has reduced one spill.

Modified:
llvm/trunk/test/CodeGen/X86/pr1505b.ll

Modified: llvm/trunk/test/CodeGen/X86/pr1505b.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr1505b.ll?rev=45814&r1=45813&r2=45814&view=diff

==
--- llvm/trunk/test/CodeGen/X86/pr1505b.ll (original)
+++ llvm/trunk/test/CodeGen/X86/pr1505b.ll Wed Jan  9 20:54:40 2008
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | llc -mcpu=i486 | grep fstpl | count 4
+; RUN: llvm-as < %s | llc -mcpu=i486 | grep fstpl | count 3
 ; RUN: llvm-as < %s | llc -mcpu=i486 | grep fstps | count 3
 
 ; ModuleID = ''


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45815 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

2008-01-09 Thread Owen Anderson
Author: resistor
Date: Wed Jan  9 21:12:54 2008
New Revision: 45815

URL: http://llvm.org/viewvc/llvm-project?rev=45815&view=rev
Log:
Don't use LiveVariables::VarInfo::DefInst.

Modified:
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=45815&r1=45814&r2=45815&view=diff

==
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Jan  9 21:12:54 2008
@@ -309,7 +309,14 @@
   // are actually two values in the live interval.  Because of this we
   // need to take the LiveRegion that defines this register and split it
   // into two values.
-  unsigned DefIndex = getDefIndex(getInstructionIndex(vi.DefInst));
+  MachineRegisterInfo& MRI = mbb->getParent()->getRegInfo();
+  unsigned lowIndex = ~0U;
+  for (MachineRegisterInfo::def_iterator DI = MRI.def_begin(interval.reg),
+  DE = MRI.def_end(); DI != DE; ++DI)
+if (getInstructionIndex(&*DI) < lowIndex)
+  lowIndex = getInstructionIndex(&*DI);
+  
+  unsigned DefIndex = getDefIndex(lowIndex);
   unsigned RedefIndex = getDefIndex(MIIdx);
 
   const LiveRange *OldLR = interval.getLiveRangeContaining(RedefIndex-1);


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r45815 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

2008-01-09 Thread Chris Lattner
> URL: http://llvm.org/viewvc/llvm-project?rev=45815&view=rev
> Log:
> Don't use LiveVariables::VarInfo::DefInst.

Cool, question though:

> +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Jan  9  
> 21:12:54 2008
> @@ -309,7 +309,14 @@
>   // are actually two values in the live interval.  Because of  
> this we
>   // need to take the LiveRegion that defines this register and  
> split it
>   // into two values.
> -  unsigned DefIndex =  
> getDefIndex(getInstructionIndex(vi.DefInst));

In the old code, when it introduces multiple definitions of a vreg,  
did it clear DefInst?  If so, this code can only be triggered for  
vregs with a single def.

>
> +  MachineRegisterInfo& MRI = mbb->getParent()->getRegInfo();

I think that MRI should become and ivar in liveintervalanalysis.

>
> +  unsigned lowIndex = ~0U;
> +  for (MachineRegisterInfo::def_iterator DI =  
> MRI.def_begin(interval.reg),
> +  DE = MRI.def_end(); DI != DE; ++DI)
> +if (getInstructionIndex(&*DI) < lowIndex)
> +  lowIndex = getInstructionIndex(&*DI);
> +
> +  unsigned DefIndex = getDefIndex(lowIndex);

It would be really nice if you could drop the loop.  It's unclear why  
it's right anyway, the numbering is not necessarily contiguous across  
code...

-Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r45812 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

2008-01-09 Thread Chris Lattner

On Jan 9, 2008, at 6:18 PM, Evan Cheng wrote:

> Author: evancheng
> Date: Wed Jan  9 20:18:37 2008
> New Revision: 45812
>
> URL: http://llvm.org/viewvc/llvm-project?rev=45812&view=rev
> Log:
> Add a isImmutable bit to StackObject. Fixed stack objects are  
> immutable (in the function) unless specified otherwise.

Hi Evan, please describe what "immutable" means more clearly.  The  
definition you have is "If true, the value of the stack object does  
not change in this function".  Please say something like "If true, the  
value is set before the function is entered, and we know the function  
never modifies the stack slot." or something like this.

Thanks!  I'll make the x86 backend check this predicate.

-Chris

>
> Modified:
>llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
>
> Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
> URL: 
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=45812&r1=45811&r2=45812&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ==
> --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Wed Jan  9  
> 20:18:37 2008
> @@ -86,8 +86,13 @@
> // the function.  This field has no meaning for a variable sized  
> element.
> int64_t SPOffset;
>
> -StackObject(uint64_t Sz, unsigned Al, int64_t SP)
> -  : Size(Sz), Alignment(Al), SPOffset(SP) {}
> +// isImmutable - If true, the value of the stack object does  
> not change
> +// in this function. By default, fixed objects are immutable  
> unless marked
> +// otherwise.
> +bool isImmutable;
> +
> +StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM =  
> false)
> +  : Size(Sz), Alignment(Al), SPOffset(SP), isImmutable(IM) {}
>   };
>
>   /// Objects - The list of stack objects allocated...
> @@ -255,11 +260,13 @@
>
>   /// CreateFixedObject - Create a new object at a fixed location on  
> the stack.
>   /// All fixed objects should be created before other objects are  
> created for
> -  /// efficiency.  This returns an index with a negative value.
> +  /// efficiency. By default, fixed objects are immutable. This  
> returns an
> +  /// index with a negative value.
>   ///
> -  int CreateFixedObject(uint64_t Size, int64_t SPOffset) {
> +  int CreateFixedObject(uint64_t Size, int64_t SPOffset,
> +bool Immutable = true) {
> assert(Size != 0 && "Cannot allocate zero size fixed stack  
> objects!");
> -Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset));
> +Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset,  
> Immutable));
> return -++NumFixedObjects;
>   }
>
> @@ -269,6 +276,12 @@
> return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects);
>   }
>
> +  /// isImmutableObjectIndex - Returns true if the specified index  
> corresponds
> +  /// to an immutable object.
> +  bool isImmutableObjectIndex(int ObjectIdx) const {
> +return Objects[ObjectIdx+NumFixedObjects].isImmutable;
> +  }
> +
>   /// CreateStackObject - Create a new statically sized stack  
> object, returning
>   /// a postive identifier to represent it.
>   ///
>
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45816 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 22:16:31 2008
New Revision: 45816

URL: http://llvm.org/viewvc/llvm-project?rev=45816&view=rev
Log:
verify that the frame index is immutable before remat'ing (still disabled)
or being side-effect free.

Modified:
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=45816&r1=45815&r2=45816&view=diff

==
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Jan  9 22:16:31 2008
@@ -749,10 +749,11 @@
 // values.
 #if 0
 // FIXME: This is disabled due to a remat bug. rdar://5671644
-MachineFunction *MF = MI->getParent()->getParent();
-if (MI->getOperand(1).isFI() && 
-MF->getFrameInfo()->isFixedObjectIndex(MI->getOperand(1).getIndex()))
-  return true;
+if (MI->getOperand(1).isFI()) {
+  const MachineFrameInfo 
&MFI=*MI->getParent()->getParent()->getFrameInfo();
+  int Idx = MI->getOperand(1).getIndex();
+  return MFI.isFixedObjectIndex(Idx) && MFI.isImmutableObjectIndex(Idx);
+}
 #endif
   
 return false;
@@ -805,9 +806,11 @@
 // invariant across the whole function, because we don't redefine argument
 // values.
 MachineFunction *MF = MI->getParent()->getParent();
-if (MI->getOperand(1).isFI() && 
-MF->getFrameInfo()->isFixedObjectIndex(MI->getOperand(1).getIndex()))
-  return true;
+if (MI->getOperand(1).isFI()) {
+  const MachineFrameInfo &MFI = *MF->getFrameInfo();
+  int Idx = MI->getOperand(1).getIndex();
+  return MFI.isFixedObjectIndex(Idx) && MFI.isImmutableObjectIndex(Idx);
+}
   
 return false;
   }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45817 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.cpp CodeGenTarget.h InstrInfoEmitter.cpp

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 22:38:57 2008
New Revision: 45817

URL: http://llvm.org/viewvc/llvm-project?rev=45817&view=rev
Log:
realize that instructions who match intrinsics  that read memory read memory.
Also, instructions with any nodes that are SDNPMayLoad also read memory.

Modified:
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/trunk/utils/TableGen/CodeGenTarget.h
llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp

Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=45817&r1=45816&r2=45817&view=diff

==
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Wed Jan  9 22:38:57 2008
@@ -319,6 +319,8 @@
   Properties |= 1 << SDNPOptInFlag;
 } else if (PropList[i]->getName() == "SDNPMayStore") {
   Properties |= 1 << SDNPMayStore;
+} else if (PropList[i]->getName() == "SDNPMayLoad") {
+  Properties |= 1 << SDNPMayLoad;
 } else {
   cerr << "Unknown SD Node property '" << PropList[i]->getName()
<< "' on node '" << R->getName() << "'!\n";

Modified: llvm/trunk/utils/TableGen/CodeGenTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.h?rev=45817&r1=45816&r2=45817&view=diff

==
--- llvm/trunk/utils/TableGen/CodeGenTarget.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenTarget.h Wed Jan  9 22:38:57 2008
@@ -37,6 +37,7 @@
   SDNPOutFlag,
   SDNPInFlag,
   SDNPOptInFlag,
+  SDNPMayLoad,
   SDNPMayStore
 };
 

Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=45817&r1=45816&r2=45817&view=diff

==
--- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Wed Jan  9 22:38:57 2008
@@ -174,12 +174,21 @@
   const SDNodeInfo &OpInfo = CDP.getSDNodeInfo(N->getOperator());
   
   // If node writes to memory, it obviously stores to memory.
-  if (OpInfo.hasProperty(SDNPMayStore)) {
+  if (OpInfo.hasProperty(SDNPMayStore))
 mayStore = true;
-  } else if (const CodeGenIntrinsic *IntInfo = N->getIntrinsicInfo(CDP)) {
+  
+  // If it reads memory, remember this.
+  if (OpInfo.hasProperty(SDNPMayLoad))
+mayLoad = true;
+  
+  if (const CodeGenIntrinsic *IntInfo = N->getIntrinsicInfo(CDP)) {
 // If this is an intrinsic, analyze it.
-if (IntInfo->ModRef >= CodeGenIntrinsic::WriteArgMem)
+if (IntInfo->ModRef >= CodeGenIntrinsic::WriteArgMem) {
   mayStore = true;// Intrinsics that can write to memory are 
'mayStore'.
+}
+
+if (IntInfo->ModRef >= CodeGenIntrinsic::ReadArgMem)
+  mayLoad  = true;// These may also load memory.
   }
 }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45818 - /llvm/trunk/lib/Target/TargetSelectionDAG.td

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 22:44:32 2008
New Revision: 45818

URL: http://llvm.org/viewvc/llvm-project?rev=45818&view=rev
Log:
add SDNPMayLoad to the 'load' sdnode definition.  This is enough to get all the 
x86 
instructions (with patterns) that load memory marked, for example.

Modified:
llvm/trunk/lib/Target/TargetSelectionDAG.td

Modified: llvm/trunk/lib/Target/TargetSelectionDAG.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetSelectionDAG.td?rev=45818&r1=45817&r2=45818&view=diff

==
--- llvm/trunk/lib/Target/TargetSelectionDAG.td (original)
+++ llvm/trunk/lib/Target/TargetSelectionDAG.td Wed Jan  9 22:44:32 2008
@@ -190,6 +190,7 @@
 def SDNPInFlag  : SDNodeProperty;   // Read a flag operand
 def SDNPOptInFlag   : SDNodeProperty;   // Optionally read a flag operand
 def SDNPMayStore: SDNodeProperty;   // May write to memory, sets 
'mayStore'.
+def SDNPMayLoad : SDNodeProperty;   // May read memory, sets 'mayLoad'.
 
 
//===--===//
 // Selection DAG Node definitions.
@@ -313,7 +314,8 @@
 
 // Do not use ld, st directly. Use load, extload, sextload, zextload, store,
 // and truncst (see below).
-def ld : SDNode<"ISD::LOAD"   , SDTLoad,  [SDNPHasChain]>;
+def ld : SDNode<"ISD::LOAD"   , SDTLoad,
+[SDNPHasChain, SDNPMayLoad]>;
 def st : SDNode<"ISD::STORE"  , SDTStore,
 [SDNPHasChain, SDNPMayStore]>;
 def ist: SDNode<"ISD::STORE"  , SDTIStore,


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r45815 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

2008-01-09 Thread Owen Anderson
You really need to address these to Evan.  I asked him what to do for  
LiveIntervalAnalysis, and this is what he told me :-)


--Owen

On Jan 9, 2008, at 10:08 PM, Chris Lattner wrote:


URL: http://llvm.org/viewvc/llvm-project?rev=45815&view=rev
Log:
Don't use LiveVariables::VarInfo::DefInst.


Cool, question though:


+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Jan  9
21:12:54 2008
@@ -309,7 +309,14 @@
 // are actually two values in the live interval.  Because of
this we
 // need to take the LiveRegion that defines this register and
split it
 // into two values.
-  unsigned DefIndex =
getDefIndex(getInstructionIndex(vi.DefInst));


In the old code, when it introduces multiple definitions of a vreg,
did it clear DefInst?  If so, this code can only be triggered for
vregs with a single def.



+  MachineRegisterInfo& MRI = mbb->getParent()->getRegInfo();


I think that MRI should become and ivar in liveintervalanalysis.



+  unsigned lowIndex = ~0U;
+  for (MachineRegisterInfo::def_iterator DI =
MRI.def_begin(interval.reg),
+  DE = MRI.def_end(); DI != DE; ++DI)
+if (getInstructionIndex(&*DI) < lowIndex)
+  lowIndex = getInstructionIndex(&*DI);
+
+  unsigned DefIndex = getDefIndex(lowIndex);


It would be really nice if you could drop the loop.  It's unclear why
it's right anyway, the numbering is not necessarily contiguous across
code...

-Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




smime.p7s
Description: S/MIME cryptographic signature
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45819 - /llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 22:44:48 2008
New Revision: 45819

URL: http://llvm.org/viewvc/llvm-project?rev=45819&view=rev
Log:
Infer mayload

Modified:
llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp

Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=45819&r1=45818&r2=45819&view=diff

==
--- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Wed Jan  9 22:44:48 2008
@@ -205,7 +205,7 @@
   
   InstAnalyzer(CDP, mayStore, 
mayLoad,NeverHasSideEffects).Analyze(Inst.TheDef);
 
-  // InstAnalyzer only correctly analyzes mayStore so far.
+  // InstAnalyzer only correctly analyzes mayStore/mayLoad so far.
   if (Inst.mayStore) {  // If the .td file explicitly sets mayStore, use it.
 // If we decided that this is a store from the pattern, then the .td file
 // entry is redundant.
@@ -217,8 +217,18 @@
 mayStore = true;
   }
 
-  // These two override everything.
-  mayLoad = Inst.mayLoad;
+  if (Inst.mayLoad) {  // If the .td file explicitly sets mayLoad, use it.
+// If we decided that this is a load from the pattern, then the .td file
+// entry is redundant.
+if (mayLoad)
+  fprintf(stderr, 
+  "Warning: mayLoad flag explicitly set on instruction '%s'"
+  " but flag already inferred from pattern.\n", 
+  Inst.TheDef->getName().c_str());
+mayLoad = true;
+  }
+  
+  
   NeverHasSideEffects = Inst.neverHasSideEffects;
 
 #if 0


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r45815 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

2008-01-09 Thread Owen Anderson
Oh, and it did pass SPEC2000 and SPEC2006, so it can't be too wrong,  
can it?


--Owen

On Jan 9, 2008, at 10:44 PM, Owen Anderson wrote:

You really need to address these to Evan.  I asked him what to do  
for LiveIntervalAnalysis, and this is what he told me :-)


--Owen

On Jan 9, 2008, at 10:08 PM, Chris Lattner wrote:


URL: http://llvm.org/viewvc/llvm-project?rev=45815&view=rev
Log:
Don't use LiveVariables::VarInfo::DefInst.


Cool, question though:


+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Jan  9
21:12:54 2008
@@ -309,7 +309,14 @@
// are actually two values in the live interval.  Because of
this we
// need to take the LiveRegion that defines this register and
split it
// into two values.
-  unsigned DefIndex =
getDefIndex(getInstructionIndex(vi.DefInst));


In the old code, when it introduces multiple definitions of a vreg,
did it clear DefInst?  If so, this code can only be triggered for
vregs with a single def.



+  MachineRegisterInfo& MRI = mbb->getParent()->getRegInfo();


I think that MRI should become and ivar in liveintervalanalysis.



+  unsigned lowIndex = ~0U;
+  for (MachineRegisterInfo::def_iterator DI =
MRI.def_begin(interval.reg),
+  DE = MRI.def_end(); DI != DE; ++DI)
+if (getInstructionIndex(&*DI) < lowIndex)
+  lowIndex = getInstructionIndex(&*DI);
+
+  unsigned DefIndex = getDefIndex(lowIndex);


It would be really nice if you could drop the loop.  It's unclear why
it's right anyway, the numbering is not necessarily contiguous across
code...

-Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




smime.p7s
Description: S/MIME cryptographic signature
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45821 - in /llvm/trunk/lib/Target: ARM/ARMInstrInfo.td ARM/ARMInstrThumb.td ARM/ARMInstrVFP.td Alpha/AlphaInstrInfo.td PowerPC/PPCInstrInfo.td X86/X86InstrFPStack.td X86/X86Inst

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 23:12:37 2008
New Revision: 45821

URL: http://llvm.org/viewvc/llvm-project?rev=45821&view=rev
Log:
get def use info more correct.

Modified:
llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
llvm/trunk/lib/Target/ARM/ARMInstrThumb.td
llvm/trunk/lib/Target/ARM/ARMInstrVFP.td
llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td
llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td
llvm/trunk/lib/Target/X86/X86InstrFPStack.td
llvm/trunk/lib/Target/X86/X86InstrInfo.td

Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=45821&r1=45820&r2=45821&view=diff

==
--- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Jan  9 23:12:37 2008
@@ -809,7 +809,7 @@
[(set GPR:$dst, (load addrmode2:$addr))]>;
 
 // Special LDR for loads from non-pc-relative constpools.
-let isSimpleLoad = 1, isReMaterializable = 1 in
+let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1 in
 def LDRcp : AI2<0x0, (outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
  "ldr", " $dst, $addr", []>;
 
@@ -831,6 +831,7 @@
  "ldr", "sb $dst, $addr",
 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
 
+let mayLoad = 1 in {
 // Load doubleword
 def LDRD  : AI3<0xD, (outs GPR:$dst), (ins addrmode3:$addr), LdFrm,
  "ldr", "d $dst, $addr",
@@ -876,6 +877,7 @@
 def LDRSB_POST: AI3po<0xD, (outs GPR:$dst, GPR:$base_wb),
   (ins GPR:$base,am3offset:$offset), LdFrm,
   "ldr", "sb $dst, [$base], $offset", "$base = $base_wb", 
[]>;
+}
 
 // Store
 def STR  : AI2<0x0, (outs), (ins GPR:$src, addrmode2:$addr), StFrm,
@@ -939,6 +941,7 @@
 //
 
 // FIXME: $dst1 should be a def.
+let mayLoad = 1 in
 def LDM : AXI4<0x0, (outs),
(ins addrmode4:$addr, pred:$p, reglist:$dst1, variable_ops),
LdFrm, "ldm${p}${addr:submode} $addr, $dst1",

Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=45821&r1=45820&r2=45821&view=diff

==
--- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Wed Jan  9 23:12:37 2008
@@ -265,7 +265,7 @@
 
 // Special instruction for restore. It cannot clobber condition register
 // when it's expanded by eliminateCallFramePseudoInstr().
-let isSimpleLoad = 1 in
+let isSimpleLoad = 1, mayLoad = 1 in
 def tRestore : TIs<(outs GPR:$dst), (ins t_addrmode_sp:$addr),
 "ldr $dst, $addr", []>;
 
@@ -276,7 +276,7 @@
   [(set GPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>;
 
 // Special LDR for loads from non-pc-relative constpools.
-let isSimpleLoad = 1, isReMaterializable = 1 in
+let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1 in
 def tLDRcp  : TIs<(outs GPR:$dst), (ins i32imm:$addr),
   "ldr $dst, $addr", []>;
 
@@ -309,6 +309,7 @@
 
 // TODO: A7-44: LDMIA - load multiple
 
+let mayLoad = 1 in
 def tPOP : TI<(outs reglist:$dst1, variable_ops), (ins),
"pop $dst1", []>;
 

Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=45821&r1=45820&r2=45821&view=diff

==
--- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Wed Jan  9 23:12:37 2008
@@ -110,6 +110,7 @@
 //  Load / store multiple Instructions.
 //
 
+let mayLoad = 1 in {
 def FLDMD : AXDI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$dst1,
variable_ops),
   "fldm${addr:submode}d${p} ${addr:base}, $dst1",
@@ -119,6 +120,7 @@
variable_ops),
   "fldm${addr:submode}s${p} ${addr:base}, $dst1",
   []>;
+}
 
 let mayStore = 1 in {
 def FSTMD : AXDI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$src1,

Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td?rev=45821&r1=45820&r2=45821&view=diff

==
--- llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td (original)
+++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td Wed Jan  9 23:12:37 2008
@@ -24,7 +24,7 @@
 def Alpha_cvttq   : SDNode<"AlphaISD::CVTTQ_"  ,  SDTFPUnaryOp, []>;
 def Alpha_gprello : SDNode<"AlphaISD::GPRelLo",   SDTIntBinOp, []>;
 def Alpha_gprelhi : SDNode<"AlphaISD::GPRelHi",   SDTIntBinOp, []>;
-def Alpha_rellit  : SDNode<"AlphaISD::RelLit",SDTIntBinOp, []>;
+def Alpha_rellit  : SDNode<"Alph

Re: [llvm-commits] [llvm] r45815 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

2008-01-09 Thread Chris Lattner

On Jan 9, 2008, at 8:48 PM, Owen Anderson wrote:
Oh, and it did pass SPEC2000 and SPEC2006, so it can't be too wrong,  
can it?


Heh, ok, well I'm still concerned with it being overkill :)

-Chris___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45822 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.cpp CodeGenTarget.h InstrInfoEmitter.cpp InstrInfoEmitter.h

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 23:39:30 2008
New Revision: 45822

URL: http://llvm.org/viewvc/llvm-project?rev=45822&view=rev
Log:
start inferring 'no side effects'.

Modified:
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/trunk/utils/TableGen/CodeGenTarget.h
llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
llvm/trunk/utils/TableGen/InstrInfoEmitter.h

Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=45822&r1=45821&r2=45822&view=diff

==
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Wed Jan  9 23:39:30 2008
@@ -321,6 +321,8 @@
   Properties |= 1 << SDNPMayStore;
 } else if (PropList[i]->getName() == "SDNPMayLoad") {
   Properties |= 1 << SDNPMayLoad;
+} else if (PropList[i]->getName() == "SDNPSideEffect") {
+  Properties |= 1 << SDNPSideEffect;
 } else {
   cerr << "Unknown SD Node property '" << PropList[i]->getName()
<< "' on node '" << R->getName() << "'!\n";

Modified: llvm/trunk/utils/TableGen/CodeGenTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.h?rev=45822&r1=45821&r2=45822&view=diff

==
--- llvm/trunk/utils/TableGen/CodeGenTarget.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenTarget.h Wed Jan  9 23:39:30 2008
@@ -38,7 +38,8 @@
   SDNPInFlag,
   SDNPOptInFlag,
   SDNPMayLoad,
-  SDNPMayStore
+  SDNPMayStore,
+  SDNPSideEffect
 };
 
 /// getValueType - Return the MVT::ValueType that the specified TableGen record

Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=45822&r1=45821&r2=45822&view=diff

==
--- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Wed Jan  9 23:39:30 2008
@@ -145,20 +145,17 @@
   const CodeGenDAGPatterns &CDP;
   bool &mayStore;
   bool &mayLoad;
-  bool &NeverHasSideEffects;
+  bool &HasSideEffects;
 public:
   InstAnalyzer(const CodeGenDAGPatterns &cdp,
-   bool &maystore, bool &mayload, bool &nhse)
-: CDP(cdp), mayStore(maystore), mayLoad(mayload), 
NeverHasSideEffects(nhse){
+   bool &maystore, bool &mayload, bool &hse)
+: CDP(cdp), mayStore(maystore), mayLoad(mayload), HasSideEffects(hse){
   }
   
   void Analyze(Record *InstRecord) {
 const TreePattern *Pattern = CDP.getInstruction(InstRecord).getPattern();
 if (Pattern == 0) return;  // No pattern.
 
-// Assume there is no side-effect unless we see one.
-NeverHasSideEffects = true;
-
 // FIXME: Assume only the first tree is the pattern. The others are clobber
 // nodes.
 AnalyzeNode(Pattern->getTree(0));
@@ -169,73 +166,85 @@
 if (N->isLeaf())
   return;
 
-if (N->getOperator()->getName() != "set") {
-  // Get information about the SDNode for the operator.
-  const SDNodeInfo &OpInfo = CDP.getSDNodeInfo(N->getOperator());
-  
-  // If node writes to memory, it obviously stores to memory.
-  if (OpInfo.hasProperty(SDNPMayStore))
-mayStore = true;
-  
-  // If it reads memory, remember this.
-  if (OpInfo.hasProperty(SDNPMayLoad))
-mayLoad = true;
-  
-  if (const CodeGenIntrinsic *IntInfo = N->getIntrinsicInfo(CDP)) {
-// If this is an intrinsic, analyze it.
-if (IntInfo->ModRef >= CodeGenIntrinsic::WriteArgMem) {
-  mayStore = true;// Intrinsics that can write to memory are 
'mayStore'.
-}
-
-if (IntInfo->ModRef >= CodeGenIntrinsic::ReadArgMem)
-  mayLoad  = true;// These may also load memory.
-  }
-}
-
+// Analyze children.
 for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i)
   AnalyzeNode(N->getChild(i));
+
+// Ignore set nodes, which are not SDNodes.
+if (N->getOperator()->getName() == "set")
+  return;
+
+// Get information about the SDNode for the operator.
+const SDNodeInfo &OpInfo = CDP.getSDNodeInfo(N->getOperator());
+
+// If node writes to memory, it obviously stores to memory.
+if (OpInfo.hasProperty(SDNPMayStore))
+  mayStore = true;
+
+// If it reads memory, remember this.
+if (OpInfo.hasProperty(SDNPMayLoad))
+  mayLoad = true;
+
+// If it reads memory, remember this.
+if (OpInfo.hasProperty(SDNPSideEffect))
+  HasSideEffects = true;
+
+if (const CodeGenIntrinsic *IntInfo = N->getIntrinsicInfo(CDP)) {
+  // If this is an intrinsic, analyze it.
+  if (IntInfo->ModRef >= CodeGenIntrinsic::ReadArgMem)
+mayLoad = true;// These may load memory.

[llvm-commits] [llvm] r45823 - /llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 23:40:54 2008
New Revision: 45823

URL: http://llvm.org/viewvc/llvm-project?rev=45823&view=rev
Log:
if an instr lacks a pattern, assume it has side effects (unless never has s-e 
is true).

Modified:
llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp

Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=45823&r1=45822&r2=45823&view=diff

==
--- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Wed Jan  9 23:40:54 2008
@@ -154,7 +154,10 @@
   
   void Analyze(Record *InstRecord) {
 const TreePattern *Pattern = CDP.getInstruction(InstRecord).getPattern();
-if (Pattern == 0) return;  // No pattern.
+if (Pattern == 0) {
+  HasSideEffects = 1;
+  return;  // No pattern.
+}
 
 // FIXME: Assume only the first tree is the pattern. The others are clobber
 // nodes.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45824 - in /llvm/trunk/lib/Target: PowerPC/PPCInstrInfo.td X86/X86InstrFPStack.td X86/X86InstrInfo.td X86/X86InstrMMX.td X86/X86InstrSSE.td X86/X86InstrX86-64.td

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 23:45:39 2008
New Revision: 45824

URL: http://llvm.org/viewvc/llvm-project?rev=45824&view=rev
Log:
remove explicit sets of 'neverHasSideEffects' that can now be 
inferred from the instr patterns.

Modified:
llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td
llvm/trunk/lib/Target/X86/X86InstrFPStack.td
llvm/trunk/lib/Target/X86/X86InstrInfo.td
llvm/trunk/lib/Target/X86/X86InstrMMX.td
llvm/trunk/lib/Target/X86/X86InstrSSE.td
llvm/trunk/lib/Target/X86/X86InstrX86-64.td

Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td?rev=45824&r1=45823&r2=45824&view=diff

==
--- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td Wed Jan  9 23:45:39 2008
@@ -695,7 +695,7 @@
  "subfic $rD, $rA, $imm", IntGeneral,
  [(set GPRC:$rD, (subc immSExt16:$imm, GPRC:$rA))]>;
 
-let isReMaterializable = 1, neverHasSideEffects = 1 in {
+let isReMaterializable = 1 in {
   def LI  : DForm_2_r0<14, (outs GPRC:$rD), (ins symbolLo:$imm),
"li $rD, $imm", IntGeneral,
[(set GPRC:$rD, immSExt16:$imm)]>;

Modified: llvm/trunk/lib/Target/X86/X86InstrFPStack.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFPStack.td?rev=45824&r1=45823&r2=45824&view=diff

==
--- llvm/trunk/lib/Target/X86/X86InstrFPStack.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrFPStack.td Wed Jan  9 23:45:39 2008
@@ -466,7 +466,7 @@
 def XCH_F: FPI<0xC8, AddRegFrm, (outs), (ins RST:$op), "fxch\t$op">, D9;
 
 // Floating point constant loads.
-let isReMaterializable = 1, neverHasSideEffects = 1 in {
+let isReMaterializable = 1 in {
 def LD_Fp032 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP,
 [(set RFP32:$dst, fpimm0)]>;
 def LD_Fp132 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP,

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=45824&r1=45823&r2=45824&view=diff

==
--- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Wed Jan  9 23:45:39 2008
@@ -566,7 +566,7 @@
 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
 "mov{l}\t{$src, $dst|$dst, $src}", []>;
-let isReMaterializable = 1, neverHasSideEffects = 1 in {
+let isReMaterializable = 1 in {
 def MOV8ri  : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
"mov{b}\t{$src, $dst|$dst, $src}",
[(set GR8:$dst, imm:$src)]>;
@@ -2466,7 +2466,7 @@
 
 // Alias instructions that map movr0 to xor.
 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
-let Defs = [EFLAGS], isReMaterializable = 1, neverHasSideEffects = 1 in {
+let Defs = [EFLAGS], isReMaterializable = 1 in {
 def MOV8r0   : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
  "xor{b}\t$dst, $dst",
  [(set GR8:$dst, 0)]>;

Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=45824&r1=45823&r2=45824&view=diff

==
--- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Wed Jan  9 23:45:39 2008
@@ -487,7 +487,7 @@
 
//===--===//
 
 // Alias instructions that map zero vector to pxor.
-let isReMaterializable = 1, neverHasSideEffects = 1 in {
+let isReMaterializable = 1 in {
   def MMX_V_SET0   : MMXI<0xEF, MRMInitReg, (outs VR64:$dst), (ins),
   "pxor\t$dst, $dst",
   [(set VR64:$dst, (v2i32 immAllZerosV))]>;

Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=45824&r1=45823&r2=45824&view=diff

==
--- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Wed Jan  9 23:45:39 2008
@@ -445,7 +445,7 @@
 // start with 'Fs'.
 
 // Alias instructions that map fld0 to pxor for sse.
-let isReMaterializable = 1, neverHasSideEffects = 1 in
+let isReMaterializable = 1 in
 def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
  "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Requires<[HasSSE1]>, TB, OpSize;
@@ -940,7 +940,7 @@
 

[llvm-commits] [llvm] r45825 - /llvm/trunk/lib/Target/TargetSelectionDAG.td

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Wed Jan  9 23:48:23 2008
New Revision: 45825

URL: http://llvm.org/viewvc/llvm-project?rev=45825&view=rev
Log:
add SDNPSideEffect node property declaration

Modified:
llvm/trunk/lib/Target/TargetSelectionDAG.td

Modified: llvm/trunk/lib/Target/TargetSelectionDAG.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetSelectionDAG.td?rev=45825&r1=45824&r2=45825&view=diff

==
--- llvm/trunk/lib/Target/TargetSelectionDAG.td (original)
+++ llvm/trunk/lib/Target/TargetSelectionDAG.td Wed Jan  9 23:48:23 2008
@@ -191,6 +191,7 @@
 def SDNPOptInFlag   : SDNodeProperty;   // Optionally read a flag operand
 def SDNPMayStore: SDNodeProperty;   // May write to memory, sets 
'mayStore'.
 def SDNPMayLoad : SDNodeProperty;   // May read memory, sets 'mayLoad'.
+def SDNPSideEffect  : SDNodeProperty;   // Sets 'HasUnmodelledSideEffects'.
 
 
//===--===//
 // Selection DAG Node definitions.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc-4.2] r45804 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm.h objc/objc-act.c

2008-01-09 Thread Bill Wendling

On Jan 9, 2008, at 5:57 PM, Chris Lattner <[EMAIL PROTECTED]> wrote:

>
> On Jan 9, 2008, at 5:28 PM, Bill Wendling wrote:
>
>> Author: void
>> Date: Wed Jan  9 19:28:25 2008
>> New Revision: 45804
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=45804&view=rev
>> Log:
>> We're creating incorrect metadata. LLVM gives this for class
>> references:
>
> Hey Bill,
>
> Is it possible to avoid having the llvm-front-end called on the objc
> metadata before its fully formed?

It might be possible. I'm just not sure how much work it will take.  
The LLVM front end is called a lot during metadata creation. Though in  
the end it would probably be the best thing to do.

> Alternatively, perhaps the objc
> front-end should set the early version of the metadata as being an
> extern instead of definition?
>
I can try this and see if it has the same effect.

-bw

> -Chris
>
>>
>> L_OBJC_CLASS_REFERENCES_0:
>> .space 4
>> ..
>> L_OBJC_CLASS_NAME_0:
>> ...
>>
>> while GCC gives:
>>
>> L_OBJC_CLASS_REFERENCES_0:
>> .long L_OBJC_CLASS_NAME_0
>> ..
>> L_OBJC_CLASS_NAME_0:
>> ...
>>
>> which is correct. What's happening is that the reference is being
>> created and
>> LLVM is setting it's initializer to "null" because it's not pointing
>> to
>> something at that time. But then reference is modified to point to
>> some
>> object. However, LLVM wasn't updating its initializer information at
>> that point.
>>
>>
>> Modified:
>>   llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
>>   llvm-gcc-4.2/trunk/gcc/llvm.h
>>   llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
>>
>> Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=45804&r1=45803&r2=45804&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> === 
>> ===
>> --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
>> +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jan  9 19:28:25 2008
>> @@ -798,6 +798,17 @@
>>  }
>> }
>>
>> +/// reset_initializer_llvm - Change the initializer for a global
>> variable.
>> +void reset_initializer_llvm(tree decl) {
>> +  // Get or create the global variable now.
>> +  GlobalVariable *GV = cast(DECL_LLVM(decl));
>> +
>> +  // Convert the initializer over.
>> +  Constant *Init = TreeConstantToLLVM::Convert(DECL_INITIAL(decl));
>> +
>> +  // Set the initializer.
>> +  GV->setInitializer(Init);
>> +}
>>
>> /// emit_global_to_llvm - Emit the specified VAR_DECL or aggregate
>> CONST_DECL to
>> /// LLVM as a global variable.  This function implements the end of
>>
>> Modified: llvm-gcc-4.2/trunk/gcc/llvm.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm.h?rev=45804&r1=45803&r2=45804&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> === 
>> ===
>> --- llvm-gcc-4.2/trunk/gcc/llvm.h (original)
>> +++ llvm-gcc-4.2/trunk/gcc/llvm.h Wed Jan  9 19:28:25 2008
>> @@ -44,12 +44,15 @@
>> /* make_decl_llvm - This is also defined in tree.h and used by
>> macros there. */
>> void make_decl_llvm(union tree_node*);
>>
>> +/* reset_initializer_llvm - Change the initializer for a global
>> variable. */
>> +void reset_initializer_llvm(union tree_node*);
>> +
>> /* emit_global_to_llvm - Emit the specified VAR_DECL to LLVM as a
>> global
>> * variable.
>> */
>> void emit_global_to_llvm(union tree_node*);
>>
>> -/* emit_global_to_llvm - Emit the specified alias to LLVM
>> +/* emit_alias_to_llvm - Emit the specified alias to LLVM
>> */
>> void emit_alias_to_llvm(union tree_node*, union tree_node*, union
>> tree_node*);
>>
>>
>> Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=45804&r1=45803&r2=45804&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> === 
>> ===
>> --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original)
>> +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Wed Jan  9 19:28:25 2008
>> @@ -76,6 +76,9 @@
>> #include "langhooks-def.h"
>> /* APPLE LOCAL optimization pragmas 3124235/3420242 */
>> #include "opts.h"
>> +#ifdef ENABLE_LLVM
>> +#include "llvm.h"   /* for reset_initializer_llvm */
>> +#endif
>>
>> #define OBJC_VOID_AT_ENDvoid_list_node
>>
>> @@ -5541,6 +5544,13 @@
>>{
>>  decl = TREE_PURPOSE (chain);
>>  finish_var_decl (decl, expr);
>> +  /* APPLE LOCAL LLVM begin - radar 5676233 */
>> +#ifdef ENABLE_LLVM
>> +  /* Reset the initializer for this reference as it most
>> likely
>> + changed.  */
>> +  reset_initializer_llvm(decl);
>> +#endif
>> +  /* APPLE LOCAL LLVM end - radar 5676233 */
>>}
>>  else
>>{
>> @@ -18172,8 +18182,16 @@
>>  for (chain = cls_ref_chain; chain; chain = TREE_CHAIN (chain))
>>{
>>  handle_class_ref (chain);
>> -  if (TREE_PURPOSE (chain))
>> +  /* APP

[llvm-commits] [llvm] r45827 - /llvm/trunk/utils/TableGen/TGParser.cpp

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Thu Jan 10 01:01:53 2008
New Revision: 45827

URL: http://llvm.org/viewvc/llvm-project?rev=45827&view=rev
Log:
Fix a crash on code like: let x = 1 {x



Modified:
llvm/trunk/utils/TableGen/TGParser.cpp

Modified: llvm/trunk/utils/TableGen/TGParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=45827&r1=45826&r2=45827&view=diff

==
--- llvm/trunk/utils/TableGen/TGParser.cpp (original)
+++ llvm/trunk/utils/TableGen/TGParser.cpp Thu Jan 10 01:01:53 2008
@@ -290,7 +290,10 @@
 ///   RangePiece ::= INTVAL '-' INTVAL
 ///   RangePiece ::= INTVAL INTVAL
 bool TGParser::ParseRangePiece(std::vector &Ranges) {
-  assert(Lex.getCode() == tgtok::IntVal && "Invalid range");
+  if (Lex.getCode() != tgtok::IntVal) {
+TokError("expected integer or bitrange");
+return true;
+  }
   int Start = Lex.getCurIntVal();
   int End;
   


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45828 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

2008-01-09 Thread Evan Cheng
Author: evancheng
Date: Thu Jan 10 01:19:43 2008
New Revision: 45828

URL: http://llvm.org/viewvc/llvm-project?rev=45828&view=rev
Log:
Clearify the meaning of immutable StackObject.

Modified:
llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=45828&r1=45827&r2=45828&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Thu Jan 10 01:19:43 2008
@@ -86,9 +86,9 @@
 // the function.  This field has no meaning for a variable sized element.
 int64_t SPOffset;
 
-// isImmutable - If true, the value of the stack object does not change
-// in this function. By default, fixed objects are immutable unless marked
-// otherwise.
+// isImmutable - If true, the value of the stack object is set before
+// entering the function and is not modified inside the function. By
+// default, fixed objects are immutable unless marked otherwise.
 bool isImmutable;
 
 StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM = false)


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r45815 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

2008-01-09 Thread Evan Cheng

On Jan 9, 2008, at 8:44 PM, Owen Anderson wrote:

> You really need to address these to Evan.  I asked him what to do  
> for LiveIntervalAnalysis, and this is what he told me :-)
>
> --Owen
>
> On Jan 9, 2008, at 10:08 PM, Chris Lattner wrote:
>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=45815&view=rev
>>> Log:
>>> Don't use LiveVariables::VarInfo::DefInst.
>>
>> Cool, question though:
>>
>>> +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Jan  9
>>> 21:12:54 2008
>>> @@ -309,7 +309,14 @@
>>>  // are actually two values in the live interval.  Because of
>>> this we
>>>  // need to take the LiveRegion that defines this register and
>>> split it
>>>  // into two values.
>>> -  unsigned DefIndex =
>>> getDefIndex(getInstructionIndex(vi.DefInst));
>>
>> In the old code, when it introduces multiple definitions of a vreg,
>> did it clear DefInst?  If so, this code can only be triggered for
>> vregs with a single def.

It does change DefInst. This code is triggered when a two-address  
instruction redefines a vreg so it can only be triggered for vregs  
with multiple def's.
>>
>>>
>>> +  MachineRegisterInfo& MRI = mbb->getParent()->getRegInfo();
>>
>> I think that MRI should become and ivar in liveintervalanalysis.

Yes, there is an ivar mri_.

>>
>>>
>>> +  unsigned lowIndex = ~0U;
>>> +  for (MachineRegisterInfo::def_iterator DI =
>>> MRI.def_begin(interval.reg),
>>> +  DE = MRI.def_end(); DI != DE; ++DI)
>>> +if (getInstructionIndex(&*DI) < lowIndex)
>>> +  lowIndex = getInstructionIndex(&*DI);
>>> +
>>> +  unsigned DefIndex = getDefIndex(lowIndex);
>>
>> It would be really nice if you could drop the loop.  It's unclear why
>> it's right anyway, the numbering is not necessarily contiguous across
>> code...

Yes, I think it' can probably be simplified. But it's probably  
correct. This is before coalescing:
v1024 = v1025
v1024 = v1024 op ?

So there must be two def's of v1024 in the same BB and we want the  
first one.

Evan

>>
>> -Chris
>>
>> ___
>> llvm-commits mailing list
>> llvm-commits@cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r45829 - in /llvm/trunk: lib/Target/Target.td lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrFPStack.td lib/Target/X86/X86InstrInfo.td lib/Target/X86/X86InstrMMX.td lib/T

2008-01-09 Thread Chris Lattner
Author: lattner
Date: Thu Jan 10 01:59:24 2008
New Revision: 45829

URL: http://llvm.org/viewvc/llvm-project?rev=45829&view=rev
Log:
Start inferring side effect information more aggressively, and fix many bugs in 
the
x86 backend where instructions were not marked maystore/mayload, and perf 
issues where
instructions were not marked neverHasSideEffects.  It would be really nice if 
we could
write patterns for copy instructions.

I have audited all the x86 instructions down to MOVDQAmr.  The flags on others 
and on
other targets are probably not right in all cases, but no clients currently use 
this
info that are enabled by default.

Modified:
llvm/trunk/lib/Target/Target.td
llvm/trunk/lib/Target/X86/X86Instr64bit.td
llvm/trunk/lib/Target/X86/X86InstrFPStack.td
llvm/trunk/lib/Target/X86/X86InstrInfo.td
llvm/trunk/lib/Target/X86/X86InstrMMX.td
llvm/trunk/lib/Target/X86/X86InstrSSE.td
llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
llvm/trunk/utils/TableGen/CodeGenInstruction.h
llvm/trunk/utils/TableGen/CodeGenTarget.cpp
llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp

Modified: llvm/trunk/lib/Target/Target.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Target.td?rev=45829&r1=45828&r2=45829&view=diff

==
--- llvm/trunk/lib/Target/Target.td (original)
+++ llvm/trunk/lib/Target/Target.td Thu Jan 10 01:59:24 2008
@@ -204,19 +204,20 @@
   bit hasCtrlDep   = 0; // Does this instruction r/w ctrl-flow chains?
   bit isNotDuplicable = 0;  // Is it unsafe to duplicate this instruction?
 
-  // Side effect flags - If neither of these flags is set, then the instruction
-  // *always* has side effects. When set, the flags have these meanings:
+  // Side effect flags - When set, the flags have these meanings:
   //
-  //  neverHasSideEffects - The instruction has no side effects that are not
-  //captured by any operands of the instruction or other flags, and when
-  //*all* instances of the instruction of that opcode have no side effects.
+  //  hasSideEffects - The instruction has side effects that are not
+  //captured by any operands of the instruction or other flags.
   //  mayHaveSideEffects  - Some instances of the instruction can have side
   //effects. The virtual method "isReallySideEffectFree" is called to
   //determine this. Load instructions are an example of where this is
   //useful. In general, loads always have side effects. However, loads from
   //constant pools don't. Individual back ends make this determination.
-  bit neverHasSideEffects = 0;
+  //  neverHasSideEffects - Set on an instruction with no pattern if it has no
+  //side effects.
+  bit hasSideEffects = 0;
   bit mayHaveSideEffects = 0;
+  bit neverHasSideEffects = 0;
   
   InstrItinClass Itinerary = NoItinerary;// Execution steps used for 
scheduling.
 
@@ -343,12 +344,14 @@
   let InOperandList = (ops variable_ops);
   let AsmString = "";
   let Namespace = "TargetInstrInfo";
+  let neverHasSideEffects = 1;
 }
 def INSERT_SUBREG : Instruction {
 let OutOperandList = (ops variable_ops);
   let InOperandList = (ops variable_ops);
   let AsmString = "";
   let Namespace = "TargetInstrInfo";
+  let neverHasSideEffects = 1;
 }
 
 
//===--===//

Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=45829&r1=45828&r2=45829&view=diff

==
--- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original)
+++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Thu Jan 10 01:59:24 2008
@@ -131,19 +131,21 @@
 
//===--===//
 //  Miscellaneous Instructions...
 //
-let Defs = [RBP,RSP], Uses = [RBP,RSP] in
+let Defs = [RBP,RSP], Uses = [RBP,RSP], mayLoad = 1, neverHasSideEffects = 1 in
 def LEAVE64  : I<0xC9, RawFrm,
  (outs), (ins), "leave", []>;
-let Defs = [RSP], Uses = [RSP] in {
+let Defs = [RSP], Uses = [RSP], neverHasSideEffects=1 in {
+let mayLoad = 1 in
 def POP64r   : I<0x58, AddRegFrm,
  (outs GR64:$reg), (ins), "pop{q}\t$reg", []>;
+let mayStore = 1 in
 def PUSH64r  : I<0x50, AddRegFrm,
  (outs), (ins GR64:$reg), "push{q}\t$reg", []>;
 }
 
-let Defs = [RSP, EFLAGS], Uses = [RSP] in
+let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in
 def POPFQ: I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W;
-let Defs = [RSP], Uses = [RSP, EFLAGS] in
+let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1 in
 def PUSHFQ   : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
 
 def LEA64_32r : I<0x8D, MRMSrcMem,
@@ -160,12 +162,16 @@
   "bswap{q}\t$dst", 
   [(set GR64:$dst, (bswap GR64:$src))]>, TB;
 // Exchange
+let neve