<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">It is very late to do that (override the DL).<div class="">My impression is that it is the responsibility of the tool that will read older bitcode to handle that before feeding it to any LLVM pass.<br class=""><div class=""><br class=""></div><div class="">— </div><div class="">Mehdi</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 30, 2015, at 4:41 PM, Eric Christopher <<a href="mailto:echristo@gmail.com" class="">echristo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">So, I know I approved this, but I just thought (and by "I just thought" I mean someone said "hey, what about") about older bitcode that has a target that changed their DataLayout representation? Now they'll get an assert. Perhaps a better thing would be to do a warning in -debug mode and set the module DL to the TargetMachine DL in this case?<div class=""><br class=""></div><div class="">-eric</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Jul 30, 2015 at 1:43 PM Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mehdi_amini<br class="">
Date: Thu Jul 30 15:33:18 2015<br class="">
New Revision: 243682<br class="">
<br class="">
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243682-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=ZupYK7S-moboIWFsr-GHPxt4zLGLd7x7qtcPZjelZbA&s=51J5nHHvaoiiiCnU9nMo6xigKVBMbvINmunM8tOKWoQ&e=" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=243682&view=rev</a><br class="">
Log:<br class="">
Add a TargetMachine hook that verifies DataLayout compatibility<br class="">
<br class="">
Summary: Also provide the associated assertion when CodeGen starts.<br class="">
<br class="">
Reviewers: echristo<br class="">
<br class="">
Subscribers: llvm-commits<br class="">
<br class="">
Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D11654&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=ZupYK7S-moboIWFsr-GHPxt4zLGLd7x7qtcPZjelZbA&s=dFba-idawpScsdmD3RxVDbAMaWx5i139aJGApanh7TA&e=" rel="noreferrer" target="_blank" class="">http://reviews.llvm.org/D11654</a><br class="">
<br class="">
From: Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>><br class="">
<br class="">
Modified:<br class="">
    llvm/trunk/include/llvm/Target/TargetMachine.h<br class="">
    llvm/trunk/lib/CodeGen/MachineFunction.cpp<br class="">
<br class="">
Modified: llvm/trunk/include/llvm/Target/TargetMachine.h<br class="">
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Target_TargetMachine.h-3Frev-3D243682-26r1-3D243681-26r2-3D243682-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=ZupYK7S-moboIWFsr-GHPxt4zLGLd7x7qtcPZjelZbA&s=RBzBihg66AqckFa8caRj18cmQMK8kAYTWOqv72Bq4QQ&e=" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=243682&r1=243681&r2=243682&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)<br class="">
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Thu Jul 30 15:33:18 2015<br class="">
@@ -133,6 +133,15 @@ public:<br class="">
   /// Create a DataLayout.<br class="">
   const DataLayout createDataLayout() const { return DL; }<br class="">
<br class="">
+  /// Test if a DataLayout if compatible with the CodeGen for this target.<br class="">
+  ///<br class="">
+  /// The LLVM Module owns a DataLayout that is used for the target independent<br class="">
+  /// optimizations and code generation. This hook provides a target specific<br class="">
+  /// check on the validity of this DataLayout.<br class="">
+  bool isCompatibleDataLayout(const DataLayout &Candidate) const {<br class="">
+    return DL == Candidate;<br class="">
+  }<br class="">
+<br class="">
   /// Get the pointer size for this target.<br class="">
   ///<br class="">
   /// This is the only time the DataLayout in the TargetMachine is used.<br class="">
<br class="">
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp<br class="">
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_MachineFunction.cpp-3Frev-3D243682-26r1-3D243681-26r2-3D243682-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=ZupYK7S-moboIWFsr-GHPxt4zLGLd7x7qtcPZjelZbA&s=_CzEzpC6ZgVVu9IRXPO1mfVxkqBfvVNSjyHEyMQluUc&e=" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=243682&r1=243681&r2=243682&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)<br class="">
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Thu Jul 30 15:33:18 2015<br class="">
@@ -85,6 +85,10 @@ MachineFunction::MachineFunction(const F<br class="">
<br class="">
   FunctionNumber = FunctionNum;<br class="">
   JumpTableInfo = nullptr;<br class="">
+<br class="">
+  assert(TM.isCompatibleDataLayout(getDataLayout()) &&<br class="">
+         "Can't create a MachineFunction using a Module with a "<br class="">
+         "Target-incompatible DataLayout attached\n");<br class="">
 }<br class="">
<br class="">
 MachineFunction::~MachineFunction() {<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="">llvm-commits@cs.uiuc.edu</a><br class="">
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></div></body></html>