[PATCH] D124878: [Bitcode] Include indirect users of BlockAddresses in bitcode

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 14:23:09 PDT 2022


nickdesaulniers added a comment.

Please add a test for:

  @foo = global i8* blockaddress(@repro, %label)
  
  define void @repro() {
    br label %label
  
  label:
    ret void
  }

That this DOES NOT emit a `BLOCKADDR_USERS`. This is the main case I care about, and I think we can be do less work with the queue in such cases. Differentiating when the use is an Instruction or not is important, because we only need to emit `BLOCKADDR_USERS` for Instructions, not globals.



================
Comment at: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:3405
     if (BlockAddress *BA = BlockAddress::lookup(&BB)) {
-      for (User *U : BA->users()) {
-        if (auto *I = dyn_cast<Instruction>(U)) {
-          Function *P = I->getParent()->getParent();
-          if (P != &F)
-            BlockAddressUsers.insert(P);
+      std::deque<Value *> BlockAddressUsersQueue;
+      SmallPtrSet<Value *, 16> BlockAddressUsersVisited;
----------------
Can we use a SmallVector (push_back, pop_back_val) instead?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124878/new/

https://reviews.llvm.org/D124878



More information about the llvm-commits mailing list