[llvm-commits] [llvm] r62107 - in /llvm/trunk: lib/Transforms/IPO/Inliner.cpp lib/Transforms/Utils/InlineCost.cpp test/Transforms/Inline/2009-01-12-RecursiveInline.ll

Duncan Sands baldrick at free.fr
Wed Jan 14 00:50:46 PST 2009

Hi Dale,

> I don't agree, I think it was indented funny before.  Let's get the  
> whole context:

it still looks funny to me, but I don't care enough to argue.

> > Also, it is
> > probably OK to inline a function with weak linkage (mayBeOverridden)  
> > into
> > itself.
> Maybe so.  What happens if different compilations make different  
> inlining decisions?  Is the linker allowed to require that all copies  
> of a weak function are the same?  I think not.

None of that matters.  Consider a function f with weak linkage that
calls itself:

define weak void @f(...) {
	call void @f(...)

There are two cases:
(1) this is the function that is finally used, i.e. the body isn't
overridden by something else at link time.  In this case it is fine
to inline f into itself.
(2) this is not the function that is finally used, i.e. the body is
discarded at link time.  Since the body is discarded, it is fine to
inline f into itself because the result is discarded anyway!

That said, this seems like a particularly unimportant optimization.



More information about the llvm-commits mailing list