[cfe-commits] [PATCH][MS][Review request] - Late Microsoft template parsing

Francois Pichet pichet2000 at gmail.com
Thu Apr 21 17:17:08 PDT 2011


On Thu, Apr 21, 2011 at 2:45 PM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
> On Apr 21, 2011, at 4:53 AM, Francois Pichet wrote:
>
>>
>> There is a 4-5% speed improvement when doing a clang self hosting with
>> delayed template parsing.
>> ./configure --enable-optimized CC=/usr/local/bin/clang
>> CXX=/usr/local/bin/clang++
>> make CXXFLAGS=-fdelayed-template-parsing.
>>
>> On my Mac Mini this is shaving about 90 seconds out of 33 minutes for
>> a complete build. The resulting binary passes all the clang test.
>
> Very interesting! Out of curiosity, is delayed template parsing compatible with the standard ?

I think not. My goal with this patch is MSVC compatibility. With
delayed template parsing all the symbols of the translation unit is
available during template parsing.
This is not standard as I understand it:

example:
template <class T>
void foo() {
    foo2();   // this compile even if foo2() is declated after foo
}

void foo2() {}

Now dgregor mentioned on the IRC channel a while back that it would be
possible to somehow modify name lookup to not consider names declared
after "foo" in standard mode delayed template parsing
(-fdelayed-template-parsing without no -fms-extensions). I have no
idea how difficult is it.



more benchmarking:

given test.cpp:
===========
#include <algorithm>
#include <complex>
#include <exception>
#include <list>
#include <stack>
#include <bitset>
#include <fstream>
#include <locale>
#include <stdexcept>
#include <functional>
#include <map>
#include <strstream>
#include <iomanip>
#include <memory>
#include <streambuf>
#include <ios>
#include <new>
#include <string>
#include <iosfwd>
#include <numeric>
#include <typeinfo>
#include <iostream>
#include <ostream>
#include <utility>
#include <istream>
#include <queue>
#include <valarray>
#include <iterator>	
#include <set>
#include <vector>
#include <deque>
#include <limits>
#include <sstream>	


int main(){
  return 0;
}
====


$ time /usr/local/bin/clang -fsyntax-only  test.cpp
real	0m0.538s
user	0m0.484s
sys	0m0.046s

$time /usr/local/bin/clang -fsyntax-only -fdelayed-template-parsing test.cpp
real	0m0.367s
user	0m0.319s
sys	0m0.043s



More information about the cfe-commits mailing list