Skip to content

Commit

Permalink
Fix CallBr pretty-printing w.r.t. opaque pointers
Browse files Browse the repository at this point in the history
Previously, the code for pretty-printing `callbr` instructins was inspecting a
pointer's pointee type, which won't work for opaque pointers. Thankfully, the
fix is simple: just use the return type that is stored separately in the
`CallBr` data constructor.

See #102.
  • Loading branch information
RyanGlScott committed Apr 6, 2023
1 parent 41506d4 commit 257a906
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Text/LLVM/PP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,10 @@ ppCall tc ty f args
ppCallBr :: LLVM => Type -> Value -> [Typed Value] -> BlockLabel -> [BlockLabel] -> Doc
ppCallBr ty f args to indirectDests =
"callbr"
<+> ppCallSym res f <> parens (commas (map (ppTyped ppValue) args))
<+> ppCallSym ty f <> parens (commas (map (ppTyped ppValue) args))
<+> "to" <+> ppLab to <+> brackets (commas (map ppLab indirectDests))
where
ppLab l = ppType (PrimType Label) <+> ppLabel l
res =
case ty of
PtrTo (FunTy r _ _) -> r
_ -> PrimType Void

-- | Print out the @<ty>|<fnty> <fnptrval>@ portion of a @call@, @callbr@, or
-- @invoke@ instruction, where:
Expand Down

0 comments on commit 257a906

Please sign in to comment.