<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 28, 2016, at 9:47 AM, David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">OK - good to know. (not sure we're talking about pessimizing it - just not adding a new/possible optimization, to be clear)<br class=""></div></div></blockquote><div><br class=""></div><div>This does not seem that clear to me. The motivation seems to be able to create global table of StringRef, which we don’t do because the lack fo constexpr of static initializers right now.</div><div>Moving forward it would mean making clang a lot slower when built with MSVC if we were going this route.</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><br class="">Just out of curiosity - are there particular reasons you prefer or need to ship an MSVC built version, rather than a bootstrapped Clang?</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Nov 28, 2016 at 9:24 AM Robinson, Paul <<a href="mailto:paul.robinson@sony.com" class="">paul.robinson@sony.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="gmail_msg m_5859138549290728135WordSection1"><p class="MsoNormal gmail_msg" style="margin-left:.5in">So I wouldn't personally worry too much about performance degredation when built with MSVC - if, when building a stage 2 on Windows (building Clang with MSVC build Clang) you do end up with a compiler with the desired
performance characteristics - then that's probably sufficient.<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" class="gmail_msg"><u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><a name="m_5859138549290728135__MailEndCompose" class="gmail_msg"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" class="gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></span></a></p>
</div></div><div lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="gmail_msg m_5859138549290728135WordSection1"><p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" class="gmail_msg">Hold on there—we deliver an MSVC-built Clang to our licensees, and I would really rather not pessimize it.<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" class="gmail_msg">--paulr<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" class="gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt" class="gmail_msg">
<div class="gmail_msg">
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in" class="gmail_msg"><p class="MsoNormal gmail_msg"><b class="gmail_msg"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" class="gmail_msg">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" class="gmail_msg"> llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]
<b class="gmail_msg">On Behalf Of </b>David Blaikie via llvm-dev<br class="gmail_msg">
<b class="gmail_msg">Sent:</b> Friday, November 25, 2016 8:52 AM<br class="gmail_msg">
<b class="gmail_msg">To:</b> Mueller-Roemer, Johannes Sebastian; Malcolm Parsons; Hal Finkel; <a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a></span></p></div></div></div></div></div><div lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="gmail_msg m_5859138549290728135WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt" class="gmail_msg"><div class="gmail_msg"><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in" class="gmail_msg"><p class="MsoNormal gmail_msg"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" class="gmail_msg"><br class="gmail_msg">
<b class="gmail_msg">Subject:</b> Re: [llvm-dev] RFC: Constructing StringRefs at compile time<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p></div></div></div></div></div><div lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="gmail_msg m_5859138549290728135WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt" class="gmail_msg"><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p>
<div class="gmail_msg"><p class="MsoNormal gmail_msg" style="margin-bottom:12.0pt"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p>
<div class="gmail_msg">
<div class="gmail_msg"><p class="MsoNormal gmail_msg">On Fri, Nov 25, 2016 at 6:10 AM Mueller-Roemer, Johannes Sebastian via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u class="gmail_msg"></u><u class="gmail_msg"></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in" class="gmail_msg"><p class="MsoNormal gmail_msg">What about going for<br class="gmail_msg">
<br class="gmail_msg">
template<unsigned N><br class="gmail_msg">
constexpr StringRef(const char (&Str)[N])<br class="gmail_msg">
<br class="gmail_msg">
and avoiding strlen entirely for string literals?<u class="gmail_msg"></u><u class="gmail_msg"></u></p>
</blockquote>
<div class="gmail_msg"><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p>
</div>
<div class="gmail_msg"><p class="MsoNormal gmail_msg">You'd at least want an assert in there (that N - 1 == strlen(Str)) in case a StringRef is ever constructed from a non-const char buffer that's only partially filled.<br class="gmail_msg">
<br class="gmail_msg">
But if we can write this in such a way that it performs well on good implementations - that seems sufficient. If getting good performance out of the compiler means bootstrapping - that's pretty much the status quo already, as I understand it.<br class="gmail_msg">
<br class="gmail_msg">
So I wouldn't personally worry too much about performance degredation when built with MSVC - if, when building a stage 2 on Windows (building Clang with MSVC build Clang) you do end up with a compiler with the desired performance characteristics - then that's
probably sufficient.<u class="gmail_msg"></u><u class="gmail_msg"></u></p>
</div>
<div class="gmail_msg"><p class="MsoNormal gmail_msg"> <u class="gmail_msg"></u><u class="gmail_msg"></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in" class="gmail_msg"><p class="MsoNormal gmail_msg"><br class="gmail_msg">
-----Original Message-----<br class="gmail_msg">
From: llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev-bounces@lists.llvm.org</a>] On Behalf Of Malcolm Parsons via llvm-dev<br class="gmail_msg">
Sent: Friday, November 25, 2016 13:34<br class="gmail_msg">
To: Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="gmail_msg" target="_blank">hfinkel@anl.gov</a>><br class="gmail_msg">
Cc: <a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
Subject: Re: [llvm-dev] RFC: Constructing StringRefs at compile time<br class="gmail_msg">
<br class="gmail_msg">
On 24 November 2016 at 15:04, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="gmail_msg" target="_blank">hfinkel@anl.gov</a>> wrote:<br class="gmail_msg">
>> Creating constexpr StringRefs isn't trivial as strlen isn't portably<br class="gmail_msg">
>> constexpr and std::char_traits<char>::length is only constexpr in<br class="gmail_msg">
>> C++17.<br class="gmail_msg">
><br class="gmail_msg">
> Why don't we just create our own traits class that has a constexpr length, and then we can switch over to the standard one when we switch to C++17?<br class="gmail_msg">
<br class="gmail_msg">
GCC and Clang treat __builtin_strlen as constexpr.<br class="gmail_msg">
MSVC 2015 doesn't support C++14 extended constexpr. I don't know how well it optimises a recursive strlen.<br class="gmail_msg">
<br class="gmail_msg">
This works as an optimisation for GCC and Clang, and doesn't make things worse for MSVC:<br class="gmail_msg">
<br class="gmail_msg">
/// Construct a string ref from a cstring.<br class="gmail_msg">
LLVM_ATTRIBUTE_ALWAYS_INLINE<br class="gmail_msg">
+#if __has_builtin(__builtin_strlen)<br class="gmail_msg">
+ /*implicit*/ constexpr StringRef(const char *Str)<br class="gmail_msg">
+ : Data(Str), Length(Str ? __builtin_strlen(Str) : 0) {} #else<br class="gmail_msg">
/*implicit*/ StringRef(const char *Str)<br class="gmail_msg">
: Data(Str), Length(Str ? ::strlen(Str) : 0) {}<br class="gmail_msg">
+#endif<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Malcolm Parsons<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
LLVM Developers mailing list<br class="gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
LLVM Developers mailing list<br class="gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u class="gmail_msg"></u><u class="gmail_msg"></u></p>
</blockquote>
</div>
</div>
</div></div></div></blockquote></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>