forked from OSchip/llvm-project
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:
parent
c5b20b5283
commit
9cca0715aa
|
@ -1954,11 +1954,13 @@ 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;
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
; RUN: opt < %s -globalopt -disable-output
|
||||
|
||||
%0 = type { i32, void ()* }
|
||||
@llvm.global_ctors = appending global [0 x %0] zeroinitializer
|
||||
|
Loading…
Reference in New Issue