summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2019-05-06 23:24:17 +0000
committerPetr Hosek <phosek@chromium.org>2019-05-06 23:24:17 +0000
commit5f2e10e9c3251f623d9962984a34ae40bb84b1ff (patch)
treeb16b4fcd9c9017544aeeb16e857f1bb13e22019e /clang/lib/CodeGen/BackendUtil.cpp
parent2ea088173df0d44db3202b6b2904901c0a6dabe5 (diff)
downloadbcm5719-llvm-5f2e10e9c3251f623d9962984a34ae40bb84b1ff.tar.gz
bcm5719-llvm-5f2e10e9c3251f623d9962984a34ae40bb84b1ff.zip
[Clang][NewPM] Don't bail out if the target machine is empty
This matches the behavior of the old pass manager. There are some targets that don't have target machine at all (e.g. le32, spir) which whose tests would never run with new pass manager. Similarly, we would need to disable tests for targets that are disabled. Differential Revision: https://reviews.llvm.org/D58374 llvm-svn: 360100
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index a43ebe9a2e0..cd2a5f6fa3f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -965,13 +965,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
TimeRegion Region(FrontendTimesIsEnabled ? &CodeGenerationTime : nullptr);
setCommandLineOpts(CodeGenOpts);
- // The new pass manager always makes a target machine available to passes
- // during construction.
- CreateTargetMachine(/*MustCreateTM*/ true);
- if (!TM)
- // This will already be diagnosed, just bail.
+ bool RequiresCodeGen = (Action != Backend_EmitNothing &&
+ Action != Backend_EmitBC &&
+ Action != Backend_EmitLL);
+ CreateTargetMachine(RequiresCodeGen);
+
+ if (RequiresCodeGen && !TM)
return;
- TheModule->setDataLayout(TM->createDataLayout());
+ if (TM)
+ TheModule->setDataLayout(TM->createDataLayout());
Optional<PGOOptions> PGOOpt;
OpenPOWER on IntegriCloud