Index: llvm/trunk/docs/LangRef.rst =================================================================== --- llvm/trunk/docs/LangRef.rst +++ llvm/trunk/docs/LangRef.rst @@ -6482,12 +6482,12 @@ @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @ctor, i8* @data }] The ``@llvm.global_ctors`` array contains a list of constructor -functions, priorities, and an optional associated global or function. +functions, priorities, and an associated global or function. The functions referenced by this array will be called in ascending order of priority (i.e. lowest first) when the module is loaded. The order of functions with the same priority is not defined. -If the third field is present, non-null, and points to a global variable +If the third field is non-null, and points to a global variable or function, the initializer function will only run if the associated data from the current module is not discarded. @@ -6502,12 +6502,12 @@ @llvm.global_dtors = appending global [1 x %0] [%0 { i32 65535, void ()* @dtor, i8* @data }] The ``@llvm.global_dtors`` array contains a list of destructor -functions, priorities, and an optional associated global or function. +functions, priorities, and an associated global or function. The functions referenced by this array will be called in descending order of priority (i.e. highest first) when the module is unloaded. The order of functions with the same priority is not defined. -If the third field is present, non-null, and points to a global variable +If the third field is non-null, and points to a global variable or function, the destructor function will only run if the associated data from the current module is not discarded. Index: llvm/trunk/docs/ReleaseNotes.rst =================================================================== --- llvm/trunk/docs/ReleaseNotes.rst +++ llvm/trunk/docs/ReleaseNotes.rst @@ -62,6 +62,10 @@ parameter is required to be a simple constant. This annotation must be accurate to avoid possible miscompiles. +* The 2-field form of global variables ``@llvm.global_ctors`` and + ``@llvm.global_dtors`` has been deleted. The third field of their element + type is now mandatory. Specify `i8* null` to migrate from the obsoleted + 2-field form. Changes to the ARM Backend -------------------------- Index: llvm/trunk/include/llvm/IR/AutoUpgrade.h =================================================================== --- llvm/trunk/include/llvm/IR/AutoUpgrade.h +++ llvm/trunk/include/llvm/IR/AutoUpgrade.h @@ -46,9 +46,9 @@ /// so that it can update all calls to the old function. void UpgradeCallsToIntrinsic(Function* F); - /// This checks for global variables which should be upgraded. It returns true - /// if it requires upgrading. - bool UpgradeGlobalVariable(GlobalVariable *GV); + /// This checks for global variables which should be upgraded. It it requires + /// upgrading, returns a pointer to the upgraded variable. + GlobalVariable *UpgradeGlobalVariable(GlobalVariable *GV); /// This checks for module flags which should be upgraded. It returns true if /// module is modified. Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2794,8 +2794,14 @@ } // Look for global variables which need to be renamed. + std::vector> UpgradedVariables; for (GlobalVariable &GV : TheModule->globals()) - UpgradeGlobalVariable(&GV); + if (GlobalVariable *Upgraded = UpgradeGlobalVariable(&GV)) + UpgradedVariables.emplace_back(&GV, Upgraded); + for (auto &Pair : UpgradedVariables) { + Pair.first->eraseFromParent(); + TheModule->getGlobalList().push_back(Pair.second); + } // Force deallocation of memory for these vectors to favor the client that // want lazy deserialization. Index: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1966,7 +1966,7 @@ /// priority. void AsmPrinter::EmitXXStructorList(const DataLayout &DL, const Constant *List, bool isCtor) { - // Should be an array of '{ int, void ()* }' structs. The first value is the + // Should be an array of '{ i32, void ()*, i8* }' structs. The first value is the // init priority. if (!isa(List)) return; @@ -1974,12 +1974,10 @@ const ConstantArray *InitList = dyn_cast(List); if (!InitList) return; // Not an array! StructType *ETy = dyn_cast(InitList->getType()->getElementType()); - // FIXME: Only allow the 3-field form in LLVM 4.0. - if (!ETy || ETy->getNumElements() < 2 || ETy->getNumElements() > 3) - return; // Not an array of two or three elements! - if (!isa(ETy->getTypeAtIndex(0U)) || - !isa(ETy->getTypeAtIndex(1U))) return; // Not (int, ptr). - if (ETy->getNumElements() == 3 && !isa(ETy->getTypeAtIndex(2U))) + 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. @@ -1995,7 +1993,7 @@ Structor &S = Structors.back(); S.Priority = Priority->getLimitedValue(65535); S.Func = CS->getOperand(1); - if (ETy->getNumElements() == 3 && !CS->getOperand(2)->isNullValue()) + if (!CS->getOperand(2)->isNullValue()) S.ComdatKey = dyn_cast(CS->getOperand(2)->stripPointerCasts()); } Index: llvm/trunk/lib/IR/AutoUpgrade.cpp =================================================================== --- llvm/trunk/lib/IR/AutoUpgrade.cpp +++ llvm/trunk/lib/IR/AutoUpgrade.cpp @@ -805,9 +805,35 @@ return Upgraded; } -bool llvm::UpgradeGlobalVariable(GlobalVariable *GV) { - // Nothing to do yet. - return false; +GlobalVariable *llvm::UpgradeGlobalVariable(GlobalVariable *GV) { + if (!(GV->hasName() && (GV->getName() == "llvm.global_ctors" || + GV->getName() == "llvm.global_dtors")) || + !GV->hasInitializer()) + return nullptr; + ArrayType *ATy = dyn_cast(GV->getValueType()); + if (!ATy) + return nullptr; + StructType *STy = dyn_cast(ATy->getElementType()); + if (!STy || STy->getNumElements() != 2) + return nullptr; + + LLVMContext &C = GV->getContext(); + IRBuilder<> IRB(C); + auto EltTy = StructType::get(STy->getElementType(0), STy->getElementType(1), + IRB.getInt8PtrTy()); + Constant *Init = GV->getInitializer(); + unsigned N = Init->getNumOperands(); + std::vector NewCtors(N); + for (unsigned i = 0; i != N; ++i) { + auto Ctor = cast(Init->getOperand(i)); + NewCtors[i] = ConstantStruct::get( + EltTy, Ctor->getAggregateElement(0u), Ctor->getAggregateElement(1), + Constant::getNullValue(IRB.getInt8PtrTy())); + } + Constant *NewInit = ConstantArray::get(ArrayType::get(EltTy, N), NewCtors); + + return new GlobalVariable(NewInit->getType(), false, GV->getLinkage(), + NewInit, GV->getName()); } // Handles upgrading SSE2/AVX2/AVX512BW PSLLDQ intrinsics by converting them Index: llvm/trunk/lib/IR/Verifier.cpp =================================================================== --- llvm/trunk/lib/IR/Verifier.cpp +++ llvm/trunk/lib/IR/Verifier.cpp @@ -641,18 +641,18 @@ PointerType *FuncPtrTy = FunctionType::get(Type::getVoidTy(Context), false)-> getPointerTo(DL.getProgramAddressSpace()); - // FIXME: Reject the 2-field form in LLVM 4.0. Assert(STy && (STy->getNumElements() == 2 || STy->getNumElements() == 3) && STy->getTypeAtIndex(0u)->isIntegerTy(32) && STy->getTypeAtIndex(1) == FuncPtrTy, "wrong type for intrinsic global variable", &GV); - if (STy->getNumElements() == 3) { - Type *ETy = STy->getTypeAtIndex(2); - Assert(ETy->isPointerTy() && - cast(ETy)->getElementType()->isIntegerTy(8), - "wrong type for intrinsic global variable", &GV); - } + Assert(STy->getNumElements() == 3, + "the third field of the element type is mandatory, " + "specify i8* null to migrate from the obsoleted 2-field form"); + Type *ETy = STy->getTypeAtIndex(2); + Assert(ETy->isPointerTy() && + cast(ETy)->getElementType()->isIntegerTy(8), + "wrong type for intrinsic global variable", &GV); } } Index: llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp =================================================================== --- llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp +++ llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp @@ -27,44 +27,24 @@ // Get the current set of static global constructors and add the new ctor // to the list. SmallVector CurrentCtors; - StructType *EltTy; + StructType *EltTy = StructType::get( + IRB.getInt32Ty(), PointerType::getUnqual(FnTy), IRB.getInt8PtrTy()); if (GlobalVariable *GVCtor = M.getNamedGlobal(Array)) { - ArrayType *ATy = cast(GVCtor->getValueType()); - StructType *OldEltTy = cast(ATy->getElementType()); - // Upgrade a 2-field global array type to the new 3-field format if needed. - if (Data && OldEltTy->getNumElements() < 3) - EltTy = StructType::get(IRB.getInt32Ty(), PointerType::getUnqual(FnTy), - IRB.getInt8PtrTy()); - else - EltTy = OldEltTy; if (Constant *Init = GVCtor->getInitializer()) { unsigned n = Init->getNumOperands(); CurrentCtors.reserve(n + 1); - for (unsigned i = 0; i != n; ++i) { - auto Ctor = cast(Init->getOperand(i)); - if (EltTy != OldEltTy) - Ctor = - ConstantStruct::get(EltTy, Ctor->getAggregateElement((unsigned)0), - Ctor->getAggregateElement(1), - Constant::getNullValue(IRB.getInt8PtrTy())); - CurrentCtors.push_back(Ctor); - } + for (unsigned i = 0; i != n; ++i) + CurrentCtors.push_back(cast(Init->getOperand(i))); } GVCtor->eraseFromParent(); - } else { - // Use the new three-field struct if there isn't one already. - EltTy = StructType::get(IRB.getInt32Ty(), PointerType::getUnqual(FnTy), - IRB.getInt8PtrTy()); } - // Build a 2 or 3 field global_ctor entry. We don't take a comdat key. + // Build a 3 field global_ctor entry. We don't take a comdat key. Constant *CSVals[3]; CSVals[0] = IRB.getInt32(Priority); CSVals[1] = F; - // FIXME: Drop support for the two element form in LLVM 4.0. - if (EltTy->getNumElements() >= 3) - CSVals[2] = Data ? ConstantExpr::getPointerCast(Data, IRB.getInt8PtrTy()) - : Constant::getNullValue(IRB.getInt8PtrTy()); + CSVals[2] = Data ? ConstantExpr::getPointerCast(Data, IRB.getInt8PtrTy()) + : Constant::getNullValue(IRB.getInt8PtrTy()); Constant *RuntimeCtorInit = ConstantStruct::get(EltTy, makeArrayRef(CSVals, EltTy->getNumElements())); Index: llvm/trunk/test/Bitcode/metadata-2.ll =================================================================== --- llvm/trunk/test/Bitcode/metadata-2.ll +++ llvm/trunk/test/Bitcode/metadata-2.ll @@ -2,7 +2,7 @@ ; RUN: verify-uselistorder < %s %0 = type { %object.ModuleInfo.__vtbl*, i8*, %"byte[]", %1, %"ClassInfo[]", i32, void ()*, void ()*, void ()*, i8*, void ()* } ; type %0 %1 = type { i64, %object.ModuleInfo* } ; type %1 - %2 = type { i32, void ()* } ; type %2 + %2 = type { i32, void ()*, i8* } ; type %2 %"ClassInfo[]" = type { i64, %object.ClassInfo** } %"Interface[]" = type { i64, %object.Interface* } %"ModuleInfo[]" = type { i64, %object.ModuleInfo** } @@ -24,7 +24,7 @@ @_D5tango4core8BitManip8__ModuleZ = global %0 { %object.ModuleInfo.__vtbl* @_D10ModuleInfo6__vtblZ, i8* null, %"byte[]" { i64 19, i8* getelementptr ([20 x i8], [20 x i8]* @.str, i32 0, i32 0) }, %1 zeroinitializer, %"ClassInfo[]" zeroinitializer, i32 4, void ()* null, void ()* null, void ()* null, i8* null, void ()* null } ; <%0*> [#uses=1] @_D5tango4core8BitManip11__moduleRefZ = internal global %ModuleReference { %ModuleReference* null, %object.ModuleInfo* bitcast (%0* @_D5tango4core8BitManip8__ModuleZ to %object.ModuleInfo*) } ; <%ModuleReference*> [#uses=2] @_Dmodule_ref = external global %ModuleReference* ; <%ModuleReference**> [#uses=2] -@llvm.global_ctors = appending constant [1 x %2] [%2 { i32 65535, void ()* @_D5tango4core8BitManip16__moduleinfoCtorZ }] ; <[1 x %2]*> [#uses=0] +@llvm.global_ctors = appending constant [1 x %2] [%2 { i32 65535, void ()* @_D5tango4core8BitManip16__moduleinfoCtorZ, i8* null }] ; <[1 x %2]*> [#uses=0] define fastcc i32 @_D5tango4core8BitManip6popcntFkZi(i32 %x_arg) nounwind readnone { entry: Index: llvm/trunk/test/Bitcode/upgrade-global-ctors.ll =================================================================== --- llvm/trunk/test/Bitcode/upgrade-global-ctors.ll +++ llvm/trunk/test/Bitcode/upgrade-global-ctors.ll @@ -1,5 +1,5 @@ ; RUN: llvm-dis < %s.bc| FileCheck %s ; RUN: verify-uselistorder < %s.bc -; Global constructors should no longer be upgraded when reading bitcode. -; CHECK: @llvm.global_ctors = appending global [0 x { i32, void ()* }] zeroinitializer +; The 2-field form @llvm.global_ctors will be upgraded when reading bitcode. +; CHECK: @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer Index: llvm/trunk/test/Bitcode/upgrade-global-dtors.ll =================================================================== --- llvm/trunk/test/Bitcode/upgrade-global-dtors.ll +++ llvm/trunk/test/Bitcode/upgrade-global-dtors.ll @@ -0,0 +1,5 @@ +; RUN: llvm-dis < %s.bc | FileCheck %s +; RUN: verify-uselistorder < %s.bc + +; The 2-field form @llvm.global_dtors will be upgraded when reading bitcode. +; CHECK: @llvm.global_dtors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* null, i8* null }, { i32, void ()*, i8* } { i32 65534, void ()* null, i8* null }] Index: llvm/trunk/test/CodeGen/AArch64/init-array.ll =================================================================== --- llvm/trunk/test/CodeGen/AArch64/init-array.ll +++ llvm/trunk/test/CodeGen/AArch64/init-array.ll @@ -5,6 +5,6 @@ ret void } -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] ; CHECK: .section .init_array Index: llvm/trunk/test/CodeGen/ARM/ctor_order.ll =================================================================== --- llvm/trunk/test/CodeGen/ARM/ctor_order.ll +++ llvm/trunk/test/CodeGen/ARM/ctor_order.ll @@ -21,7 +21,7 @@ ; GNUEABI: .long f152 -@llvm.global_ctors = appending global [2 x { i32, void ()* }] [ { i32, void ()* } { i32 151, void ()* @f151 }, { i32, void ()* } { i32 152, void ()* @f152 } ] +@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 151, void ()* @f151, i8* null }, { i32, void ()*, i8* } { i32 152, void ()* @f152, i8* null } ] define void @f151() { entry: Index: llvm/trunk/test/CodeGen/ARM/ctors_dtors.ll =================================================================== --- llvm/trunk/test/CodeGen/ARM/ctors_dtors.ll +++ llvm/trunk/test/CodeGen/ARM/ctors_dtors.ll @@ -11,8 +11,8 @@ ; GNUEABI: .section .init_array,"aw",%init_array ; GNUEABI: .section .fini_array,"aw",%fini_array -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @__mf_init } ] ; <[1 x { i32, void ()* }]*> [#uses=0] -@llvm.global_dtors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @__mf_fini } ] ; <[1 x { i32, void ()* }]*> [#uses=0] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @__mf_init, i8* null } ] ; <[1 x { i32, void ()*, i8* }]*> [#uses=0] +@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @__mf_fini, i8* null } ] ; <[1 x { i32, void ()*, i8* }]*> [#uses=0] define void @__mf_init() { entry: Index: llvm/trunk/test/CodeGen/Mips/init-array.ll =================================================================== --- llvm/trunk/test/CodeGen/Mips/init-array.ll +++ llvm/trunk/test/CodeGen/Mips/init-array.ll @@ -2,7 +2,7 @@ target triple = "mipsel-unknown-linux" -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @test }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @test, i8* null }] ; CHECK: .section ; CHECK: .init_array ; CHECK-NOT: .ctors Index: llvm/trunk/test/CodeGen/PowerPC/pr17354.ll =================================================================== --- llvm/trunk/test/CodeGen/PowerPC/pr17354.ll +++ llvm/trunk/test/CodeGen/PowerPC/pr17354.ll @@ -10,7 +10,7 @@ %struct.CS = type { i32 } @_ZL3glb = internal global [1 x %struct.CS] zeroinitializer, align 4 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] define internal void @__cxx_global_var_init() section ".text.startup" { entry: Index: llvm/trunk/test/CodeGen/RISCV/init-array.ll =================================================================== --- llvm/trunk/test/CodeGen/RISCV/init-array.ll +++ llvm/trunk/test/CodeGen/RISCV/init-array.ll @@ -20,7 +20,7 @@ ret void } -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] ;INITARRAY: section .init_array ;INITARRAY-NOT: .section .ctors Index: llvm/trunk/test/CodeGen/SPARC/2008-10-10-InlineAsmMemoryOperand.ll =================================================================== --- llvm/trunk/test/CodeGen/SPARC/2008-10-10-InlineAsmMemoryOperand.ll +++ llvm/trunk/test/CodeGen/SPARC/2008-10-10-InlineAsmMemoryOperand.ll @@ -2,7 +2,7 @@ ; PR 1557 target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f128:128:128" -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @set_fast_math } ] ; <[1 x { i32, void ()* }]*> [#uses=0] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @set_fast_math, i8* null } ] ; <[1 x { i32, void ()*, i8* }]*> [#uses=0] define internal void @set_fast_math() nounwind { entry: Index: llvm/trunk/test/CodeGen/X86/2007-06-04-X86-64-CtorAsmBugs.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/2007-06-04-X86-64-CtorAsmBugs.ll +++ llvm/trunk/test/CodeGen/X86/2007-06-04-X86-64-CtorAsmBugs.ll @@ -3,7 +3,7 @@ %struct.A = type { [1024 x i8] } @_ZN1A1aE = global %struct.A zeroinitializer, align 32 ; <%struct.A*> [#uses=1] -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN1A1aE } ] ; <[1 x { i32, void ()* }]*> [#uses=0] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN1A1aE, i8* null } ] ; <[1 x { i32, void ()*, i8* null }]*> [#uses=0] define internal void @_GLOBAL__I__ZN1A1aE() section "__TEXT,__StaticInit,regular,pure_instructions" { entry: Index: llvm/trunk/test/CodeGen/X86/2011-08-29-InitOrder.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/2011-08-29-InitOrder.ll +++ llvm/trunk/test/CodeGen/X86/2011-08-29-InitOrder.ll @@ -2,7 +2,7 @@ ; RUN: llc < %s -mtriple=i386-apple-darwin | FileCheck %s --check-prefix=CHECK-DARWIN ; PR5329 -@llvm.global_ctors = appending global [3 x { i32, void ()* }] [{ i32, void ()* } { i32 2000, void ()* @construct_2 }, { i32, void ()* } { i32 3000, void ()* @construct_3 }, { i32, void ()* } { i32 1000, void ()* @construct_1 }] +@llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 2000, void ()* @construct_2, i8* null }, { i32, void ()*, i8* } { i32 3000, void ()* @construct_3, i8* null }, { i32, void ()*, i8* } { i32 1000, void ()* @construct_1, i8* null }] ; CHECK-DEFAULT: .section .ctors.64535,"aw",@progbits ; CHECK-DEFAULT: .long construct_1 ; CHECK-DEFAULT: .section .ctors.63535,"aw",@progbits @@ -14,7 +14,7 @@ ; CHECK-DARWIN-NEXT: .long _construct_2 ; CHECK-DARWIN-NEXT: .long _construct_3 -@llvm.global_dtors = appending global [3 x { i32, void ()* }] [{ i32, void ()* } { i32 2000, void ()* @destruct_2 }, { i32, void ()* } { i32 1000, void ()* @destruct_1 }, { i32, void ()* } { i32 3000, void ()* @destruct_3 }] +@llvm.global_dtors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 2000, void ()* @destruct_2, i8* null }, { i32, void ()*, i8* } { i32 1000, void ()* @destruct_1, i8* null }, { i32, void ()*, i8* } { i32 3000, void ()* @destruct_3, i8* null }] ; CHECK-DEFAULT: .section .dtors.64535,"aw",@progbits ; CHECK-DEFAULT: .long destruct_1 ; CHECK-DEFAULT: .section .dtors.63535,"aw",@progbits Index: llvm/trunk/test/CodeGen/X86/init-priority.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/init-priority.ll +++ llvm/trunk/test/CodeGen/X86/init-priority.ll @@ -16,7 +16,7 @@ @c1 = global %class.C zeroinitializer, align 1 @d1 = global %class.D zeroinitializer, align 1 -@llvm.global_ctors = appending global [2 x { i32, void ()* }] [{ i32, void ()* } { i32 101, void ()* @_GLOBAL__I_000101 }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 101, void ()* @_GLOBAL__I_000101, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] define linkonce_odr void @_ZN1CC1Ev(%class.C* nocapture %this) { entry: Index: llvm/trunk/test/CodeGen/X86/negate-add-zero.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/negate-add-zero.ll +++ llvm/trunk/test/CodeGen/X86/negate-add-zero.ll @@ -188,7 +188,6 @@ @"\01LC28" = external constant [15 x i8] ; <[15 x i8]*> [#uses=0] @"\01LC29" = external constant [20 x i8] ; <[20 x i8]*> [#uses=0] @"\01LC30" = external constant [41 x i8] ; <[41 x i8]*> [#uses=0] -@llvm.global_ctors = external global [1 x { i32, void ()* }] ; <[1 x { i32, void ()* }]*> [#uses=0] declare void @_GLOBAL__I__ZN9HingeNode7DEG2RADE() section "__TEXT,__StaticInit,regular,pure_instructions" Index: llvm/trunk/test/DebugInfo/COFF/asan-module-ctor.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/asan-module-ctor.ll +++ llvm/trunk/test/DebugInfo/COFF/asan-module-ctor.ll @@ -21,7 +21,7 @@ target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32" target triple = "i686-pc-win32" -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 1, void ()* @asan.module_ctor }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @asan.module_ctor, i8* null }] ; Function Attrs: nounwind sanitize_address define i32 @foo() #0 !dbg !4 { Index: llvm/trunk/test/DebugInfo/COFF/asan-module-without-functions.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/asan-module-without-functions.ll +++ llvm/trunk/test/DebugInfo/COFF/asan-module-without-functions.ll @@ -14,11 +14,11 @@ target triple = "i686-pc-win32" @c = global { i8, [63 x i8] } { i8 42, [63 x i8] zeroinitializer }, align 32 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 1, void ()* @asan.module_ctor }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @asan.module_ctor, i8* null }] @___asan_gen_ = private constant [7 x i8] c"asan.c\00", align 1 @___asan_gen_1 = private unnamed_addr constant [2 x i8] c"c\00", align 1 @0 = internal global [1 x { i32, i32, i32, i32, i32, i32 }] [{ i32, i32, i32, i32, i32, i32 } { i32 ptrtoint ({ i8, [63 x i8] }* @c to i32), i32 1, i32 64, i32 ptrtoint ([2 x i8]* @___asan_gen_1 to i32), i32 ptrtoint ([7 x i8]* @___asan_gen_ to i32), i32 0 }] -@llvm.global_dtors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 1, void ()* @asan.module_dtor }] +@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @asan.module_dtor, i8* null }] define internal void @asan.module_ctor() { call void @__asan_init_v3() Index: llvm/trunk/test/DebugInfo/Generic/incorrect-variable-debugloc.ll =================================================================== --- llvm/trunk/test/DebugInfo/Generic/incorrect-variable-debugloc.ll +++ llvm/trunk/test/DebugInfo/Generic/incorrect-variable-debugloc.ll @@ -52,7 +52,7 @@ %struct.B = type { i32 } %struct.A = type { i8 } -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 1, void ()* @asan.module_ctor }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @asan.module_ctor, i8* null }] @__asan_option_detect_stack_use_after_return = external global i32 @___asan_gen_ = private unnamed_addr constant [11 x i8] c"1 32 8 1 A\00", align 1 @___asan_gen_1 = private unnamed_addr constant [13 x i8] c"1 32 1 3 tmp\00", align 1 Index: llvm/trunk/test/DebugInfo/X86/cu-ranges-odr.ll =================================================================== --- llvm/trunk/test/DebugInfo/X86/cu-ranges-odr.ll +++ llvm/trunk/test/DebugInfo/X86/cu-ranges-odr.ll @@ -23,7 +23,7 @@ %class.A = type { i32 } @a = global %class.A zeroinitializer, align 4, !dbg !0 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] define internal void @__cxx_global_var_init() section ".text.startup" !dbg !18 { entry: Index: llvm/trunk/test/DebugInfo/X86/dbg_value_direct.ll =================================================================== --- llvm/trunk/test/DebugInfo/X86/dbg_value_direct.ll +++ llvm/trunk/test/DebugInfo/X86/dbg_value_direct.ll @@ -19,7 +19,7 @@ @__asan_mapping_offset = linkonce_odr constant i64 2147450880 @__asan_mapping_scale = linkonce_odr constant i64 3 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 1, void ()* @asan.module_ctor }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @asan.module_ctor, i8* null }] @___asan_gen_ = private unnamed_addr constant [16 x i8] c"1 32 4 5 .addr \00", align 1 ; Function Attrs: sanitize_address uwtable Index: llvm/trunk/test/DebugInfo/X86/debug-ranges-offset.ll =================================================================== --- llvm/trunk/test/DebugInfo/X86/debug-ranges-offset.ll +++ llvm/trunk/test/DebugInfo/X86/debug-ranges-offset.ll @@ -6,7 +6,7 @@ ; low_pc for the compile unit. ; CHECK-NOT: .rela.debug_ranges -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 0, void ()* @__msan_init }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__msan_init, i8* null }] @str = private unnamed_addr constant [4 x i8] c"zzz\00" @__msan_retval_tls = external thread_local(initialexec) global [8 x i64] @__msan_retval_origin_tls = external thread_local(initialexec) global i32 Index: llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll =================================================================== --- llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll +++ llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll @@ -181,7 +181,7 @@ @_ZN7echidna8capybara8mongoose6animalE = global %"class.echidna::capybara::mongoose::fluffy" zeroinitializer, align 4, !dbg !6 @w = internal global %"struct.::walrus" zeroinitializer, align 1, !dbg !16 @wom = global %struct.wombat zeroinitializer, align 4, !dbg !25 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] ; Function Attrs: nounwind uwtable define void @_Z3foov() #0 !dbg !40 { Index: llvm/trunk/test/Feature/global_pv.ll =================================================================== --- llvm/trunk/test/Feature/global_pv.ll +++ llvm/trunk/test/Feature/global_pv.ll @@ -3,8 +3,8 @@ @G1 = global i32 zeroinitializer @G2 = global i32 zeroinitializer @g = global <2 x i32*> zeroinitializer -%0 = type { i32, void ()* } -@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @test }] +%0 = type { i32, void ()*, i8* } +@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @test, i8* null }] define internal void @test() { %A = insertelement <2 x i32*> undef, i32* @G1, i32 0 %B = insertelement <2 x i32*> %A, i32* @G2, i32 1 Index: llvm/trunk/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll =================================================================== --- llvm/trunk/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll +++ llvm/trunk/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll @@ -26,7 +26,7 @@ ret void } -@llvm.global_ctors = appending global [2 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @__late_ctor }, { i32, void ()* } { i32 0, void ()* @__early_ctor }] +@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__late_ctor, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @__early_ctor, i8* null }] define internal void @__late_ctor() sanitize_address section ".text.startup" { entry: Index: llvm/trunk/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll =================================================================== --- llvm/trunk/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll +++ llvm/trunk/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll @@ -1,18 +0,0 @@ -; MSan converts 2-element global_ctors to 3-element when adding the new entry. -; RUN: opt < %s -msan-with-comdat -S -passes=msan 2>&1 | FileCheck %s -; RUN: opt < %s -msan -msan-with-comdat -S | FileCheck %s - -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -; CHECK: $msan.module_ctor = comdat any -; CHECK: @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @msan.module_ctor, i8* bitcast (void ()* @msan.module_ctor to i8*) }] - -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @f }] - -define internal void @f() { -entry: - ret void -} - -; CHECK: define internal void @msan.module_ctor() comdat { Index: llvm/trunk/test/Linker/ctors5.ll =================================================================== --- llvm/trunk/test/Linker/ctors5.ll +++ llvm/trunk/test/Linker/ctors5.ll @@ -1,8 +0,0 @@ -; RUN: llvm-link -S %s | FileCheck %s - -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @f }] -; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null }] - -define void @f() { - ret void -} Index: llvm/trunk/test/Linker/global_ctors.ll =================================================================== --- llvm/trunk/test/Linker/global_ctors.ll +++ llvm/trunk/test/Linker/global_ctors.ll @@ -1,29 +0,0 @@ -; RUN: llvm-link -S %s %S/Inputs/old_global_ctors.3.4.bc | FileCheck %s -; RUN: llvm-link -S %S/Inputs/old_global_ctors.3.4.bc %s | FileCheck %s - -; old_global_ctors.3.4.bc contains the following LLVM IL, assembled into -; bitcode by llvm-as from 3.4. It uses a two element @llvm.global_ctors array. -; --- -; declare void @a_global_ctor() -; declare void @b_global_ctor() -; -; @llvm.global_ctors = appending global [2 x { i32, void ()* } ] [ -; { i32, void ()* } { i32 65535, void ()* @a_global_ctor }, -; { i32, void ()* } { i32 65535, void ()* @b_global_ctor } -; ] -; --- - -declare void @c_global_ctor() -declare void @d_global_ctor() - -@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* } ] [ - { i32, void ()*, i8* } { i32 65535, void ()* @c_global_ctor, i8* null }, - { i32, void ()*, i8* } { i32 65535, void ()* @d_global_ctor, i8* null } -] - -; CHECK: @llvm.global_ctors = appending global [4 x { i32, void ()*, i8* }] [ -; CHECK-DAG: { i32, void ()*, i8* } { i32 65535, void ()* @a_global_ctor, i8* null } -; CHECK-DAG: { i32, void ()*, i8* } { i32 65535, void ()* @b_global_ctor, i8* null } -; CHECK-DAG: { i32, void ()*, i8* } { i32 65535, void ()* @c_global_ctor, i8* null } -; CHECK-DAG: { i32, void ()*, i8* } { i32 65535, void ()* @d_global_ctor, i8* null } -; CHECK: ] Index: llvm/trunk/test/MC/ARM/cxx-global-constructor.ll =================================================================== --- llvm/trunk/test/MC/ARM/cxx-global-constructor.ll +++ llvm/trunk/test/MC/ARM/cxx-global-constructor.ll @@ -2,7 +2,7 @@ ; RUN: -filetype=obj -o - | llvm-readobj -r | FileCheck %s -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @f }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null }] define void @f() { ret void Index: llvm/trunk/test/Transforms/GlobalDCE/global_ctors.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalDCE/global_ctors.ll +++ llvm/trunk/test/Transforms/GlobalDCE/global_ctors.ll @@ -1,12 +1,12 @@ ; RUN: opt -S -globaldce < %s | FileCheck %s ; Test that the presence of debug intrinsics isn't affecting GlobalDCE. -; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_notremovable }] +; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_notremovable, i8* null }] ; CHECK-NOT: @_GLOBAL__I_a declare void @_notremovable() -@llvm.global_ctors = appending global [3 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_b }, { i32, void ()* } { i32 65535, void ()* @_notremovable }] +@llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_b, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_notremovable, i8* null }] @x = internal unnamed_addr constant i8 undef, align 1 Index: llvm/trunk/test/Transforms/GlobalDCE/global_ctors_integration.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalDCE/global_ctors_integration.ll +++ llvm/trunk/test/Transforms/GlobalDCE/global_ctors_integration.ll @@ -9,7 +9,7 @@ @foo = global %class.Foo zeroinitializer, align 4 @_ZN3Bar18LINKER_INITIALIZEDE = external constant i32 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" { %1 = load i32, i32* @_ZN3Bar18LINKER_INITIALIZEDE, align 4 Index: llvm/trunk/test/Transforms/GlobalOpt/2006-07-07-InlineAsmCrash.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2006-07-07-InlineAsmCrash.ll +++ llvm/trunk/test/Transforms/GlobalOpt/2006-07-07-InlineAsmCrash.ll @@ -16,7 +16,7 @@ %"struct.std::vector >" = type { %"struct.std::_Vector_base >" } @registry_lock = external global %struct..0FileDescriptor ; <%struct..0FileDescriptor*> [#uses=0] @_ZN61FLAG__foo_int32_44FLAGS_E = external global %"struct.FlagRegisterer" ; <%"struct.FlagRegisterer"*> [#uses=0] -@llvm.global_ctors = appending global [20 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_10FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN60FLAG__foo_bool_19FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZNK5Bzh4Enum13is_contiguousEv }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_17FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int32_21FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN7ScannerC2Ev }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__Z11StripStringPSsPKcc }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZNK9__gnu_cxx4hashI11StringPieceEclERKS1_ }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN8Hasher325ResetEj }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__Z25ACLRv }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int64_25FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int32_7FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_18FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_17FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int32_25FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_eventbuf }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int32_26FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_16FLAGS_E }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__ZN17InitializerC2EPKcS1_PFvvE }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__checker_bcad_variable } ] ; <[20 x { i32, void ()* }]*> [#uses=0] +@llvm.global_ctors = appending global [20 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_10FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN60FLAG__foo_bool_19FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZNK5Bzh4Enum13is_contiguousEv, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_17FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int32_21FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN7ScannerC2Ev, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__Z11StripStringPSsPKcc, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZNK9__gnu_cxx4hashI11StringPieceEclERKS1_, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN8Hasher325ResetEj, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__Z25ACLRv, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int64_25FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int32_7FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_18FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_17FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int32_25FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_eventbuf, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN61FLAG__foo_int32_26FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN62FLAG__foo_string_16FLAGS_E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__ZN17InitializerC2EPKcS1_PFvvE, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__checker_bcad_variable, i8* null } ] ; <[20 x { i32, void ()*, i8* }]*> [#uses=0] declare void @_GLOBAL__I__ZN62FLAG__foo_string_10FLAGS_E() Index: llvm/trunk/test/Transforms/GlobalOpt/2007-06-04-PackedStruct.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2007-06-04-PackedStruct.ll +++ llvm/trunk/test/Transforms/GlobalOpt/2007-06-04-PackedStruct.ll @@ -9,8 +9,8 @@ %"struct.std::_Rb_tree_node_base" = type { i32, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"* } %"struct.std::map,std::allocator > >" = type { %"struct.std::_Rb_tree,std::_Select1st >,std::less,std::allocator > >" } @someMap = global %"struct.std::map,std::allocator > >" zeroinitializer ; <%"struct.std::map,std::allocator > >"*> [#uses=1] -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_someMap } ] ; <[1 x { i32, void ()* }]*> [#uses=0] -@llvm.global_dtors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @_GLOBAL__D_someMap } ] ; <[1 x { i32, void ()* }]*> [#uses=0] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_someMap, i8* null } ] ; <[1 x { i32, void ()*, i8* }]*> [#uses=0] +@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_someMap, i8* null } ] ; <[1 x { i32, void ()*, i8* }]*> [#uses=0] define void @_GLOBAL__I_someMap() { entry: Index: llvm/trunk/test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll +++ llvm/trunk/test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll @@ -6,7 +6,7 @@ @SomeVar = weak_odr global i32 0 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @CTOR } ] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @CTOR, i8* null } ] define internal void @CTOR() { store i32 23, i32* @SomeVar Index: llvm/trunk/test/Transforms/GlobalOpt/2011-04-09-EmptyGlobalCtors.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2011-04-09-EmptyGlobalCtors.ll +++ llvm/trunk/test/Transforms/GlobalOpt/2011-04-09-EmptyGlobalCtors.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -globalopt -disable-output -%0 = type { i32, void ()* } +%0 = type { i32, void ()*, i8* } @llvm.global_ctors = appending global [0 x %0] zeroinitializer Index: llvm/trunk/test/Transforms/GlobalOpt/assume.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/assume.ll +++ llvm/trunk/test/Transforms/GlobalOpt/assume.ll @@ -2,7 +2,7 @@ ; CHECK: @tmp = local_unnamed_addr global i32 42 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] @tmp = global i32 0 define i32 @TheAnswerToLifeTheUniverseAndEverything() { Index: llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll +++ llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll @@ -94,10 +94,10 @@ } @llvm.global_ctors = appending constant - [6 x { i32, void ()* }] - [{ i32, void ()* } { i32 65535, void ()* @test1 }, - { i32, void ()* } { i32 65535, void ()* @test2 }, - { i32, void ()* } { i32 65535, void ()* @test3 }, - { i32, void ()* } { i32 65535, void ()* @test4 }, - { i32, void ()* } { i32 65535, void ()* @test5 }, - { i32, void ()* } { i32 65535, void ()* @test6 }] + [6 x { i32, void ()*, i8* }] + [{ i32, void ()*, i8* } { i32 65535, void ()* @test1, i8* null }, + { i32, void ()*, i8* } { i32 65535, void ()* @test2, i8* null }, + { i32, void ()*, i8* } { i32 65535, void ()* @test3, i8* null }, + { i32, void ()*, i8* } { i32 65535, void ()* @test4, i8* null }, + { i32, void ()*, i8* } { i32 65535, void ()* @test5, i8* null }, + { i32, void ()*, i8* } { i32 65535, void ()* @test6, i8* null }] Index: llvm/trunk/test/Transforms/GlobalOpt/crash.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/crash.ll +++ llvm/trunk/test/Transforms/GlobalOpt/crash.ll @@ -2,12 +2,12 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" target triple = "i386-apple-darwin9.8" -%0 = type { i32, void ()* } +%0 = type { i32, void ()*, i8* } %struct.btSimdScalar = type { %"union.btSimdScalar::$_14" } %"union.btSimdScalar::$_14" = type { <4 x float> } @_ZL6vTwist = global %struct.btSimdScalar zeroinitializer ; <%struct.btSimdScalar*> [#uses=1] -@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @_GLOBAL__I__ZN21btConeTwistConstraintC2Ev }] ; <[12 x %0]*> [#uses=0] +@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @_GLOBAL__I__ZN21btConeTwistConstraintC2Ev, i8* null }] ; <[12 x %0]*> [#uses=0] define internal void @_GLOBAL__I__ZN21btConeTwistConstraintC2Ev() nounwind section "__TEXT,__StaticInit,regular,pure_instructions" { entry: Index: llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll +++ llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll @@ -2,7 +2,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-apple-darwin10.0.0" -%0 = type { i32, void ()* } +%0 = type { i32, void ()*, i8* } %struct.foo = type { i32* } %struct.bar = type { i128 } @@ -10,7 +10,7 @@ @H = global i32 0, align 4 @X = global %struct.foo zeroinitializer, align 8 @X2 = global %struct.bar zeroinitializer, align 8 -@llvm.global_ctors = appending global [2 x %0] [%0 { i32 65535, void ()* @init1 }, %0 { i32 65535, void ()* @init2 }] +@llvm.global_ctors = appending global [2 x %0] [%0 { i32 65535, void ()* @init1, i8* null }, %0 { i32 65535, void ()* @init2, i8* null }] ; PR8710 - GlobalOpt shouldn't change the global's initializer to have this ; arbitrary constant expression, the code generator can't handle it. Index: llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll +++ llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll @@ -6,7 +6,7 @@ ; CHECK: @H = local_unnamed_addr global i32 2 ; CHECK: @I = local_unnamed_addr global i32 2 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @CTOR } ] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @CTOR, i8* null } ] @addr = external global i32 @G = internal global [6 x [5 x i32]] zeroinitializer @H = global i32 80 Index: llvm/trunk/test/Transforms/GlobalOpt/cxx-dtor.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/cxx-dtor.ll +++ llvm/trunk/test/Transforms/GlobalOpt/cxx-dtor.ll @@ -1,12 +1,12 @@ ; RUN: opt < %s -S -passes='cgscc(inline),function(early-cse),globalopt' | FileCheck %s -%0 = type { i32, void ()* } +%0 = type { i32, void ()*, i8* } %struct.A = type { i8 } %struct.B = type { } @a = global %struct.A zeroinitializer, align 1 @__dso_handle = external global i8* -@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] ; CHECK-NOT: call i32 @__cxa_atexit Index: llvm/trunk/test/Transforms/GlobalOpt/externally-initialized-global-ctr.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/externally-initialized-global-ctr.ll +++ llvm/trunk/test/Transforms/GlobalOpt/externally-initialized-global-ctr.ll @@ -9,7 +9,7 @@ @"\01L_OBJC_METH_VAR_NAME_40" = internal global [7 x i8] c"print:\00", section "__TEXT,__objc_methname,cstring_literals", align 1 @"\01L_OBJC_SELECTOR_REFERENCES_41" = internal externally_initialized global i8* getelementptr inbounds ([7 x i8], [7 x i8]* @"\01L_OBJC_METH_VAR_NAME_40", i32 0, i32 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip" -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] @llvm.used = appending global [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @"\01L_OBJC_METH_VAR_NAME_40", i32 0, i32 0), i8* bitcast (i8** @"\01L_OBJC_SELECTOR_REFERENCES_41" to i8*)] define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" { Index: llvm/trunk/test/Transforms/GlobalOpt/int_sideeffect.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/int_sideeffect.ll +++ llvm/trunk/test/Transforms/GlobalOpt/int_sideeffect.ll @@ -6,7 +6,7 @@ declare void @llvm.sideeffect() -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @ctor } ] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @ctor, i8* null } ] @G = global i32 0 define internal void @ctor() { Index: llvm/trunk/test/Transforms/GlobalOpt/invariant-nodatalayout.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/invariant-nodatalayout.ll +++ llvm/trunk/test/Transforms/GlobalOpt/invariant-nodatalayout.ll @@ -13,5 +13,5 @@ } @llvm.global_ctors = appending constant - [1 x { i32, void ()* }] - [ { i32, void ()* } { i32 65535, void ()* @ctor1 } ] + [1 x { i32, void ()*, i8* }] + [ { i32, void ()*, i8* } { i32 65535, void ()* @ctor1, i8* null } ] Index: llvm/trunk/test/Transforms/GlobalOpt/invariant.group.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/invariant.group.ll +++ llvm/trunk/test/Transforms/GlobalOpt/invariant.group.ll @@ -11,7 +11,7 @@ @tmp3 = global i32 0 @ptrToTmp3 = global i32* null -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] define i32 @TheAnswerToLifeTheUniverseAndEverything() { ret i32 42 Index: llvm/trunk/test/Transforms/GlobalOpt/invariant.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/invariant.ll +++ llvm/trunk/test/Transforms/GlobalOpt/invariant.ll @@ -52,8 +52,8 @@ @llvm.global_ctors = appending constant - [4 x { i32, void ()* }] - [ { i32, void ()* } { i32 65535, void ()* @ctor1 }, - { i32, void ()* } { i32 65535, void ()* @ctor2 }, - { i32, void ()* } { i32 65535, void ()* @ctor3 }, - { i32, void ()* } { i32 65535, void ()* @ctor4 } ] + [4 x { i32, void ()*, i8* }] + [ { i32, void ()*, i8* } { i32 65535, void ()* @ctor1, i8* null }, + { i32, void ()*, i8* } { i32 65535, void ()* @ctor2, i8* null }, + { i32, void ()*, i8* } { i32 65535, void ()* @ctor3, i8* null }, + { i32, void ()*, i8* } { i32 65535, void ()* @ctor4, i8* null } ] Index: llvm/trunk/test/Transforms/GlobalOpt/invoke.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/invoke.ll +++ llvm/trunk/test/Transforms/GlobalOpt/invoke.ll @@ -4,7 +4,7 @@ ; Globalopt should be able to evaluate an invoke. ; CHECK: @tmp = local_unnamed_addr global i32 1 -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] @tmp = global i32 0 define i32 @one() { Index: llvm/trunk/test/Transforms/GlobalOpt/memset-null.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/memset-null.ll +++ llvm/trunk/test/Transforms/GlobalOpt/memset-null.ll @@ -1,12 +1,12 @@ ; RUN: opt -globalopt -S < %s | FileCheck %s ; PR10047 -%0 = type { i32, void ()* } +%0 = type { i32, void ()*, i8* } %struct.A = type { [100 x i32] } ; CHECK: @a @a = global %struct.A zeroinitializer, align 4 -@llvm.global_ctors = appending global [2 x %0] [%0 { i32 65535, void ()* @_GLOBAL__I_a }, %0 { i32 65535, void ()* @_GLOBAL__I_b }] +@llvm.global_ctors = appending global [2 x %0] [%0 { i32 65535, void ()* @_GLOBAL__I_a, i8* null }, %0 { i32 65535, void ()* @_GLOBAL__I_b, i8* null }] declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind Index: llvm/trunk/test/Transforms/GlobalOpt/undef-init.ll =================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/undef-init.ll +++ llvm/trunk/test/Transforms/GlobalOpt/undef-init.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -globalopt -S | FileCheck %s ; CHECK-NOT: store -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__Z3foov } ] ; <[1 x { i32, void ()* }]*> [#uses=0] +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [ { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I__Z3foov, i8* null } ] ; <[1 x { i32, void ()*, i8* }]*> [#uses=0] @X.0 = internal global i32 undef ; [#uses=2] define i32 @_Z3foov() { Index: llvm/trunk/test/Transforms/ObjCARC/apelim.ll =================================================================== --- llvm/trunk/test/Transforms/ObjCARC/apelim.ll +++ llvm/trunk/test/Transforms/ObjCARC/apelim.ll @@ -1,7 +1,7 @@ ; RUN: opt -S -objc-arc-apelim < %s | FileCheck %s ; rdar://10227311 -@llvm.global_ctors = appending global [2 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_x }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_y }] +@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_x, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_y, i8* null }] @x = global i32 0 Index: llvm/trunk/test/Transforms/ObjCARC/comdat-ipo.ll =================================================================== --- llvm/trunk/test/Transforms/ObjCARC/comdat-ipo.ll +++ llvm/trunk/test/Transforms/ObjCARC/comdat-ipo.ll @@ -2,7 +2,7 @@ ; See PR26774 -@llvm.global_ctors = appending global [2 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_x }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_y }] +@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_x, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_y, i8* null }] @x = global i32 0 Index: llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll =================================================================== --- llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll +++ llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll @@ -9,7 +9,7 @@ ; BCA-NOT: &1 | FileCheck %s + +@llvm.global_ctors = appending global [1 x { i32, void()* } ] [ + { i32, void()* } { i32 65535, void ()* null } +] +; CHECK: the third field of the element type is mandatory, specify i8* null to migrate from the obsoleted 2-field form