[llvm] [MTE] [NFC] use vector to collect globals to tag (PR #120283)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 10:47:51 PST 2024


https://github.com/fmayer updated https://github.com/llvm/llvm-project/pull/120283

>From 76829f2ba98e97b5641622d01a65f69dfdf13e9c Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Tue, 17 Dec 2024 10:43:22 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index a1f5e5d208ffba..43e6270491d75a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2444,11 +2444,14 @@ bool AsmPrinter::doFinalization(Module &M) {
   // we can conditionalize accesses based on whether or not it is nullptr.
   MF = nullptr;
 
-  for (GlobalVariable &G : make_early_inc_range(M.globals())) {
+  std::vector<GlobalVariable*> GlobalsToTag;
+  for (GlobalVariable &G : M.globals()) {
     if (G.isDeclaration() || !G.isTagged())
       continue;
-    tagGlobalDefinition(M, &G);
+    GlobalsToTag.push_back(&G);
   }
+  for (GlobalVariable* G : GlobalsToTag)
+    tagGlobalDefinition(M, G);
 
   // Gather all GOT equivalent globals in the module. We really need two
   // passes over the globals: one to compute and another to avoid its emission

>From cca0d6a9e0406415d9cacc171ea68547ec766491 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Tue, 17 Dec 2024 10:47:35 -0800
Subject: [PATCH 2/2] fmt

Created using spr 1.3.4
---
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 43e6270491d75a..47a93d624dfa9c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2444,13 +2444,13 @@ bool AsmPrinter::doFinalization(Module &M) {
   // we can conditionalize accesses based on whether or not it is nullptr.
   MF = nullptr;
 
-  std::vector<GlobalVariable*> GlobalsToTag;
+  std::vector<GlobalVariable *> GlobalsToTag;
   for (GlobalVariable &G : M.globals()) {
     if (G.isDeclaration() || !G.isTagged())
       continue;
     GlobalsToTag.push_back(&G);
   }
-  for (GlobalVariable* G : GlobalsToTag)
+  for (GlobalVariable *G : GlobalsToTag)
     tagGlobalDefinition(M, G);
 
   // Gather all GOT equivalent globals in the module. We really need two



More information about the llvm-commits mailing list