@@ -175,6 +175,25 @@ private def collectLowLevelMechanicsFromStmts (stmts : List Stmt) : List String
175175 []
176176 stmts
177177
178+ private def lowLevelMechanicsFromEcmModule (mod : ECM.ExternalCallModule) : List String :=
179+ match mod.name with
180+ | "create2Deploy" => ["create2" ]
181+ | "sstore2ReadCode" => ["extcodecopy" ]
182+ | _ => []
183+
184+ private def collectLowLevelMechanicsFromEcmModules (modules : List ECM.ExternalCallModule) : List String :=
185+ dedupPreserve (modules.flatMap lowLevelMechanicsFromEcmModule)
186+
187+ private def collectUsedEcmModulesFromStmts (stmts : List Stmt) : List ECM.ExternalCallModule :=
188+ dedupEcmModules <|
189+ Stmt.foldList
190+ (fun acc stmt _ =>
191+ match stmt with
192+ | .ecm mod _ => acc ++ [mod]
193+ | _ => acc)
194+ []
195+ stmts
196+
178197private def collectAxiomatizedPrimitivesFromStmts (stmts : List Stmt) : List String :=
179198 dedupPreserve <|
180199 Stmt.foldList
@@ -385,7 +404,8 @@ def collectEventEmissionMechanics (spec : CompilationModel) : List String :=
385404
386405private def isDeniedLowLevelMechanic (mechanic : String) : Bool :=
387406 match mechanic with
388- | "call" | "staticcall" | "delegatecall" | "create2" | "returndataSize" | "returndataCopy"
407+ | "call" | "staticcall" | "delegatecall" | "create2" | "codecopy" | "extcodecopy"
408+ | "returndataSize" | "returndataCopy"
389409 | "revertReturndata" | "rawRevert" | "returndataOptionalBoolAt" | "blobbasefee" => true
390410 | _ => false
391411
@@ -399,7 +419,8 @@ def collectLowLevelMechanics (spec : CompilationModel) : List String :=
399419 | some ctor => ctor.body
400420 | none => []
401421 let allStmts := stmtsFromCtor ++ spec.functions.flatMap stmtsFromFn
402- collectLowLevelMechanicsFromStmts allStmts
422+ dedupPreserve (collectLowLevelMechanicsFromStmts allStmts ++
423+ collectLowLevelMechanicsFromEcmModules (collectUsedEcmModulesFromStmts allStmts))
403424
404425/-- Collect partially modeled linear-memory mechanics used by a spec. -/
405426def collectLinearMemoryMechanics (spec : CompilationModel) : List String :=
@@ -667,16 +688,6 @@ private def collectUsedExternalNamesByStatus
667688example : collectUsedExternalNamesFromStmts [stmtExternalArgSmoke] = ["oracle" ] := by
668689 native_decide
669690
670- private def collectUsedEcmModulesFromStmts (stmts : List Stmt) : List ECM.ExternalCallModule :=
671- dedupEcmModules <|
672- Stmt.foldList
673- (fun acc stmt _ =>
674- match stmt with
675- | .ecm mod _ => acc ++ [mod]
676- | _ => acc)
677- []
678- stmts
679-
680691/-- Collect ECM modules that are actually referenced by the spec, including
681692 constructor bodies. This shared view keeps machine-readable reports and
682693 compiler summaries aligned. -/
@@ -923,13 +934,15 @@ private def usageSiteSummary
923934 (localObligations : List LocalObligation)
924935 (stmts : List Stmt) :
925936 UsageSiteSummary :=
926- let mechanics := collectLowLevelMechanicsFromStmts stmts
937+ let siteModules := collectUsedEcmModulesFromStmts stmts
938+ let mechanics :=
939+ dedupPreserve (collectLowLevelMechanicsFromStmts stmts ++
940+ collectLowLevelMechanicsFromEcmModules siteModules)
927941 let eventEmission := collectEventEmissionMechanicsFromStmts stmts
928942 let proxyUpgradeability := collectProxyUpgradeabilityMechanicsFromMechanics mechanics
929943 let runtimeIntrospection := collectRuntimeIntrospectionMechanicsFromStmts stmts
930944 let primitives := collectAxiomatizedPrimitivesFromStmts stmts
931945 let siteExternals := collectUsedExternalAssumptionsFromStmts spec.externals stmts
932- let siteModules := collectUsedEcmModulesFromStmts stmts
933946 let siteLocalObligations := collectLocalObligationsFromStmts localObligations stmts
934947 let siteUnsafeYulContracts := collectUnsafeYulContractsFromStmts stmts
935948 let siteUnsafeBlocks := collectUnsafeBlockReasonsFromStmts stmts
0 commit comments