[PATCH] D72386: [ThinLTO] pass UnrollLoops/VectorizeLoop/VectorizeSLP in CGOpts down to pass builder in ltobackend
Wei Mi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 7 23:20:34 PST 2020
wmi updated this revision to Diff 236767.
wmi added a comment.
update flag in the test.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72386/new/
https://reviews.llvm.org/D72386
Files:
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/thinlto-debug-pm.c
llvm/include/llvm/LTO/Config.h
llvm/lib/LTO/LTOBackend.cpp
llvm/tools/llvm-lto2/CMakeLists.txt
Index: llvm/tools/llvm-lto2/CMakeLists.txt
===================================================================
--- llvm/tools/llvm-lto2/CMakeLists.txt
+++ llvm/tools/llvm-lto2/CMakeLists.txt
@@ -9,6 +9,7 @@
LTO
MC
Object
+ Passes
Support
Target
)
Index: llvm/lib/LTO/LTOBackend.cpp
===================================================================
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -169,7 +169,7 @@
PassInstrumentationCallbacks PIC;
StandardInstrumentations SI;
SI.registerCallbacks(PIC);
- PassBuilder PB(TM, PipelineTuningOptions(),PGOOpt, &PIC);
+ PassBuilder PB(TM, Conf.PTO, PGOOpt, &PIC);
AAManager AA;
// Parse a custom AA pipeline if asked to.
Index: llvm/include/llvm/LTO/Config.h
===================================================================
--- llvm/include/llvm/LTO/Config.h
+++ llvm/include/llvm/LTO/Config.h
@@ -16,6 +16,7 @@
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Target/TargetOptions.h"
@@ -126,6 +127,8 @@
/// with llvm-lto2.
std::unique_ptr<raw_ostream> ResolutionFile;
+ PipelineTuningOptions PTO;
+
/// The following callbacks deal with tasks, which normally represent the
/// entire optimization and code generation pipeline for what will become a
/// single native object file. Each task has a unique identifier between 0 and
Index: clang/test/CodeGen/thinlto-debug-pm.c
===================================================================
--- clang/test/CodeGen/thinlto-debug-pm.c
+++ clang/test/CodeGen/thinlto-debug-pm.c
@@ -13,5 +13,15 @@
// O2-OLDPM: Loop Vectorization
// O0-OLDPM-NOT: Loop Vectorization
+// Test to ensure the SLP flag is passed down to the ThinLTO backend.
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -vectorize-slp
+// -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -fdebug-pass-manager
+// -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O2-SLP
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O0 -vectorize-slp
+// -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -fdebug-pass-manager
+// -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O0-SLP
+// O2-SLP: Running pass: SLPVectorizerPass
+// O0-SLP-NOT: Running pass: SLPVectorizerPass
+
void foo() {
}
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1440,6 +1440,12 @@
Conf.OptLevel = CGOpts.OptimizationLevel;
initTargetOptions(Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts);
Conf.SampleProfile = std::move(SampleProfile);
+ Conf.PTO.LoopUnrolling = CGOpts.UnrollLoops;
+ // For historical reasons, loop interleaving is set to mirror setting for loop
+ // unrolling.
+ Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops;
+ Conf.PTO.LoopVectorization = CGOpts.VectorizeLoop;
+ Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP;
// Context sensitive profile.
if (CGOpts.hasProfileCSIRInstr()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72386.236767.patch
Type: text/x-patch
Size: 3161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200108/ba8234d7/attachment.bin>
More information about the llvm-commits
mailing list