[llvm] db9f06c - Remove cl::callback from AArch64CodeLayoutOpt and AddressSanitizer (#226757)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 27 11:56:56 PDT 2026


Author: Fangrui Song
Date: 2026-09-27T11:56:46-07:00
New Revision: db9f06ce021c54523afc8bf9d0cfe45aba2eba09

URL: https://github.com/llvm/llvm-project/commit/db9f06ce021c54523afc8bf9d0cfe45aba2eba09
DIFF: https://github.com/llvm/llvm-project/commit/db9f06ce021c54523afc8bf9d0cfe45aba2eba09.diff

LOG: Remove cl::callback from AArch64CodeLayoutOpt and AddressSanitizer (#226757)

cl::callback will be removed to enable migration to TableGen based
representation

LLM-aided

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/AArch64CodeLayoutOpt.cpp
    llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64CodeLayoutOpt.cpp b/llvm/lib/Target/AArch64/AArch64CodeLayoutOpt.cpp
index 76ba3f38be549..582dff927e07d 100644
--- a/llvm/lib/Target/AArch64/AArch64CodeLayoutOpt.cpp
+++ b/llvm/lib/Target/AArch64/AArch64CodeLayoutOpt.cpp
@@ -56,11 +56,7 @@ static cl::opt<unsigned> FunctionAlignBytes(
     "aarch64-code-layout-opt-align-functions", cl::Hidden,
     cl::desc("Function alignment in bytes for code layout optimization "
              "(must be a power of 2)"),
-    cl::init(64), cl::callback([](const unsigned &Val) {
-      if (!isPowerOf2_32(Val))
-        report_fatal_error(
-            "aarch64-code-layout-opt-align must be a power of 2");
-    }));
+    cl::init(64));
 
 STATISTIC(NumFunctionsAligned,
           "Number of functions with aligned (to 64-bytes by default)");
@@ -267,6 +263,9 @@ bool AArch64CodeLayoutOpt::optimizeForCodeLayout(MachineFunction &MF,
   if (!Changed)
     return false;
 
+  if (!isPowerOf2_32(FunctionAlignBytes))
+    reportFatalUsageError(
+        "aarch64-code-layout-opt-align-functions must be a power of 2");
   if (MF.getAlignment() < Align(FunctionAlignBytes)) {
     MF.setAlignment(Align(FunctionAlignBytes));
     ++NumFunctionsAligned;

diff  --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 3e9b0b3d39c47..6e028b5659fed 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -20,7 +20,6 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
@@ -443,13 +442,10 @@ static cl::opt<AsanDtorKind> ClOverrideDestructorKind(
                           "Use global destructors")),
     cl::init(AsanDtorKind::Invalid), cl::Hidden);
 
-static SmallSet<unsigned, 8> SrcAddrSpaces;
 static cl::list<unsigned> ClAddrSpaces(
     "asan-instrument-address-spaces",
     cl::desc("Only instrument variables in the specified address spaces."),
-    cl::Hidden, cl::CommaSeparated, cl::callback([](const unsigned &AddrSpace) {
-      SrcAddrSpaces.insert(AddrSpace);
-    }));
+    cl::Hidden, cl::CommaSeparated);
 
 // Debug flags.
 
@@ -1411,8 +1407,8 @@ static bool isSupportedAddrspace(const Triple &TargetTriple, Value *Addr) {
   Type *PtrTy = cast<PointerType>(Addr->getType()->getScalarType());
   unsigned int AddrSpace = PtrTy->getPointerAddressSpace();
 
-  if (!SrcAddrSpaces.empty())
-    return SrcAddrSpaces.count(AddrSpace);
+  if (!ClAddrSpaces.empty())
+    return is_contained(ClAddrSpaces, AddrSpace);
 
   if (TargetTriple.isAMDGPU())
     return !isUnsupportedAMDGPUAddrspace(Addr);


        


More information about the llvm-commits mailing list