[llvm] [LLVM] Add support for printing and parsing symbolic address spaces (PR #169422)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 10:52:30 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/include/llvm/TargetParser/NVPTXAddressSpaces.h llvm/include/llvm/TargetParser/Triple.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/Target/NVPTX/NVPTX.h llvm/lib/TargetParser/Triple.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 03b31f77f..b283e3836 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -633,7 +633,7 @@ void TypePrinting::incorporateTypes() {
 }
 
 static void printAddressSpace(const Module *M, unsigned AS, raw_ostream &OS,
-                              StringRef Prefix = " ", StringRef Suffix = "", 
+                              StringRef Prefix = " ", StringRef Suffix = "",
                               bool ForcePrint = false) {
   if (AS == 0 && !ForcePrint)
     return;
@@ -3913,7 +3913,8 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
   if (!UA.empty())
     Out << UA << ' ';
 
-  printAddressSpace(GV->getParent(), GV->getType()->getAddressSpace(), Out, /*Prefix=*/"", /*Suffix=*/" ");
+  printAddressSpace(GV->getParent(), GV->getType()->getAddressSpace(), Out,
+                    /*Prefix=*/"", /*Suffix=*/" ");
   if (GV->isExternallyInitialized()) Out << "externally_initialized ";
   Out << (GV->isConstant() ? "constant " : "global ");
   TypePrinter.print(GV->getValueType(), Out);
@@ -4190,7 +4191,8 @@ void AssemblyWriter::printFunction(const Function *F) {
   const Module *Mod = F->getParent();
   bool ForcePrintAddressSpace =
       !Mod || Mod->getDataLayout().getProgramAddressSpace() != 0;
-  printAddressSpace(Mod, F->getAddressSpace(), Out, /*Prefix=*/" ", /*Suffix=*/"", ForcePrintAddressSpace);
+  printAddressSpace(Mod, F->getAddressSpace(), Out, /*Prefix=*/" ",
+                    /*Suffix=*/"", ForcePrintAddressSpace);
   if (Attrs.hasFnAttrs())
     Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttrs());
   if (F->hasSection()) {
@@ -4378,7 +4380,8 @@ static void maybePrintCallAddrSpace(const Value *Operand, const Instruction *I,
   // the resulting file even without a datalayout string.
   bool ForcePrintAddrSpace =
       !Mod || Mod->getDataLayout().getProgramAddressSpace() != 0;
-  printAddressSpace(Mod, CallAddrSpace, Out, /*Prefix=*/" ", /*Suffix=*/"", ForcePrintAddrSpace);
+  printAddressSpace(Mod, CallAddrSpace, Out, /*Prefix=*/" ", /*Suffix=*/"",
+                    ForcePrintAddrSpace);
 }
 
 // This member is called for each Instruction in a function..
@@ -4745,7 +4748,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
       Out << ", align " << A->value();
     }
 
-    printAddressSpace(AI->getModule(), AI->getAddressSpace(), Out, /*Prefix=*/", ");
+    printAddressSpace(AI->getModule(), AI->getAddressSpace(), Out,
+                      /*Prefix=*/", ");
   } else if (isa<CastInst>(I)) {
     if (Operand) {
       Out << ' ';

``````````

</details>


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


More information about the llvm-commits mailing list