Skip to content

Unable to pretty print functions #12

@jaseemabid

Description

@jaseemabid

Found this module failing with a pattern match error even though I can compile it just fine.

*** Exception: src/LLVM/Pretty.hs:485:7-66: Irrefutable pattern failed for pattern functionType@(FunctionType {..})
Module
{ moduleName = "calc"
, moduleSourceFileName = "<string>"
, moduleDataLayout = Nothing
, moduleTargetTriple = Nothing
, moduleDefinitions =
      [ GlobalDefinition
            (Function
             { linkage = External
             , visibility = Default
             , dllStorageClass = Nothing
             , callingConvention = C
             , returnAttributes = []
             , returnType = IntegerType {typeBits = 64}
             , name = Name "a"
             , parameters =
                   ( [Parameter (IntegerType {typeBits = 64}) (Name "x") []]
                   , False)
             , functionAttributes = []
             , section = Nothing
             , comdat = Nothing
             , alignment = 0
             , garbageCollectorName = Nothing
             , prefix = Nothing
             , basicBlocks =
                   [ BasicBlock
                         (Name "entry")
                         []
                         (Do
                              (Ret
                               { returnOperand =
                                     Just
                                         (LocalReference
                                              (IntegerType {typeBits = 64})
                                              (Name "x"))
                               , metadata' = []
                               }))
                   ]
             , personalityFunction = Nothing
             })
      , GlobalDefinition
            (Function
             { linkage = External
             , visibility = Default
             , dllStorageClass = Nothing
             , callingConvention = C
             , returnAttributes = []
             , returnType = IntegerType {typeBits = 64}
             , name = Name "main"
             , parameters =
                   ( [Parameter (IntegerType {typeBits = 64}) (Name "argv") []]
                   , False)
             , functionAttributes = []
             , section = Nothing
             , comdat = Nothing
             , alignment = 0
             , garbageCollectorName = Nothing
             , prefix = Nothing
             , basicBlocks =
                   [ BasicBlock
                         (Name "entry")
                         [ UnName 0 :=
                           Call
                           { tailCallKind = Nothing
                           , callingConvention = C
                           , returnAttributes = []
                           , function =
                                 Right
                                     (ConstantOperand
                                          (GlobalReference
                                               (IntegerType {typeBits = 64})
                                               (Name "a")))
                           , arguments =
                                 [ ( ConstantOperand
                                         (Int
                                          {integerBits = 64, integerValue = 4})
                                   , [])
                                 ]
                           , functionAttributes = []
                           , metadata = []
                           }
                         ]
                         (Do
                              (Ret
                               { returnOperand =
                                     Just
                                         (LocalReference
                                              (IntegerType {typeBits = 64})
                                              (UnName 0))
                               , metadata' = []
                               }))
                   ]
             , personalityFunction = Nothing
             })
      ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions