llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-function-specialization

Author: Tony Varghese (tonykuttai)

<details>
<summary>Changes</summary>

**Note**: This PR adds LTO support for the pragma comment copyright feature 
implemented in #<!-- -->178184. Should be reviewed/merged after #<!-- -->178184.

`LowerCommentStringPass` implements `#pragma comment(copyright, ...)` on AIX by 
creating a TU-local  `@<!-- -->__loadtime_comment_str` global in the 
`__loadtime_comment` section and attaching `!implicit.ref` metadata to all 
defined functions. The PowerPC backend reads `!implicit.ref` and emits `.ref` 
directives from each function csect to the copyright string csect, so the AIX 
XCOFF linker keeps the copyright string alive whenever any function from the TU 
is live.

To keep the Pragma comment copyright strings alive during ThinLTO import and 
later GlobalDCE:  
- Update LowerCommentStringPass to emit `weak_odr, hidden` hash-named load-time 
comment strings so they can be imported across ThinLTO module boundaries.
- update `ModuleSummaryAnalysis` to include globals referenced via 
`!implicit.ref` metadata as explicit reference edges in the ThinLTO module 
summary via a new helper `findImplicitRefEdges`.
- Finally, Preserve such globals by adding available_externally globals 
referenced from imported functions' `!implicit.ref` metadata to 
`llvm.compiler.used` after import.



---

Patch is 55.60 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/199398.diff


35 Files Affected:

- (modified) clang/docs/LanguageExtensions.rst (+23) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+4) 
- (modified) clang/include/clang/Basic/PragmaKinds.h (+2-1) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+3) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+41) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+10-1) 
- (modified) clang/lib/Parse/ParsePragma.cpp (+33-4) 
- (modified) clang/test/CXX/module/cpp.pre/module_decl.cpp (+1-1) 
- (added) clang/test/CodeGen/PowerPC/pragma-comment-copyright-modules.cpp (+30) 
- (added) clang/test/CodeGen/PowerPC/pragma-comment.c (+22) 
- (modified) clang/test/CodeGen/lto-newpm-pipeline.c (+2) 
- (added) clang/test/Preprocessor/pragma-comment.c (+92) 
- (added) llvm/include/llvm/Transforms/Utils/LowerCommentStringPass.h (+24) 
- (modified) llvm/lib/Analysis/ModuleSummaryAnalysis.cpp (+24) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1) 
- (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+14) 
- (modified) llvm/lib/Passes/PassRegistry.def (+1) 
- (modified) llvm/lib/Transforms/IPO/FunctionImport.cpp (+34) 
- (modified) llvm/lib/Transforms/Utils/CMakeLists.txt (+1) 
- (added) llvm/lib/Transforms/Utils/LowerCommentStringPass.cpp (+151) 
- (modified) llvm/lib/Transforms/Utils/SCCPSolver.cpp (+27-1) 
- (added) llvm/test/Analysis/ModuleSummaryAnalysis/implicit-ref-edges.ll (+39) 
- (modified) llvm/test/CodeGen/AArch64/print-pipeline-passes.ll (+1-1) 
- (modified) llvm/test/CodeGen/Hexagon/print-pipeline-passes.ll (+1-1) 
- (added) llvm/test/LTO/PowerPC/pragma-comment-copyright-lto.ll (+88) 
- (added) llvm/test/LTO/PowerPC/pragma-comment-copyright-thinlto.ll (+67) 
- (modified) llvm/test/Other/new-pm-O0-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll (+1) 
- (added) llvm/test/Transforms/LowerCommentString/lower-comment-string.ll (+41) 


``````````diff
diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index fbb9947f39d3e..992c6f2927be8 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -6821,6 +6821,29 @@ The ``#pragma comment(lib, ...)`` directive is supported 
on all ELF targets.
 The second parameter is the library name (without the traditional Unix prefix 
of
 ``lib``).  This allows you to provide an implicit link of dependent libraries.
 
+Embedding Copyright Information on AIX
+======================================
+Clang supports the ``#pragma comment(copyright, "string")`` directive for AIX
+targets. This directive embeds a copyright or identifying string into the
+compiled object file. The string is included in the final executable or shared
+library and loaded into memory at program runtime. The directive is ignored on
+non-AIX targets.
+
+.. code-block:: c
+
+   #pragma comment(copyright, "string-literal")
+
+The second argument is an ordinary string literal. Concatenated ordinary string
+literals are also accepted. The directive is intended to appear at file scope;
+Clang treats it as being at file scope when it appears within other scopes.
+
+Interaction with C++20 Modules
+-------------------------------
+
+When ``#pragma comment(copyright, ...)`` appears in a C++20 module interface
+unit, the copyright string is embedded only in the object file compiled from
+that interface unit. Importing TUs do not re-emit the string.
+
 Evaluating Object Size
 ======================
 
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 7bcd1870a2600..91632f8d2376c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1360,6 +1360,10 @@ def err_pragma_comment_unknown_kind : Error<"unknown 
kind of pragma comment">;
 // PS4 recognizes only #pragma comment(lib)
 def warn_pragma_comment_ignored : Warning<"'#pragma comment %0' ignored">,
   InGroup<IgnoredPragmas>;
+def warn_pragma_comment_once
+    : Warning<"'#pragma comment %0' "
+              "ignored: it can be specified only once per translation unit">,
+      InGroup<IgnoredPragmas>;
 // - #pragma detect_mismatch
 def err_pragma_detect_mismatch_malformed : Error<
   "pragma detect_mismatch is malformed; it requires two comma-separated "
diff --git a/clang/include/clang/Basic/PragmaKinds.h 
b/clang/include/clang/Basic/PragmaKinds.h
index 42f049f7323d2..52ca58855d460 100644
--- a/clang/include/clang/Basic/PragmaKinds.h
+++ b/clang/include/clang/Basic/PragmaKinds.h
@@ -17,7 +17,8 @@ enum PragmaMSCommentKind {
   PCK_Lib,      // #pragma comment(lib, ...)
   PCK_Compiler, // #pragma comment(compiler, ...)
   PCK_ExeStr,   // #pragma comment(exestr, ...)
-  PCK_User      // #pragma comment(user, ...)
+  PCK_User,     // #pragma comment(user, ...)
+  PCK_Copyright // #pragma comment(copyright, ...)
 };
 
 enum PragmaMSStructKind {
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index abb6869a2b46e..d90090b82fb7a 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -2608,6 +2608,9 @@ void TextNodeDumper::VisitPragmaCommentDecl(const 
PragmaCommentDecl *D) {
   case PCK_User:
     OS << "user";
     break;
+  case PCK_Copyright:
+    OS << "copyright";
+    break;
   }
   StringRef Arg = D->getArg();
   if (!Arg.empty())
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 50089f4a5016a..9dedbed54c77a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1744,6 +1744,8 @@ void CodeGenModule::Release() {
 
   EmitBackendOptionsMetadata(getCodeGenOpts());
 
+  EmitLoadTimeComment();
+
   // If there is device offloading code embed it in the host now.
   EmbedObject(&getModule(), CodeGenOpts, *getFileSystem(), getDiags());
 
@@ -3687,6 +3689,35 @@ void CodeGenModule::AddDependentLib(StringRef Lib) {
   LinkerOptionsMetadata.push_back(llvm::MDNode::get(C, MDOpts));
 }
 
+/// Process copyright pragma and create LLVM metadata.
+///
+/// Only one copyright pragma is allowed per translation unit. Subsequent
+/// pragmas in the same TU are ignored with a warning at the parse level.
+void CodeGenModule::ProcessPragmaCommentCopyright(StringRef Comment,
+                                                  bool isFromASTFile) {
+  assert(getTriple().isOSAIX() &&
+         "pragma comment copyright is supported only when targeting AIX");
+
+  // Interaction with C++20 Modules and PCH:
+  // When a module interface unit containing a copyright pragma is imported,
+  // Clang deserializes the PragmaCommentDecl from the precompiled module file
+  // (.pcm) into the importing TU's AST. isFromASTFile() returns true for such
+  // deserialized declarations. We skip those to ensure only the module
+  // interface TU that originally parsed the pragma emits the copyright 
metadata
+  // -- not every TU that imports it. This prevents duplicate copyright strings
+  // in the final binary.
+  if (isFromASTFile)
+    return;
+
+  assert(!LoadTimeComment &&
+         "Only one copyright pragma allowed per translation unit.");
+
+  // Create LLVM metadata with the comment string.
+  auto &C = getLLVMContext();
+  llvm::Metadata *Ops[] = {llvm::MDString::get(C, Comment)};
+  LoadTimeComment = llvm::MDNode::get(C, Ops);
+}
+
 /// Add link options implied by the given module, including modules
 /// it depends on, using a postorder walk.
 static void addLinkOptionsPostorder(CodeGenModule &CGM, Module *Mod,
@@ -4207,6 +4238,13 @@ bool CodeGenModule::MustBeEmitted(const ValueDecl 
*Global) {
   return getContext().DeclMustBeEmitted(Global);
 }
 
+void CodeGenModule::EmitLoadTimeComment() {
+  if (LoadTimeComment) {
+    auto *NMD = 
getModule().getOrInsertNamedMetadata("comment_string.loadtime");
+    NMD->addOperand(LoadTimeComment);
+  }
+}
+
 bool CodeGenModule::MayBeEmittedEagerly(const ValueDecl *Global) {
   // In OpenMP 5.0 variables and function may be marked as
   // device_type(host/nohost) and we should not emit them eagerly unless we 
sure
@@ -7966,6 +8004,9 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     case PCK_Lib:
         AddDependentLib(PCD->getArg());
       break;
+    case PCK_Copyright:
+      ProcessPragmaCommentCopyright(PCD->getArg(), PCD->isFromASTFile());
+      break;
     case PCK_Compiler:
     case PCK_ExeStr:
     case PCK_User:
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 959e02924a9f7..2106ad26d54f0 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -619,6 +619,9 @@ class CodeGenModule : public CodeGenTypeCache {
   /// A vector of metadata strings for dependent libraries for ELF.
   SmallVector<llvm::MDNode *, 16> ELFDependentLibraries;
 
+  /// Metadata for copyright pragma comment (if present).
+  llvm::MDNode *LoadTimeComment = nullptr;
+
   /// @name Cache for Objective-C runtime types
   /// @{
 
@@ -1544,7 +1547,6 @@ class CodeGenModule : public CodeGenTypeCache {
   /// Appends a dependent lib to the appropriate metadata value.
   void AddDependentLib(StringRef Lib);
 
-
   llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD);
 
   void setFunctionLinkage(GlobalDecl GD, llvm::Function *F) {
@@ -1953,6 +1955,9 @@ class CodeGenModule : public CodeGenTypeCache {
   ABIArgInfo convertABIArgInfo(const llvm::abi::ArgInfo &AbiInfo,
                                QualType Type);
 
+  /// Process #pragma comment(copyright, ...).
+  void ProcessPragmaCommentCopyright(StringRef Comment, bool isFromASTFile);
+
   bool shouldDropDLLAttribute(const Decl *D, const llvm::GlobalValue *GV) 
const;
 
   llvm::Constant *GetOrCreateLLVMFunction(
@@ -2166,6 +2171,10 @@ class CodeGenModule : public CodeGenTypeCache {
   /// Emit deactivation symbols for any PFP fields whose offset is taken with
   /// offsetof.
   void emitPFPFieldsWithEvaluatedOffset();
+
+  /// Emit the load-time comment metadata (e.g., from
+  /// #pragma comment(copyright, ...)) for the translation unit.
+  void EmitLoadTimeComment();
 };
 
 }  // end namespace CodeGen
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 237874de9f8a3..f58d2c70b7d98 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -237,6 +237,7 @@ struct PragmaCommentHandler : public PragmaHandler {
 
 private:
   Sema &Actions;
+  bool SeenCopyrightInTU = false; // TU-scoped
 };
 
 struct PragmaDetectMismatchHandler : public PragmaHandler {
@@ -480,7 +481,8 @@ void Parser::initializePragmaHandlers() {
   PP.AddPragmaHandler(OpenACCHandler.get());
 
   if (getLangOpts().MicrosoftExt ||
-      getTargetInfo().getTriple().isOSBinFormatELF()) {
+      getTargetInfo().getTriple().isOSBinFormatELF() ||
+      getTargetInfo().getTriple().isOSAIX()) {
     MSCommentHandler = std::make_unique<PragmaCommentHandler>(Actions);
     PP.AddPragmaHandler(MSCommentHandler.get());
   }
@@ -607,7 +609,8 @@ void Parser::resetPragmaHandlers() {
   OpenACCHandler.reset();
 
   if (getLangOpts().MicrosoftExt ||
-      getTargetInfo().getTriple().isOSBinFormatELF()) {
+      getTargetInfo().getTriple().isOSBinFormatELF() ||
+      getTargetInfo().getTriple().isOSAIX()) {
     PP.RemovePragmaHandler(MSCommentHandler.get());
     MSCommentHandler.reset();
   }
@@ -3269,7 +3272,9 @@ void 
PragmaDetectMismatchHandler::HandlePragma(Preprocessor &PP,
 /// \code
 ///   #pragma comment(linker, "foo")
 /// \endcode
-/// 'linker' is one of five identifiers: compiler, exestr, lib, linker, user.
+/// 'linker' is one of six identifiers: compiler, copyright, exestr, lib,
+/// linker, user.
+///
 /// "foo" is a string, which is fully macro expanded, and permits string
 /// concatenation, embedded escape characters etc.  See MSDN for more details.
 void PragmaCommentHandler::HandlePragma(Preprocessor &PP,
@@ -3289,7 +3294,7 @@ void PragmaCommentHandler::HandlePragma(Preprocessor &PP,
     return;
   }
 
-  // Verify that this is one of the 5 explicitly listed options.
+  // Verify that this is one of the 6 explicitly listed options.
   IdentifierInfo *II = Tok.getIdentifierInfo();
   PragmaMSCommentKind Kind =
       llvm::StringSwitch<PragmaMSCommentKind>(II->getName())
@@ -3298,18 +3303,38 @@ void PragmaCommentHandler::HandlePragma(Preprocessor 
&PP,
           .Case("compiler", PCK_Compiler)
           .Case("exestr", PCK_ExeStr)
           .Case("user", PCK_User)
+          .Case("copyright", PCK_Copyright)
           .Default(PCK_Unknown);
   if (Kind == PCK_Unknown) {
     PP.Diag(Tok.getLocation(), diag::err_pragma_comment_unknown_kind);
     return;
   }
 
+  if (PP.getTargetInfo().getTriple().isOSAIX() && Kind != PCK_Copyright) {
+    // Currently, pragma comment kinds aside from "copyright" are not fully
+    // implemented by Clang for AIX targets.
+    PP.Diag(Tok.getLocation(), diag::warn_pragma_comment_ignored)
+        << II->getName();
+    return;
+  }
+
   if (PP.getTargetInfo().getTriple().isOSBinFormatELF() && Kind != PCK_Lib) {
     PP.Diag(Tok.getLocation(), diag::warn_pragma_comment_ignored)
         << II->getName();
     return;
   }
 
+  // Handle pragma comment copyright kind.
+  if (Kind == PCK_Copyright) {
+    if (SeenCopyrightInTU) {
+      // pragma comment copyright can each appear only once in a TU.
+      PP.Diag(Tok.getLocation(), diag::warn_pragma_comment_once)
+          << II->getName();
+      return;
+    }
+    SeenCopyrightInTU = true;
+  }
+
   // Read the optional string if present.
   PP.Lex(Tok);
   std::string ArgumentString;
@@ -3336,6 +3361,10 @@ void PragmaCommentHandler::HandlePragma(Preprocessor &PP,
     return;
   }
 
+  // Skip further processing for well-formed copyright with an empty string.
+  if (Kind == PCK_Copyright && ArgumentString.empty())
+    return;
+
   // If the pragma is lexically sound, notify any interested PPCallbacks.
   if (PP.getPPCallbacks())
     PP.getPPCallbacks()->PragmaComment(CommentLoc, II, ArgumentString);
diff --git a/clang/test/CXX/module/cpp.pre/module_decl.cpp 
b/clang/test/CXX/module/cpp.pre/module_decl.cpp
index 5c29aeff1b632..1d964fab6acb9 100644
--- a/clang/test/CXX/module/cpp.pre/module_decl.cpp
+++ b/clang/test/CXX/module/cpp.pre/module_decl.cpp
@@ -5,7 +5,7 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/gnu_line_marker.cpp 
-verify -o %t/gnu_line_marker.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/include.cpp -verify -o 
%t/include.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/ident.cpp -verify -o 
%t/ident.pcm
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_comment.cpp 
-verify -o %t/pragma_comment.pcm
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-win32 -emit-module-interface 
%t/pragma_comment.cpp -verify -o %t/pragma_comment.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_mark.cpp 
-verify -o %t/pragma_mark.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface 
%t/pragma_detect_mismatch.cpp -verify -o %t/pragma_detect_mismatch.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_clang_debug.cpp 
-verify -o %t/pragma_clang_debug.pcm
diff --git a/clang/test/CodeGen/PowerPC/pragma-comment-copyright-modules.cpp 
b/clang/test/CodeGen/PowerPC/pragma-comment-copyright-modules.cpp
new file mode 100644
index 0000000000000..b2ea09e17be74
--- /dev/null
+++ b/clang/test/CodeGen/PowerPC/pragma-comment-copyright-modules.cpp
@@ -0,0 +1,30 @@
+// RUN: split-file %s %t
+
+// Build the module interface to a PCM
+// RUN: %clang_cc1 -std=c++20 -triple powerpc-ibm-aix \
+// RUN:   -emit-module-interface %t/copymod.cppm -o %t/copymod.pcm
+
+// Verify that module interface emits copyright global when compiled to IR
+
+// RUN: %clang_cc1 -std=c++20 -triple powerpc-ibm-aix -emit-llvm 
%t/copymod.cppm -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK-MOD
+// CHECK-MOD: @[[LOADTIME_COMMENT_STR:__loadtime_comment_str_[0-9a-f]+]] = 
weak_odr hidden unnamed_addr constant [10 x i8] c"module me\00", align 1
+// CHECK-MOD: @llvm.compiler.used = appending global {{.*}} 
@[[LOADTIME_COMMENT_STR]]
+
+// Compile an importing TU that uses the prebuilt module and verify that it
+// does NOT re-emit the module's copyright global.
+
+// RUN: %clang_cc1 -std=c++20 -triple powerpc-ibm-aix \
+// RUN:   -fprebuilt-module-path=%t -emit-llvm %t/importmod.cc -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK-IMPORT
+// CHECK-IMPORT-NOT: @__loadtime_comment_str_
+// CHECK-IMPORT-NOT: c"module me\00"
+
+//--- copymod.cppm
+export module copymod;
+#pragma comment(copyright, "module me")
+export inline void f [[gnu::always_inline]]() {}
+
+//--- importmod.cc
+import copymod;
+void g() { f(); }
diff --git a/clang/test/CodeGen/PowerPC/pragma-comment.c 
b/clang/test/CodeGen/PowerPC/pragma-comment.c
new file mode 100644
index 0000000000000..32afb8bdfa33a
--- /dev/null
+++ b/clang/test/CodeGen/PowerPC/pragma-comment.c
@@ -0,0 +1,22 @@
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 %t/pragma-copyright.c -triple powerpc-ibm-aix   -emit-llvm 
-disable-llvm-passes -o - | FileCheck %s  --check-prefix=CHECK-COPYRIGHT
+// RUN: %clang_cc1 %t/pragma-copyright.c -triple powerpc64-ibm-aix -emit-llvm 
-disable-llvm-passes -o - | FileCheck %s  --check-prefix=CHECK-COPYRIGHT
+
+// RUN: %clang_cc1 %t/operator-pragma-copyright.c -triple powerpc-ibm-aix   
-emit-llvm -disable-llvm-passes -o - | FileCheck %s 
--check-prefix=CHECK-OPERATOR
+// RUN: %clang_cc1 %t/operator-pragma-copyright.c -triple powerpc64-ibm-aix 
-emit-llvm -disable-llvm-passes -o - | FileCheck %s 
--check-prefix=CHECK-OPERATOR
+
+//--- pragma-copyright.c
+#pragma comment(copyright, "@(#) Hello, " " world\n\t\"quoted\"")
+
+int main() { return 0; }
+
+// CHECK-COPYRIGHT: !comment_string.loadtime = !{![[COPYRIGHT:[0-9]+]]}
+// CHECK-COPYRIGHT: ![[COPYRIGHT]] = !{!"@(#) Hello, world\0A\09\22quoted\22"}
+
+//--- operator-pragma-copyright.c
+_Pragma("comment(copyright, \"IBM Copyright Pragma Operator\")")
+void foo() {}
+
+// CHECK-OPERATOR: !comment_string.loadtime = !{![[COPYRIGHT:[0-9]+]]}
+// CHECK-OPERATOR: ![[COPYRIGHT]] = !{!"IBM Copyright Pragma Operator"}
diff --git a/clang/test/CodeGen/lto-newpm-pipeline.c 
b/clang/test/CodeGen/lto-newpm-pipeline.c
index ea9784a76f923..664c56f0fe76f 100644
--- a/clang/test/CodeGen/lto-newpm-pipeline.c
+++ b/clang/test/CodeGen/lto-newpm-pipeline.c
@@ -32,6 +32,7 @@
 // CHECK-FULL-O0-NEXT: Running pass: AlwaysInlinerPass
 // CHECK-FULL-O0-NEXT: Running analysis: ProfileSummaryAnalysis
 // CHECK-FULL-O0-NEXT: Running pass: CoroConditionalWrapper
+// CHECK-FULL-O0-NEXT: Running pass: LowerCommentStringPass
 // CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: AnnotationRemarksPass
@@ -46,6 +47,7 @@
 // CHECK-THIN-O0-NEXT: Running pass: AlwaysInlinerPass
 // CHECK-THIN-O0-NEXT: Running analysis: ProfileSummaryAnalysis
 // CHECK-THIN-O0-NEXT: Running pass: CoroConditionalWrapper
+// CHECK-THIN-O0-NEXT: Running pass: LowerCommentStringPass
 // CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: AnnotationRemarksPass
diff --git a/clang/test/Preprocessor/pragma-comment.c 
b/clang/test/Preprocessor/pragma-comment.c
new file mode 100644
index 0000000000000..f365edf661588
--- /dev/null
+++ b/clang/test/Preprocessor/pragma-comment.c
@@ -0,0 +1,92 @@
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsyntax-only -verify 
%t/unsupported.c
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify 
%t/unsupported.c
+// RUN: %clang_cc1 -triple systemz -fsyntax-only -verify %t/unsupported.c
+// RUN: %clang_cc1 -triple powerpc64-linux-gnu -fsyntax-only -verify 
%t/unsupported.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/copyright.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/copyright.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/empty-copyright.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/empty-copyright.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/other-kinds.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/other-kinds.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/duplicate.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/duplicate.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/raw-string-literal.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/raw-string-literal.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/concat-escape.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/concat-escape.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/u8-literal.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/u8-literal.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/wide-literal.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/wide-literal.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/utf16-literal.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/utf16-literal.c
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix   -fsyntax-only -verify 
%t/utf32-literal.c
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -fsyntax-only -verify 
%t/utf32-literal.c
+
+//--- unsupported.c
+// pragma comment kinds not supported on this target.
+#pragma comment(copyright, "copyright")            // expected-warning 
{{'#pragma comment copyright' ignored}}
+#pragma comment(compiler)                          // expected-warning 
{{'#pragma comment compiler' ignored}}
+#pragma comment(exestr, "foo")                     // expected-warning 
{{'#pragma comment exestr' ignored}}
+#pragma comment(user, "foo\abar\nbaz\tsomething")  // expected-warning 
{{'#pragma comment user' ignored}}
+#pragma comment(timestamp)                         // expected-error {{unknown 
kind of pragma comment}}
+#pragma comment(date)                              // expected-error {{unknown 
kind of pragma comment}}
+
+//--- copyright.c
+// Copyright pragma is...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/199398
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to