#4992: LLVM trashes registers for primitive calls
--------------------------------+-------------------------------------------
    Reporter:  scpmw            |        Owner:  davidterei@…        
        Type:  bug              |       Status:  patch               
    Priority:  normal           |    Milestone:                      
   Component:  Compiler (LLVM)  |      Version:  7.1                 
    Keywords:                   |     Testcase:                      
   Blockedby:                   |   Difficulty:                      
          Os:  Linux            |     Blocking:                      
Architecture:  x86_64 (amd64)   |      Failure:  Runtime crash       
--------------------------------+-------------------------------------------

Comment(by dterei):

 Is it not possible for you to simply attach the original program that
 crashes without the patch? If its private code you could just share it
 with me via email if you would prefer. I am not 100% convinced this patch
 solves the root of the problem.

 Across C calls (regardless of prim or not) the registers are trashed
 because GHC has previously generated code to save and restore the
 appropriate registers. In the Cmm code given to the LLVM backend
 spill/reload of the R3... registers already exists and so to have LLVM do
 it as well just duplicates work. Thats why the backend simply trashes all
 the caller save registers blindly. This isn't the best solution but it
 shouldn't cause any bugs.

 e.g so if R3 is live across a call you should see code like:

 {{{
 %lnXe = load i64* %R3_Var
 store i64 %ln1zX, i64* %ln1zZ
 store i64 undef, i64* %R3_Var
 store i64 undef, i64* %R4_Var
 store i64 undef, i64* %R5_Var
 store i64 undef, i64* %R6_Var
 store float undef, float* %F1_Var
 store float undef, float* %F2_Var
 store float undef, float* %F3_Var
 store float undef, float* %F4_Var
 store double undef, double* %D1_Var
 store double undef, double* %D2_Var
 %ln1A0 = call ccc double (double)* @tan( double 0x3FE0000000000000 )
 nounwind
 store i64 %lnXe, i64* %R3_Var
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4992#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to