[PATCH] D122328: [IRMover] Do not drop names of struct types that are used

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 23 10:04:32 PDT 2022


jdoerfert created this revision.
Herald added subscribers: bollu, hiraditya.
Herald added a project: All.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: LLVM.

When we link bitcode via clang (`-mlink-bitcode-file`) we can end up
removing the name of a struct type that is present in the user code
and the linked in file. This occurred for OpenMP codes but turned out
to be really hard to reproduce. The necessary code change to avoid
dropping those names is simple though and hopefully uncontroversial.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122328

Files:
  llvm/lib/Linker/IRMover.cpp


Index: llvm/lib/Linker/IRMover.cpp
===================================================================
--- llvm/lib/Linker/IRMover.cpp
+++ llvm/lib/Linker/IRMover.cpp
@@ -324,7 +324,10 @@
 
     if (StructType *OldT =
             DstStructTypesSet.findNonOpaque(ElementTypes, IsPacked)) {
-      STy->setName("");
+      // We can endup with STy being in the destination module and in this case
+      // we should not remove the name. Just keep using the OldT == STy.
+      if (OldT != STy)
+         STy->setName("");
       return *Entry = OldT;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122328.417677.patch
Type: text/x-patch
Size: 560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220323/58ac5bc0/attachment.bin>


More information about the llvm-commits mailing list