Add back a couple checks removed by r129128; the fact that an intitializer

is an array of structures doesn't imply it's a ConstantArray of
ConstantStruct.

llvm-svn: 129207
This commit is contained in:
Eli Friedman 2011-04-09 09:11:09 +00:00
parent c5b20b5283
commit 9cca0715aa
2 changed files with 11 additions and 4 deletions

View File

@ -1954,10 +1954,12 @@ GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) {
// only allowed to optimize the initializer if it is unique.
if (!GV->hasUniqueInitializer()) return 0;
ConstantArray *CA = cast<ConstantArray>(GV->getInitializer());
ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer());
if (!CA) return 0;
for (User::op_iterator i = CA->op_begin(), e = CA->op_end(); i != e; ++i) {
ConstantStruct *CS = cast<ConstantStruct>(*i);
ConstantStruct *CS = dyn_cast<ConstantStruct>(*i);
if (!CS) return 0;
if (isa<ConstantPointerNull>(CS->getOperand(1)))
continue;

View File

@ -0,0 +1,5 @@
; RUN: opt < %s -globalopt -disable-output
%0 = type { i32, void ()* }
@llvm.global_ctors = appending global [0 x %0] zeroinitializer