[PATCH] D153600: Implement -frecord-command-line for XCOFF

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 3 19:41:07 PDT 2023


hubert.reinterpretcast added inline comments.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:2338
   // Emit bytes for llvm.commandline metadata.
-  emitModuleCommandLines(M);
+  // The command line metadata waas emitted earlier on XCOFF.
+  if (!TM.getTargetTriple().isOSBinFormatXCOFF())
----------------
Minor nit: Typo.


================
Comment at: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:2974
+    RSOS << "@(#)" << MDS->getString();
+    RSOS.write('\0');
+  }
----------------
stephenpeckham wrote:
> I would use a newline here.  The AIX **what **command looks for @(#) and echos subsequent bytes until it sees a double quote, a backslash, a > symbol, newline, or null byte.  The @(#) is not echoed, nor is the terminating character.  The **what **command prints a newline after it finds a terminating character.  This means that if the command line contains any of the special characters, the line will be truncated.
> 
> Exception:  If the @(#) is followed by "opt " or " opt ", the terminating characters are only a newline or null byte. This allows any of the other special characters to be part of the command line. It doesn't really matter if you use a newline or a null byte, but the legacy XL compiler uses a newline. The "opt" keyword should appear if the command line can contain a double quote, a > or a backslash.
> 
> The legacy compiler also uses other keywords besides "opt", including "version" and "cfg".  The **what** command doesn't do anything special with these keywords.
As mentioned offline, newline on its own has potential of ambiguity because it can appear in command line options (null bytes cannot). If there is a preference for newline to be present, then having a null byte after could help.

Note that `@(#)opt ` can appear on the command line too. Using `what` will have limitations (but we should leave the possibility open for other tools/methods to work).



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153600/new/

https://reviews.llvm.org/D153600



More information about the cfe-commits mailing list