[LLVMbugs] [Bug 11779] New: 'ret' instruction unwanted interaction

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 16 19:55:24 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=11779

             Bug #: 11779
           Summary: 'ret' instruction unwanted interaction
           Product: libraries
           Version: 3.0
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: mooneer at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


I am in the process of porting the Kite programming language to LLVM. While
implementing the "return" statement, I encountered a very unusual problem.

Example Kite code:

method x()
[
    return 1;
];

x()|print;

Generated LLVM intermediate code:


; ModuleID = '__root_module'

@0 = internal unnamed_addr constant [5 x i8] c"x__o\00"
@1 = internal unnamed_addr constant [6 x i8] c"print\00"

define i32* @__static_init____o(i32* %this) {
entry:
  %0 = alloca i32*
  store i32* %this, i32** %0
  %1 = call i32* @kite_method_alloc(i32* bitcast (i32* (i32*)* @x__o to i32*),
i32 1)
  %2 = load i32** %0
  %3 = call i32** @kite_dynamic_object_get_property(i32* %2, i8* getelementptr
inbounds ([5 x i8]* @0, i32 0, i32 0), i1 true)
  store i32* %1, i32** %3
  %4 = load i32** %0
  %5 = call i32* @x__o(i32* %4)
  %6 = call i32* @kite_find_funccall(i32* %5, i8* getelementptr inbounds ([6 x
i8]* @1, i32 0, i32 0), i32 1)
  %7 = bitcast i32* %6 to i32* (i32*)*
  %8 = call i32* %7(i32* %5)
  ret i32* %8
}

define i32* @x__o(i32* %this) {
entry:
  %0 = alloca i32*
  store i32* %this, i32** %0
  %1 = call i32* @System__integer__obj__i(i32 1)
  ret i32* %1
  ret i32* %1
}

declare i32* @System__integer__obj__i(i32)

declare i32* @kite_method_alloc(i32*, i32)

declare i32** @kite_dynamic_object_get_property(i32*, i8*, i1)

declare i32* @kite_find_funccall(i32*, i8*, i32)

Execution result:

System.exceptions.NotImplemented: Could not find method print that takes 0
argument(s).
    in (main program) + 0x7a

GDB shows that System__integer__obj__i is returning the correct result, but
kite_find_funccall receives a different first parameter than that which obj__i
returns. I've worked around the issue for the time being and suppressed the
generation of one of the ret instructions, but logic dictates that anything
below the first 'ret' statement is effectively not there at all.

TO DUPLICATE:

1. Clone the Git repository: https://github.com/tmiw/kite-llvm.
2. Comment out lines 1312-1313 and 1325 in src/codegen/llvm_node_codegen.cpp.
3. vim Makefile
4. make
5. ./kite example_code.kt (where example_code.kt is the example Kite code
above). ./kite -xd will display the LLVM intermediate code without executing
it.

Let me know if you need anything else. Thanks!

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list