CliftImportModel: refactor visitGlobalVariableOp

Split visitFunctionOp into two parts:
1. a new recordGlobalVariableOpName helper, which records the name for
any GlobalVariableOp;
2 the existing visitGlobalVariableOp, that now delegates to the helper.

The helper exists so that, like recordFunctionOpName, it can be invoked
from contexts other than the top-level module walk, in particular, when
a clift::UseOp in a function body refers to a GlobalVariableOp.

Pure refactor: behavior is unchanged.
This commit is contained in:
Pietro Fezzardi
2026-06-08 19:12:34 +02:00
parent 98b0dd9380
commit 7aad574196
@@ -625,7 +625,11 @@ public:
return mlir::success();
}
mlir::LogicalResult visitGlobalVariableOp(clift::GlobalVariableOp Op) {
// Record the descriptive info for the given global variable op. Mirrors
// recordFunctionOpName: contains no per-function state and is therefore
// safe to call from any visit context (module level or while walking a
// function body following a clift::UseOp).
mlir::LogicalResult recordGlobalVariableOpName(clift::GlobalVariableOp Op) {
if (const model::Segment *Segment = getModelSegment(Op)) {
Symbols.record(Op, NameBuilder.name(Model, *Segment));
@@ -640,6 +644,10 @@ public:
revng_abort("Invalid global variable handle");
}
mlir::LogicalResult visitGlobalVariableOp(clift::GlobalVariableOp Op) {
return recordGlobalVariableOpName(Op);
}
//===-------------------------- Comment import --------------------------===//
mlir::LogicalResult visitStatementOp(clift::StatementOpInterface Op) {