On 3 January 2013 17:38, Johannes Pfau <nos...@example.com> wrote: > Am Thu, 3 Jan 2013 16:47:00 +0000 > schrieb Iain Buclaw <ibuc...@ubuntu.com>: > > > On 3 January 2013 16:12, Johannes Pfau <nos...@example.com> wrote: > > > > > Then there's the question why the outer function has to be a > > > template as well for this to happen: It's because if it's not a > > > template, gdc uses a completely different code path: There's a > > > "!gen.functionNeedsChain (f)" check in outputFunction which is false > > > for the failing case. (cgraph_finalize_function marks the function > > > as reachable) > > > > > > > > That might be just it then... > > I admit I don't really know why this check is needed but even if I try > to call cgraph_finalize_function for indirectLess the backend dies with > the same error. Actually my statement above was wrong, > cgraph_finalize_function only marks the function as reachable if it's > TREE_PUBLIC/. The not-templated case works even without > cgraph_finalize_function so that's not the issue. > > I would have thought that it be a little more factors than that. Remember, TREE_PUBLIC only means whether or not the function is callable outside of the module we are compiling (TREE_PUBLIC=0 means that the function is not marked as global in the assembly output).
I think it would be a mixture between what DECL_CONTEXT is set for the affected functions, and the order that the functions generated are passed to cgraph_finalize_function. > > > > I have been rolling round my head to remove the notion of functions > > nested in functions within the D codegen. Having only RECORD and > > UNION types set in DECL_CONTEXT. So all public functions are > > TREE_PUBLIC=1 (unless there's some overriding attribute), and all > > nested functions are TREE_PUBLIC=0. > > I see! That's why percolateDown is public, but isn't it essentially a > nested function in the test case? > > What I said was an idea that *could* be implemented, but is not yet. See ObjectFile::setupSymbolStorage for why templates are public by default... -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';