Realized that getelementptr might be doing to right thing, and that the uninitialized data comes from padding.

This commit is contained in:
Samuel Hammersberg 2023-03-22 10:24:00 +01:00
parent ae34c494f5
commit d36370329e
2 changed files with 20 additions and 10 deletions

View file

@ -106,6 +106,7 @@ data LLVMIr
| Declare LLVMType Ident Params
| SetVariable Ident LLVMIr
| Variable Ident
| GetElementPtr LLVMType LLVMType LLVMValue LLVMType LLVMValue LLVMType LLVMValue
| GetElementPtrInbounds LLVMType LLVMType LLVMValue LLVMType LLVMValue LLVMType LLVMValue
| Add LLVMType LLVMValue LLVMValue
| Sub LLVMType LLVMValue LLVMValue
@ -146,6 +147,12 @@ llvmIrToString = go 0
insToString :: Int -> LLVMIr -> String
insToString i l =
replicate i '\t' <> case l of
(GetElementPtr t1 t2 p t3 v1 t4 v2) -> do
-- getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0
concat
[ "getelementptr ", show t1, ", " , show t2
, " ", show p, ", ", show t3, " ", show v1,
", ", show t4, " ", show v2, "\n" ]
(GetElementPtrInbounds t1 t2 p t3 v1 t4 v2) -> do
-- getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0
concat