summaryrefslogtreecommitdiff
path: root/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-01-02 15:08:04 +0000
committerAlp Toker <alp@nuanti.com>2014-01-02 15:08:04 +0000
commit2a030a3aec48ed18846518aab60e5e5e72f381cc (patch)
tree7bc2e30a55613ecef9e353e139356a116ced09d2 /lib/CodeGen/BackendUtil.cpp
parent65f5b90a5b0623d7fc053050ca0fade528ed12ee (diff)
downloadclang-2a030a3aec48ed18846518aab60e5e5e72f381cc.tar.gz
clang-2a030a3aec48ed18846518aab60e5e5e72f381cc.tar.bz2
clang-2a030a3aec48ed18846518aab60e5e5e72f381cc.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/BackendUtil.cpp')
-rw-r--r--lib/CodeGen/BackendUtil.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp
index 55970cdf84..db979b3524 100644
--- a/lib/CodeGen/BackendUtil.cpp
+++ b/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;
+ }
+ }
}