[llvm] [MTE] generalize overalignment / size of MTE globals (PR #121957)
    Jessica Clarke via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Jan  7 08:27:31 PST 2025
    
    
  
================
@@ -2438,12 +2446,14 @@ bool AsmPrinter::doFinalization(Module &M) {
 
   std::vector<GlobalVariable *> GlobalsToTag;
   for (GlobalVariable &G : M.globals()) {
-    if (G.isDeclaration() || !G.isTagged())
+    if (G.isDeclaration())
       continue;
-    GlobalsToTag.push_back(&G);
+    if (G.getRequiredGlobalAlignment().has_value() ||
+        G.getRequiredGlobalSize().has_value())
+      GlobalsToTag.push_back(&G);
   }
   for (GlobalVariable *G : GlobalsToTag)
-    tagGlobalDefinition(M, G);
+    tagGlobalDefinition(G);
----------------
jrtc27 wrote:
Why did you choose to modify the IR rather than alter emitGlobalVariable to align and pad as it emits them? I don't think it really matters (though could be missing some subtleties), but it would seem more efficient to do it on the fly rather than create a whole bunch of new GlobalVariables and RAUW. That also lets you skip creating a modified initialiser and instead just emit some extra zeroes in emitGlobalConstant. This is the approach we took in CHERI LLVM instead.
https://github.com/llvm/llvm-project/pull/121957
    
    
More information about the llvm-commits
mailing list