From lattner at cs.uiuc.edu Mon Oct 6 10:03:04 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 10:03:04 2003
Subject: [llvm-commits] CVS: llvm/include/Support/Timer.h
Message-ID: <200310061502.KAA26667@apoc.cs.uiuc.edu>
Changes in directory llvm/include/Support:
Timer.h updated: 1.9 -> 1.10
---
Log message:
Doxygenize class comments. Add new NamedRegionTimer class
---
Diffs of the changes:
Index: llvm/include/Support/Timer.h
diff -u llvm/include/Support/Timer.h:1.9 llvm/include/Support/Timer.h:1.10
--- llvm/include/Support/Timer.h:1.9 Fri Jul 25 12:23:27 2003
+++ llvm/include/Support/Timer.h Mon Oct 6 10:02:16 2003
@@ -1,24 +1,7 @@
//===-- Support/Timer.h - Interval Timing Support ---------------*- C++ -*-===//
//
-// This file defines three classes: Timer, TimeRegion, and TimerGroup.
-//
-// The Timer class is used to track the amount of time spent between invocations
-// of it's startTimer()/stopTimer() methods. Given appropriate OS support it
-// can also keep track of the RSS of the program at various points. By default,
-// the Timer will print the amount of time it has captured to standard error
-// when the laster timer is destroyed, otherwise it is printed when it's
-// TimerGroup is destroyed. Timer's do not print their information if they are
-// never started.
-//
-// The TimeRegion class is used as a helper class to call the startTimer() and
-// stopTimer() methods of the Timer class. When the object is constructed, it
-// starts the timer specified as it's argument. When it is destroyed, it stops
-// the relevant timer. This makes it easy to time a region of code.
-//
-// The TimerGroup class is used to group together related timers into a single
-// report that is printed when the TimerGroup is destroyed. It is illegal to
-// destroy a TimerGroup object before all of the Timers in it are gone. A
-// TimerGroup can be specified for a newly created timer in its constructor.
+// This file defines three classes: Timer, TimeRegion, and TimerGroup,
+// documented below.
//
//===----------------------------------------------------------------------===//
@@ -32,6 +15,14 @@
class TimerGroup;
+/// Timer - This class is used to track the amount of time spent between
+/// invocations of it's startTimer()/stopTimer() methods. Given appropriate OS
+/// support it can also keep track of the RSS of the program at various points.
+/// By default, the Timer will print the amount of time it has captured to
+/// standard error when the laster timer is destroyed, otherwise it is printed
+/// when it's TimerGroup is destroyed. Timer's do not print their information
+/// if they are never started.
+///
class Timer {
double Elapsed; // Wall clock time elapsed in seconds
double UserTime; // User time elapsed
@@ -52,7 +43,7 @@
double getWallTime() const { return Elapsed; }
long getMemUsed() const { return MemUsed; }
long getPeakMem() const { return PeakMem; }
- std::string getName() const { return Name; }
+ std::string getName() const { return Name; }
const Timer &operator=(const Timer &T) {
Elapsed = T.Elapsed;
@@ -106,6 +97,11 @@
};
+/// The TimeRegion class is used as a helper class to call the startTimer() and
+/// stopTimer() methods of the Timer class. When the object is constructed, it
+/// starts the timer specified as it's argument. When it is destroyed, it stops
+/// the relevant timer. This makes it easy to time a region of code.
+///
class TimeRegion {
Timer &T;
TimeRegion(const TimeRegion &); // DO NOT IMPLEMENT
@@ -118,6 +114,22 @@
}
};
+
+/// NamedRegionTimer - This class is basically a combination of TimeRegion and
+/// Timer. It allows you to declare a new timer, AND specify the region to
+/// time, all in one statement. All timers with the same name are merged. This
+/// is primarily used for debugging and for hunting performance problems.
+///
+struct NamedRegionTimer : public TimeRegion {
+ NamedRegionTimer(const std::string &Name);
+};
+
+
+/// The TimerGroup class is used to group together related timers into a single
+/// report that is printed when the TimerGroup is destroyed. It is illegal to
+/// destroy a TimerGroup object before all of the Timers in it are gone. A
+/// TimerGroup can be specified for a newly created timer in its constructor.
+///
class TimerGroup {
std::string Name;
unsigned NumTimers;
From lattner at cs.uiuc.edu Mon Oct 6 10:03:09 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 10:03:09 2003
Subject: [llvm-commits] CVS: llvm/lib/Support/Timer.cpp
Message-ID: <200310061502.KAA26676@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Support:
Timer.cpp updated: 1.24 -> 1.25
---
Log message:
Implement the NamedRegionTimer class
---
Diffs of the changes:
Index: llvm/lib/Support/Timer.cpp
diff -u llvm/lib/Support/Timer.cpp:1.24 llvm/lib/Support/Timer.cpp:1.25
--- llvm/lib/Support/Timer.cpp:1.24 Fri Aug 1 17:15:15 2003
+++ llvm/lib/Support/Timer.cpp Mon Oct 6 10:02:31 2003
@@ -16,6 +16,7 @@
#include
+ +
+ +
+
+
+
+ to a simple interpreter, lli also has a tracing mode (entered by + specifying -trace on the command line). Finally, for + architectures that support it (currently only x86 and Sparc), by default, + lli will function as a Just-In-Time compiler (if the + functionality was compiled in), and will execute the code much + faster than the interpreter.
-
+ performs a variety of optimizations, and outputs LLVM bytecode. Thus + when you invoke llvmgcc -c x.c -o x.o, you are causing + gccas to be run, which writes the x.o file (which is + an LLVM bytecode file that can be disassembled or manipulated just like + any other bytecode file). The command line interface to gccas + is designed to be as close as possible to the system + `as' utility so that the gcc frontend itself did not have to be + modified to interface to a "weird" assembler.
- - -
- -This document intentionally does not prescribe fixed standards for religious issues such as brace placement and space usage. For issues like this, follow the golden rule: +This document attempts to describe a few coding standards that are being used in +the LLVM source tree. Although no coding standards should be regarded as +absolute requirements to be followed in all instances, coding standards can be +useful.
+
+This document intentionally does not prescribe fixed standards for religious
+issues such as brace placement and space usage. For issues like this, follow
+the golden rule:
-If you are adding a significant body of source to a project, feel free to use whatever style you are most comfortable with. If you are extending, enhancing, or bug fixing already implemented code, use the style that is already being used so that the source is uniform and easy to follow.
-
-The ultimate goal of these guidelines is the increase readability and maintainability of our common source base. If you have suggestions for topics to be included, please mail them to Chris.
+
If you are adding a significant body of source to a project, feel +free to use whatever style you are most comfortable with. If you are extending, +enhancing, or bug fixing already implemented code, use the style that is already +being used so that the source is uniform and easy to follow.+ +The ultimate goal of these guidelines is the increase readability and +maintainability of our common source base. If you have suggestions for topics to +be included, please mail them to Chris.
@@ -78,11 +88,17 @@
+Comments are one critical part of readability and maintainability. Everyone +knows they should comment, so should you. :) Although we all should probably +comment our code more than we do, there are a few very critical places that +documentation is very useful:
+Every source file should have a header on it that describes the basic purpose of +the file. If a file does not have a header, it should not be checked into CVS. +Most source trees will probably have a standard file header format. The +standard format for the LLVM source tree looks like this:
//===-- llvm/Instruction.h - Instruction class definition --------*- C++ -*--=// @@ -93,36 +109,59 @@ //===----------------------------------------------------------------------===//-A few things to note about this particular format. The "-*- C++ -*-" string on the first line is there to tell Emacs that the source file is a C++ file, not a C file (Emacs assumes .h files are C files by default [Note that tag this is not necessary in .cpp files]). The name of the file is also on the first line, along with a very short description of the purpose of the file. This is important when printing out code and flipping though lots of pages.
- -The main body of the description does not have to be very long in most cases. Here it's only two lines. If an algorithm is being implemented or something tricky is going on, a reference to the paper where it is published should be included, as well as any notes or "gotchas" in the code to watch out for.
+A few things to note about this particular format. The "-*- C++ -*-" +string on the first line is there to tell Emacs that the source file is a C++ +file, not a C file (Emacs assumes .h files are C files by default [Note that tag +this is not necessary in .cpp files]). The name of the file is also on the +first line, along with a very short description of the purpose of the file. +This is important when printing out code and flipping though lots of pages.
+ +The main body of the description does not have to be very long in most cases. +Here it's only two lines. If an algorithm is being implemented or something +tricky is going on, a reference to the paper where it is published should be +included, as well as any notes or "gotchas" in the code to watch out for.
+Classes are one fundemental part of a good object oriented design. As such, a +class definition should have a comment block that explains what the class is +used for... if it's not obvious. If it's so completely obvious your grandma +could figure it out, it's probably safe to leave it out. Naming classes +something sane goes a long ways towards avoiding writing documentation. :)
+Methods defined in a class (as well as any global functions) should also be +documented properly. A quick note about what it does any a description of the +borderline behaviour is all that is necessary here (unless something +particularly tricky or insideous is going on). The hope is that people can +figure out how to use your interfaces without reading the code itself... that is +the goal metric.
-Good things to talk about here are what happens when something unexpected happens: does the method return null? Abort? Format your hard disk?
+Good things to talk about here are what happens when something unexpected +happens: does the method return null? Abort? Format your hard disk?
+In general, prefer C++ style (//) comments. They take less space, +require less typing, don't have nesting problems, etc. There are a few cases +when it is useful to use C style (/* */) comments however:
-To comment out a large block of code, use #if 0 and #endif. These nest properly and are better behaved in general than C style comments.
+To comment out a large block of code, use #if 0 and #endif. +These nest properly and are better behaved in general than C style comments.
- -As always, follow the Golden Rule above: follow the style of existing code if your are modifying and extending it. If you like four spaces of indentation, DO NOT do that in the middle of a chunk of code with two spaces of indentation. Also, do not reindent a whole source file: it make for incredible diffs that are absolutely worthless.
+In all cases, prefer spaces to tabs in source files. People have different +prefered indentation levels, and different styles of indentation that they +like... this is fine. What isn't is that different editors/viewers expand tabs +out to different tab stops. This can cause your code to look completely +unreadable, and it is not worth dealing with.
+ +As always, follow the Golden Rule above: follow the +style of existing code if your are modifying and extending it. If you like four +spaces of indentation, DO NOT do that in the middle of a chunk of code +with two spaces of indentation. Also, do not reindent a whole source file: it +makes for incredible diffs that are absolutely worthless.
+Okay, your first year of programming you were told that indentation is +important. If you didn't believe and internalize this then, now is the time. +Just do it.
@@ -189,9 +238,17 @@
- -It is not possible to prevent all warnings from all compilers, nor is it desirable. Instead, pick a standard compiler (like gcc) that provides a good thorough set of warnings, and stick to them. At least in the case of gcc, it is possible to work around any spurious errors by changing the syntax of the code slightly. For example, an warning that annoys me occurs when I write code like this:
+If your code has compiler warnings in it, something is wrong: you aren't casting +values correctly, your have "questionable" constructs in your code, or you are +doing something legitimately wrong. Compiler warnings can cover up legitimate +errors in output and make dealing with a translation unit difficult.
+ +It is not possible to prevent all warnings from all compilers, nor is it +desirable. Instead, pick a standard compiler (like gcc) that provides +a good thorough set of warnings, and stick to them. At least in the case of +gcc, it is possible to work around any spurious errors by changing the +syntax of the code slightly. For example, an warning that annoys me occurs when +I write code like this:
if (V = getValue()) {
@@ -199,7 +256,10 @@
}
-gcc will warn me that I probably want to use the == operator, and that I probably mistyped it. In most cases, I haven't, and I really don't want the spurious errors. To fix this particular problem, I rewrite the code like this:
+gcc will warn me that I probably want to use the == operator, +and that I probably mistyped it. In most cases, I haven't, and I really don't +want the spurious errors. To fix this particular problem, I rewrite the code +like this:
if ((V = getValue())) {
@@ -429,7 +489,9 @@
Writing Iterators
-Here's a pretty good summary of how to write your own data structure iterators in a way that is compatible with the STL, and with a lot of other code out there (slightly edited by Chris):
+Here's a pretty good summary of how to write your own data structure iterators
+in a way that is compatible with the STL, and with a lot of other code out there
+(slightly edited by Chris):
From: Ross Smith
@@ -750,14 +812,16 @@
-A lot of these comments and recommendations have been culled for other sources. Two particularly important books for our work are:
+A lot of these comments and recommendations have been culled for other sources.
+Two particularly important books for our work are:
- Effective C++ by Scott Meyers. There is an online version of the book (only some chapters though) available as well.
- Large-Scale C++ Software Design by John Lakos
-If you get some free time, and you haven't read them: do so, you might learn something. :)
+If you get some free time, and you haven't read them: do so, you might learn
+something. :)
From gaeke at cs.uiuc.edu Mon Oct 6 15:51:01 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Mon Oct 6 15:51:01 2003
Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/SLI.cpp
Message-ID: <200310062050.PAA18752@trinity.cs.uiuc.edu>
Changes in directory reopt/lib/LightWtProfiling:
SLI.cpp updated: 1.7 -> 1.8
---
Log message:
Move #defines of BRANCH_ALWAYS and CALL to reopt/InstrUtils.h.
Stdify more names. No more `using namespace std'.
Untabify.
Erase more commented-out code.
Fix more asserts.
Shorten.
---
Diffs of the changes:
Index: reopt/lib/LightWtProfiling/SLI.cpp
diff -u reopt/lib/LightWtProfiling/SLI.cpp:1.7 reopt/lib/LightWtProfiling/SLI.cpp:1.8
--- reopt/lib/LightWtProfiling/SLI.cpp:1.7 Mon Oct 6 12:56:52 2003
+++ reopt/lib/LightWtProfiling/SLI.cpp Mon Oct 6 15:50:01 2003
@@ -12,23 +12,19 @@
#include
#include
-using namespace std;
-
extern "C" void llvm_time_end();
extern void countPath();
extern "C" void llvm_first_trigger();
extern void initModules ();
-enum Color{
+enum Color {
WHITE,
GREY,
BLACK
};
-#define BRANCH_ALWAYS 0x10800000
-#define CALL 0x40000000
-
-void doInlining(uint64_t addr1, vector &stack, VirtualMem *vm);
+void doInlining(uint64_t addr1, std::vector &stack,
+ VirtualMem *vm);
void doBackEdgeDFS(BasicBlock *node,
std::map &backedges,
@@ -38,7 +34,7 @@
if (color[*si] == GREY) {
//backedge node->*si
assert(backedges.find(node) == backedges.end() &&
- "Multiple backedges starting at same basic block");
+ "Multiple backedges starting at same basic block");
backedges[node] = *si;
} else if (color[*si] != BLACK) {
assert(color[*si] == WHITE);
@@ -48,65 +44,59 @@
color[node] = BLACK;
}
-void getBackEdges(map &backedges, Function *F){
+void getBackEdges (std::map &backedges, Function *F){
BasicBlock &root = F->front();
- map color;
+ std::map color;
doBackEdgeDFS(&root, backedges, color);
}
void doForwardDFS(BasicBlock *node,BasicBlock *end,
- std::map &backEdges,
- std::map &forward,
- std::map &color){
+ std::map &backEdges,
+ std::map &forward,
+ std::map &color){
color[node] = GREY;
forward[node] = 1;
- if(node != end){
- for(succ_iterator s=succ_begin(node), se=succ_end(node); s!=se; ++s){
- //if node -> *s is a backedge, neglect
- if(backEdges[node] == *s)
- continue;
- if(color[*s] == WHITE) {
- doForwardDFS(*s, end, backEdges, forward, color);
- }
- }
- }
+ if (node != end)
+ for (succ_iterator s=succ_begin(node), se=succ_end(node); s!=se; ++s) {
+ //if node -> *s is a backedge, neglect
+ if(backEdges[node] == *s)
+ continue;
+ if(color[*s] == WHITE)
+ doForwardDFS(*s, end, backEdges, forward, color);
+ }
color[node] = BLACK;
}
void getForward(BasicBlock *root, BasicBlock *end,
- std::map &backEdges,
- std::map &forward){
+ std::map &backEdges,
+ std::map &forward){
//do DFS, avoid backedges, don't go beyond end
std::map color;
doForwardDFS(root, end, backEdges, forward, color);
}
void doBackwardDFS(BasicBlock *node, BasicBlock *start,
- std::map &backEdges,
- std::map &forward,
- std::map &backward,
- std::map &color){
+ std::map &backEdges,
+ std::map &forward,
+ std::map &backward,
+ std::map &color){
color[node] = GREY;
backward[node] = 1;
- if(node != start){
- for(pred_iterator p=pred_begin(node), pe=pred_end(node); p!=pe; ++p){
- if(forward[*p]){
- if(backEdges[*p] == node){
- continue;
- }
- if(color[*p] == WHITE) {
- doBackwardDFS(*p, start, backEdges, forward, backward, color);
- }
+ if(node != start)
+ for(pred_iterator p=pred_begin(node), pe=pred_end(node); p!=pe; ++p)
+ if(forward[*p]) {
+ if(backEdges[*p] == node)
+ continue;
+ if(color[*p] == WHITE)
+ doBackwardDFS(*p, start, backEdges, forward, backward, color);
}
- }
- }
color[node] = BLACK;
}
void getBackward(BasicBlock *node, BasicBlock *start,
- std::map &backEdges,
- std::map &forward,
- std::map &backward){
+ std::map &backEdges,
+ std::map &forward,
+ std::map &backward){
//do DFS, avoid backedges, consider only forward edges
std::map color;
doBackwardDFS(node, start, backEdges, forward, backward, color);
@@ -114,27 +104,24 @@
}
void getExit(std::map &backward,
- std::map &exitBBs){
+ std::map &exitBBs){
std::vector toPush;
for(std::map::iterator MI = backward.begin(),
- ME = backward.end(); MI != ME; ++MI){
- for(succ_iterator s=succ_begin(MI->first),
- se=succ_end(MI->first); s != se; ++s){
- if(backward.find(*s) == backward.end()){
- exitBBs[*s] = 1;
- toPush.push_back(*s);
+ ME = backward.end(); MI != ME; ++MI)
+ for (succ_iterator s=succ_begin(MI->first),
+ se=succ_end(MI->first); s != se; ++s)
+ if(backward.find(*s) == backward.end()) {
+ exitBBs[*s] = 1;
+ toPush.push_back(*s);
}
- }
- }
for(std::vector::iterator VI = toPush.begin(),
- VE = toPush.end(); VI != VE; ++VI){
+ VE = toPush.end(); VI != VE; ++VI)
backward[*VI] = 1;
- }
}
void doTraceDFS(BasicBlock *node, std::vector &trace,
- std::map &backward,
- std::map &color){
+ std::map &backward,
+ std::map &color){
color[node] = GREY;
trace.push_back(node);
for(succ_iterator s=succ_begin(node), se=succ_end(node); s != se; ++s)
@@ -145,14 +132,14 @@
}
void getTrace(BasicBlock *root, std::vector &trace,
- std::map &backward){
+ std::map &backward){
//do a DFS from root ONLY on nodes in backward
std::map color;
doTraceDFS(root, trace, backward, color);
}
-void doTraceDFSForFunction(BasicBlock *node, vector &trace,
- map &color){
+void doTraceDFSForFunction(BasicBlock *node, std::vector &trace,
+ std::map &color){
color[node] = GREY;
trace.push_back(node);
for(succ_iterator s=succ_begin(node), se=succ_end(node); s != se; ++s)
@@ -214,7 +201,7 @@
//end node
assert(backEdges.find(end) != backEdges.end() &&
- "No backedge with end found");
+ "No backedge with end found");
//get forward edges
std::map forward;
@@ -266,7 +253,6 @@
trace.push_back(exit_code[0]);
trace.push_back(exit_code[1]);
trace.push_back(call_code[3]);
- //trace.push_back(exit_code[2]);
trace.push_back(BRANCH_ALWAYS);
trace.push_back(NOP);
branchMap[index + 4] = bbStart;
@@ -281,123 +267,123 @@
BasicBlock *taken=NULL, *ntaken=NULL;
TerminatorInst *TI = (*VBI)->getTerminator();
if(isa(TI)){
- BranchInst *BI = cast(TI);
- if(BI->isConditional()){
- isCondBranch = true;
- taken = BI->getSuccessor(0);
- ntaken = BI->getSuccessor(1);
- succ0 = getBasicBlockInfo(taken).first;
- succ1 = getBasicBlockInfo(ntaken).first;
- }
+ BranchInst *BI = cast(TI);
+ if(BI->isConditional()){
+ isCondBranch = true;
+ taken = BI->getSuccessor(0);
+ ntaken = BI->getSuccessor(1);
+ succ0 = getBasicBlockInfo(taken).first;
+ succ1 = getBasicBlockInfo(ntaken).first;
+ }
}
for(uint64_t addr = bbStart; addr <= bbEnd; addr+=4){//loop on BB
- unsigned instr = vm->readInstrFrmVm(addr, tr, tr2);
- if(isIndirectCall(instr)){
- trace.push_back(call_code[0]);
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace.push_back(call_code[1]);
- index += 4;
- addr += 4;
- } else if(isCallInstr(instr)){
- uint64_t callTarget = getCallTarget(instr, addr);
- if(callTarget != (uint64_t)(intptr_t)&llvm_first_trigger){
- if(isInlinable(getRevFunction(M, callTarget))){
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- callMap[index] = getCallTarget(instr, addr);
- toInline[callTarget] = 1;
- index += 2;
- addr += 4;
- } else{
- trace.push_back(call_code[0]);
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace.push_back(call_code[1]);
- callMap[index+1] = getCallTarget(instr, addr);
- index += 4;
- addr += 4;
- }
- } else{
- trace.push_back(call_code[2]); //save o7
- trace.push_back(loop_top_code[0]);
- trace.push_back(loop_top_code[1]);
- trace.push_back(call_code[3]); //restore o7
- callMap[index+1] = (uint64_t)(intptr_t)&countPath;
- index += 4;
- }
- } else if(isBranchInstr(instr)){//is branch
- assert(!isBranchNever(instr) && "Branch never not handled!");
- if(isBranchAlways(instr)){
- uint64_t target = getBranchTarget(instr, addr);
- if(target == addr1){
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace[index] = getBranchInst(instr,
- (uint64_t)(intptr_t)&trace[0],
- (uint64_t)(intptr_t)&trace[index]);
- index += 2;
- } else{
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- BasicBlock *targetBB=NULL;
- assert(getReverseBBMap(getBranchTarget(instr, addr), M, targetBB));
- branchStub[index] = targetBB;
- index += 2;
- }
- addr += 4;
- } else{
+ unsigned instr = vm->readInstrFrmVm(addr, tr, tr2);
+ if(isIndirectCall(instr)){
+ trace.push_back(call_code[0]);
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ trace.push_back(call_code[1]);
+ index += 4;
+ addr += 4;
+ } else if(isCallInstr(instr)){
+ uint64_t callTarget = getCallTarget(instr, addr);
+ if(callTarget != (uint64_t)(intptr_t)&llvm_first_trigger){
+ if(isInlinable(getRevFunction(M, callTarget))){
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ callMap[index] = getCallTarget(instr, addr);
+ toInline[callTarget] = 1;
+ index += 2;
+ addr += 4;
+ } else{
+ trace.push_back(call_code[0]);
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ trace.push_back(call_code[1]);
+ callMap[index+1] = getCallTarget(instr, addr);
+ index += 4;
+ addr += 4;
+ }
+ } else{
+ trace.push_back(call_code[2]); //save o7
+ trace.push_back(loop_top_code[0]);
+ trace.push_back(loop_top_code[1]);
+ trace.push_back(call_code[3]); //restore o7
+ callMap[index+1] = (uint64_t)(intptr_t)&countPath;
+ index += 4;
+ }
+ } else if(isBranchInstr(instr)){//is branch
+ assert(!isBranchNever(instr) && "Branch never not handled!");
+ if(isBranchAlways(instr)){
+ uint64_t target = getBranchTarget(instr, addr);
+ if(target == addr1){
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ trace[index] = getBranchInst(instr,
+ (uint64_t)(intptr_t)&trace[0],
+ (uint64_t)(intptr_t)&trace[index]);
+ index += 2;
+ } else{
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ BasicBlock *targetBB=NULL;
+ assert(getReverseBBMap(getBranchTarget(instr, addr), M, targetBB));
+ branchStub[index] = targetBB;
+ index += 2;
+ }
+ addr += 4;
+ } else{
assert (isCondBranch);
- uint64_t target = getBranchTarget(instr, addr);
- if (target == succ0) {
- isSucc0 = true;
- fillLater = index;
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace.push_back(succ1_code[0]);
- trace.push_back(succ1_code[1]);
- index += 4;
- addr += 4;
- } else {
- fillLater = index;
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace.push_back(succ0_code[0]);
- trace.push_back(succ0_code[1]);
- index += 4;
- addr += 4;
- }
- }
- } else{
- trace.push_back(instr);
- index++;
- }
+ uint64_t target = getBranchTarget(instr, addr);
+ if (target == succ0) {
+ isSucc0 = true;
+ fillLater = index;
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ trace.push_back(succ1_code[0]);
+ trace.push_back(succ1_code[1]);
+ index += 4;
+ addr += 4;
+ } else {
+ fillLater = index;
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ trace.push_back(succ0_code[0]);
+ trace.push_back(succ0_code[1]);
+ index += 4;
+ addr += 4;
+ }
+ }
+ } else{
+ trace.push_back(instr);
+ index++;
+ }
}
if(isCondBranch){
- trace.push_back(0);//dummy
- unsigned int newBranch =
+ trace.push_back(0);//dummy
+ unsigned int newBranch =
getBranchInst(trace[fillLater], (uint64_t)(intptr_t)&trace[index],
(uint64_t)(intptr_t)&trace[fillLater]);
- trace[fillLater] = newBranch;
- if(isSucc0){
- assert((taken != vBB[0]) && "Conditional branch to top!");
- trace[index] = succ0_code[0];
- trace.push_back(succ0_code[1]);
- trace.push_back(BRANCH_ALWAYS);
- trace.push_back(NOP);
- branchStub[index+2] = taken;
- index += 4;
- } else{
- assert((ntaken != vBB[0]) && "Conditional branch to top!");
- trace[index] = succ1_code[0];
- trace.push_back(succ1_code[1]);
- trace.push_back(BRANCH_ALWAYS);
- trace.push_back(NOP);
- branchStub[index+2] = ntaken;
- index += 4;
- }
+ trace[fillLater] = newBranch;
+ if(isSucc0){
+ assert((taken != vBB[0]) && "Conditional branch to top!");
+ trace[index] = succ0_code[0];
+ trace.push_back(succ0_code[1]);
+ trace.push_back(BRANCH_ALWAYS);
+ trace.push_back(NOP);
+ branchStub[index+2] = taken;
+ index += 4;
+ } else{
+ assert((ntaken != vBB[0]) && "Conditional branch to top!");
+ trace[index] = succ1_code[0];
+ trace.push_back(succ1_code[1]);
+ trace.push_back(BRANCH_ALWAYS);
+ trace.push_back(NOP);
+ branchStub[index+2] = ntaken;
+ index += 4;
+ }
}
}
}
@@ -411,24 +397,22 @@
}
- if(!tr->addTrace(addr1, endAddr, trace, 0, callMap, branchMap, tr2)){
- std::cerr<<"Could not add!\n";
- }
+ if(!tr->addTrace(addr1, endAddr, trace, 0, callMap, branchMap, tr2))
+ std::cerr << "Could not add!\n";
DEBUG(std::cerr << "Added-SLI-trace\t" << (void *)addr1 << "\t"
- << (void *)endAddr << "\t" << trace.size() << "\n");
+ << (void *)endAddr << "\t" << trace.size() << "\n");
- for(std::map::iterator MI = toInline.begin(),
- ME = toInline.end(); MI != ME; ++MI) {
- if(!tr->hasTraceAddr(MI->first)){
- vector stack;
+ for (std::map::iterator MI = toInline.begin(),
+ ME = toInline.end(); MI != ME; ++MI)
+ if (!tr->hasTraceAddr(MI->first)) {
+ std::vector stack;
stack.push_back(root->getParent());
doInlining(MI->first, stack, vm);
}
- }
}
-void doInlining(uint64_t addr1, vector &stack, VirtualMem *vm){
+void doInlining(uint64_t addr1, std::vector &stack, VirtualMem *vm){
// Make sure we have already parsed the LLVM bytecode and have the
// resulting LLVM Module handy.
if (!M)
@@ -440,16 +424,10 @@
//get BB address
BasicBlock *root = &F->front();
- //BasicBlock *end = &F->back();
- //std::cerr<(end->getTerminator()) && "Not the terminal BB");
-
//get a vector of trace
- vector vBB;
- map color;
+ std::vector vBB;
+ std::map color;
doTraceDFSForFunction(root, vBB, color);
unsigned int initial_code[] = {0x83663001};//0x82102001//move 1 to g1
@@ -462,18 +440,18 @@
//spill o0, g7->o0, call, unspill o0 0x90104000
unsigned int exit_code[] = {CALL, NOP};//call llvm_time_end
- map callMap;
- map branchMap;
- map bbPlacement;
- map branchStub;
- map toInline;
+ std::map callMap;
+ std::map branchMap;
+ std::map bbPlacement;
+ std::map branchStub;
+ std::map toInline;
int index = 0;
- vector trace;
+ std::vector trace;
//generate a vector of instructions
//assume: succ[0] is 0, succ[1] is 1
- for(vector::iterator VBI = vBB.begin(), VBE = vBB.end();
+ for(std::vector::iterator VBI = vBB.begin(), VBE = vBB.end();
VBI != VBE; ++VBI){//loop on vBB
std::pair bbInst = getBasicBlockInfo(*VBI);
@@ -492,165 +470,126 @@
if(isa(TI)){
BranchInst *BI = cast(TI);
if(BI->isConditional()){
- isCondBranch = true;
- taken = BI->getSuccessor(0);
- ntaken = BI->getSuccessor(1);
- succ0 = getBasicBlockInfo(taken).first;
- succ1 = getBasicBlockInfo(ntaken).first;
+ isCondBranch = true;
+ taken = BI->getSuccessor(0);
+ ntaken = BI->getSuccessor(1);
+ succ0 = getBasicBlockInfo(taken).first;
+ succ1 = getBasicBlockInfo(ntaken).first;
}
}
-
for(uint64_t addr = bbStart; addr <= bbEnd; addr+=4){//loop on BB
unsigned instr = vm->readInstrFrmVm(addr, tr, tr2);
-
- if(isIndirectCall(instr)){
- trace.push_back(call_code[0]);
+ if (isIndirectCall(instr)) {
+ trace.push_back(call_code[0]);
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ trace.push_back(call_code[1]);
+ index += 4;
+ addr += 4;
+ } else if (isCallInstr(instr)) {
+ uint64_t callTarget = getCallTarget(instr, addr);
+ if(callTarget != (uint64_t)(intptr_t)&llvm_first_trigger){
+ if(isInlinable(getRevFunction(M, callTarget)) &&
+ find(stack.begin(), stack.end(),
+ getRevFunction(M, callTarget)) == stack.end()){
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ callMap[index] = getCallTarget(instr, addr);
+ toInline[callTarget] = 1;
+ index += 2;
+ addr += 4;
+ } else {
+ trace.push_back(call_code[0]);
+ trace.push_back(instr);
+ trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
+ trace.push_back(call_code[1]);
+ callMap[index+1] = getCallTarget(instr, addr);
+ index += 4;
+ addr += 4;
+ }
+ } else {
+ trace.push_back(call_code[2]); //save o7
+ trace.push_back(loop_top_code[0]);
+ trace.push_back(loop_top_code[1]);
+ trace.push_back(call_code[3]); //restore o7
+ callMap[index+1] = (uint64_t)(intptr_t)&countPath;
+ index += 4;
+ }
+ } else if(isBranchInstr(instr)){//is branch
+ assert ((isBranchAlways (instr) || isCondBranch)
+ && "Unhandled type of branch instruction");
+ uint64_t target = getBranchTarget(instr, addr);
trace.push_back(instr);
- //trace.push_back(NOP);
trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace.push_back(call_code[1]);
- index += 4;
+ if (isBranchAlways(instr)) {
+ BasicBlock *targetBB = NULL;
+ assert(getReverseBBMap(getBranchTarget(instr, addr), M, targetBB));
+ branchStub[index] = targetBB;
+ index += 2;
+ } else if (isCondBranch) {
+ fillLater = index;
+ if (target == succ0) {
+ isSucc0 = true;
+ trace.push_back(succ1_code[0]);
+ trace.push_back(succ1_code[1]);
+ } else{
+ trace.push_back(succ0_code[0]);
+ trace.push_back(succ0_code[1]);
+ }
+ index += 4;
+ }
addr += 4;
- }
- else if(isCallInstr(instr)){
- uint64_t callTarget = getCallTarget(instr, addr);
- if(callTarget != (uint64_t)(intptr_t)&llvm_first_trigger){
- if(isInlinable(getRevFunction(M, callTarget)) &&
- find(stack.begin(), stack.end(),
- getRevFunction(M, callTarget)) == stack.end()){
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- callMap[index] = getCallTarget(instr, addr);
- toInline[callTarget] = 1;
- index += 2;
- addr += 4;
- }
- else{
- trace.push_back(call_code[0]);
- trace.push_back(instr);
- //trace.push_back(NOP);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace.push_back(call_code[1]);
- callMap[index+1] = getCallTarget(instr, addr);
- index += 4;
- addr += 4;
- }
- }
- else{
- trace.push_back(call_code[2]); //save o7
- trace.push_back(loop_top_code[0]);
- trace.push_back(loop_top_code[1]);
- trace.push_back(call_code[3]); //restore o7
- callMap[index+1] = (uint64_t)(intptr_t)&countPath;
- index += 4;
- }
- }
- else if(isBranchInstr(instr)){//is branch
- assert(!isBranchNever(instr) && "Branch never not handled!");
- if(isBranchAlways(instr)){
- uint64_t target = getBranchTarget(instr, addr);
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
-
- BasicBlock *targetBB=NULL;
- assert(getReverseBBMap(getBranchTarget(instr, addr), M, targetBB));
- branchStub[index] = targetBB;
- index += 2;
- addr += 4;
- }
- else{
- if(isCondBranch){
- uint64_t target = getBranchTarget(instr, addr);
- if(target == succ0){
- isSucc0 = true;
- fillLater = index;
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace.push_back(succ1_code[0]);
- trace.push_back(succ1_code[1]);
- index += 4;
- addr += 4;
- }
- else{
- fillLater = index;
- trace.push_back(instr);
- trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2));
- trace.push_back(succ0_code[0]);
- trace.push_back(succ0_code[1]);
- index += 4;
- addr += 4;
- }
- }
- else{
- assert(false && "Should not be here!");
- }
- }
- }
- else{
- trace.push_back(instr);
- index++;
+ } else {
+ trace.push_back(instr);
+ index++;
}
}
- if(isCondBranch){
+ if (isCondBranch) {
trace.push_back(0);//dummy
-
- unsigned int newBranch = getBranchInst(trace[fillLater],
- (uint64_t)(intptr_t)&trace[index],
- (uint64_t)(intptr_t)&trace[fillLater]);
-
+ unsigned int newBranch =
+ getBranchInst(trace[fillLater],
+ (uint64_t)(intptr_t)&trace[index],
+ (uint64_t)(intptr_t)&trace[fillLater]);
trace[fillLater] = newBranch;
-
- if(isSucc0){
- trace[index] = succ0_code[0];
- trace.push_back(succ0_code[1]);
- trace.push_back(BRANCH_ALWAYS);
- trace.push_back(NOP);
-
- if(taken == vBB[0]){
- assert(false && "Conditional branch to top!");
- }
- branchStub[index+2] = taken;
- index += 4;
- }
- else{
- trace[index] = succ1_code[0];
- trace.push_back(succ1_code[1]);
- trace.push_back(BRANCH_ALWAYS);
- if(ntaken == vBB[0]){
- assert(false && "Conditional branch to top!");
- }
- branchStub[index+2] = ntaken;
- trace.push_back(NOP);
- index += 4;
+ if (isSucc0) {
+ assert ((taken != vBB[0]) && "Conditional branch to top!");
+ trace[index] = succ0_code[0];
+ trace.push_back(succ0_code[1]);
+ branchStub[index+2] = taken;
+ } else {
+ assert ((ntaken != vBB[0]) && "Conditional branch to top!");
+ trace[index] = succ1_code[0];
+ trace.push_back(succ1_code[1]);
+ branchStub[index+2] = ntaken;
}
+ trace.push_back(BRANCH_ALWAYS);
+ trace.push_back(NOP);
+ index += 4;
}
-
}
- for(map::iterator MI = branchStub.begin(),
- ME = branchStub.end(); MI != ME; ++MI){
- trace[MI->first] = getBranchInst(trace[MI->first],
- (uint64_t)(intptr_t)&trace[bbPlacement[MI->second]],
- (uint64_t)(intptr_t)&trace[MI->first]);
+ for (std::map::iterator MI = branchStub.begin(),
+ ME = branchStub.end(); MI != ME; ++MI) {
+ trace[MI->first] =
+ getBranchInst(trace[MI->first],
+ (uint64_t)(intptr_t)&trace[bbPlacement[MI->second]],
+ (uint64_t)(intptr_t)&trace[MI->first]);
}
uint64_t fakeEnd = 0;
- if(F->size() > 1){
- if(!tr->addTrace(addr1, fakeEnd, trace, 0, callMap, branchMap, tr2)){
- std::cerr<<"Could not add!\n";
- }
- }
+ if (F->size() > 1)
+ if (!tr->addTrace(addr1, fakeEnd, trace, 0, callMap, branchMap, tr2))
+ std::cerr << "Could not add!\n";
DEBUG(std::cerr << "Added-SLI-inline\t" << (void *)addr1 << "\t" <<
- trace.size() << "\n");
+ trace.size() << "\n");
- for(map::iterator MI = toInline.begin(), ME = toInline.end();
- MI != ME; ++MI){
- if(!tr->hasTraceAddr(MI->first)){
+ for (std::map::iterator MI = toInline.begin(),
+ ME = toInline.end(); MI != ME; ++MI)
+ if (!tr->hasTraceAddr(MI->first)) {
stack.push_back(root->getParent());
doInlining(MI->first, stack, vm);
}
- }
}
From lattner at cs.uiuc.edu Mon Oct 6 15:53:03 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 15:53:03 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/Makefile
Message-ID: <200310062052.PAA26010@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/External/SPEC/CINT2000:
Makefile updated: 1.5 -> 1.6
---
Log message:
Add the three remaining spec tests, though they don't work, they shouldn't stop the nightly tester
---
Diffs of the changes:
Index: llvm/test/Programs/External/SPEC/CINT2000/Makefile
diff -u llvm/test/Programs/External/SPEC/CINT2000/Makefile:1.5 llvm/test/Programs/External/SPEC/CINT2000/Makefile:1.6
--- llvm/test/Programs/External/SPEC/CINT2000/Makefile:1.5 Sat Sep 20 10:17:14 2003
+++ llvm/test/Programs/External/SPEC/CINT2000/Makefile Mon Oct 6 15:51:56 2003
@@ -2,9 +2,12 @@
PARALLEL_DIRS := \
164.gzip \
175.vpr \
+ 176.gcc \
181.mcf \
186.crafty \
197.parser \
+ 252.eon \
+ 253.perlbmk \
254.gap \
255.vortex \
256.bzip2 \
From gaeke at cs.uiuc.edu Mon Oct 6 15:56:01 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Mon Oct 6 15:56:01 2003
Subject: [llvm-commits] CVS: CVSROOT/commit-diffs.pl
Message-ID: <200310062055.PAA18788@trinity.cs.uiuc.edu>
Changes in directory CVSROOT:
commit-diffs.pl updated: 1.43 -> 1.44
---
Log message:
Put the number of pluses and minuses in the e-mail message. Heh heh heh.
---
Diffs of the changes:
Index: CVSROOT/commit-diffs.pl
diff -u CVSROOT/commit-diffs.pl:1.43 CVSROOT/commit-diffs.pl:1.44
--- CVSROOT/commit-diffs.pl:1.43 Fri Aug 1 16:17:10 2003
+++ CVSROOT/commit-diffs.pl Mon Oct 6 15:55:11 2003
@@ -121,7 +121,10 @@
}
}
$msg .= "\n---\nLog message:\n\n" . join('', at logmessage);
-$msg .= "\n---\nDiffs of the changes:\n\n" . $diffs;
+foreach my $line (split /\n/, $diffs) {
+ $pluses++ if /^\+/; $minuses++ if /^\-/;
+}
+$msg .= "\n---\nDiffs of the changes: (+$pluses -$minuses)\n\n" . $diffs;
open TEMP, ">$TEMPFILE";
print TEMP $msg;
From gaeke at cs.uiuc.edu Mon Oct 6 15:57:01 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Mon Oct 6 15:57:01 2003
Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/SLI.cpp
Message-ID: <200310062056.PAA18804@trinity.cs.uiuc.edu>
Changes in directory reopt/lib/LightWtProfiling:
SLI.cpp updated: 1.8 -> 1.9
---
Log message:
file header comment.
---
Diffs of the changes: (+ -)
Index: reopt/lib/LightWtProfiling/SLI.cpp
diff -u reopt/lib/LightWtProfiling/SLI.cpp:1.8 reopt/lib/LightWtProfiling/SLI.cpp:1.9
--- reopt/lib/LightWtProfiling/SLI.cpp:1.8 Mon Oct 6 15:50:01 2003
+++ reopt/lib/LightWtProfiling/SLI.cpp Mon Oct 6 15:56:06 2003
@@ -1,3 +1,8 @@
+//===- SLI.cpp - Perform second-level instrumentation ------------*- C++-*---=//
+//
+//
+//===----------------------------------------------------------------------===//
+
#include "GetTimer.h"
#include "Globals.h"
#include "Support/DataTypes.h"
@@ -25,7 +30,6 @@
void doInlining(uint64_t addr1, std::vector &stack,
VirtualMem *vm);
-
void doBackEdgeDFS(BasicBlock *node,
std::map &backedges,
std::map &color) {
From gaeke at cs.uiuc.edu Mon Oct 6 15:58:03 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Mon Oct 6 15:58:03 2003
Subject: [llvm-commits] CVS: CVSROOT/commit-diffs.pl
Message-ID: <200310062057.PAA18818@trinity.cs.uiuc.edu>
Changes in directory CVSROOT:
commit-diffs.pl updated: 1.44 -> 1.45
---
Log message:
initialize variable.
---
Diffs of the changes: (+ -)
Index: CVSROOT/commit-diffs.pl
diff -u CVSROOT/commit-diffs.pl:1.44 CVSROOT/commit-diffs.pl:1.45
--- CVSROOT/commit-diffs.pl:1.44 Mon Oct 6 15:55:11 2003
+++ CVSROOT/commit-diffs.pl Mon Oct 6 15:57:01 2003
@@ -121,6 +121,8 @@
}
}
$msg .= "\n---\nLog message:\n\n" . join('', at logmessage);
+my $pluses = 0;
+my $minuses = 0;
foreach my $line (split /\n/, $diffs) {
$pluses++ if /^\+/; $minuses++ if /^\-/;
}
From lattner at cs.uiuc.edu Mon Oct 6 19:50:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 19:50:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/
Message-ID: <200310070049.TAA26877@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
---
Log message:
Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++ added to the repository
---
Diffs of the changes: (+0 -0)
From lattner at cs.uiuc.edu Mon Oct 6 19:51:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 19:51:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp
Message-ID: <200310070050.TAA26907@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
ary2.cpp added (r1.1)
---
Log message:
Initial checkin of ary2 test
---
Diffs of the changes: (+0 -0)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp:1.1
*** /dev/null Mon Oct 6 19:50:22 2003
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp Mon Oct 6 19:50:12 2003
***************
*** 0 ****
--- 1,43 ----
+ // -*- mode: c++ -*-
+ // $Id: ary2.cpp,v 1.1 2003/10/07 00:50:12 lattner Exp $
+ // http://www.bagley.org/~doug/shootout/
+
+ #include
+ #include
+
+ int
+ main(int argc, char *argv[]) {
+ int i, n = ((argc == 2) ? atoi(argv[1]) : 1);
+ typedef vector ARY;
+ ARY x(n);
+ ARY y(n);
+
+ for (i=0; i= 0;) {
+ y[i] = x[i]; --i;
+ y[i] = x[i]; --i;
+ y[i] = x[i]; --i;
+ y[i] = x[i]; --i;
+ y[i] = x[i]; --i;
+
+ y[i] = x[i]; --i;
+ y[i] = x[i]; --i;
+ y[i] = x[i]; --i;
+ y[i] = x[i]; --i;
+ y[i] = x[i]; --i;
+ }
+
+ cout << y.back() << endl;
+ }
From lattner at cs.uiuc.edu Mon Oct 6 19:52:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 19:52:00 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp
Message-ID: <200310070051.TAA26936@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
ary.cpp added (r1.1)
---
Log message:
Initial checkin of ary test
---
Diffs of the changes: (+0 -0)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp:1.1
*** /dev/null Mon Oct 6 19:51:10 2003
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp Mon Oct 6 19:51:00 2003
***************
*** 0 ****
--- 1,23 ----
+ // -*- mode: c++ -*-
+ // $Id: ary.cpp,v 1.1 2003/10/07 00:51:00 lattner Exp $
+ // http://www.bagley.org/~doug/shootout/
+
+ #include
+ #include
+
+ int
+ main(int argc, char *argv[]) {
+ int i, n = ((argc == 2) ? atoi(argv[1]) : 1);
+ typedef vector ARY;
+ ARY x(n);
+ ARY y(n);
+
+ for (i=0; i= 0; --i) {
+ y[i] = x[i];
+ }
+
+ cout << y.back() << endl;
+ }
From lattner at cs.uiuc.edu Mon Oct 6 19:53:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 19:53:00 2003
Subject: [llvm-commits] CVS: CVSROOT/commit-diffs.pl
Message-ID: <200310070052.TAA26976@apoc.cs.uiuc.edu>
Changes in directory CVSROOT:
commit-diffs.pl updated: 1.45 -> 1.46
---
Log message:
Actually search the line in question. Avoid spamming me with lots of uninitialized value problems
---
Diffs of the changes: (+0 -0)
Index: CVSROOT/commit-diffs.pl
diff -u CVSROOT/commit-diffs.pl:1.45 CVSROOT/commit-diffs.pl:1.46
--- CVSROOT/commit-diffs.pl:1.45 Mon Oct 6 15:57:01 2003
+++ CVSROOT/commit-diffs.pl Mon Oct 6 19:52:39 2003
@@ -124,7 +124,7 @@
my $pluses = 0;
my $minuses = 0;
foreach my $line (split /\n/, $diffs) {
- $pluses++ if /^\+/; $minuses++ if /^\-/;
+ $pluses++ if /^\+/ $line; $minuses++ if /^\-/ $line;
}
$msg .= "\n---\nDiffs of the changes: (+$pluses -$minuses)\n\n" . $diffs;
From lattner at cs.uiuc.edu Mon Oct 6 19:58:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 19:58:00 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ackermann.cpp
Message-ID: <200310070057.TAA27106@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
ackermann.cpp added (r1.1)
---
Log message:
new testcase
---
Diffs of the changes: (+17 -2)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ackermann.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ackermann.cpp:1.1
*** /dev/null Mon Oct 6 19:57:18 2003
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ackermann.cpp Mon Oct 6 19:57:08 2003
***************
*** 0 ****
--- 1,17 ----
+ // -*- mode: c++ -*-
+ // $Id: ackermann.cpp,v 1.1 2003/10/07 00:57:08 lattner Exp $
+ // http://www.bagley.org/~doug/shootout/
+
+ #include
+ #include
+
+ using namespace std;
+
+ int Ack(int M, int N) { return(M ? (Ack(M-1,N ? Ack(M,(N-1)) : 1)) : N+1); }
+
+ int main(int argc, char *argv[]) {
+ int n = ((argc == 2) ? atoi(argv[1]) : 1);
+
+ cout << "Ack(3," << n << "): " << Ack(3, n) << endl;
+ return(0);
+ }
From lattner at cs.uiuc.edu Mon Oct 6 20:01:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 20:01:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp
Message-ID: <200310070100.UAA27184@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
lists1.cpp added (r1.1)
---
Log message:
new testcase
---
Diffs of the changes: (+72 -2)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp:1.1
*** /dev/null Mon Oct 6 20:00:55 2003
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp Mon Oct 6 20:00:44 2003
***************
*** 0 ****
--- 1,72 ----
+ // -*- mode: c++ -*-
+ // $Id: lists1.cpp,v 1.1 2003/10/07 01:00:44 lattner Exp $
+ // http://www.bagley.org/~doug/shootout/
+
+ #include
+ #include
+ #include
+
+ using namespace std;
+
+ void list_print_n (list L, int n) {
+ int c, lastc = n - 1;
+ list::iterator i;
+ for (c = 0, i = L.begin(); i != L.end(), c < n; ++i, ++c) {
+ cout << (*i);
+ if (c < lastc) cout << " ";
+ }
+ cout << endl;
+ }
+
+ int main(int argc, char* argv[]) {
+ int N = (argc == 2 ? (atoi(argv[1]) < 1 ? 1 : atoi(argv[1])): 1);
+ list::iterator i;
+
+ // create empty list B
+ list B;
+
+ // create list (A) of integers from 1 through N
+ list A(N);
+ iota(A.begin(), A.end(), 1);
+
+ // move each individual item from A to B, in a loop, reversing order
+ while (! A.empty()) {
+ B.push_front(A.front());
+ A.pop_front();
+ }
+
+ // print first 2 elements of B
+ list_print_n(B, 2);
+
+ // reverse B (can be done in place)
+ B.reverse();
+ // reverse(B.begin(), B.end());
+
+ // is 0 a member of B?
+ cout << ((find(B.begin(), B.end(), 0) == B.end()) ? "false" : "true") << endl;
+
+ // is N a member of B?
+ cout << ((find(B.begin(), B.end(), N) == B.end()) ? "false" : "true") << endl;
+
+ // filter values from B to A that are less than N/2, preserving order
+ int mid = N/2;
+ for (i = B.begin(); i != B.end(); ++i) {
+ if ((*i) < mid) A.push_back(*i);
+ }
+
+ // print first ten items of A
+ list_print_n(A, 10);
+
+ // print sum of items in A that are less than 1000
+ int sum = 0;
+ for (i = A.begin(); i != A.end(); ++i) {
+ if ((*i) < 1000) sum += (*i);
+ }
+ cout << sum << endl;
+
+ // append B to end of A
+ A.splice(A.end(), B);
+
+ // print length and last element of A
+ cout << A.size() << " " << A.back() << endl;
+ }
From lattner at cs.uiuc.edu Mon Oct 6 20:03:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 20:03:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp
Message-ID: <200310070102.UAA27224@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
lists.cpp added (r1.1)
---
Log message:
new testcase
---
Diffs of the changes: (+50 -2)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp:1.1
*** /dev/null Mon Oct 6 20:02:45 2003
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp Mon Oct 6 20:02:35 2003
***************
*** 0 ****
--- 1,50 ----
+ // -*- mode: c++ -*-
+ // $Id: lists.cpp,v 1.1 2003/10/07 01:02:35 lattner Exp $
+ // http://www.bagley.org/~doug/shootout/
+ // from Bill Lear
+
+ #include
+ #include
+ #include
+
+ using namespace std;
+
+ const size_t SIZE = 10000;
+
+ size_t test_lists() {
+ std::list li1(SIZE);
+
+ std::iota(li1.begin(), li1.end(), 1);
+
+ std::list li2(li1);
+
+ std::list li3;
+
+ size_t N = li2.size();
+ while (N--) {
+ li3.push_back(li2.front());
+ li2.pop_front();
+ }
+
+ N = li3.size();
+ while (N--) {
+ li2.push_back(li3.back());
+ li3.pop_back();
+ }
+
+ li1.reverse();
+
+ return (li1.front() == SIZE) && (li1 == li2) ? li1.size() : 0;
+ }
+
+ int main(int argc, char* argv[]) {
+ size_t ITER = (argc == 2 ? (atoi(argv[1]) < 1 ? 1 : atoi(argv[1])): 1);
+
+ size_t result = 0;
+ while (ITER > 0) {
+ result = test_lists();
+ --ITER;
+ }
+
+ std::cout << result << std::endl;
+ }
From lattner at cs.uiuc.edu Mon Oct 6 20:04:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 20:04:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp lists1.cpp
Message-ID: <200310070103.UAA27277@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
lists.cpp updated: 1.1 -> 1.2
lists1.cpp updated: 1.1 -> 1.2
---
Log message:
iota is a historical oddity from the SGI STL, it is not part of the standard
---
Diffs of the changes: (+21 -5)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp
diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp:1.1 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp:1.2
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp:1.1 Mon Oct 6 20:02:35 2003
+++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp Mon Oct 6 20:03:17 2003
@@ -1,5 +1,5 @@
// -*- mode: c++ -*-
-// $Id: lists.cpp,v 1.1 2003/10/07 01:02:35 lattner Exp $
+// $Id: lists.cpp,v 1.2 2003/10/07 01:03:17 lattner Exp $
// http://www.bagley.org/~doug/shootout/
// from Bill Lear
@@ -11,10 +11,18 @@
const size_t SIZE = 10000;
+template
+void
+iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
+{
+ while (__first != __last)
+ *__first++ = __value++;
+}
+
size_t test_lists() {
std::list li1(SIZE);
- std::iota(li1.begin(), li1.end(), 1);
+ iota(li1.begin(), li1.end(), 1);
std::list li2(li1);
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp
diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp:1.1 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp:1.2
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp:1.1 Mon Oct 6 20:00:44 2003
+++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp Mon Oct 6 20:03:17 2003
@@ -1,10 +1,18 @@
// -*- mode: c++ -*-
-// $Id: lists1.cpp,v 1.1 2003/10/07 01:00:44 lattner Exp $
+// $Id: lists1.cpp,v 1.2 2003/10/07 01:03:17 lattner Exp $
// http://www.bagley.org/~doug/shootout/
#include
#include
#include
+
+template
+void
+iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
+{
+ while (__first != __last)
+ *__first++ = __value++;
+}
using namespace std;
From lattner at cs.uiuc.edu Mon Oct 6 20:07:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 20:07:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp
Message-ID: <200310070106.UAA27379@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
reversefile.cpp added (r1.1)
---
Log message:
new testcase
---
Diffs of the changes: (+25 -2)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp:1.1
*** /dev/null Mon Oct 6 20:06:06 2003
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp Mon Oct 6 20:05:56 2003
***************
*** 0 ****
--- 1,25 ----
+ // -*- mode: c++ -*-
+ // $Id: reversefile.cpp,v 1.1 2003/10/07 01:05:56 lattner Exp $
+ // http://www.bagley.org/~doug/shootout/
+ // with help from Allan Stokes
+
+ #include
+ #include
+ #include
+ #include
+
+ using namespace std;
+
+ int main() {
+ typedef deque LINES;
+ LINES l;
+ char line[256];
+ char buff[4096];
+ cin.rdbuf()->pubsetbuf(buff, 4096); // enable buffering
+ cout.rdbuf()->pubsetbuf(buff, 4096); // enable buffering
+
+ while (cin.getline(line, 256)) {
+ l.push_front(line);
+ }
+ copy (l.begin(), l.end(), ostream_iterator(cout,"\n"));
+ }
From lattner at cs.uiuc.edu Mon Oct 6 20:07:03 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 20:07:03 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp
Message-ID: <200310070106.UAA27410@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
reversefile.cpp updated: 1.1 -> 1.2
---
Log message:
Add needed #include
---
Diffs of the changes: (+3 -2)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp
diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp:1.1 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp:1.2
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp:1.1 Mon Oct 6 20:05:56 2003
+++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/reversefile.cpp Mon Oct 6 20:06:17 2003
@@ -1,5 +1,5 @@
// -*- mode: c++ -*-
-// $Id: reversefile.cpp,v 1.1 2003/10/07 01:05:56 lattner Exp $
+// $Id: reversefile.cpp,v 1.2 2003/10/07 01:06:17 lattner Exp $
// http://www.bagley.org/~doug/shootout/
// with help from Allan Stokes
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
using namespace std;
From lattner at cs.uiuc.edu Mon Oct 6 20:08:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 20:08:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/spellcheck.cpp
Message-ID: <200310070107.UAA27425@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
spellcheck.cpp added (r1.1)
---
Log message:
new benchmark
---
Diffs of the changes: (+75 -2)
Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/spellcheck.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/spellcheck.cpp:1.1
*** /dev/null Mon Oct 6 20:07:00 2003
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/spellcheck.cpp Mon Oct 6 20:06:50 2003
***************
*** 0 ****
--- 1,75 ----
+ // -*- mode: c++ -*-
+ // $Id: spellcheck.cpp,v 1.1 2003/10/07 01:06:50 lattner Exp $
+ // http://www.bagley.org/~doug/shootout/
+ // STL spell checker from Bill Lear
+
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ using namespace std;
+
+ typedef std::pair span;
+
+ namespace std {
+ template <> struct hash;
+ template <> struct equal_to;
+ }
+
+ template<> struct hash {
+ inline size_t operator()(const span& s) const {
+ size_t h = 0;
+ const char* end = s.second;
+ for (const char* begin = s.first; begin != end; ++begin) {
+ h = 5 * h + *begin;
+ }
+ return h;
+ }
+ };
+
+ template<> struct equal_to {
+ inline bool operator()(const span& s1, const span& s2) const {
+ return (s1.second - s1.first) == (s2.second - s2.first) &&
+ std::equal(s1.first, s1.second, s2.first);
+ }
+ };
+
+ class spell_checker {
+ public:
+ spell_checker() {
+ std::ifstream in("Usr.Dict.Words");
+ char line[32];
+ while (in.getline(line, 32)) {
+ const char* begin = line;
+ const char* end = line + in.gcount() - 1;
+ if (dict.end() == dict.find(span(begin, end))) {
+ const size_t len = end - begin;
+ char* word = new char[len];
+ copy(begin, end, word);
+ ++dict[span(word, word + len)];
+ }
+ }
+ }
+
+ void process(std::istream& in) {
+ char line[32];
+ while (in.getline(line, 32)) {
+ if (dict.end() == dict.find(span(line, line + in.gcount() - 1))) {
+ cout << line << '\n';
+ }
+ }
+ }
+
+ private:
+ std::hash_map dict;
+ };
+
+ int main() {
+ spell_checker spell;
+ char buff[4096];
+ cin.rdbuf()->pubsetbuf(buff, 4096); // enable buffering
+ spell.process(cin);
+ }
From lattner at cs.uiuc.edu Mon Oct 6 20:09:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Oct 6 20:09:01 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/spellcheck.cpp
Message-ID: <200310070108.UAA27485@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:
spellcheck.cpp updated: 1.1 -> 1.2
---
Log message:
Ugh, this uses a wierd implementation of hash_map, which is not standardized
I don't want to even THINK About autoconfing this test, so switch it to use