Skip to content

Commit

Permalink
Code cleanup, remove unused code, changesome XXX comments to TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
pschachte committed Oct 9, 2024
1 parent 63ab5aa commit b3956b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
10 changes: 4 additions & 6 deletions src/AliasAnalysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,8 @@ _maybeAliasPrimArgs args = do
ArgGlobal global ty -> maybeAddressAlias arg ty $ AliasByGlobal global
_ -> return Nothing
maybeAddressAlias arg ty item = do
-- isPhantom <- argIsPhantom arg
rep <- lookupTypeRepresentation ty
-- Only Pointer type will create alias
-- if not isPhantom && rep == Just Pointer
-- Only Pointer types will create alias
if rep == Just Pointer
then return $ Just item
else return Nothing
Expand Down Expand Up @@ -575,12 +573,12 @@ updateMultiSpeczDepInfo multiSpeczDepInfo callSiteID pSpec items =
-- XXX currently it relies on the size arg of the access instruction. Another
-- way (much more flexible) to do it is introducing some lpvm instructions
-- that do nothing and only provide information for the compiler.
-- XXX call "GC_free" on large unused dead cells.
-- TODO call "GC_free" on large unused dead cells.
-- (according to https://github.com/ivmai/bdwgc, > 8 bytes)
-- XXX we'd like this analysis to detect structures that are dead aside from
-- TODO we'd like this analysis to detect structures that are dead aside from
-- later access instructions, which could be moved earlier to allow the
-- structure to be reused.
-- XXX consider re-run the optimiser after this or even run this before the
-- TODO consider re-run the optimiser after this or even run this before the
-- optimiser.


Expand Down
13 changes: 6 additions & 7 deletions src/LLVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ writeConstDeclaration spec@(ClosureSpec pspec args) n = do
argReps <- mapM argTypeRep args
declareStructConstant closureName
((ArgGlobal (GlobalVariable pname) (Representation CPointer), CPointer)
-- ((ArgInt 42 intType, Bits 64)
: zip args argReps)
Nothing

Expand Down Expand Up @@ -592,7 +591,6 @@ closeClosure :: PrimProto -> ProcBody -> (PrimProto, ProcBody)
closeClosure proto@PrimProto{primProtoParams=params}
body@ProcBody{bodyPrims=prims} =
(proto{primProtoParams=envPrimParam:actualParams},
-- envPrimParam:(setPrimParamType AnyType <$> actualParams)},
body{bodyPrims=unpacker ++ prims})
where
(free, actualParams) = List.partition ((==Free) . primParamFlowType) params
Expand Down Expand Up @@ -713,7 +711,7 @@ writeAssemblySwitch outs v rep cases dflt = do
Nothing -> return ()
Just dfltCode -> do
llvmPutStrLn $ dfltLabel ++ ":"
-- I don't think the Nothing case ever happens, but in case it does...
-- I don't think the Nothing case ever happens, but just in case...
writeAssemblyBody outs dfltCode


Expand All @@ -737,7 +735,7 @@ writeAssemblyPrim instr@(PrimForeign "llvm" op flags args) pos = do
logLLVM $ "* Translating LLVM instruction " ++ show instr
writeLLVMCall op flags args pos
writeAssemblyPrim instr@(PrimForeign "lpvm" op flags args) pos = do
-- Some of these should be handled before releasing deferred calls
-- Some of these must be handled before releasing deferred calls
logLLVM $ "* Translating LPVM instruction " ++ show instr
writeLPVMCall op flags args pos
writeAssemblyPrim instr@(PrimForeign "c" cfn flags args) pos = do
Expand Down Expand Up @@ -867,7 +865,7 @@ writeLPVMCall "load" _ args pos = do
shouldnt $ "lpvm load with inputs " ++ show ins ++ " and outputs "
++ show outs
writeLPVMCall "store" _ args pos = do
-- XXX We could actually support take-reference for this op
-- TODO We could actually support take-reference for this op
releaseDeferredCall
args' <- partitionArgs "lpvm store instruction" args
case args' of
Expand Down Expand Up @@ -1213,6 +1211,7 @@ llvmAssignConvertedResult arg@ArgVar{argVarName=varName,argVarType=ty}
llvmAssignConvertedResult notAVar _ _ =
shouldnt $ "llvmAssignConvertedResult into non-variable " ++ show notAVar


-- | Split parameter list into separate list of input, output, out-by-reference,
-- and take-reference arguments, ignoring any phantom parameters.
partitionParams :: [PrimParam]
Expand Down Expand Up @@ -1355,7 +1354,6 @@ llvmValue argVar@ArgVar{argVarName=var, argVarType=ty} = do
(Nothing,_) -> do
logLLVM $ "Using unknown LLVM variable " ++ realVar
return realVar
-- (Nothing,_) -> shouldnt $ "Using unknown LLVM variable " ++ realVar
(Just defRep, useRep) | equivLLTypes defRep useRep -> return realVar
(Just defRep, useRep) ->
typeConvertedBare thisRep argVar{argVarType=Representation defRep}
Expand Down Expand Up @@ -1541,6 +1539,7 @@ typeConvertedBare toTy fromArg
typeConvert fromArg writeArg
llvmValue readArg


-- | An LLVM constant expression of the specified type toTy, when the constant
-- is initially of the specified type fromTy. This may take the form of an
-- LLVM type conversion expression, which is fully evaluated at compile-time, so
Expand Down Expand Up @@ -1992,6 +1991,7 @@ convertOutByRefArg ArgVar{argVarName=name, argVarType=ty,
convertOutByRefArg other =
shouldnt $ "Expected out-by-reference argument: " ++ show other


-- | Generate code to allocate heap memory, with the size in bytes specified as
-- a PrimArg, so it can be a variable. The result will be converted to the type
-- of the result variable.
Expand Down Expand Up @@ -2028,7 +2028,6 @@ llvmGlobalName s =
'@' : llvmQuoteIfNecessary s



-- | Wrap quotes around the specified string, using character escapes for any
-- special characters, if it contains any characters but alphanumerics,
-- underscores, or period characters.
Expand Down

0 comments on commit b3956b2

Please sign in to comment.