[PATCH] Verify clang TargetInfo DataLayouts against LLVM
Alp Toker
alp at nuanti.com
Sun Dec 29 17:53:27 PST 2013
Hi Rafael,
This is all that's left to enable opportunistic checking at clang IRGen
time where an LLVM TargetMachine is available.
include/clang/CodeGen/BackendUtil.h | 4 ++--
lib/CodeGen/BackendUtil.cpp | 11 ++++++++---
lib/CodeGen/CodeGenAction.cpp | 3 ++-
3 files changed, 12 insertions(+), 6 deletions(-)
Re-posting the updated patch as I lost track of the original thread, and
CC'ing in llvm-commits.
You mentioned there's a remaining inconsistent ARM DataLayout that needs
to get fixed before we switch this on -- was it determined if it's the
LLVM or clang string that's at fault?
Alp.
--
http://www.nuanti.com
the browser experts
-------------- next part --------------
diff --git a/include/clang/CodeGen/BackendUtil.h b/include/clang/CodeGen/BackendUtil.h
index b9f352c..f8b90b3 100644
--- a/include/clang/CodeGen/BackendUtil.h
+++ b/include/clang/CodeGen/BackendUtil.h
@@ -33,8 +33,8 @@ namespace clang {
void EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts,
const TargetOptions &TOpts, const LangOptions &LOpts,
- llvm::Module *M,
- BackendAction Action, raw_ostream *OS);
+ StringRef TDesc, llvm::Module *M, BackendAction Action,
+ raw_ostream *OS);
}
#endif
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp
index 55970cd..7b436a3 100644
--- a/lib/CodeGen/BackendUtil.cpp
+++ b/lib/CodeGen/BackendUtil.cpp
@@ -610,10 +610,15 @@ 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.
+ assert(TDesc.empty() || !AsmHelper.TM ||
+ TDesc == AsmHelper.TM->getDataLayout()->getStringRepresentation());
}
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp
index 8efeba6..3c9a225 100644
--- a/lib/CodeGen/CodeGenAction.cpp
+++ b/lib/CodeGen/CodeGenAction.cpp
@@ -150,6 +150,7 @@ namespace clang {
Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);
EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
+ C.getTargetInfo().getTargetDescription(),
TheModule.get(), Action, AsmOutStream);
Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
@@ -422,7 +423,7 @@ void CodeGenAction::ExecuteAction() {
EmitBackendOutput(CI.getDiagnostics(), CI.getCodeGenOpts(),
TargetOpts, CI.getLangOpts(),
- TheModule.get(),
+ CI.getTarget().getTargetDescription(), TheModule.get(),
BA, OS);
return;
}
More information about the llvm-commits
mailing list