Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler bug: "cannot convert type" error on first function call, result on second #9947

Closed
kmsquire opened this issue Jan 28, 2015 · 2 comments
Labels
kind:bug Indicates an unexpected problem or unintended behavior

Comments

@kmsquire
Copy link
Member

While debugging #9936, I came up with the following minimal code example that exhibits some strange behavior:

julia> function badfn()
           if 1 == 0
               1
           else
               min(uint128(2),1)
           end
       end
badfn (generic function with 1 method)

julia> badfn()
ERROR: error compiling badfn: cannot convert type to a julia type

julia> badfn()
0x00000000000000000000000000000001

julia> @code_llvm badfn()
ERROR: error compiling badfn: cannot convert type to a julia type
 in code_llvm at reflection.jl:158
 in code_llvm at reflection.jl:159

julia> versioninfo()
Julia Version 0.4.0-dev+2945
Commit a503afb* (2015-01-27 19:55 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin14.0.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

This happens on both v0.3 and v0.4.

@kmsquire kmsquire added the kind:bug Indicates an unexpected problem or unintended behavior label Jan 28, 2015
@JeffBezanson
Copy link
Sponsor Member

This patch should work. If somebody wants to add a test and commit it that would be great. otherwise I'll get to it eventually.

--- a/src/intrinsics.cpp
+++ b/src/intrinsics.cpp
@@ -878,9 +878,10 @@ static Value *emit_intrinsic(intrinsic f, jl_value_t **args
                                                  emit_expr(args[2], ctx, false)
         }
         else if (t1 == t2 && llt1 == llt2 && llt1 != jl_pvalue_llvmt) {
-            ifelse_result = builder.CreateSelect(isfalse,
-                                                 auto_unbox(args[3], ctx),
-                                                 auto_unbox(args[2], ctx));
+            Value *x = auto_unbox(args[3], ctx);
+            ifelse_result = tpropagate(x, builder.CreateSelect(isfalse,
+                                                               x,
+                                                               auto_unbox(args[2], ctx)));
         }
         else {
             Value *arg1 = boxed(emit_expr(args[3],ctx,false), ctx, expr_type(ar

@kmsquire
Copy link
Member Author

I'll do it.

@kmsquire kmsquire mentioned this issue Jan 29, 2015
JeffBezanson added a commit that referenced this issue Feb 6, 2015
(cherry picked from commit 2d684a7)
ref PR #9952

Conflicts:
	test/core.jl

adjust Uint construction syntax for 0.3
tkelman pushed a commit that referenced this issue Feb 6, 2015
Add more types to `searchsorted` tests

Testing with *Int128 types is triggering an compiler error, so they are
commented out for now.  We can add them back to the once #9947 is fixed

Convert Unsigned to Signed before subtraction

Fix Uint handling for `searchsortedlast`

Re-enable `*Int128` tests for searchsorted`

Previously blocked by #9947

Make `Float16`, `*Int128` promote to `Float32`

(cherry picked from commit c402273,
syntax adjusted for 0.3)
ref PR #9936
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants