<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=""><div class="">Now that we redirected all the CodeGen to the DataLayout attached to the Module, the impact of not having the correct one is unpredictable, and I feel this is even more unfriendly. It’s not like there are no change in behavior without the assert.</div><div class=""><br class=""></div><div class="">As a client I would prefer an assert (that would not impact my production) that I will notice during testing instead of weird codegen bug at runtime.<div class=""><br class=""></div><div class="">— </div><div class="">Mehdi</div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jul 30, 2015, at 4:46 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="">I guess? I mean, it seems pretty unfriendly at the moment, but you might be right and have them remember to upgrade their DataLayout instead if they put one in the module.<div class=""><br class=""></div><div class="">-eric<br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Jul 30, 2015 at 4:44 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"><div style="word-wrap:break-word" 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></div><div style="word-wrap:break-word" class=""><div class=""><div class="">Mehdi</div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 30, 2015, at 4:41 PM, Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank" class="">echristo@gmail.com</a>> wrote:</div><br class=""><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" target="_blank" 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=kTcvYbI_uRyOPM5oDPU-jXNeK0-J_KtAh55NgEf76HI&s=ZgYSkKAUqmwryfb3ThTxMwdRWGdfxFBC4qKWGollCP0&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=kTcvYbI_uRyOPM5oDPU-jXNeK0-J_KtAh55NgEf76HI&s=r7hxM6Vma7JCrQGFUVqReM6D1XdZLoSokhw1GG-lg6I&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=kTcvYbI_uRyOPM5oDPU-jXNeK0-J_KtAh55NgEf76HI&s=sdD6zpLshxQjw6tw370zMrpCMsfcoVWktK6r7Hjhp8Q&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=kTcvYbI_uRyOPM5oDPU-jXNeK0-J_KtAh55NgEf76HI&s=bD7Dw7ju3ZW3R7A6902xbIWKX2ND9CzbjqT2PaKO0Lw&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></div></blockquote></div></div></div>
</div></blockquote></div><br class=""></div></body></html>