freebsd-nq/contrib/llvm/lib/Analysis/Trace.cpp

53 lines
1.7 KiB
C++
Raw Normal View History

2009-06-02 17:52:33 +00:00
//===- Trace.cpp - Implementation of Trace class --------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This class represents a single trace of LLVM basic blocks. A trace is a
// single entry, multiple exit, region of code that is often hot. Trace-based
// optimizations treat traces almost like they are a large, strange, basic
// block: because the trace path is assumed to be hot, optimizations for the
// fall-through path are made at the expense of the non-fall-through paths.
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/Trace.h"
#include "llvm/IR/Function.h"
2010-01-01 10:31:22 +00:00
#include "llvm/Support/Debug.h"
2009-10-14 17:57:32 +00:00
#include "llvm/Support/raw_ostream.h"
2009-06-02 17:52:33 +00:00
using namespace llvm;
Function *Trace::getFunction() const {
return getEntryBasicBlock()->getParent();
}
Module *Trace::getModule() const {
return getFunction()->getParent();
}
/// print - Write trace to output stream.
///
2009-10-14 17:57:32 +00:00
void Trace::print(raw_ostream &O) const {
Function *F = getFunction();
O << "; Trace from function " << F->getName() << ", blocks:\n";
2009-06-02 17:52:33 +00:00
for (const_iterator i = begin(), e = end(); i != e; ++i) {
O << "; ";
(*i)->printAsOperand(O, true, getModule());
2009-06-02 17:52:33 +00:00
O << "\n";
}
O << "; Trace parent function: \n" << *F;
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2009-06-02 17:52:33 +00:00
/// dump - Debugger convenience method; writes trace to standard error
/// output stream.
///
LLVM_DUMP_METHOD void Trace::dump() const {
2010-01-01 10:31:22 +00:00
print(dbgs());
2009-06-02 17:52:33 +00:00
}
#endif