diff --git a/Chapter07/tinylang/lib/CodeGen/CGModule.cpp b/Chapter07/tinylang/lib/CodeGen/CGModule.cpp index 9963d2c..04f7c99 100644 --- a/Chapter07/tinylang/lib/CodeGen/CGModule.cpp +++ b/Chapter07/tinylang/lib/CodeGen/CGModule.cpp @@ -97,10 +97,12 @@ void CGModule::run(ModuleDeclaration *Mod) { if (auto *Var = llvm::dyn_cast(Decl)) { // Create global variables + llvm::Type *T = convertType(Var->getType()); llvm::GlobalVariable *V = new llvm::GlobalVariable( - *M, convertType(Var->getType()), + *M, T, /*isConstant=*/false, - llvm::GlobalValue::PrivateLinkage, nullptr, + llvm::GlobalValue::PrivateLinkage, + llvm::UndefValue::get(T), mangleName(Var)); Globals[Var] = V; if (CGDebugInfo *Dbg = getDbgInfo())