AddDiscriminators: Create new MDLocation directly
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 14 Apr 2015 00:34:30 +0000 (00:34 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 14 Apr 2015 00:34:30 +0000 (00:34 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234824 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0d489bba3cb80c34d9ab91bde6e4cf4b75199bfa..40b21717a0d6849c365b33ee926e06b41bb4303b 100644 (file)
@@ -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 {
index fc302010b6e316d2f8beaf679c1a1efbd1fcea7f..a2d58fca67a4f1391cae079cba21e318b759aa95 100644 (file)
@@ -47,15 +47,6 @@ void DICompileUnit::replaceGlobalVariables(DIArray GlobalVariables) {
   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];
index e8f1d5c83c66199aba786315c27b09de5832fb73..4197e35f2677eb65113f5771f6ea9e70967cb009 100644 (file)
@@ -198,7 +198,9 @@ bool AddDiscriminators::runOnFunction(Function &F) {
         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