summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-10-24 03:52:31 +0000
committerNadav Rotem <nrotem@apple.com>2012-10-24 03:52:31 +0000
commitdc06b2d39d23210b996ad9a1df8402fb732457f1 (patch)
tree75bec11788f2d3f0362d3a2a7ab5e774a957f9e3 /clang/lib/CodeGen/BackendUtil.cpp
parent67c3cf5357c7971a8f20f8b0e1d197f905a982e1 (diff)
downloadbcm5719-llvm-dc06b2d39d23210b996ad9a1df8402fb732457f1.tar.gz
bcm5719-llvm-dc06b2d39d23210b996ad9a1df8402fb732457f1.zip
Clang now attempts to create a TargetMachine whenever a triple is given.
Many of our tests specify triples that are not built into clang. In this commit we allow clang to fail loading the triple if we are only using clang to emit llvm ir. llvm-svn: 166543
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index ff1fa390d1b..ab9d49499da 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -100,9 +100,15 @@ private:
void CreatePasses(TargetMachine *TM);
- /// CreateTargetMachine - Generates the TargetMachine. Returns Null
- /// if it is unable to create the target machine.
- TargetMachine *CreateTargetMachine();
+ /// CreateTargetMachine - Generates the TargetMachine.
+ /// Returns Null if it is unable to create the target machine.
+ /// Some of our clang tests specify triples which are not built
+ /// into clang. This is okay because these tests check the generated
+ /// IR, and they require DataLayout which depends on the triple.
+ /// In this case, we allow this method to fail and not report an error.
+ /// When MustCreateTM is used, we print an error if we are unable to load
+ /// the requested target.
+ TargetMachine *CreateTargetMachine(bool MustCreateTM);
/// AddEmitPasses - Add passes necessary to emit assembly or LLVM IR.
///
@@ -260,18 +266,18 @@ void EmitAssemblyHelper::CreatePasses(TargetMachine *TM) {
if (CodeGenOpts.getDebugInfo() == CodeGenOptions::NoDebugInfo)
MPM->add(createStripSymbolsPass(true));
}
-
-
+
PMBuilder.populateModulePassManager(*MPM);
}
-TargetMachine *EmitAssemblyHelper::CreateTargetMachine() {
+TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
// Create the TargetMachine for generating code.
std::string Error;
std::string Triple = TheModule->getTargetTriple();
const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
if (!TheTarget) {
- Diags.Report(diag::err_fe_unable_to_create_target) << Error;
+ if (MustCreateTM)
+ Diags.Report(diag::err_fe_unable_to_create_target) << Error;
return 0;
}
@@ -466,7 +472,10 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) {
TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : 0);
llvm::formatted_raw_ostream FormattedOS;
- TargetMachine *TM = CreateTargetMachine();
+ bool UsesCodeGen = (Action != Backend_EmitNothing &&
+ Action != Backend_EmitBC &&
+ Action != Backend_EmitLL);
+ TargetMachine *TM = CreateTargetMachine(UsesCodeGen);
CreatePasses(TM);
switch (Action) {
OpenPOWER on IntegriCloud