Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jul 2014 23:16:28 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r269000 - in stable/10/contrib/llvm: include/llvm lib/CodeGen/AsmPrinter patches tools/clang/lib/CodeGen
Message-ID:  <201407222316.s6MNGSpt064478@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Tue Jul 22 23:16:28 2014
New Revision: 269000
URL: http://svnweb.freebsd.org/changeset/base/269000

Log:
  MFC debug info for variadic functions
  
  r264826: Merge LLVM r202188:
  
      Debug info: Support variadic functions.
      Variadic functions have an unspecified parameter tag after the last
      argument. In IR this is represented as an unspecified parameter in the
      subroutine type.
  
      Paired commit with CFE r202185.
  
      rdar://problem/13690847
  
      This re-applies r202184 + a bugfix in DwarfDebug's argument handling.
  
    This merge includes a change to use the LLVM 3.4 API in
    lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:
  
    DwarfUnit -> CompileUnit
  
  r264827: Merge Clang r202185:
  
      Debug info: Generate debug info for variadic functions.
      Paired commit with LLVM.
  
      rdar://problem/13690847
  
    This merege includes changes to use the Clang 3.4 API (revisions
    199686 and 200082) in lib/CodeGen/CGDebugInfo.cpp:
  
    getParamType  -> getArgType
    getNumParams  -> getNumArgs
    getReturnType -> getResultType
  
  r264828: Add patches corresponding to r264826 and r264827
  
  Sponsored by:	DARPA, AFRL

Added:
  stable/10/contrib/llvm/patches/patch-r264826-llvm-r202188-variadic-fn-debug-info.diff
     - copied unchanged from r264828, head/contrib/llvm/patches/patch-r264826-llvm-r202188-variadic-fn-debug-info.diff
  stable/10/contrib/llvm/patches/patch-r264827-clang-r202185-variadic-fn-debug-info.diff
     - copied unchanged from r264828, head/contrib/llvm/patches/patch-r264827-clang-r202185-variadic-fn-debug-info.diff
Modified:
  stable/10/contrib/llvm/include/llvm/DIBuilder.h
  stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  stable/10/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/llvm/include/llvm/DIBuilder.h
==============================================================================
--- stable/10/contrib/llvm/include/llvm/DIBuilder.h	Tue Jul 22 23:10:12 2014	(r268999)
+++ stable/10/contrib/llvm/include/llvm/DIBuilder.h	Tue Jul 22 23:16:28 2014	(r269000)
@@ -439,7 +439,7 @@ namespace llvm {
     /// through debug info anchors.
     void retainType(DIType T);
 
-    /// createUnspecifiedParameter - Create unspeicified type descriptor
+    /// createUnspecifiedParameter - Create unspecified type descriptor
     /// for a subroutine type.
     DIDescriptor createUnspecifiedParameter();
 

Modified: stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
==============================================================================
--- stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp	Tue Jul 22 23:10:12 2014	(r268999)
+++ stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp	Tue Jul 22 23:16:28 2014	(r269000)
@@ -1116,6 +1116,22 @@ void CompileUnit::constructTypeDIE(DIE &
     addSourceLine(&Buffer, DTy);
 }
 
+/// constructSubprogramArguments - Construct function argument DIEs.
+void CompileUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) {
+    for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
+      DIDescriptor Ty = Args.getElement(i);
+      if (Ty.isUnspecifiedParameter()) {
+        assert(i == N-1 && "ellipsis must be the last argument");
+        createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
+      } else {
+        DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
+        addType(Arg, DIType(Ty));
+        if (DIType(Ty).isArtificial())
+          addFlag(Arg, dwarf::DW_AT_artificial);
+      }
+    }
+}
+
 /// Return true if the type is appropriately scoped to be contained inside
 /// its own type unit.
 static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) {
@@ -1170,19 +1186,12 @@ void CompileUnit::constructTypeDIE(DIE &
       addType(&Buffer, RTy);
 
     bool isPrototyped = true;
-    // Add arguments.
-    for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) {
-      DIDescriptor Ty = Elements.getElement(i);
-      if (Ty.isUnspecifiedParameter()) {
-        createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
-        isPrototyped = false;
-      } else {
-        DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
-        addType(Arg, DIType(Ty));
-        if (DIType(Ty).isArtificial())
-          addFlag(Arg, dwarf::DW_AT_artificial);
-      }
-    }
+    if (Elements.getNumElements() == 2 &&
+        Elements.getElement(1).isUnspecifiedParameter())
+      isPrototyped = false;
+
+    constructSubprogramArguments(Buffer, Elements);
+
     // Add prototype flag if we're dealing with a C language and the
     // function has been prototyped.
     uint16_t Language = getLanguage();
@@ -1475,13 +1484,7 @@ DIE *CompileUnit::getOrCreateSubprogramD
 
     // Add arguments. Do not add arguments for subprogram definition. They will
     // be handled while processing variables.
-    for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
-      DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
-      DIType ATy(Args.getElement(i));
-      addType(Arg, ATy);
-      if (ATy.isArtificial())
-        addFlag(Arg, dwarf::DW_AT_artificial);
-    }
+    constructSubprogramArguments(*SPDie, Args);
   }
 
   if (SP.isArtificial())

Modified: stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
==============================================================================
--- stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h	Tue Jul 22 23:10:12 2014	(r268999)
+++ stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h	Tue Jul 22 23:16:28 2014	(r269000)
@@ -342,6 +342,9 @@ public:
   void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym);
 
 private:
+  /// constructSubprogramArguments - Construct function argument DIEs.
+  void constructSubprogramArguments(DIE &Buffer, DIArray Args);
+
   /// constructTypeDIE - Construct basic type die from DIBasicType.
   void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
 

Modified: stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
==============================================================================
--- stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp	Tue Jul 22 23:10:12 2014	(r268999)
+++ stable/10/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp	Tue Jul 22 23:16:28 2014	(r269000)
@@ -404,15 +404,21 @@ DIE *DwarfDebug::updateSubprogramScopeDI
         DIArray Args = SPTy.getTypeArray();
         uint16_t SPTag = SPTy.getTag();
         if (SPTag == dwarf::DW_TAG_subroutine_type)
+          // FIXME: Use DwarfUnit::constructSubprogramArguments() here.
           for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
-            DIE *Arg =
-                SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
             DIType ATy(Args.getElement(i));
-            SPCU->addType(Arg, ATy);
-            if (ATy.isArtificial())
-              SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
-            if (ATy.isObjectPointer())
-              SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
+            if (ATy.isUnspecifiedParameter()) {
+              assert(i == N-1 && "ellipsis must be the last argument");
+              SPCU->createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, *SPDie);
+            } else {
+              DIE *Arg =
+                SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
+              SPCU->addType(Arg, ATy);
+              if (ATy.isArtificial())
+                SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
+              if (ATy.isObjectPointer())
+                SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
+            }
           }
         DIE *SPDeclDie = SPDie;
         SPDie =
@@ -579,7 +585,7 @@ DIE *DwarfDebug::createScopeChildrenDIE(
     DIE *ObjectPointer = NULL;
 
   // Collect arguments for current function.
-  if (LScopes.isCurrentFunctionScope(Scope))
+  if (LScopes.isCurrentFunctionScope(Scope)) {
     for (unsigned i = 0, N = CurrentFnArguments.size(); i < N; ++i)
       if (DbgVariable *ArgDV = CurrentFnArguments[i])
         if (DIE *Arg =
@@ -588,6 +594,16 @@ DIE *DwarfDebug::createScopeChildrenDIE(
           if (ArgDV->isObjectPointer()) ObjectPointer = Arg;
         }
 
+    // Create the unspecified parameter that marks a function as variadic.
+    DISubprogram SP(Scope->getScopeNode());
+    assert(SP.Verify());
+    DIArray FnArgs = SP.getType().getTypeArray();
+    if (FnArgs.getElement(FnArgs.getNumElements()-1).isUnspecifiedParameter()) {
+      DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters);
+      Children.push_back(Ellipsis);
+    }
+  }
+
   // Collect lexical scope children first.
   const SmallVectorImpl<DbgVariable *> &Variables =ScopeVariables.lookup(Scope);
   for (unsigned i = 0, N = Variables.size(); i < N; ++i)

Copied: stable/10/contrib/llvm/patches/patch-r264826-llvm-r202188-variadic-fn-debug-info.diff (from r264828, head/contrib/llvm/patches/patch-r264826-llvm-r202188-variadic-fn-debug-info.diff)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/llvm/patches/patch-r264826-llvm-r202188-variadic-fn-debug-info.diff	Tue Jul 22 23:16:28 2014	(r269000, copy of r264828, head/contrib/llvm/patches/patch-r264826-llvm-r202188-variadic-fn-debug-info.diff)
@@ -0,0 +1,176 @@
+Merge LLVM r202188:
+
+  Debug info: Support variadic functions.
+  Variadic functions have an unspecified parameter tag after the last
+  argument. In IR this is represented as an unspecified parameter in the
+  subroutine type.
+
+  Paired commit with CFE r202185.
+
+  rdar://problem/13690847
+
+  This re-applies r202184 + a bugfix in DwarfDebug's argument handling.
+
+This merge includes a change to use the LLVM 3.4 API in
+lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:
+
+DwarfUnit -> CompileUnit
+
+Sponsored by:       DARPA, AFRL
+
+http://svnweb.freebsd.org/changeset/base/264826
+
+Index: include/llvm/DIBuilder.h
+===================================================================
+--- include/llvm/DIBuilder.h	(revision 264825)
++++ include/llvm/DIBuilder.h	(revision 264826)
+@@ -439,7 +439,7 @@
+     /// through debug info anchors.
+     void retainType(DIType T);
+ 
+-    /// createUnspecifiedParameter - Create unspeicified type descriptor
++    /// createUnspecifiedParameter - Create unspecified type descriptor
+     /// for a subroutine type.
+     DIDescriptor createUnspecifiedParameter();
+ 
+Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+===================================================================
+--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp	(revision 264825)
++++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp	(revision 264826)
+@@ -404,15 +404,21 @@
+         DIArray Args = SPTy.getTypeArray();
+         uint16_t SPTag = SPTy.getTag();
+         if (SPTag == dwarf::DW_TAG_subroutine_type)
++          // FIXME: Use DwarfUnit::constructSubprogramArguments() here.
+           for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
+-            DIE *Arg =
++            DIType ATy(Args.getElement(i));
++            if (ATy.isUnspecifiedParameter()) {
++              assert(i == N-1 && "ellipsis must be the last argument");
++              SPCU->createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, *SPDie);
++            } else {
++              DIE *Arg =
+                 SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
+-            DIType ATy(Args.getElement(i));
+-            SPCU->addType(Arg, ATy);
+-            if (ATy.isArtificial())
+-              SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
+-            if (ATy.isObjectPointer())
+-              SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
++              SPCU->addType(Arg, ATy);
++              if (ATy.isArtificial())
++                SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
++              if (ATy.isObjectPointer())
++                SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
++            }
+           }
+         DIE *SPDeclDie = SPDie;
+         SPDie =
+@@ -579,7 +585,7 @@
+     DIE *ObjectPointer = NULL;
+ 
+   // Collect arguments for current function.
+-  if (LScopes.isCurrentFunctionScope(Scope))
++  if (LScopes.isCurrentFunctionScope(Scope)) {
+     for (unsigned i = 0, N = CurrentFnArguments.size(); i < N; ++i)
+       if (DbgVariable *ArgDV = CurrentFnArguments[i])
+         if (DIE *Arg =
+@@ -588,6 +594,16 @@
+           if (ArgDV->isObjectPointer()) ObjectPointer = Arg;
+         }
+ 
++    // Create the unspecified parameter that marks a function as variadic.
++    DISubprogram SP(Scope->getScopeNode());
++    assert(SP.Verify());
++    DIArray FnArgs = SP.getType().getTypeArray();
++    if (FnArgs.getElement(FnArgs.getNumElements()-1).isUnspecifiedParameter()) {
++      DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters);
++      Children.push_back(Ellipsis);
++    }
++  }
++
+   // Collect lexical scope children first.
+   const SmallVectorImpl<DbgVariable *> &Variables =ScopeVariables.lookup(Scope);
+   for (unsigned i = 0, N = Variables.size(); i < N; ++i)
+Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+===================================================================
+--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp	(revision 264825)
++++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp	(revision 264826)
+@@ -1116,6 +1116,22 @@
+     addSourceLine(&Buffer, DTy);
+ }
+ 
++/// constructSubprogramArguments - Construct function argument DIEs.
++void CompileUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) {
++    for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
++      DIDescriptor Ty = Args.getElement(i);
++      if (Ty.isUnspecifiedParameter()) {
++        assert(i == N-1 && "ellipsis must be the last argument");
++        createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
++      } else {
++        DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
++        addType(Arg, DIType(Ty));
++        if (DIType(Ty).isArtificial())
++          addFlag(Arg, dwarf::DW_AT_artificial);
++      }
++    }
++}
++
+ /// Return true if the type is appropriately scoped to be contained inside
+ /// its own type unit.
+ static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) {
+@@ -1170,19 +1186,12 @@
+       addType(&Buffer, RTy);
+ 
+     bool isPrototyped = true;
+-    // Add arguments.
+-    for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) {
+-      DIDescriptor Ty = Elements.getElement(i);
+-      if (Ty.isUnspecifiedParameter()) {
+-        createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
+-        isPrototyped = false;
+-      } else {
+-        DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
+-        addType(Arg, DIType(Ty));
+-        if (DIType(Ty).isArtificial())
+-          addFlag(Arg, dwarf::DW_AT_artificial);
+-      }
+-    }
++    if (Elements.getNumElements() == 2 &&
++        Elements.getElement(1).isUnspecifiedParameter())
++      isPrototyped = false;
++
++    constructSubprogramArguments(Buffer, Elements);
++
+     // Add prototype flag if we're dealing with a C language and the
+     // function has been prototyped.
+     uint16_t Language = getLanguage();
+@@ -1475,13 +1484,7 @@
+ 
+     // Add arguments. Do not add arguments for subprogram definition. They will
+     // be handled while processing variables.
+-    for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
+-      DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
+-      DIType ATy(Args.getElement(i));
+-      addType(Arg, ATy);
+-      if (ATy.isArtificial())
+-        addFlag(Arg, dwarf::DW_AT_artificial);
+-    }
++    constructSubprogramArguments(*SPDie, Args);
+   }
+ 
+   if (SP.isArtificial())
+Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+===================================================================
+--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.h	(revision 264825)
++++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.h	(revision 264826)
+@@ -342,6 +342,9 @@
+   void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym);
+ 
+ private:
++  /// constructSubprogramArguments - Construct function argument DIEs.
++  void constructSubprogramArguments(DIE &Buffer, DIArray Args);
++
+   /// constructTypeDIE - Construct basic type die from DIBasicType.
+   void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
+ 

Copied: stable/10/contrib/llvm/patches/patch-r264827-clang-r202185-variadic-fn-debug-info.diff (from r264828, head/contrib/llvm/patches/patch-r264827-clang-r202185-variadic-fn-debug-info.diff)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/llvm/patches/patch-r264827-clang-r202185-variadic-fn-debug-info.diff	Tue Jul 22 23:16:28 2014	(r269000, copy of r264828, head/contrib/llvm/patches/patch-r264827-clang-r202185-variadic-fn-debug-info.diff)
@@ -0,0 +1,74 @@
+Merge Clang r202185:
+
+  Debug info: Generate debug info for variadic functions.
+  Paired commit with LLVM.
+
+  rdar://problem/13690847
+
+This merege includes changes to use the Clang 3.4 API (revisions
+199686 and 200082) in lib/CodeGen/CGDebugInfo.cpp:
+
+getParamType  -> getArgType
+getNumParams  -> getNumArgs
+getReturnType -> getResultType
+
+Sponsored by:	DARPA, AFRL
+
+http://svnweb.freebsd.org/changeset/base/264827
+
+Index: tools/clang/lib/CodeGen/CGDebugInfo.cpp
+===================================================================
+--- tools/clang/lib/CodeGen/CGDebugInfo.cpp	(revision 264826)
++++ tools/clang/lib/CodeGen/CGDebugInfo.cpp	(revision 264827)
+@@ -37,7 +37,7 @@
+ #include "llvm/IR/Module.h"
+ #include "llvm/Support/Dwarf.h"
+ #include "llvm/Support/FileSystem.h"
+-#include "llvm/Support/Path.h"
++#include "llvm/Support/Path.h"
+ using namespace clang;
+ using namespace clang::CodeGen;
+ 
+@@ -342,9 +342,9 @@
+   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
+     MainFileDir = MainFile->getDir()->getName();
+     if (MainFileDir != ".") {
+-      llvm::SmallString<1024> MainFileDirSS(MainFileDir);
+-      llvm::sys::path::append(MainFileDirSS, MainFileName);
+-      MainFileName = MainFileDirSS.str();
++      llvm::SmallString<1024> MainFileDirSS(MainFileDir);
++      llvm::sys::path::append(MainFileDirSS, MainFileName);
++      MainFileName = MainFileDirSS.str();
+     }
+   }
+ 
+@@ -760,6 +760,8 @@
+   else if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(Ty)) {
+     for (unsigned i = 0, e = FPT->getNumArgs(); i != e; ++i)
+       EltTys.push_back(getOrCreateType(FPT->getArgType(i), Unit));
++    if (FPT->isVariadic())
++      EltTys.push_back(DBuilder.createUnspecifiedParameter());
+   }
+ 
+   llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
+@@ -2420,6 +2422,20 @@
+     llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
+     return DBuilder.createSubroutineType(F, EltTypeArray);
+   }
++
++  // Variadic function.
++  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
++    if (FD->isVariadic()) {
++      SmallVector<llvm::Value *, 16> EltTys;
++      EltTys.push_back(getOrCreateType(FD->getResultType(), F));
++      if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FnType))
++        for (unsigned i = 0, e = FPT->getNumArgs(); i != e; ++i)
++          EltTys.push_back(getOrCreateType(FPT->getArgType(i), F));
++      EltTys.push_back(DBuilder.createUnspecifiedParameter());
++      llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
++      return DBuilder.createSubroutineType(F, EltTypeArray);
++    }
++
+   return llvm::DICompositeType(getOrCreateType(FnType, F));
+ }
+ 

Modified: stable/10/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp
==============================================================================
--- stable/10/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp	Tue Jul 22 23:10:12 2014	(r268999)
+++ stable/10/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp	Tue Jul 22 23:16:28 2014	(r269000)
@@ -37,7 +37,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
+#include "llvm/Support/Path.h"
 using namespace clang;
 using namespace clang::CodeGen;
 
@@ -342,9 +342,9 @@ void CGDebugInfo::CreateCompileUnit() {
   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
     MainFileDir = MainFile->getDir()->getName();
     if (MainFileDir != ".") {
-      llvm::SmallString<1024> MainFileDirSS(MainFileDir);
-      llvm::sys::path::append(MainFileDirSS, MainFileName);
-      MainFileName = MainFileDirSS.str();
+      llvm::SmallString<1024> MainFileDirSS(MainFileDir);
+      llvm::sys::path::append(MainFileDirSS, MainFileName);
+      MainFileName = MainFileDirSS.str();
     }
   }
 
@@ -760,6 +760,8 @@ llvm::DIType CGDebugInfo::CreateType(con
   else if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(Ty)) {
     for (unsigned i = 0, e = FPT->getNumArgs(); i != e; ++i)
       EltTys.push_back(getOrCreateType(FPT->getArgType(i), Unit));
+    if (FPT->isVariadic())
+      EltTys.push_back(DBuilder.createUnspecifiedParameter());
   }
 
   llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
@@ -2420,6 +2422,20 @@ llvm::DICompositeType CGDebugInfo::getOr
     llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
     return DBuilder.createSubroutineType(F, EltTypeArray);
   }
+
+  // Variadic function.
+  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
+    if (FD->isVariadic()) {
+      SmallVector<llvm::Value *, 16> EltTys;
+      EltTys.push_back(getOrCreateType(FD->getResultType(), F));
+      if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FnType))
+        for (unsigned i = 0, e = FPT->getNumArgs(); i != e; ++i)
+          EltTys.push_back(getOrCreateType(FPT->getArgType(i), F));
+      EltTys.push_back(DBuilder.createUnspecifiedParameter());
+      llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
+      return DBuilder.createSubroutineType(F, EltTypeArray);
+    }
+
   return llvm::DICompositeType(getOrCreateType(FnType, F));
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407222316.s6MNGSpt064478>