[llvm] r234824 - AddDiscriminators: Create new MDLocation directly

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Apr 13 17:34:31 PDT 2015


Author: dexonsmith
Date: Mon Apr 13 19:34:30 2015
New Revision: 234824

URL: http://llvm.org/viewvc/llvm-project?rev=234824&view=rev
Log:
AddDiscriminators: Create new MDLocation directly

I don't see a reason to add the `copyWithNewScope()` API over to
`MDLocation` -- it seems to be a holdover from when creating locations
required knowing details of operand layout -- so change
`AddDiscriminators` to call `MDLocation::get()` directly.  Should be no
functionality change here.

Modified:
    llvm/trunk/include/llvm/IR/DebugInfo.h
    llvm/trunk/lib/IR/DebugInfo.cpp
    llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234824&r1=234823&r2=234824&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 13 19:34:30 2015
@@ -705,9 +705,6 @@ public:
 
   /// \brief Generate a new discriminator value for this location.
   unsigned computeNewDiscriminator(LLVMContext &Ctx);
-
-  /// \brief Return a copy of this location with a different scope.
-  DILocation copyWithNewScope(LLVMContext &Ctx, DILexicalBlockFile NewScope);
 };
 
 class DIObjCProperty : public DIDescriptor {

Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=234824&r1=234823&r2=234824&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Apr 13 19:34:30 2015
@@ -47,15 +47,6 @@ void DICompileUnit::replaceGlobalVariabl
   get()->replaceGlobalVariables(MDGlobalVariableArray(GlobalVariables));
 }
 
-DILocation DILocation::copyWithNewScope(LLVMContext &Ctx,
-                                        DILexicalBlockFile NewScope) {
-  assert(NewScope && "Expected valid scope");
-
-  const auto *Old = cast<MDLocation>(DbgNode);
-  return DILocation(MDLocation::get(Ctx, Old->getLine(), Old->getColumn(),
-                                    NewScope, Old->getInlinedAt()));
-}
-
 unsigned DILocation::computeNewDiscriminator(LLVMContext &Ctx) {
   std::pair<const char *, unsigned> Key(getFilename().data(), getLineNumber());
   return ++Ctx.pImpl->DiscriminatorTable[Key];

Modified: llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp?rev=234824&r1=234823&r2=234824&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp Mon Apr 13 19:34:30 2015
@@ -198,7 +198,9 @@ bool AddDiscriminators::runOnFunction(Fu
         unsigned Discriminator = FirstDIL.computeNewDiscriminator(Ctx);
         DILexicalBlockFile NewScope =
             Builder.createLexicalBlockFile(Scope, File, Discriminator);
-        DILocation NewDIL = FirstDIL.copyWithNewScope(Ctx, NewScope);
+        DILocation NewDIL =
+            MDLocation::get(Ctx, FirstDIL->getLine(), FirstDIL->getColumn(),
+                            NewScope, FirstDIL->getInlinedAt());
         DebugLoc newDebugLoc = NewDIL.get();
 
         // Attach this new debug location to First and every





More information about the llvm-commits mailing list