Skip to content

Commit 8ef5d30

Browse files
committed
Fix program-scope global variable initialization
Need to check that the variable has an initializer before we try and use it.
1 parent 4d78949 commit 8ef5d30

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/Program.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ void Program::allocateProgramScopeVars()
192192
itr++)
193193
{
194194
auto var = llvm::cast<llvm::GlobalVariable>(itr->first);
195-
const llvm::Constant* initializer = var->getInitializer();
196-
if (!initializer)
195+
if (!var->hasInitializer())
196+
{
197197
continue;
198+
}
199+
const llvm::Constant* initializer = var->getInitializer();
198200

199201
size_t varptr = itr->second.getPointer();
200202
if (initializer->getType()->getTypeID() == llvm::Type::PointerTyID)

0 commit comments

Comments
 (0)