[PATCH] D90782: [LTO] set data layout for module before optimize&codegen
Yuanfang Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 4 11:55:37 PST 2020
ychen created this revision.
ychen added reviewers: mehdi_amini, tejohnson.
Herald added subscribers: llvm-commits, steven_wu, hiraditya, inglorion.
Herald added a project: LLVM.
ychen requested review of this revision.
This is currently done for Clang & legacy regular LTO API. For
consistency, add the same logic to new LTO API, legacy ThinLTO API.
`check-all` shows no regression.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90782
Files:
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
Index: llvm/lib/LTO/ThinLTOCodeGenerator.cpp
===================================================================
--- llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -232,6 +232,8 @@
static void optimizeModule(Module &TheModule, TargetMachine &TM,
unsigned OptLevel, bool Freestanding,
ModuleSummaryIndex *Index) {
+ TheModule.setDataLayout(TM.createDataLayout());
+
// Populate the PassManager
PassManagerBuilder PMB;
PMB.LibraryInfo = new TargetLibraryInfoImpl(TM.getTargetTriple());
Index: llvm/lib/LTO/LTOBackend.cpp
===================================================================
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -519,6 +519,8 @@
return TOrErr.takeError();
std::unique_ptr<TargetMachine> TM = createTargetMachine(C, *TOrErr, *Mod);
+ if (TM)
+ Mod->setDataLayout(TM->createDataLayout());
if (!C.CodeGenOnly) {
if (!opt(C, TM.get(), 0, *Mod, /*IsThinLTO=*/false,
@@ -567,6 +569,8 @@
return TOrErr.takeError();
std::unique_ptr<TargetMachine> TM = createTargetMachine(Conf, *TOrErr, Mod);
+ if (TM)
+ Mod.setDataLayout(TM->createDataLayout());
// Setup optimization remarks.
auto DiagFileOrErr = lto::setupLLVMOptimizationRemarks(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90782.302926.patch
Type: text/x-patch
Size: 1318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201104/6cd8491a/attachment.bin>
More information about the llvm-commits
mailing list