[lld] [LLD][COFF] Detect weak reference cycles. (PR #104463)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 09:52:35 PDT 2024


================
@@ -126,9 +127,14 @@ DefinedImportThunk::DefinedImportThunk(COFFLinkerContext &ctx, StringRef name,
 
 Defined *Undefined::getWeakAlias() {
   // A weak alias may be a weak alias to another symbol, so check recursively.
-  for (Symbol *a = weakAlias; a; a = cast<Undefined>(a)->weakAlias)
+  SmallSet<Symbol *, 4> weakChain;
----------------
MaskRay wrote:

DenseMap, which I believe has the least code size increase.

SmallPtrSet would be better than SmallSet but its small container case compiles to additional code than DenseMap.

https://github.com/llvm/llvm-project/pull/104463


More information about the llvm-commits mailing list