From 40d7d2ed66c20ccdd1a5e5a4c76879ca0bb40918 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 23 Mar 2022 15:19:29 +0100 Subject: [Bitcode] Check for live uses of llvm.cmdline/embedded.module The one use check here is very misleading: At this point we should actually have no uses, because the only possible use in llvm.used was already dropped. But because the use in llvm.used is generally bitcasted, we end up still having one dead use here. What we actually want to check is that there are no live uses, for which a helper has recently been added. --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 96f5666..d203fab 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4943,7 +4943,7 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, ConstantExpr::getPointerBitCastOrAddrSpaceCast(GV, UsedElementType)); if (llvm::GlobalVariable *Old = M.getGlobalVariable("llvm.embedded.module", true)) { - assert(Old->hasOneUse() && + assert(Old->hasZeroLiveUses() && "llvm.embedded.module can only be used once in llvm.compiler.used"); GV->takeName(Old); Old->eraseFromParent(); @@ -4966,7 +4966,7 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, UsedArray.push_back( ConstantExpr::getPointerBitCastOrAddrSpaceCast(GV, UsedElementType)); if (llvm::GlobalVariable *Old = M.getGlobalVariable("llvm.cmdline", true)) { - assert(Old->hasOneUse() && + assert(Old->hasZeroLiveUses() && "llvm.cmdline can only be used once in llvm.compiler.used"); GV->takeName(Old); Old->eraseFromParent(); -- cgit v1.1