[llvm] 40d7d2e - [Bitcode] Check for live uses of llvm.cmdline/embedded.module

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 23 07:40:01 PDT 2022


Author: Nikita Popov
Date: 2022-03-23T15:39:39+01:00
New Revision: 40d7d2ed66c20ccdd1a5e5a4c76879ca0bb40918

URL: https://github.com/llvm/llvm-project/commit/40d7d2ed66c20ccdd1a5e5a4c76879ca0bb40918
DIFF: https://github.com/llvm/llvm-project/commit/40d7d2ed66c20ccdd1a5e5a4c76879ca0bb40918.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 96f56665be999..d203fab3155a6 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();


        


More information about the llvm-commits mailing list