Skip to content

Commit bfe9860

Browse files
committed
add some notes about the portability model
llvm-svn: 38977
1 parent aecc057 commit bfe9860

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

clang/NOTES.txt

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,50 @@
11

2+
//===---------------------------------------------------------------------===//
23

34
To time GCC preprocessing speed without output, use:
45
"time gcc -MM file"
6+
This is similar to -Eonly.
7+
8+
//===---------------------------------------------------------------------===//
59

610
Interesting fact:
711
clang -Eonly INPUTS/carbon-header-C-E.c
812

9-
is faster than:
13+
is much faster than:
1014
wc -w INPUTS/carbon-header-C-E.c
1115
!!
1216

17+
//===---------------------------------------------------------------------===//
18+
19+
The 'portability' model in clang is sufficient to catch translation units (or
20+
their parts) that are not portable, but it doesn't help if the system headers
21+
are non-portable and not fixed. An alternative model that would be easy to use
22+
is a 'tainting' scheme. Consider:
23+
24+
inline int foo() {
25+
#ifdef __i386__
26+
return 1;
27+
#else
28+
return 2;
29+
#endif
30+
}
31+
32+
It would be trivial to mark 'foo' as being non-portable (tainted) instead of
33+
marking the entire translation unit. Then, if foo is never called/used by the
34+
current translation unit, the t-u wouldn't be marked non-portable. However,
35+
there is no good way to handle stuff like:
36+
37+
extern int X, Y;
38+
39+
#ifndef __POWERPC__
40+
#define X Y
41+
#endif
42+
43+
int bar() { return X; }
44+
45+
When compiling for powerpc, the #define is skipped, so it doesn't know that bar
46+
uses a #define that is set on some other target. In practice, limited cases
47+
could be handled by scanning the skipped region of a #if, but the fully general
48+
case cannot be implemented efficiently.
49+
50+
//===---------------------------------------------------------------------===//

0 commit comments

Comments
 (0)