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

Empty Basic Blocks #17

Open
nwtgck opened this issue Feb 8, 2018 · 0 comments
Open

Empty Basic Blocks #17

nwtgck opened this issue Feb 8, 2018 · 0 comments

Comments

@nwtgck
Copy link
Contributor

nwtgck commented Feb 8, 2018

Hi, developers of llvm-hs-quote.

Environment

llvm-hs-quote: 1497273
stack solver: lts-10.3 (this is the same as llvm-hs-quote)

Proposal

Allow library users to use $bbs with empty [BasicBlock].

My concern

module11 [bBlock] has no error in the following code. However, module11 [] has a runtime error.

module11 :: [AST.Global.BasicBlock] -> AST.Module
module11 basicBlocks = [Quote.LLVM.llmod|
  define void @myfunc(i32 %a, i32 %b) {
    $bbs:basicBlocks
    ret void
  }
|]

runtime error message

Pattern match failure in do expression at ...

To avoid the empty-list problem, I should write the following. In the code, betterModule11 [] has no error, but it is redundant.

betterModule11 :: [AST.Global.BasicBlock] -> AST.Module
betterModule11 basicBlocks =
  if Prelude.null basicBlocks
    then
      [Quote.LLVM.llmod|
        define void @myfunc(i32 %a, i32 %b) {
          ret void
        }
      |]
    else
      [Quote.LLVM.llmod|
        define void @myfunc(i32 %a, i32 %b) {
          $bbs:basicBlocks
          ret void
        }
      |]

The code is just an example. In actual program using this library, allowing empty list is more convenient. I was wondering whether you allow to us use $bbs with empty [BasicBlock].

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

1 participant