<div dir="ltr">Just wanted to say thanks, and do ping me if you run into trouble finding a way to get the backend to behave here.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 14, 2014 at 8:44 AM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: bogner<br>
Date: Thu Aug 14 10:44:29 2014<br>
New Revision: 215648<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=215648&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=215648&view=rev</a><br>
Log:<br>
Revert "CodeGen: When bitfields fall on natural boundaries, split them up"<br>
<br>
It fits better with LLVM's memory model to try to do this in the<br>
backend. Specifically, narrowing wide loads in the backends should be<br>
relatively straightforward and is generally valuable, whereas widening<br>
loads tends to be very constrained.<br>
<br>
Discussion here:<br>
<br>
<a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140811/112581.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140811/112581.html</a><br>
<br>
This reverts commit r215614.<br>
<br>
Removed:<br>
cfe/trunk/test/CodeGen/bitfield-machinewords.c<br>
Modified:<br>
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=215648&r1=215647&r2=215648&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=215648&r1=215647&r2=215648&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Thu Aug 14 10:44:29 2014<br>
@@ -377,10 +377,6 @@ CGRecordLowering::accumulateBitFields(Re<br>
}<br>
return;<br>
}<br>
-<br>
- llvm::Type *WordType =<br>
- DataLayout.getLargestLegalIntType(Types.getLLVMContext());<br>
- uint64_t WordSize = WordType ? DataLayout.getTypeSizeInBits(WordType) : 0;<br>
for (;;) {<br>
// Check to see if we need to start a new run.<br>
if (Run == FieldEnd) {<br>
@@ -396,12 +392,9 @@ CGRecordLowering::accumulateBitFields(Re<br>
++Field;<br>
continue;<br>
}<br>
- // Add bitfields to the run as long as they qualify. If we end up on a word<br>
- // boundary we insert a break since it's equivalent and very wide types are<br>
- // harder to optimize with.<br>
+ // Add bitfields to the run as long as they qualify.<br>
if (Field != FieldEnd && Field->getBitWidthValue(Context) != 0 &&<br>
- Tail == getFieldBitOffset(*Field) &&<br>
- WordSize != Tail - StartBitOffset) {<br>
+ Tail == getFieldBitOffset(*Field)) {<br>
Tail += Field->getBitWidthValue(Context);<br>
++Field;<br>
continue;<br>
<br>
Removed: cfe/trunk/test/CodeGen/bitfield-machinewords.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bitfield-machinewords.c?rev=215647&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bitfield-machinewords.c?rev=215647&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/bitfield-machinewords.c (original)<br>
+++ cfe/trunk/test/CodeGen/bitfield-machinewords.c (removed)<br>
@@ -1,79 +0,0 @@<br>
-// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK32<br>
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK64<br>
-<br>
-typedef unsigned long long uint64_t;<br>
-<br>
-struct thirty_two_bit_fields {<br>
- unsigned int ttbf1 : 32;<br>
- unsigned int ttbf2 : 32;<br>
- unsigned int ttbf3 : 32;<br>
- unsigned int ttbf4 : 32;<br>
-};<br>
-void ttbf(struct thirty_two_bit_fields *x) {}<br>
-// CHECK32: %struct.thirty_two_bit_fields = type { i32, i32, i32, i32 }<br>
-// CHECK64: %struct.thirty_two_bit_fields = type { i64, i64 }<br>
-<br>
-struct thirty_two_in_sixty_four {<br>
- uint64_t ttisf1 : 32;<br>
- uint64_t ttisf2 : 32;<br>
- uint64_t ttisf3 : 32;<br>
- uint64_t ttisf4 : 32;<br>
-};<br>
-void ttisf(struct thirty_two_in_sixty_four *x) {}<br>
-// CHECK32: %struct.thirty_two_in_sixty_four = type { i32, i32, i32, i32 }<br>
-// CHECK64: %struct.thirty_two_in_sixty_four = type { i64, i64 }<br>
-<br>
-struct everything_fits {<br>
- unsigned int ef1 : 2;<br>
- unsigned int ef2 : 29;<br>
- unsigned int ef3 : 1;<br>
-<br>
- unsigned int ef4 : 16;<br>
- unsigned int ef5 : 16;<br>
-<br>
- unsigned int ef6 : 7;<br>
- unsigned int ef7 : 25;<br>
-};<br>
-void ef(struct everything_fits *x) {}<br>
-// CHECK32: %struct.everything_fits = type { i32, i32, i32 }<br>
-// CHECK64: %struct.everything_fits = type <{ i64, i32 }><br>
-<br>
-struct not_lined_up {<br>
- uint64_t nlu1 : 31;<br>
- uint64_t nlu2 : 2;<br>
- uint64_t nlu3 : 32;<br>
- uint64_t nlu4 : 31;<br>
-};<br>
-void nlu(struct not_lined_up *x) {}<br>
-// CHECK32: %struct.not_lined_up = type { i96 }<br>
-// CHECK64: %struct.not_lined_up = type { i40, i64 }<br>
-<br>
-struct padding_between_words {<br>
- unsigned int pbw1 : 16;<br>
- unsigned int pbw2 : 14;<br>
-<br>
- unsigned int pbw3 : 12;<br>
- unsigned int pbw4 : 16;<br>
-<br>
- unsigned int pbw5 : 8;<br>
- unsigned int pbw6 : 10;<br>
-<br>
- unsigned int pbw7 : 20;<br>
- unsigned int pbw8 : 10;<br>
-};<br>
-void pbw(struct padding_between_words *x) {}<br>
-// CHECK32: %struct.padding_between_words = type { i32, i32, i24, i32 }<br>
-// CHECK64: %struct.padding_between_words = type { i32, i32, i24, i32 }<br>
-<br>
-struct unaligned_are_coalesced {<br>
- uint64_t uac1 : 16;<br>
- uint64_t uac2 : 32;<br>
- uint64_t uac3 : 16;<br>
- uint64_t uac4 : 48;<br>
- uint64_t uac5 : 64;<br>
- uint64_t uac6 : 16;<br>
- uint64_t uac7 : 32;<br>
-};<br>
-void uac(struct unaligned_are_coalesced *x) {}<br>
-// CHECK32: %struct.unaligned_are_coalesced = type { i112, i112 }<br>
-// CHECK64: %struct.unaligned_are_coalesced = type { i64, i48, i64, i48 }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>