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

Binding non-alias arguments with type parameters fails in llvm #375

Closed
brson opened this issue May 16, 2011 · 5 comments
Closed

Binding non-alias arguments with type parameters fails in llvm #375

brson opened this issue May 16, 2011 · 5 comments

Comments

@brson
Copy link
Contributor

brson commented May 16, 2011

make stage2/std.o CFG_DISABLE_OPTIMIZE=1 results in the following:

Instruction does not dominate all uses!
  %20 = load %tydesc** %19
  store %tydesc* %20, %tydesc** %7
Broken module found, compilation aborted!
Stack dump:
0.      Running pass 'Function Pass Manager' on module 'rust_out'.
1.      Running pass 'Module Verifier' on function '@_rust_thunk1273_deque_create_grow'
Aborted

The following test cases reproduces:

fn grow[T](vec[T] elts) {
  auto copy_op = bind grow[T](elts);
}

fn main() {
}

And fails with the following:

Instruction does not dominate all uses!
  %19 = load %tydesc** %18
  store %tydesc* %19, %tydesc** %6
Broken module found, compilation aborted!
Stack dump:
0.      Running pass 'Function Pass Manager' on module 'rust_out'.
1.      Running pass 'Module Verifier' on function '@_rust_thunk17_grow'
Aborted

The code generated for the thunk in the test case looks like:

define internal fastcc void @_rust_thunk17_grow(i1*, %task*, %10*) {
allocas:
  %3 = alloca [1 x %tydesc*]
  %4 = alloca %tydesc
  %5 = alloca %13*
  br label %copy_args

copy_args:                                        ; preds = %allocas                                                                              
  br label %derived_tydescs

derived_tydescs:                                  ; preds = %copy_args                                                                            
  %6 = getelementptr [1 x %tydesc*]* %3, i32 0, i32 0
  store %tydesc* %19, %tydesc** %6
  %7 = load %tydesc* @_rust_tydesc11_grow
  store %tydesc %7, %tydesc* %4
  %8 = getelementptr %tydesc* %4, i32 0, i32 0
  %9 = getelementptr [1 x %tydesc*]* %3, i32 0, i32 0
  %10 = getelementptr %tydesc* %4, i32 0, i32 0
  store %tydesc** %9, %tydesc*** %10
  %11 = getelementptr %tydesc* %4, i32 0, i32 1
  store i32 ptrtoint (i1** getelementptr (i1** null, i32 1) to i32), i32* %11
  %12 = getelementptr %tydesc* %4, i32 0, i32 2
  store i32 ptrtoint (i1** getelementptr (%15* null, i64 0, i32 1) to i32), i32* %12
  br label %13

; <label>:13                                      ; preds = %derived_tydescs                                                                      
  %14 = bitcast %10* %2 to %20*
  %15 = getelementptr %20* %14, i32 0, i32 1, i32 1
  %16 = getelementptr %22* %15, i32 0, i32 1
  %17 = load %10** %16
  %18 = getelementptr %20* %14, i32 0, i32 1, i32 3, i32 0
  %19 = load %tydesc** %18
  %20 = getelementptr %20* %14, i32 0, i32 1, i32 2, i32 0
  %21 = load %13** %20
  store %13* %21, %13** %5
  %22 = bitcast %13** %5 to i8*
  %23 = getelementptr %tydesc* %4, i32 0, i32 0
  %24 = load %tydesc*** %23
  %25 = getelementptr %tydesc* %4, i32 0, i32 3
  %26 = load void (i1*, %task*, i1*, %tydesc**, i8*)** %25
  call fastcc void %26(i1* null, %task* %1, i1* null, %tydesc** %24, i8* %22)
  %27 = getelementptr %22* %15, i32 0, i32 0
  %28 = bitcast void (i1*, %task*, %10*, %13*)** %27 to void (i1*, %task*, %10*, %tydesc*, %13*)**
  %29 = load void (i1*, %task*, %10*, %tydesc*, %13*)** %28
  call fastcc void %29(i1* %0, %task* %1, %10* %17, %tydesc* %19, %13* %21)
  ret void
}

Note that this only happens when generating unoptimized code - the verifier runs after the optimizer, which seems to hide problems in code generation.

@ghost ghost assigned brson May 17, 2011
@brson
Copy link
Contributor Author

brson commented May 23, 2011

It appears to only happen for non-alias bound arguments with type parameters.

brson added a commit that referenced this issue May 24, 2011
@brson
Copy link
Contributor Author

brson commented May 24, 2011

I committed a workaround for the issue in the standard library, but it can still be reproduced with the provided test case

@brson
Copy link
Contributor Author

brson commented Jun 23, 2011

Optimization no longer needs to be disabled to reproduce this

@msullivan
Copy link
Contributor

A very reduced test case:

fn oops[A](@A x)  {
    bind oops(x);
}

@ghost ghost assigned msullivan Jul 8, 2011
@msullivan
Copy link
Contributor

Closed by #645.

dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
antoyo added a commit to antoyo/rust that referenced this issue Oct 27, 2023
Make build scripts work with rust bootstrap
calebzulawski added a commit to calebzulawski/rust that referenced this issue Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants