diff options
author | Alp Toker <alp@nuanti.com> | 2014-01-02 15:08:04 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-01-02 15:08:04 +0000 |
commit | e83b9060cb913bd687fb5a78298404f8283cf3cb (patch) | |
tree | de623fa40c17f50c5d08e071ccc084ee2cbf48db /clang/lib/CodeGen/BackendUtil.cpp | |
parent | 961728064e0a3d13cb99d7db1144831056ff04f4 (diff) | |
download | bcm5719-llvm-e83b9060cb913bd687fb5a78298404f8283cf3cb.tar.gz bcm5719-llvm-e83b9060cb913bd687fb5a78298404f8283cf3cb.zip |
Verify that clang TargetInfo descriptions match DataLayout strings from LLVM
The backend string is only verified when available as it's possible to run
clang IRGen for targets that haven't been built or don't exist in LLVM.
llvm-svn: 198309
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 55970cdf842..db979b3524d 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -610,10 +610,23 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) { void clang::EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts, - const LangOptions &LOpts, - Module *M, - BackendAction Action, raw_ostream *OS) { + const LangOptions &LOpts, StringRef TDesc, + Module *M, BackendAction Action, + raw_ostream *OS) { EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, LOpts, M); AsmHelper.EmitAssembly(Action, OS); + + // If an optional clang TargetInfo description string was passed in, use it to + // verify the LLVM TargetMachine's DataLayout. + if (AsmHelper.TM && !TDesc.empty()) { + std::string DLDesc = + AsmHelper.TM->getDataLayout()->getStringRepresentation(); + if (DLDesc != TDesc) { + unsigned DiagID = Diags.getCustomDiagID( + DiagnosticsEngine::Error, "backend data layout '%0' does not match " + "expected target description '%1'"); + Diags.Report(DiagID) << DLDesc << TDesc; + } + } } |