llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Nuri Amari (NuriAmari)

<details>
<summary>Changes</summary>

Without this change, passing -fthinlto-index causes -fpass-plugin arguments to 
be ignored. We want to be able to use plugins with distributed thin-lto, so add 
support for this.

---
Full diff: https://github.com/llvm/llvm-project/pull/183525.diff


2 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (+1) 
- (added) clang/test/CodeGen/distributed-thin-lto/pass-plugin.ll (+25) 


``````````diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 94257fb96fc7f..9b7c7cef8a5d3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1382,6 +1382,7 @@ runThinLTOBackend(CompilerInstance &CI, 
ModuleSummaryIndex *CombinedIndex,
   Conf.RemarksFormat = CGOpts.OptRecordFormat;
   Conf.SplitDwarfFile = CGOpts.SplitDwarfFile;
   Conf.SplitDwarfOutput = CGOpts.SplitDwarfOutput;
+  Conf.PassPlugins = CGOpts.PassPlugins;
   switch (Action) {
   case Backend_EmitNothing:
     Conf.PreCodeGenModuleHook = [](size_t Task, const llvm::Module &Mod) {
diff --git a/clang/test/CodeGen/distributed-thin-lto/pass-plugin.ll 
b/clang/test/CodeGen/distributed-thin-lto/pass-plugin.ll
new file mode 100644
index 0000000000000..fef5f1f3c2c0c
--- /dev/null
+++ b/clang/test/CodeGen/distributed-thin-lto/pass-plugin.ll
@@ -0,0 +1,25 @@
+; REQUIRES: x86-registered-target, plugins, examples
+
+;; Validate that -fpass-plugin works for distributed ThinLTO backends.
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,main,px
+
+; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
+; RUN:   -O2 -emit-obj -fthinlto-index=%t.o.thinlto.bc \
+; RUN:   -fpass-plugin=%llvmshlibdir/Bye%pluginext \
+; RUN:   -mllvm -wave-goodbye \
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck %s
+
+; CHECK: Bye: main
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-grtev4-linux-gnu"
+
+define i32 @main() {
+entry:
+  ret i32 0
+}

``````````

</details>


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

Reply via email to