Skip to content

Commit

Permalink
Fix bug and better memtrack
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeBajczi committed Nov 13, 2024
1 parent 8a95eef commit 3165862
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ class MemsafetyPass(val parseContext: ParseContext) : ProcedurePass {
?: XcfaGlobalVar(Var("__ptr", sizeVar.type.indexType), pointerType.nullValue)
.also { builder.parent.addVar(it) }
.wrappedVar
val remained = Gt(ArrayReadExpr.create<Type, Type>(sizeVar.ref, anyBase.ref), fitsall.nullValue)
val remained = // 3k+0: malloc
Gt(
ArrayReadExpr.create<Type, Type>(sizeVar.ref, Mul(anyBase.ref, pointerType.getValue("3"))),
fitsall.nullValue,
)

for (incomingEdge in LinkedHashSet(finalLoc.incomingEdges)) {
builder.removeEdge(incomingEdge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ class ReferenceElimination(val parseContext: ParseContext) : ProcedurePass {
builder.parent.addVar(XcfaGlobalVar(varDecl, lit))
parseContext.metadata.create(varDecl.ref, "cType", ptrType)
val assign = AssignStmtLabel(varDecl, lit)
Pair(varDecl, SequenceLabel(listOf(assign)))
val labels =
if (MemsafetyPass.NEED_CHECK) {
val assign2 = builder.parent.allocateUnit(parseContext, varDecl.ref)

listOf(assign, assign2)
} else {
listOf(assign)
}
Pair(varDecl, SequenceLabel(labels))
}
}
checkState(globalReferredVars is Map<*, *>, "ReferenceElimination needs info on references")
Expand Down

0 comments on commit 3165862

Please sign in to comment.