[LLVMdev] Getting rid of the DoesntAccessMemoryFns and OnlyReadsMemoryFns tables

Duncan Sands baldrick at free.fr
Fri Nov 23 07:18:19 PST 2007

The DoesntAccessMemoryFns and OnlyReadsMemoryFns tables are used
by alias analysis to specify which standard functions don't access
memory or only read memory.  However gcc now automatically supplies
this information to us.  I checked on my x86 linux box what gcc gives
for the functions listed in those tables.  While gcc mostly agrees
with them, there are the following differences (using -ffast-math,
otherwise gcc says that a bunch of math ones are readonly because
they depend on the floating point mode; I think gcc is correct to
say this):

function	LLVM says	gcc says
--------	---------	--------
isalnum		readnone	readonly
isalpha		readnone	readonly
iscntrl		readnone	readonly
isgraph		readnone	readonly
islower		readnone	readonly
isprint		readnone	readonly
ispunct		readnone	readonly
isspace		readnone	readonly
isupper		readnone	readonly
tolower		readnone	readonly
toupper		readnone	readonly
iswalnum	readnone	readonly
iswalpha	readnone	readonly
iswcntrl	readnone	readonly
iswdigit	readnone	readonly
iswgraph	readnone	readonly
iswlower	readnone	readonly
iswprint	readnone	readonly
iswpunct	readnone	readonly
iswspace	readnone	readonly
iswupper	readnone	readonly
iswxdigit	readnone	readonly
towlower	readnone	readonly
towupper	readnone	readonly
iswctype	readnone	nothing
towctrans	readnone	nothing
btowc		readnone	nothing
wctob		readnone	nothing
nan		readonly	readnone
nanf		readonly	readnone
wcscoll		readonly	nothing
feof		readonly	nothing
ferror		readonly	nothing
fileno		readonly	nothing
feof_unlocked	readonly	nothing
ferror_unlocked	readonly	nothing
fileno_unlocked	readonly	nothing

I think gcc marks all those alphabetical routines "readonly" rather
than "readnone" because they depend on the locale; so I guess gcc
is right about those ones.

That leaves the following list for which gcc doesn't say either
readnone or readonly on my machine: iswctype, towctrans, btowc, wctob, wcscoll,
feof, ferror, fileno, feof_unlocked, ferror_unlocked, fileno_unlocked.

We could keep some small tables just for these, or nuke the tables altogether
and assume that gcc knows what it is doing.  In my opinion we should believe
gcc and nuke the tables.



More information about the llvm-dev mailing list