First Last Prev Next    No search results available
Details
: [llvmg++] Front-end attempts to return structure by value
Bug#: 148
: tools
: llvm-g++
Status: RESOLVED
Resolution: FIXED
: All
: All
: 1.0
: P2
: major
: 1.1

:
: compile-fail
:
:
  Show dependency tree - Show dependency graph
People
Reporter: John T. Criswell <criswell@uiuc.edu>
Assigned To: Chris Lattner <sabre@nondot.org>
:

Attachments
Reproduces the problem. (202 bytes, text/plain)
2003-11-21 16:54, John T. Criswell
Details


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2003-11-21 14:11
When compiling and linking the lshaped program (part of ATR), the symbol
_ZNK18OsiSolverInterface20getFractionalIndicesEd is defined twice in the
resulting bytecode file: once as an undefined symbol and once as a defined local
function (according to llvm-nm).

This causes the JIT problems; the first time it looks for the function, it
thinks it is external and attmepts to find it in the JIT's address space.  Later
on, the JIT finds the function definition and uses it properly.

I'm guessing this behavior is from the libraries used by gccld.
------- Comment #1 From John T. Criswell 2003-11-21 15:07:01 -------
Note that this occurs when gccld's optimizations are enabled or disabled (i.e.
it's not an optimizer problem).
------- Comment #2 From John T. Criswell 2003-11-21 16:45:06 -------
This is actually a bug in the g++ front end.

The front end is creating a function that returns an aggregate type (as opposed
to moving the aggregate type into the first parameter).  This causes there to be
two different typed functions with the same name.  Hence, the JIT goes looking
for the version returning the aggregate type, can't find it, and fails.

Now, the trick is: Can I reduce it to a usable test case?
------- Comment #3 From John T. Criswell 2003-11-21 16:54:07 -------
Created an attachment (id=30) [details]
Reproduces the problem.

This reproduces the problem when gccas has assertions that check for functions
that return aggregate types.
------- Comment #4 From Chris Lattner 2003-11-22 21:08:02 -------
Thanks for reducing this testcase John!

-Chris
------- Comment #5 From Chris Lattner 2003-11-25 01:56:08 -------
Note that, with the new assertion in the parser, this problem is blocking
building libstdc++.  :(

-Chris
------- Comment #6 From Chris Lattner 2003-11-25 02:21:11 -------
Testcase reduced to:

#include <vector>

std::vector<int> my_method ();
int main (){
  my_method ();
  return 0;
}

... next step, get rid of #include.
------- Comment #7 From Chris Lattner 2003-11-25 02:48:05 -------
Fixed.

Testcase here: 2003-11-25-ReturningOpaqueByValue.cpp

The patch:
$ diff -u llvm-types.c~ llvm-types.c
--- llvm-types.c~       2003-11-19 18:59:34.000000000 -0600
+++ llvm-types.c        2003-11-25 02:41:55.000000000 -0600
@@ -874,7 +874,7 @@
      * returning void and taking struct argument as it's first
      * parameter.
      */
-    if (RetType->ID == StructTyID) {
+    if (RetType->ID == StructTyID || RetType->ID == OpaqueTyID) {
       FirstArgTy = llvm_type_get_pointer(RetType);
       NumArgs++;
       RetType = VoidTy;

First Last Prev Next    No search results available