Hi all,
In the LLVM backend for the DDC compiler, since version 2.7 I have
been doing the following:
declare external ccc i32 @some_fn(%struct.Obj* ) align 8
; bunch more declarations and code.
define external ccc i32 @some_fn(%struct.Obj* %_p_vn)
{
entry:
but now I'm getting an error at the function definition saying:
error: invalid redefinition of function 'some_fn'
So my questions are:
a) Is this a bug? Should llvm be allowing this?
b) Is there a good reason why I should not be allowed both declare
and a defined a function in the same module?
c) Am I doing something else wrong.
Cheers,
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
Erik de Castro Lopo <mle+cl at mega-nerd.com> writes: [snip]> declare external ccc i32 @some_fn(%struct.Obj* ) align 8 > > ; bunch more declarations and code. > > define external ccc i32 @some_fn(%struct.Obj* %_p_vn)[snip]> c) Am I doing something else wrong.I guess that the problem is with the missing `align 8' on the `define'.
Óscar Fuentes wrote:> Erik de Castro Lopo <mle+cl at mega-nerd.com> writes: > > [snip] > > > declare external ccc i32 @some_fn(%struct.Obj* ) align 8 > > > > ; bunch more declarations and code. > > > > define external ccc i32 @some_fn(%struct.Obj* %_p_vn) > [snip] > > c) Am I doing something else wrong. > > I guess that the problem is with the missing `align 8' on the `define'.Nope, if I add an 'align 8' to the definition, I still get the same error. Here is a minimal test case: declare i32 @plus_two(i32) define i32 @plus_two(i32 %x) { %1 = add nsw i32 %x, 2 ret i32 %1 } for which llc gives the error: llc: a.ll:4:12: error: invalid redefinition of function 'plus_two' define i32 @plus_two(i32 %x) { Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
On Sun, Nov 27, 2011 at 3:10 PM, Erik de Castro Lopo <mle+cl at mega-nerd.com>wrote:> b) Is there a good reason why I should not be allowed both declare > and a defined a function in the same module? >I don't know the reason, but I do remember that LLVM does not allow you to declare a function and define it. Reid -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111127/5b3ad319/attachment.html>
Reid Kleckner wrote:> On Sun, Nov 27, 2011 at 3:10 PM, Erik de Castro Lopo > <mle+cl at mega-nerd.com>wrote: > > > b) Is there a good reason why I should not be allowed both declare > > and a defined a function in the same module? > > > > I don't know the reason, but I do remember that LLVM does not allow you to > declare a function and define it.Ok, thanks. I'll have to fix my code generator. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/