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 fails to add required calls to copyPacked automatically. #187

Open
vidsinghal opened this issue Jan 26, 2023 · 0 comments
Open

Comments

@vidsinghal
Copy link
Collaborator

vidsinghal commented Jan 26, 2023

In the following code, processAdtCorrect generates the correct code via call to copyPacked in the top level DSL.
processAdtInCorrect is the version of the code where there in no copyPacked call in the top level DSL and fails to generate the correct code.

module Main where

import Strings
import Contents
import Adts


-- This program is for re-creating the copy packed bug. 
-- processAdtCorrect genertes the correct file, but to do so we have to insert a copyPacked call at the front end which the compiler should ideally do automatically. 
-- processAdtInCorrect is the same function but without the call to copyPacked. 
-- The Adt is printed after every function call.
-- Compilation command used: gibbon --packed  --no-gc --to-exe replicate_copyPacked_bug.hs
-- TODO: Paste C code to show what exactly is happening here. 
         
processAdtCorrect :: Adt -> Adt
processAdtCorrect adt = case adt of 
				Nil -> Nil
				AC rst content  -> let newContent = processContent content 
						       newRst     = processAdtCorrect rst
                                                   in AC newRst (copyPacked newContent)

processAdtInCorrect :: Adt -> Adt
processAdtInCorrect adt = case adt of
				Nil -> Nil
                                AC rst content  -> let newContent = processContent content
                                                       newRst     = processAdtCorrect rst
                                                   in AC newRst newContent


gibbon_main = 
    let ac            = mkACList 3 5
        _             = printsym (quote "Printing the AC Adt right after constructing it\n")
        _             = printPacked ac
        _             = printsym (quote "NEWLINE")
        ac_correct    = processAdtCorrect ac
        _             = printsym (quote "Print the new Adt after calling processAdtCorrect function\n")
        _             = printPacked ac_correct
        _             = printsym (quote "NEWLINE")
        ac_incorrect  = processAdtInCorrect ac
        _             = printsym (quote "Printing the new Adt after calling processAdtInCorrect function\n")
        _             = printPacked ac_incorrect
        _             = printsym (quote "NEWLINE")
    in ()

Code and module files available here: https://github.com/iu-parfunc/gibbon/tree/master/gibbon-compiler/examples/layout_benchmarks

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

2 participants