From 6d984eb5d2d4b4a0fb64504e03c3d3c19c32024a Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 20 Dec 2013 22:01:25 +0000 Subject: Override the datalayout in a module with -triple. This matches llc's behavior. Before this patch clang would create a TargetInfo base on -triple but a llvm CodeGen based on the triple in the module. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197837 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenAction.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CodeGenAction.cpp') diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index 047dc53a0b..6fceabd109 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/lib/CodeGen/CodeGenAction.cpp @@ -419,9 +419,18 @@ void CodeGenAction::ExecuteAction() { CI.getDiagnostics().Report(Loc, DiagID); return; } + const TargetOptions &TargetOpts = CI.getTargetOpts(); + if (TheModule->getTargetTriple() != TargetOpts.Triple) { + unsigned DiagID = CI.getDiagnostics().getCustomDiagID( + DiagnosticsEngine::Warning, + "overriding the module target triple with %0"); + + CI.getDiagnostics().Report(SourceLocation(), DiagID) << TargetOpts.Triple; + TheModule->setTargetTriple(TargetOpts.Triple); + } EmitBackendOutput(CI.getDiagnostics(), CI.getCodeGenOpts(), - CI.getTargetOpts(), CI.getLangOpts(), + TargetOpts, CI.getLangOpts(), TheModule.get(), BA, OS); return; -- cgit v1.2.3