[PATCH] D138944: [AIX][LTO] Properly respect LDR_CNTRL and set MAXDATA32 to 0xA0000000 at DSA

wael yehia via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 12:48:51 PST 2022


w2yehia created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
Herald added a project: All.
w2yehia requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

0xA0000000 at DSA is the safest maximum we can set MAXDATA32 to before calling the system assembler.
Also fix the logic for appending any user defined value of the LDR_CNTRL variable (in the current logic the shell variable expansion does not occur, so the value of LDR_CNTRL ends up being `MAXDATA32=0x80000000@${LDR_CNTRL}`)


https://reviews.llvm.org/D138944

Files:
  llvm/lib/LTO/LTOCodeGenerator.cpp


Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -261,13 +261,18 @@
     }
   }
 
+  // Setup the LDR_CNTRL variable
+  std::string LDR_CNTRL_var = "LDR_CNTRL=MAXDATA32=0xA0000000 at DSA";
+  if (Optional<std::string> V = sys::Process::GetEnv("LDR_CNTRL"))
+    LDR_CNTRL_var += ("@" + *V);
+
   // Prepare inputs for the assember.
   const auto &Triple = TargetMach->getTargetTriple();
   const char *Arch = Triple.isArch64Bit() ? "-a64" : "-a32";
   std::string ObjectFileName(AssemblyFile);
   ObjectFileName[ObjectFileName.size() - 1] = 'o';
   SmallVector<StringRef, 8> Args = {
-      "/bin/env",     "LDR_CNTRL=MAXDATA32=0x80000000@${LDR_CNTRL}",
+      "/bin/env",     LDR_CNTRL_var,
       AssemblerPath,  Arch,
       "-many",        "-o",
       ObjectFileName, AssemblyFile};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138944.478688.patch
Type: text/x-patch
Size: 924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221129/ef177959/attachment.bin>


More information about the llvm-commits mailing list