[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 14:40:35 PDT 2022
jdoerfert updated this revision to Diff 417752.
jdoerfert added a comment.
Try a different strategy to avoid dropping used struct names
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122328/new/
https://reviews.llvm.org/D122328
Files:
llvm/include/llvm/Linker/IRMover.h
llvm/lib/Linker/IRMover.cpp
Index: llvm/lib/Linker/IRMover.cpp
===================================================================
--- llvm/lib/Linker/IRMover.cpp
+++ llvm/lib/Linker/IRMover.cpp
@@ -14,6 +14,7 @@
#include "llvm/ADT/Triple.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
+#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GVMaterializer.h"
@@ -55,7 +56,14 @@
public:
TypeMapTy(IRMover::IdentifiedStructTypeSet &DstStructTypesSet)
- : DstStructTypesSet(DstStructTypesSet) {}
+ : DstStructTypesSet(DstStructTypesSet) {
+ // Existing destination types are mapped to themselves as they are already
+ // available.
+ for (StructType *OpaqueSTy : DstStructTypesSet.range_opaque())
+ MappedTypes[OpaqueSTy] = OpaqueSTy;
+ for (StructType *NonOpaqueSTy : DstStructTypesSet.range_non_opaque())
+ MappedTypes[NonOpaqueSTy] = NonOpaqueSTy;
+ }
IRMover::IdentifiedStructTypeSet &DstStructTypesSet;
/// Indicate that the specified type in the destination module is conceptually
Index: llvm/include/llvm/Linker/IRMover.h
===================================================================
--- llvm/include/llvm/Linker/IRMover.h
+++ llvm/include/llvm/Linker/IRMover.h
@@ -12,6 +12,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ADT/iterator_range.h"
#include <functional>
namespace llvm {
@@ -58,6 +59,27 @@
void addOpaque(StructType *Ty);
StructType *findNonOpaque(ArrayRef<Type *> ETypes, bool IsPacked);
bool hasType(StructType *Ty);
+
+ using const_non_opaque_iterator =
+ decltype(NonOpaqueStructTypes)::const_iterator;
+ const_non_opaque_iterator begin_non_opaque() const {
+ return NonOpaqueStructTypes.begin();
+ }
+ const_non_opaque_iterator end_non_opaque() const {
+ return NonOpaqueStructTypes.end();
+ }
+ llvm::iterator_range<const_non_opaque_iterator> range_non_opaque() {
+ return llvm::make_range(begin_non_opaque(), end_non_opaque());
+ }
+
+ using const_opaque_iterator = decltype(OpaqueStructTypes)::const_iterator;
+ const_opaque_iterator begin_opaque() const {
+ return OpaqueStructTypes.begin();
+ }
+ const_opaque_iterator end_opaque() const { return OpaqueStructTypes.end(); }
+ llvm::iterator_range<const_opaque_iterator> range_opaque() {
+ return llvm::make_range(begin_opaque(), end_opaque());
+ }
};
IRMover(Module &M);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122328.417752.patch
Type: text/x-patch
Size: 2545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220323/8957843d/attachment.bin>
More information about the llvm-commits
mailing list