diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 7d0050ff8ea..f44457f3b05 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2090,21 +2090,10 @@ void AsmPrinter::emitXXStructorList(const DataLayout &DL, const Constant *List, // init priority. if (!isa(List)) return; - // Sanity check the structors list. - const ConstantArray *InitList = dyn_cast(List); - if (!InitList) return; // Not an array! - StructType *ETy = dyn_cast(InitList->getType()->getElementType()); - if (!ETy || ETy->getNumElements() != 3 || - !isa(ETy->getTypeAtIndex(0U)) || - !isa(ETy->getTypeAtIndex(1U)) || - !isa(ETy->getTypeAtIndex(2U))) - return; // Not (int, ptr, ptr). - // Gather the structors in a form that's convenient for sorting by priority. SmallVector Structors; - for (Value *O : InitList->operands()) { - ConstantStruct *CS = dyn_cast(O); - if (!CS) continue; // Malformed. + for (Value *O : cast(List)->operands()) { + auto *CS = cast(O); if (CS->getOperand(1)->isNullValue()) break; // Found a null terminator, skip the rest. ConstantInt *Priority = dyn_cast(CS->getOperand(0)); diff --git a/test/ExecutionEngine/OrcMCJIT/test-global-ctors.ll b/test/ExecutionEngine/OrcMCJIT/test-global-ctors.ll index d66efc27fb4..c42f193f4ba 100644 --- a/test/ExecutionEngine/OrcMCJIT/test-global-ctors.ll +++ b/test/ExecutionEngine/OrcMCJIT/test-global-ctors.ll @@ -1,8 +1,8 @@ ; RUN: %lli -jit-kind=orc-mcjit %s > /dev/null ; XFAIL: darwin @var = global i32 1, align 4 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @ctor_func }] -@llvm.global_dtors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @dtor_func }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @ctor_func, i8* null }] +@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @dtor_func, i8* null }] define i32 @main() nounwind { entry: