Page MenuHomePhabricator

[CodeGen] make isTriviallyRecursive handle more trivial recursion
AbandonedPublic

Authored by george.burgess.iv on Apr 14 2020, 1:27 PM.

Details

Summary

This function was not catching all forms of trivial recursion, meaning:

void *memcpy(void *a, const void *b, size_t n) {
  return __builtin_memcpy(a, b, n);
}

would be considered trivially recursive, whereas

void *memcpy(void *a, const void *b, size_t n) {
  return memcpy(a, b, n);
}

would not.

Diff Detail

Event Timeline

Could you go into a little more detail what problem you're trying to resolve?

isTriviallyRecursive is specifically a narrow hack to handle weird cases where a function is trying to hide the fact that it's calling itself, in ways that would convince gcc that the called function is different. If a function is actually explicitly calling itself, it's on the user to make sure they don't write an infinite loop, I think.

george.burgess.iv abandoned this revision.Apr 14 2020, 2:23 PM

Nothing in the real world :)

I was writing test-cases for a soon-to-be-in-your-inbox patch, and initially wrote memcpy recursion in terms of memcpy, rather than __builtin_memcpy. Wasn't sure if this was an oversight, or intended. The comments around the use of this through isTriviallyRecursive said "a[n externally-available] function that calls itself is clearly not equivalent to the real implementation." Since this behavior is intentional, I'll see if I can make that commentary a bit more clear instead.

Thanks!