Skip to content

Commit

Permalink
Support no-op pointer casts
Browse files Browse the repository at this point in the history
`ICastOp`s that change the pointee type become no-ops by the time we get
to LLVM with opaque pointer types, but we should still declare those as
supported casts.
  • Loading branch information
apaszke committed May 13, 2022
1 parent 76e766b commit 282e1e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/JIT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ compileInstr instr = case instr of
(L.FloatingPointType _, L.IntegerType _) -> emitInstr dt $ L.FPToSI x dt []
(L.IntegerType _, L.FloatingPointType _) -> emitInstr dt $ L.SIToFP x dt []
#if MIN_VERSION_llvm_hs(15,0,0)
-- Pointee casts become no-ops, because LLVM uses opaque pointers
(L.PointerType a , L.PointerType a') | a == a' -> return x
(L.IntegerType 64, ptrTy@(L.PointerType _)) -> emitInstr ptrTy $ L.IntToPtr x ptrTy []
(L.PointerType _ , L.IntegerType 64) -> emitInstr i64 $ L.PtrToInt x i64 []
#else
Expand Down

0 comments on commit 282e1e8

Please sign in to comment.