[llvm-commits] [llvm] r127470 - in /llvm/trunk/tools/llvm-dis: Makefile llvm-dis.cpp
Devang Patel
dpatel at apple.com
Fri Mar 11 10:07:34 PST 2011
Author: dpatel
Date: Fri Mar 11 12:07:33 2011
New Revision: 127470
URL: http://llvm.org/viewvc/llvm-project?rev=127470&view=rev
Log:
While printing annotations, print line number and variable name if debug info is present.
Modified:
llvm/trunk/tools/llvm-dis/Makefile
llvm/trunk/tools/llvm-dis/llvm-dis.cpp
Modified: llvm/trunk/tools/llvm-dis/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dis/Makefile?rev=127470&r1=127469&r2=127470&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dis/Makefile (original)
+++ llvm/trunk/tools/llvm-dis/Makefile Fri Mar 11 12:07:33 2011
@@ -9,7 +9,7 @@
LEVEL = ../..
TOOLNAME = llvm-dis
-LINK_COMPONENTS := bitreader
+LINK_COMPONENTS := bitreader analysis
# This tool has no plugins, optimize startup time.
TOOL_NO_EXPORTS = 1
Modified: llvm/trunk/tools/llvm-dis/llvm-dis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dis/llvm-dis.cpp?rev=127470&r1=127469&r2=127470&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dis/llvm-dis.cpp (original)
+++ llvm/trunk/tools/llvm-dis/llvm-dis.cpp Fri Mar 11 12:07:33 2011
@@ -19,7 +19,9 @@
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Type.h"
+#include "llvm/IntrinsicInst.h"
#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Assembly/AssemblyAnnotationWriter.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormattedStream.h"
@@ -50,6 +52,16 @@
namespace {
+static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) {
+ OS << DL.getLine() << ":" << DL.getCol();
+ if (MDNode *N = DL.getInlinedAt(getGlobalContext())) {
+ DebugLoc IDL = DebugLoc::getFromDILocation(N);
+ if (!IDL.isUnknown()) {
+ OS << "@";
+ printDebugLoc(IDL,OS);
+ }
+ }
+}
class CommentWriter : public AssemblyAnnotationWriter {
public:
void emitFunctionAnnot(const Function *F,
@@ -58,10 +70,43 @@
OS << '\n';
}
void printInfoComment(const Value &V, formatted_raw_ostream &OS) {
- if (V.getType()->isVoidTy()) return;
-
- OS.PadToColumn(50);
- OS << "; [#uses=" << V.getNumUses() << ']'; // Output # uses
+ bool Padded = false;
+ if (!V.getType()->isVoidTy()) {
+ OS.PadToColumn(50);
+ Padded = true;
+ OS << "; [#uses=" << V.getNumUses() << ']'; // Output # uses
+ }
+ if (const Instruction *I = dyn_cast<Instruction>(&V)) {
+ const DebugLoc &DL = I->getDebugLoc();
+ if (!DL.isUnknown()) {
+ if (!Padded) {
+ OS.PadToColumn(50);
+ Padded = true;
+ OS << ";";
+ }
+ OS << " [debug line = ";
+ printDebugLoc(DL,OS);
+ OS << "]";
+ }
+ if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I)) {
+ DIVariable Var(DDI->getVariable());
+ if (!Padded) {
+ OS.PadToColumn(50);
+ Padded = true;
+ OS << ";";
+ }
+ OS << " [debug variable = " << Var.getName() << "]";
+ }
+ else if (const DbgValueInst *DVI = dyn_cast<DbgValueInst>(I)) {
+ DIVariable Var(DVI->getVariable());
+ if (!Padded) {
+ OS.PadToColumn(50);
+ Padded = true;
+ OS << ";";
+ }
+ OS << " [debug variable = " << Var.getName() << "]";
+ }
+ }
}
};
More information about the llvm-commits
mailing list