[IR] Disallow llvm.global_ctors and llvm.global_dtors of the 2-field form in textual...
authorFangrui Song <maskray@google.com>
Wed, 15 May 2019 02:35:32 +0000 (02:35 +0000)
committerFangrui Song <maskray@google.com>
Wed, 15 May 2019 02:35:32 +0000 (02:35 +0000)
commitf4dfd63c74899e2953b176de2174ae7a8924a72c
tree10b8dd0ca599015981cbea658f927847791c4d5b
parentbd3adfe5e3bcb6f8f16166d1fd8a3f3c4fd70307
[IR] Disallow llvm.global_ctors and llvm.global_dtors of the 2-field form in textual format

The 3-field form was introduced by D3499 in 2014 and the legacy 2-field
form was planned to be removed in LLVM 4.0

For the textual format, this patch migrates the existing 2-field form to
use the 3-field form and deletes the compatibility code.
test/Verifier/global-ctors-2.ll checks we have a friendly error message.

For bitcode, lib/IR/AutoUpgrade UpgradeGlobalVariables will upgrade the
2-field form (add i8* null as the third field).

Reviewed By: rnk, dexonsmith

Differential Revision: https://reviews.llvm.org/D61547

llvm-svn: 360742
60 files changed:
llvm/docs/LangRef.rst
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/IR/AutoUpgrade.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Utils/ModuleUtils.cpp
llvm/test/Bitcode/metadata-2.ll
llvm/test/Bitcode/upgrade-global-ctors.ll
llvm/test/Bitcode/upgrade-global-dtors.ll [new file with mode: 0644]
llvm/test/Bitcode/upgrade-global-dtors.ll.bc [new file with mode: 0644]
llvm/test/CodeGen/AArch64/init-array.ll
llvm/test/CodeGen/ARM/ctor_order.ll
llvm/test/CodeGen/ARM/ctors_dtors.ll
llvm/test/CodeGen/Mips/init-array.ll
llvm/test/CodeGen/PowerPC/pr17354.ll
llvm/test/CodeGen/RISCV/init-array.ll
llvm/test/CodeGen/SPARC/2008-10-10-InlineAsmMemoryOperand.ll
llvm/test/CodeGen/X86/2007-06-04-X86-64-CtorAsmBugs.ll
llvm/test/CodeGen/X86/2011-08-29-InitOrder.ll
llvm/test/CodeGen/X86/init-priority.ll
llvm/test/CodeGen/X86/negate-add-zero.ll
llvm/test/DebugInfo/COFF/asan-module-ctor.ll
llvm/test/DebugInfo/COFF/asan-module-without-functions.ll
llvm/test/DebugInfo/Generic/incorrect-variable-debugloc.ll
llvm/test/DebugInfo/X86/cu-ranges-odr.ll
llvm/test/DebugInfo/X86/dbg_value_direct.ll
llvm/test/DebugInfo/X86/debug-ranges-offset.ll
llvm/test/DebugInfo/X86/generate-odr-hash.ll
llvm/test/Feature/global_pv.ll
llvm/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll
llvm/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll [deleted file]
llvm/test/Linker/ctors5.ll [deleted file]
llvm/test/Linker/global_ctors.ll [deleted file]
llvm/test/MC/ARM/cxx-global-constructor.ll
llvm/test/Transforms/GlobalDCE/global_ctors.ll
llvm/test/Transforms/GlobalDCE/global_ctors_integration.ll
llvm/test/Transforms/GlobalOpt/2006-07-07-InlineAsmCrash.ll
llvm/test/Transforms/GlobalOpt/2007-06-04-PackedStruct.ll
llvm/test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll
llvm/test/Transforms/GlobalOpt/2011-04-09-EmptyGlobalCtors.ll
llvm/test/Transforms/GlobalOpt/assume.ll
llvm/test/Transforms/GlobalOpt/constantfold-initializers.ll
llvm/test/Transforms/GlobalOpt/crash.ll
llvm/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll
llvm/test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll
llvm/test/Transforms/GlobalOpt/cxx-dtor.ll
llvm/test/Transforms/GlobalOpt/externally-initialized-global-ctr.ll
llvm/test/Transforms/GlobalOpt/int_sideeffect.ll
llvm/test/Transforms/GlobalOpt/invariant-nodatalayout.ll
llvm/test/Transforms/GlobalOpt/invariant.group.ll
llvm/test/Transforms/GlobalOpt/invariant.ll
llvm/test/Transforms/GlobalOpt/invoke.ll
llvm/test/Transforms/GlobalOpt/memset-null.ll
llvm/test/Transforms/GlobalOpt/undef-init.ll
llvm/test/Transforms/ObjCARC/apelim.ll
llvm/test/Transforms/ObjCARC/comdat-ipo.ll
llvm/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
llvm/test/Verifier/global-ctors-2.ll [new file with mode: 0644]