AArch64: fix big-endian immediate materialisation
[oota-llvm.git] / lib / IR / DebugLoc.cpp
index a45b622a71b9c258269ca4528b758ee342ad6a28..e8bdccebae96d5445abd9fd103d61466e14055c5 100644 (file)
@@ -76,7 +76,7 @@ MDNode *DebugLoc::getScopeNode(const LLVMContext &Ctx) const {
   return getScope(Ctx);
 }
 
-DebugLoc DebugLoc::getFnDebugLoc(const LLVMContext &Ctx) {
+DebugLoc DebugLoc::getFnDebugLoc(const LLVMContext &Ctx) const {
   const MDNode *Scope = getScopeNode(Ctx);
   DISubprogram SP = getDISubprogram(Scope);
   if (SP.isSubprogram()) {
@@ -167,6 +167,28 @@ void DebugLoc::dump(const LLVMContext &Ctx) const {
 #endif
 }
 
+void DebugLoc::print(const LLVMContext &Ctx, raw_ostream &OS) const {
+  if (!isUnknown()) {
+    // Print source line info.
+    DIScope Scope(getScope(Ctx));
+    assert((!Scope || Scope.isScope()) &&
+           "Scope of a DebugLoc should be null or a DIScope.");
+    if (Scope)
+      OS << Scope.getFilename();
+    else
+      OS << "<unknown>";
+    OS << ':' << getLine();
+    if (getCol() != 0)
+      OS << ':' << getCol();
+    DebugLoc InlinedAtDL = DebugLoc::getFromDILocation(getInlinedAt(Ctx));
+    if (!InlinedAtDL.isUnknown()) {
+      OS << " @[ ";
+      InlinedAtDL.print(Ctx, OS);
+      OS << " ]";
+    }
+  }
+}
+
 //===----------------------------------------------------------------------===//
 // DenseMap specialization
 //===----------------------------------------------------------------------===//
@@ -260,7 +282,7 @@ void DebugRecVH::deleted() {
   
   MDNode *OldScope = Entry.first.get();
   MDNode *OldInlinedAt = Entry.second.get();
-  assert(OldScope != 0 && OldInlinedAt != 0 &&
+  assert(OldScope && OldInlinedAt &&
          "Entry should be non-canonical if either val dropped to null");
 
   // Otherwise, we do have an entry in it, nuke it and we're done.
@@ -314,7 +336,7 @@ void DebugRecVH::allUsesReplacedWith(Value *NewVa) {
   
   MDNode *OldScope = Entry.first.get();
   MDNode *OldInlinedAt = Entry.second.get();
-  assert(OldScope != 0 && OldInlinedAt != 0 &&
+  assert(OldScope && OldInlinedAt &&
          "Entry should be non-canonical if either val dropped to null");
   
   // Otherwise, we do have an entry in it, nuke it and we're done.