diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 09:15:18 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 09:15:18 +0000 |
| commit | 39e50838bd12057d9305575f50c63990984df01a (patch) | |
| tree | 6ff2b45ed79aff00582c62942c2a283d92329b4f /lib/CodeGen/CodeGen.cc | |
| parent | e1f41ed9fafaf7eb4f2da6878a3fabcf2f7c021e (diff) | |
feat(codegen): GLOBAL variables as LLVM globals
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/CodeGen.cc')
| -rw-r--r-- | lib/CodeGen/CodeGen.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc index e7116dd..6aa1558 100644 --- a/lib/CodeGen/CodeGen.cc +++ b/lib/CodeGen/CodeGen.cc @@ -166,8 +166,9 @@ void CodeGen::selectUnit(size_t Unit) { void CodeGen::importSymbols() { Symbols.clear(); for (size_t I = 0; I < Exports.size(); ++I) { - if (I != CurrentUnit && isVisible(I)) - Symbols.insert(Exports[I].begin(), Exports[I].end()); + if (!isVisible(I)) continue; + for (const auto &[Name, Info] : Exports[I]) + if (I != CurrentUnit || Info.IsGlobal) Symbols.emplace(Name, Info); } } @@ -286,6 +287,13 @@ void CodeGen::compile(const std::vector<SourceUnit> &Sources) { } Exports[I] = Symbols; } + for (int Phase = 0; Phase < 2; ++Phase) { + for (size_t I = 0; I < Sources.size(); ++I) { + selectUnit(I); + importSymbols(); + runGlobalPrePass(Sources[I], Phase); + } + } for (size_t I = 0; I < Sources.size(); ++I) { selectUnit(I); importSymbols(); |
