Re: [PATCH] D15641: [Driver] Pass -O* to the gold plugin via -plugin-opt

2015-12-19 Thread James Molloy via cfe-commits
Hi Mehdi,

> On 18 Dec 2015, at 23:17, Mehdi Amini  wrote:
>
> The alternative to the command line flag is to encode the optimization level 
> in the bitcode itself.

You may have answered Joerg's question here - I take it this is not yet 
implemented?

James
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

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


Re: [PATCH] D13419: Fix several problems at the intersection of template instantiations and visibility

2015-12-19 Thread Keno Fischer via cfe-commits
loladiro added a comment.

bump again


Repository:
  rL LLVM

http://reviews.llvm.org/D13419



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


Re: [PATCH] D15641: [Driver] Pass -O* to the gold plugin via -plugin-opt

2015-12-19 Thread Mehdi Amini via cfe-commits


Sent from my iPhone

> On Dec 18, 2015, at 11:11 PM, James Molloy  wrote:
> 
> Hi Mehdi,
> 
>> On 18 Dec 2015, at 23:17, Mehdi Amini  wrote:
>> 
>> The alternative to the command line flag is to encode the optimization level 
>> in the bitcode itself.
> 
> You may have answered Joerg's question here - I take it this is not yet 
> implemented?

Not implemented. We have settled on the various tradeoff. Are you interested to 
think about this?
-- 
Mehdi
> 
> James
> IMPORTANT NOTICE: The contents of this email and any attachments are 
> confidential and may also be privileged. If you are not the intended 
> recipient, please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy the 
> information in any medium. Thank you.
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15641: [Driver] Pass -O* to the gold plugin via -plugin-opt

2015-12-19 Thread James Molloy via cfe-commits
It's interesting to think about, but not something I'm intending to attack
right now.

I mainly just wanted to know the answer to Joerg's question, and now I do :)

James
On Sat, 19 Dec 2015 at 17:17, Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
>
> Sent from my iPhone
>
> > On Dec 18, 2015, at 11:11 PM, James Molloy  wrote:
> >
> > Hi Mehdi,
> >
> >> On 18 Dec 2015, at 23:17, Mehdi Amini  wrote:
> >>
> >> The alternative to the command line flag is to encode the optimization
> level in the bitcode itself.
> >
> > You may have answered Joerg's question here - I take it this is not yet
> implemented?
>
> Not implemented. We have settled on the various tradeoff. Are you
> interested to think about this?
> --
> Mehdi
> >
> > James
> > IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
> >
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15641: [Driver] Pass -O* to the gold plugin via -plugin-opt

2015-12-19 Thread Mehdi Amini via cfe-commits

> On Dec 19, 2015, at 8:11 AM, James Molloy  wrote:
> 
> It's interesting to think about, but not something I'm intending to attack 
> right now. 
> 
> I mainly just wanted to know the answer to Joerg's question, and now I do :)


I missed Joerg’s question earlier, I didn’t know what you were referring to. So 
I’ll answer here: AFAIK per-function attributes do not record the optimization 
level but only some optimization attributes: minsize, optsize, option. 
A fundamental issue is that the pipeline can change between O0/O1/O2/O3, and 
this is intrinsically problematic since the pipeline cannot be “per-function” 
overall.
What we were thinking to implement would be some information at the module 
level to instruct the ThinLTO optimizer of the flags to enable/disable, 
probably in global metadata.

The CodeGenOpt::Level has the same issue that it could be used to change the 
pipeline theoretically. It is not a problem at the time since (AFAIK) the 
CodeGen pipeline is intrinsically per function, but this may change with the 
new instruction selector.

— 
Mehdi


> 
> James
> On Sat, 19 Dec 2015 at 17:17, Mehdi Amini via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
> 
> Sent from my iPhone
> 
> > On Dec 18, 2015, at 11:11 PM, James Molloy  > > wrote:
> >
> > Hi Mehdi,
> >
> >> On 18 Dec 2015, at 23:17, Mehdi Amini  >> > wrote:
> >>
> >> The alternative to the command line flag is to encode the optimization 
> >> level in the bitcode itself.
> >
> > You may have answered Joerg's question here - I take it this is not yet 
> > implemented?
> 
> Not implemented. We have settled on the various tradeoff. Are you interested 
> to think about this?
> --
> Mehdi
> >
> > James
> > IMPORTANT NOTICE: The contents of this email and any attachments are 
> > confidential and may also be privileged. If you are not the intended 
> > recipient, please notify the sender immediately and do not disclose the 
> > contents to any other person, use it for any purpose, or store or copy the 
> > information in any medium. Thank you.
> >
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 

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


Re: [PATCH] D15651: Driver part of debugger tuning

2015-12-19 Thread Paul Robinson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256104: Driver part of debugger tuning. (authored by 
probinson).

Changed prior to commit:
  http://reviews.llvm.org/D15651?vs=43259&id=43304#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15651

Files:
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/debug-options.c
  cfe/trunk/test/Driver/split-debug.c

Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1514,8 +1514,11 @@
 Note that these flags should appear after the corresponding profile
 flags to have an effect.
 
+Controlling Debug Information
+-
+
 Controlling Size of Debug Information
--
+^
 
 Debug info kind generated by Clang can be set by one of the flags listed
 below. If multiple flags are present, the last one is used.
@@ -1559,6 +1562,21 @@
 
   Generate complete debug info.
 
+Controlling Debugger "Tuning"
+^
+
+While Clang generally emits standard DWARF debug info (http://dwarfstd.org),
+different debuggers may know how to take advantage of different specific DWARF
+features. You can "tune" the debug info for one of several different debuggers.
+
+.. option:: -ggdb, -glldb, -gsce
+
+  Tune the debug info for the ``gdb``, ``lldb``, or Sony Computer Entertainment
+  debugger, respectively. Each of these options implies **-g**. (Therefore, if
+  you want both **-gline-tables-only** and debugger tuning, the tuning option
+  must come first.)
+
+
 Comment Parsing Options
 ---
 
Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -18,6 +18,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Target/TargetOptions.h"
 #include 
 #include 
 
@@ -304,6 +305,11 @@
   // i.e. a value of 'true' does not imply that debugging is wanted.
   virtual bool GetDefaultStandaloneDebug() const { return false; }
 
+  // Return the default debugger "tuning."
+  virtual llvm::DebuggerKind getDefaultDebuggerTuning() const {
+return llvm::DebuggerKind::GDB;
+  }
+
   /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
   virtual bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const {
 return false;
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -71,6 +71,9 @@
 def f_Group   : OptionGroup<"">, Group;
 def f_clang_Group : OptionGroup<"">, Group;
 def g_Group   : OptionGroup<"">;
+def gN_Group  : OptionGroup<"">, Group;
+def ggdbN_Group   : OptionGroup<"">, Group;
+def gTune_Group   : OptionGroup<"">, Group;
 def g_flags_Group : OptionGroup<"">;
 def i_Group   : OptionGroup<"">, Group;
 def clang_i_Group : OptionGroup<"">, Group;
@@ -1130,20 +1133,20 @@
 HelpText<"remap file source paths in debug info">;
 def g_Flag : Flag<["-"], "g">, Group,
   HelpText<"Generate source-level debug information">;
-def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,
+def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,
   HelpText<"Emit debug line number tables only">;
 def gmlt : Flag<["-"], "gmlt">, Alias;
-def g0 : Flag<["-"], "g0">, Group;
-def g1 : Flag<["-"], "g1">, Group, Alias;
-def g2 : Flag<["-"], "g2">, Group;
-def g3 : Flag<["-"], "g3">, Group;
-def ggdb : Flag<["-"], "ggdb">, Group;
-def ggdb0 : Flag<["-"], "ggdb0">, Alias;
-// Redirect ggdb1 to , not ,
-// because aliases of aliases aren't allowed.
-def ggdb1 : Flag<["-"], "ggdb1">, Alias;
-def ggdb2 : Flag<["-"], "ggdb2">, Alias;
-def ggdb3 : Flag<["-"], "ggdb3">, Alias;
+def g0 : Flag<["-"], "g0">, Group;
+def g1 : Flag<["-"], "g1">, Group, Alias;
+def g2 : Flag<["-"], "g2">, Group;
+def g3 : Flag<["-"], "g3">, Group;
+def ggdb : Flag<["-"], "ggdb">, Group;
+def ggdb0 : Flag<["-"], "ggdb0">, Group;
+def ggdb1 : Flag<["-"], "ggdb1">, Group;
+def ggdb2 : Flag<["-"], "ggdb2">, Group;
+def ggdb3 : Flag<["-"], "ggdb3">, Group;
+def glldb : Flag<["-"], "glldb">, Group;
+def gsce : Flag<["-"], "gsce">, Group;
 def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group,
   HelpText<"Generate source-level debug information with dwarf version 2">;
 def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group,
Index: cfe/trunk/test/Driver/debug-options.c

r256104 - Driver part of debugger tuning.

2015-12-19 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Sat Dec 19 13:41:48 2015
New Revision: 256104

URL: http://llvm.org/viewvc/llvm-project?rev=256104&view=rev
Log:
Driver part of debugger tuning.

Adds driver options named -glldb and -gsce to mean -g plus tuning for
lldb and SCE debuggers respectively; the existing -ggdb option does
the same for gdb. Existing options -ggdb0, -ggdb1 etc. unpack into
-ggdb -g.  (There will not be -glldb or -gsce options.) The
tuning gets a target-specific default in the driver, and is passed
into cc1 with the new -debugger-tuning option.

As fallout, fixes where '-gsplit-dwarf -g0' would ignore the -g0 part
on Linux.

Differential Revision: http://reviews.llvm.org/D15651

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/debug-options.c
cfe/trunk/test/Driver/split-debug.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=256104&r1=256103&r2=256104&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Sat Dec 19 13:41:48 2015
@@ -1514,8 +1514,11 @@ In these cases, you can use the flag ``-
 Note that these flags should appear after the corresponding profile
 flags to have an effect.
 
+Controlling Debug Information
+-
+
 Controlling Size of Debug Information
--
+^
 
 Debug info kind generated by Clang can be set by one of the flags listed
 below. If multiple flags are present, the last one is used.
@@ -1559,6 +1562,21 @@ below. If multiple flags are present, th
 
   Generate complete debug info.
 
+Controlling Debugger "Tuning"
+^
+
+While Clang generally emits standard DWARF debug info (http://dwarfstd.org),
+different debuggers may know how to take advantage of different specific DWARF
+features. You can "tune" the debug info for one of several different debuggers.
+
+.. option:: -ggdb, -glldb, -gsce
+
+  Tune the debug info for the ``gdb``, ``lldb``, or Sony Computer Entertainment
+  debugger, respectively. Each of these options implies **-g**. (Therefore, if
+  you want both **-gline-tables-only** and debugger tuning, the tuning option
+  must come first.)
+
+
 Comment Parsing Options
 ---
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=256104&r1=256103&r2=256104&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sat Dec 19 13:41:48 2015
@@ -71,6 +71,9 @@ def d_Group   : OptionGroup<
 def f_Group   : OptionGroup<"">, Group;
 def f_clang_Group : OptionGroup<"">, 
Group;
 def g_Group   : OptionGroup<"">;
+def gN_Group  : OptionGroup<"">, Group;
+def ggdbN_Group   : OptionGroup<"">, Group;
+def gTune_Group   : OptionGroup<"">, Group;
 def g_flags_Group : OptionGroup<"">;
 def i_Group   : OptionGroup<"">, Group;
 def clang_i_Group : OptionGroup<"">, Group;
@@ -1130,20 +1133,20 @@ def fdebug_prefix_map_EQ
 HelpText<"remap file source paths in debug info">;
 def g_Flag : Flag<["-"], "g">, Group,
   HelpText<"Generate source-level debug information">;
-def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,
+def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,
   HelpText<"Emit debug line number tables only">;
 def gmlt : Flag<["-"], "gmlt">, Alias;
-def g0 : Flag<["-"], "g0">, Group;
-def g1 : Flag<["-"], "g1">, Group, Alias;
-def g2 : Flag<["-"], "g2">, Group;
-def g3 : Flag<["-"], "g3">, Group;
-def ggdb : Flag<["-"], "ggdb">, Group;
-def ggdb0 : Flag<["-"], "ggdb0">, Alias;
-// Redirect ggdb1 to , not ,
-// because aliases of aliases aren't allowed.
-def ggdb1 : Flag<["-"], "ggdb1">, Alias;
-def ggdb2 : Flag<["-"], "ggdb2">, Alias;
-def ggdb3 : Flag<["-"], "ggdb3">, Alias;
+def g0 : Flag<["-"], "g0">, Group;
+def g1 : Flag<["-"], "g1">, Group, Alias;
+def g2 : Flag<["-"], "g2">, Group;
+def g3 : Flag<["-"], "g3">, Group;
+def ggdb : Flag<["-"], "ggdb">, Group;
+def ggdb0 : Flag<["-"], "ggdb0">, Group;
+def ggdb1 : Flag<["-"], "ggdb1">, Group;
+def ggdb2 : Flag<["-"], "ggdb2">, Group;
+def ggdb3 : Flag<["-"], "ggdb3">, Group;
+def glldb : Flag<["-"], "glldb">, Group;
+def gsce : Flag<["-"], "gsce">, Group;
 def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group,
   HelpText<"Generate source-level debug information with dwarf version 2">;
 def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group,

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 

[PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility

2015-12-19 Thread Ehsan Akhgari via cfe-commits
ehsan created this revision.
ehsan added reviewers: rnk, rsmith.
ehsan added a subscriber: cfe-commits.

This fixes PR25875.  When the trailing comma in a macro argument list is
elided, we need to treat it similarly to the case where a variadic macro
misses one actual argument.

http://reviews.llvm.org/D15670

Files:
  include/clang/Lex/Token.h
  lib/Lex/PPMacroExpansion.cpp
  lib/Lex/TokenLexer.cpp
  test/Preprocessor/microsoft-ext.c

Index: test/Preprocessor/microsoft-ext.c
===
--- test/Preprocessor/microsoft-ext.c
+++ test/Preprocessor/microsoft-ext.c
@@ -34,3 +34,12 @@
 
 MAKE_FUNC(MAK, ER, int a, _COMMA, int b);
 // CHECK: void func(int a , int b) {}
+
+#define macro(a, b) (a - b)
+void function(int a);
+#define COMMA_ELIDER(...) \
+  macro(x, __VA_ARGS__); \
+  function(x, __VA_ARGS__);
+COMMA_ELIDER();
+// CHECK: (x - );
+// CHECK: function(x);
Index: lib/Lex/TokenLexer.cpp
===
--- lib/Lex/TokenLexer.cpp
+++ lib/Lex/TokenLexer.cpp
@@ -154,12 +154,17 @@
   // Remove the comma.
   ResultToks.pop_back();
 
-  // If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
-  // then removal of the comma should produce a placemarker token (in C99
-  // terms) which we model by popping off the previous ##, giving us a plain
-  // "X" when __VA_ARGS__ is empty.
-  if (!ResultToks.empty() && ResultToks.back().is(tok::hashhash))
-ResultToks.pop_back();
+  if (!ResultToks.empty()) {
+// If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
+// then removal of the comma should produce a placemarker token (in C99
+// terms) which we model by popping off the previous ##, giving us a plain
+// "X" when __VA_ARGS__ is empty.
+if (ResultToks.back().is(tok::hashhash))
+  ResultToks.pop_back();
+
+// Remember that this comma was elided.
+ResultToks.back().setFlag(Token::CommaAfterElided);
+  }
 
   // Never add a space, even if the comma, ##, or arg had a space.
   NextTokGetsSpace = false;
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -725,6 +725,7 @@
   // heap allocations in the common case.
   SmallVector ArgTokens;
   bool ContainsCodeCompletionTok = false;
+  bool FoundElidedComma = false;
 
   SourceLocation TooManyArgsLoc;
 
@@ -767,6 +768,10 @@
 // If we found the ) token, the macro arg list is done.
 if (NumParens-- == 0) {
   MacroEnd = Tok.getLocation();
+  if (!ArgTokens.empty() &&
+  ArgTokens.back().commaAfterElided()) {
+FoundElidedComma = true;
+  }
   break;
 }
   } else if (Tok.is(tok::l_paren)) {
@@ -911,7 +916,7 @@
   // then we have an empty "()" argument empty list.  This is fine, even if
   // the macro expects one argument (the argument is just empty).
   isVarargsElided = MI->isVariadic();
-} else if (MI->isVariadic() &&
+} else if ((FoundElidedComma || MI->isVariadic()) &&
(NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
 (NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...) -> A()
   // Varargs where the named vararg parameter is missing: OK as extension.
Index: include/clang/Lex/Token.h
===
--- include/clang/Lex/Token.h
+++ include/clang/Lex/Token.h
@@ -85,6 +85,7 @@
 IgnoredComma = 0x80,   // This comma is not a macro argument separator (MS).
 StringifiedInMacro = 0x100, // This string or character literal is formed by
 // macro stringizing or charizing operator.
+CommaAfterElided = 0x200, // The comma following this token was elided (MS).
   };
 
   tok::TokenKind getKind() const { return Kind; }
@@ -297,6 +298,11 @@
   bool stringifiedInMacro() const {
 return (Flags & StringifiedInMacro) ? true : false;
   }
+
+  /// Returns true if the comma after this token was elided.
+  bool commaAfterElided() const {
+return (Flags & CommaAfterElided) ? true : false;
+  }
 };
 
 /// \brief Information about the conditional stack (\#if directives)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15674: [CodeGen] Fix assignments of inline layouts into the byref structure

2015-12-19 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added a reviewer: rjmccall.
vsk added a subscriber: cfe-commits.

[CodeGen] Fix assignments of inline layouts into the byref structure

When using blocks, a byref structure is created to represent the
closure. The "byref.layout" field of this structure is an i8*. However,
some 'inline' layouts are represented as i64's, not i8*'s.

Prior to r246985 we cast the i64 'inline' layout to an i8* before
assigning it into the byref structure. This patch brings the cast back
and adds a regression test.

rdar://23713871

http://reviews.llvm.org/D15674

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CGObjCRuntime.h
  test/CodeGenObjCXX/blocks.mm

Index: test/CodeGenObjCXX/blocks.mm
===
--- test/CodeGenObjCXX/blocks.mm
+++ test/CodeGenObjCXX/blocks.mm
@@ -68,3 +68,18 @@
 takeBlock(^{ useValues(ptr, this); });
   }
 };
+
+// rdar://problem/23713871
+// Check that we don't crash when using BLOCK_LAYOUT_STRONG.
+#pragma clang assume_nonnull begin
+@interface NSUUID @end
+#pragma clang assume_nonnull end
+
+struct Wrapper1 { NSUUID *Ref; };
+struct Wrapper2 { Wrapper1 W1; };
+
+@implementation B
+- (void) captureStrongRef {
+  __block Wrapper2 W2;
+}
+@end
Index: lib/CodeGen/CGObjCRuntime.h
===
--- lib/CodeGen/CGObjCRuntime.h
+++ lib/CodeGen/CGObjCRuntime.h
@@ -275,8 +275,9 @@
   const CodeGen::CGBlockInfo &blockInfo) = 0;
   virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule &CGM,
   const CodeGen::CGBlockInfo &blockInfo) = 0;
-  virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule &CGM,
-   QualType T) = 0;
+  virtual llvm::Value *BuildByrefLayout(CodeGen::CodeGenModule &CGM,
+CodeGen::CodeGenFunction &CGF,
+QualType T) = 0;
   virtual llvm::GlobalVariable *GetClassGlobal(const std::string &Name,
bool Weak = false) = 0;
 
Index: lib/CodeGen/CGObjCMac.cpp
===
--- lib/CodeGen/CGObjCMac.cpp
+++ lib/CodeGen/CGObjCMac.cpp
@@ -1054,8 +1054,9 @@
   llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule &CGM,
  const CGBlockInfo &blockInfo) override;
 
-  llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule &CGM,
-   QualType T) override;
+  llvm::Value *BuildByrefLayout(CodeGen::CodeGenModule &CGM,
+CodeGen::CodeGenFunction &CGF,
+QualType T) override;
 };
 
 class CGObjCMac : public CGObjCCommonMac {
@@ -2630,17 +2631,22 @@
 }
 
 
-llvm::Constant *CGObjCCommonMac::BuildByrefLayout(CodeGen::CodeGenModule &CGM,
-  QualType T) {
+llvm::Value *CGObjCCommonMac::BuildByrefLayout(CodeGen::CodeGenModule &CGM,
+   CodeGen::CodeGenFunction &CGF,
+   QualType T) {
   assert(CGM.getLangOpts().getGC() == LangOptions::NonGC);
   assert(!T->isArrayType() && "__block array variable should not be caught");
   CharUnits fieldOffset;
   RunSkipBlockVars.clear();
   bool hasUnion = false;
   if (const RecordType *record = T->getAs()) {
 BuildRCBlockVarRecordLayout(record, fieldOffset, hasUnion, true /*ByrefLayout */);
 llvm::Constant *Result = getBitmapBlockLayout(true);
-return Result;
+if (isa(Result))
+  return CGF.Builder.CreateIntToPtr(Result, CGM.Int8PtrTy,
+"byref.layout_cast");
+else
+  return Result;
   }
   llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy);
   return nullPtr;
Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -565,7 +565,8 @@
 return NULLPtr;
   }
 
-  llvm::Constant *BuildByrefLayout(CodeGenModule &CGM, QualType T) override {
+  llvm::Value *BuildByrefLayout(CodeGenModule &CGM, CodeGenFunction &CGF,
+QualType T) override {
 return NULLPtr;
   }
 
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -2242,7 +2242,7 @@
   }
 
   if (ByRefHasLifetime && HasByrefExtendedLayout) {
-auto layoutInfo = CGM.getObjCRuntime().BuildByrefLayout(CGM, type);
+auto layoutInfo = CGM.getObjCRuntime().BuildByrefLayout(CGM, *this, type);
 storeHeaderField(layoutInfo, getPointerSize(), "byref.layout");
   }
 }
___
cfe-commits mailing list
cfe