[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-11 Thread Vedant Kumar via Phabricator via cfe-commits
vsk reopened this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Sorry about that, reopening per Eric's comment.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64540/new/

https://reviews.llvm.org/D64540



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365809: [CGDebugInfo] Simplify EmitFunctionDecl parameters, 
NFC (authored by vedantk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64540?vs=209082=209289#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64540/new/

https://reviews.llvm.org/D64540

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3621,18 +3621,19 @@
 RegionMap[D].reset(SP);
 }
 
-void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-   QualType FnType, llvm::Function *Fn) {
+llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
+  SourceLocation Loc,
+  QualType FnType,
+  bool IsDeclForCallSite) {
   StringRef Name;
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
   if (!D)
-return;
+return nullptr;
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
-  bool IsDeclForCallSite = Fn ? true : false;
   llvm::DIScope *FDContext =
   IsDeclForCallSite ? Unit : getDeclContextDescriptor(D);
   llvm::DINodeArray TParamsArray;
@@ -3665,11 +3666,8 @@
   FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
-
-  if (IsDeclForCallSite)
-Fn->setSubprogram(SP);
-
   DBuilder.retainType(SP);
+  return SP;
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
@@ -3691,8 +3689,13 @@
   if (Func->getSubprogram())
 return;
 
-  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
-EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
+  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined()) {
+llvm::DISubprogram *SP =
+EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType,
+ /*IsDeclForCallSite=*/true);
+assert(SP && "Could not find decl for callee?");
+Func->setSubprogram(SP);
+  }
 }
 
 void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy , GlobalDecl GD) 
{
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -408,10 +408,11 @@
   /// End an inlined function scope.
   void EmitInlineFunctionEnd(CGBuilderTy );
 
-  /// Emit debug info for a function declaration.
-  /// \p Fn is set only when a declaration for a debug call site gets created.
-  void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-QualType FnType, llvm::Function *Fn = nullptr);
+  /// Emit debug info for a function declaration. Set \p IsDeclForCallSite if
+  /// a call site entry must reference the declaration.
+  llvm::DISubprogram *EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+   QualType FnType,
+   bool IsDeclForCallSite = false);
 
   /// Emit debug info for an extern function being called.
   /// This is needed for call site debug info.


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3621,18 +3621,19 @@
 RegionMap[D].reset(SP);
 }
 
-void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-   QualType FnType, llvm::Function *Fn) {
+llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
+  SourceLocation Loc,
+  QualType FnType,
+  bool IsDeclForCallSite) {
   StringRef Name;
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
   if (!D)
-return;
+return nullptr;
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
-  bool IsDeclForCallSite = Fn ? true : false;
   llvm::DIScope *FDContext =
   IsDeclForCallSite ? Unit : getDeclContextDescriptor(D);
   llvm::DINodeArray TParamsArray;
@@ -3665,11 +3666,8 @@
   FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
-
-  if (IsDeclForCallSite)
-Fn->setSubprogram(SP);
-
   

[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-11 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Not a huge fan of boolean parameters like this, perhaps factor out the context 
as well into the caller and then we don't need it at all? Something else?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64540/new/

https://reviews.llvm.org/D64540



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro accepted this revision.
djtodoro added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks @vsk!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64540/new/

https://reviews.llvm.org/D64540



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
vsk added reviewers: djtodoro, aprantl.

Replace a `llvm::Function *` parameter with a bool, which seems harder
to set to the wrong value by accident.


https://reviews.llvm.org/D64540

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h


Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -408,10 +408,11 @@
   /// End an inlined function scope.
   void EmitInlineFunctionEnd(CGBuilderTy );
 
-  /// Emit debug info for a function declaration.
-  /// \p Fn is set only when a declaration for a debug call site gets created.
-  void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-QualType FnType, llvm::Function *Fn = nullptr);
+  /// Emit debug info for a function declaration. Set \p IsDeclForCallSite if
+  /// a call site entry must reference the declaration.
+  llvm::DISubprogram *EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+   QualType FnType,
+   bool IsDeclForCallSite = false);
 
   /// Emit debug info for an extern function being called.
   /// This is needed for call site debug info.
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3618,18 +3618,19 @@
 RegionMap[D].reset(SP);
 }
 
-void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-   QualType FnType, llvm::Function *Fn) {
+llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
+  SourceLocation Loc,
+  QualType FnType,
+  bool IsDeclForCallSite) {
   StringRef Name;
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
   if (!D)
-return;
+return nullptr;
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
-  bool IsDeclForCallSite = Fn ? true : false;
   llvm::DIScope *FDContext =
   IsDeclForCallSite ? Unit : getDeclContextDescriptor(D);
   llvm::DINodeArray TParamsArray;
@@ -3662,11 +3663,8 @@
   FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
-
-  if (IsDeclForCallSite)
-Fn->setSubprogram(SP);
-
   DBuilder.retainType(SP);
+  return SP;
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
@@ -3688,8 +3686,13 @@
   if (Func->getSubprogram())
 return;
 
-  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
-EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
+  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined()) {
+llvm::DISubprogram *SP =
+EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType,
+ /*IsDeclForCallSite=*/true);
+assert(SP && "Could not find decl for callee?");
+Func->setSubprogram(SP);
+  }
 }
 
 void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy , GlobalDecl GD) 
{


Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -408,10 +408,11 @@
   /// End an inlined function scope.
   void EmitInlineFunctionEnd(CGBuilderTy );
 
-  /// Emit debug info for a function declaration.
-  /// \p Fn is set only when a declaration for a debug call site gets created.
-  void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-QualType FnType, llvm::Function *Fn = nullptr);
+  /// Emit debug info for a function declaration. Set \p IsDeclForCallSite if
+  /// a call site entry must reference the declaration.
+  llvm::DISubprogram *EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+   QualType FnType,
+   bool IsDeclForCallSite = false);
 
   /// Emit debug info for an extern function being called.
   /// This is needed for call site debug info.
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3618,18 +3618,19 @@
 RegionMap[D].reset(SP);
 }
 
-void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-   QualType FnType, llvm::Function *Fn) {
+llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
+  SourceLocation Loc,
+  QualType FnType,
+