Optimization

共 4 篇文章。

clang优化器的一个问题

• Development

📜 历史文件已不具备现实意义

今天的一个偶然的发现。FreeBSD clang version 3.6.1 (tags/RELEASE_361/final 237755) 20150525。clang 3.8 2015/07/20 的版本同样有此问题。

之前, FreeBSD 上 strndup(3) 的实现是这样的:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
char *
strndup(const char *str, size_t n)
{
	size_t len;
	char *copy;

	len = strnlen(str, n);
	if ((copy = malloc(len + 1)) == NULL)
		return (NULL);
	memcpy(copy, str, len);
	copy[len] = '\0';
	return (copy);
}

而 OpenBSD 上的实现,则是这样的:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
char *
strndup(const char *str, size_t maxlen)
{
	char *copy;
	size_t len;

	len = strnlen(str, maxlen);
	copy = malloc(len + 1);
	if (copy != NULL) {
		(void)memcpy(copy, str, len);
		copy[len] = '\0';
	}

	return copy;
}
阅读全文… ( 本文约 304 字,阅读大致需要 1 分钟 )

gcc 3.4 listed in FreeBSD 5.3-R todo list

• Development

It’s our pleasure to see GCC 3.4 import to be listed in FreeBSD 5.3-R todo list. Unfortunatelly, gmake is now a required prerequisite when building GCC 3.4, this may slow down the import progress.

阅读全文… ( 本文约 125 字,阅读大致需要 1 分钟 )

Profile-based compile optimization

• Development

junsu has pointed out that gcc has the ablity to do profile, record the data and optimize the generated code according to the data. The nearest compiler guru I can visit is Prof. Husheng LIAO (sorry, the link here is not available to the Internet at the time writing, but this is hopefully to be changed soon) who recently concentrate his research in optimization for the Java Language Compiling process.

Further information will be available here soon.

参与评论