diff --git a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c --- a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c +++ b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c @@ -33,7 +33,7 @@ i_DIFlagPublic, i_DIFlagFwdDecl, i_DIFlagAppleBlock, - i_DIFlagReservedBit4, + i_DIFlagIsZeroSize, i_DIFlagVirtual, i_DIFlagArtificial, i_DIFlagExplicit, @@ -78,8 +78,8 @@ return LLVMDIFlagFwdDecl; case i_DIFlagAppleBlock: return LLVMDIFlagAppleBlock; - case i_DIFlagReservedBit4: - return LLVMDIFlagReservedBit4; + case i_DIFlagIsZeroSize: + return LLVMDIFlagIsZeroSize; case i_DIFlagVirtual: return LLVMDIFlagVirtual; case i_DIFlagArtificial: diff --git a/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml b/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml --- a/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml +++ b/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml @@ -65,7 +65,7 @@ | Public | FwdDecl | AppleBlock - | ReservedBit4 + | IsZeroSize | Virtual | Artificial | Explicit diff --git a/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli b/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli --- a/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli +++ b/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli @@ -65,7 +65,7 @@ | Public | FwdDecl | AppleBlock - | ReservedBit4 + | IsZeroSize | Virtual | Artificial | Explicit diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h --- a/llvm/include/llvm-c/DebugInfo.h +++ b/llvm/include/llvm-c/DebugInfo.h @@ -31,7 +31,7 @@ LLVMDIFlagPublic = 3, LLVMDIFlagFwdDecl = 1 << 2, LLVMDIFlagAppleBlock = 1 << 3, - LLVMDIFlagReservedBit4 = 1 << 4, + LLVMDIFlagIsZeroSize = 1 << 4, LLVMDIFlagVirtual = 1 << 5, LLVMDIFlagArtificial = 1 << 6, LLVMDIFlagExplicit = 1 << 7, @@ -59,8 +59,8 @@ LLVMDIFlagLittleEndian = 1 << 28, LLVMDIFlagAllCallsDescribed = 1 << 29, LLVMDIFlagIndirectVirtualBase = (1 << 2) | (1 << 5), - LLVMDIFlagAccessibility = LLVMDIFlagPrivate | LLVMDIFlagProtected | - LLVMDIFlagPublic, + LLVMDIFlagAccessibility = + LLVMDIFlagPrivate | LLVMDIFlagProtected | LLVMDIFlagPublic, LLVMDIFlagPtrToMemberRep = LLVMDIFlagSingleInheritance | LLVMDIFlagMultipleInheritance | LLVMDIFlagVirtualInheritance diff --git a/llvm/include/llvm/IR/DebugInfoFlags.def b/llvm/include/llvm/IR/DebugInfoFlags.def --- a/llvm/include/llvm/IR/DebugInfoFlags.def +++ b/llvm/include/llvm/IR/DebugInfoFlags.def @@ -36,8 +36,10 @@ HANDLE_DI_FLAG(3, Public) HANDLE_DI_FLAG((1 << 2), FwdDecl) HANDLE_DI_FLAG((1 << 3), AppleBlock) -// Used to be BlockByRef, can be reused for anything except DICompositeType. -HANDLE_DI_FLAG((1 << 4), ReservedBit4) +// IsZeroSize is valid only for DIDerivedType. +// This bit was used as BlockByrefStruct for DICompositeType (D67453), do not +// reuse it for DICompositeType so that Verifier can detect old bitcode. +HANDLE_DI_FLAG((1 << 4), IsZeroSize) HANDLE_DI_FLAG((1 << 5), Virtual) HANDLE_DI_FLAG((1 << 6), Artificial) HANDLE_DI_FLAG((1 << 7), Explicit) diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -1102,7 +1102,9 @@ N.getRawVTableHolder()); AssertDI(!hasConflictingReferenceFlags(N.getFlags()), "invalid reference flags", &N); - unsigned DIBlockByRefStruct = 1 << 4; + const unsigned DIBlockByRefStruct = 1 << 4; + static_assert(DIBlockByRefStruct == DINode::FlagIsZeroSize, + "DI Flag BlockByRefStruct == IsZeroSize"); AssertDI((N.getFlags() & DIBlockByRefStruct) == 0, "DIBlockByRefStruct on DICompositeType is no longer supported", &N); diff --git a/llvm/test/Verifier/blockbyref.ll b/llvm/test/Verifier/blockbyref.ll --- a/llvm/test/Verifier/blockbyref.ll +++ b/llvm/test/Verifier/blockbyref.ll @@ -16,4 +16,4 @@ !0 = !{i32 2, !"Debug Info Version", i32 3} !1 = distinct !DISubprogram() !2 = !DILocalVariable(scope: !1, type: !3) -!3 = !DICompositeType(tag: DW_TAG_structure_type, flags: DIFlagReservedBit4) +!3 = !DICompositeType(tag: DW_TAG_structure_type, flags: DIFlagIsZeroSize)