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

Build is broken when optimization is turned off #836

Closed
marijnh opened this issue Aug 18, 2011 · 6 comments
Closed

Build is broken when optimization is turned off #836

marijnh opened this issue Aug 18, 2011 · 6 comments
Assignees

Comments

@marijnh
Copy link
Contributor

marijnh commented Aug 18, 2011

While building stage1/lib/libstd.so:

rustc: /home/marijn/prog/llvm/include/llvm/Support/Casting.h:194: typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X = llvm::FrameIndexSDNode, Y = llvm::SDNode*, typename llvm::cast_retty<To, From>::ret_type = llvm::FrameIndexSDNode*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Stack dump:
0.  Running pass 'Function Pass Manager' on module 'rust_out'.
1.  Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN3int6to_strE'
Aborted
make: *** [stage1/lib/libstd.so] Error 134
make: Target `all' not remade because of errors.
make: Leaving directory `/home/marijn/src/rust'
@msullivan
Copy link
Contributor

Bisecting.

@msullivan
Copy link
Contributor

117d21d is the commit that broke it.

@pcwalton
Copy link
Contributor

Taking this; I believe I have an LLVM fix for it.

@ghost ghost assigned pcwalton Aug 18, 2011
@pcwalton
Copy link
Contributor

LLVM patch:

Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp    (revision 137913)
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp    (working copy)
@@ -4957,11 +4957,16 @@
   }
   case Intrinsic::gcroot:
     if (GFI) {
-      const Value *Alloca = I.getArgOperand(0);
-      const Constant *TypeMap = cast<Constant>(I.getArgOperand(1));
+      const Value *Alloca = I.getArgOperand(0)->stripPointerCasts();
+      assert(isa<AllocaInst>(Alloca) && "First argument to gcroot() must be "
+             "an alloca or a bitcast of one!");

+      const Value *TypeMap = I.getArgOperand(1);
+      assert(isa<Constant>(TypeMap) && "Second argument to gcroot() must be "
+             "a constant!");
+
       FrameIndexSDNode *FI = cast<FrameIndexSDNode>(getValue(Alloca).getNode());
-      GFI->addStackRoot(FI->getIndex(), TypeMap);
+      GFI->addStackRoot(FI->getIndex(), cast<Constant>(TypeMap));
     }
     return 0;
   case Intrinsic::gcread:

@pcwalton
Copy link
Contributor

Fix has been sent to espindola; leaving this open until it's upstreamed, but this isn't breaking the build any longer.

@marijnh
Copy link
Contributor Author

marijnh commented Aug 30, 2011

This seems to have landed (I removed the patch when updating LLVM this week, and I can still build without optimize)

@marijnh marijnh closed this as completed Aug 30, 2011
arielb1 pushed a commit to arielb1/rust that referenced this issue Apr 10, 2015
keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
Add constants for memfd_create syscall
bors pushed a commit to rust-lang-ci/rust that referenced this issue Oct 26, 2020
Fixes rust-lang#836

Benchmark #1: simple-raytracer/raytracer_cg_clif
  Time (mean ± σ):      9.250 s ±  0.056 s    [User: 9.213 s, System: 0.015 s]
  Range (min … max):    9.151 s …  9.348 s    20 runs

Benchmark #2: simple-raytracer/raytracer_cg_clif_cold_separated
  Time (mean ± σ):      9.179 s ±  0.101 s    [User: 9.141 s, System: 0.016 s]
  Range (min … max):    9.070 s …  9.473 s    20 runs

Summary
  'simple-raytracer/raytracer_cg_clif_cold_separated' ran
    1.01 ± 0.01 times faster than 'simple-raytracer/raytracer_cg_clif'
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

No branches or pull requests

3 participants