From 615d2eee71147c8d18905eae7ae9a3d0b6902424 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Thu, 14 Nov 2024 11:35:06 +0100 Subject: [PATCH] Not removing 'unnecessary' atomics --- .../theta/xcfa/passes/ProcedurePassManager.kt | 1 - .../mit/theta/xcfa/passes/RemoveAtomics.kt | 51 ------------------- 2 files changed, 52 deletions(-) delete mode 100644 subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/RemoveAtomics.kt diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ProcedurePassManager.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ProcedurePassManager.kt index 89a0808921..0e624b12d3 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ProcedurePassManager.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ProcedurePassManager.kt @@ -70,7 +70,6 @@ class CPasses(checkOverflow: Boolean, parseContext: ParseContext, uniqueWarningL UnusedLocRemovalPass(), ), listOf(FetchExecuteWriteback(parseContext)), - listOf(RemoveAtomics()), ) class ChcPasses(parseContext: ParseContext, uniqueWarningLogger: Logger) : diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/RemoveAtomics.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/RemoveAtomics.kt deleted file mode 100644 index f36f8d5ae1..0000000000 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/RemoveAtomics.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2024 Budapest University of Technology and Economics - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package hu.bme.mit.theta.xcfa.passes - -import hu.bme.mit.theta.xcfa.getFlatLabels -import hu.bme.mit.theta.xcfa.model.FenceLabel -import hu.bme.mit.theta.xcfa.model.SequenceLabel -import hu.bme.mit.theta.xcfa.model.XcfaProcedureBuilder - -class RemoveAtomics : ProcedurePass { - - override fun run(builder: XcfaProcedureBuilder): XcfaProcedureBuilder { - for (xcfaEdge in LinkedHashSet(builder.getEdges())) { - val labels = xcfaEdge.getFlatLabels() - val (beginIndex, beginLabel) = - labels - .mapIndexed { i1, i2 -> Pair(i1, i2) } - .firstOrNull { - it.second is FenceLabel && (it.second as FenceLabel).labels.contains("ATOMIC_BEGIN") - } ?: continue - val (endIndex, endLabel) = - labels - .mapIndexed { i1, i2 -> Pair(i1, i2) } - .lastOrNull { - it.second is FenceLabel && (it.second as FenceLabel).labels.contains("ATOMIC_END") - } ?: continue - val newLabels = - labels.subList(0, beginIndex) + - labels.subList(beginIndex + 1, endIndex).filter { - it !is FenceLabel || !it.labels.any { it.contains("ATOMIC_") } - } + - labels.subList(endIndex + 1, labels.size) - builder.removeEdge(xcfaEdge) - builder.addEdge(xcfaEdge.withLabel(SequenceLabel(newLabels))) - } - return builder - } -}