[llvm] [llvm][GlobalOpt] Preserve COMDAT during SRA splitting (PR #220721)
Miguel A. Arroyo via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 14:56:26 PDT 2026
================
@@ -656,7 +657,17 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const DataLayout &DL) {
++NumSRA;
assert(NewGlobals.size() > 0);
- return NewGlobals.begin()->second;
+
+ auto *FirstNewGV = NewGlobals.begin()->second;
+
+ // For COFF, the comdat must contain a member which has the same name as the
+ // group. We rename the first new global to match.
----------------
mayanez wrote:
That's fair, we could consider creating an empty global. However, the leader will need to be preserved (this is what the other [PR](https://github.com/llvm/llvm-project/pull/220737) addresses).
I think the main benefit to the empty global is that we can pick the smallest type possible (which is not guaranteed if we use the first element).
Does that make sense?
https://github.com/llvm/llvm-project/pull/220721
More information about the llvm-commits
mailing list