<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 29, 2014 at 11:31 AM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">Reid Kleckner wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hi nicholas, nlewycky,<br>
<br>
This was an oversight in the original support.  As it is, I stuffed this<br>
bit into the alignment.  The alignment is stored in log2 form, so it<br>
doesn't need more than 6 bits.<br>
</blockquote>
<br></div>
How was alloca encoded in the 3.4 release? What would it someone need to have in their 3.4 .bc file to cause it to be read as inalloca in 3.5? "align 18446744073709551616"?</blockquote><div><br></div><div>I think using alignment of 9223372036854775808 (2**63) will be read in as 'inalloca' with this patch, because it's encoded as log2(alignment)+1, and reconstituted with (1<<align)>>1.  Do you want to raise the bar for the maximum supported alignment?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5">
<br>
  On the other hand, adding a separate<br>
</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5">
record might be cleaner.  Hence, I'm asking for a review, since we can't<br>
change the decision once we make it.<br>
<br>
<a href="http://reviews.llvm.org/D3943" target="_blank">http://reviews.llvm.org/D3943</a><br>
<br>
Files:<br>
   include/llvm/Bitcode/<u></u>LLVMBitCodes.h<br>
   lib/Bitcode/Reader/<u></u>BitcodeReader.cpp<br>
   lib/Bitcode/Writer/<u></u>BitcodeWriter.cpp<br>
   test/Bitcode/inalloca.ll<br>
<br>
Index: include/llvm/Bitcode/<u></u>LLVMBitCodes.h<br>
==============================<u></u>==============================<u></u>=======<br>
--- include/llvm/Bitcode/<u></u>LLVMBitCodes.h<br>
+++ include/llvm/Bitcode/<u></u>LLVMBitCodes.h<br>
@@ -289,7 +289,7 @@<br>
      FUNC_CODE_INST_PHI         = 16, // PHI:        [ty, val0,bb0, ...]<br>
      // 17 is unused.<br>
      // 18 is unused.<br>
-    FUNC_CODE_INST_ALLOCA      = 19, // ALLOCA:     [instty, op, align]<br>
+    FUNC_CODE_INST_ALLOCA      = 19, // ALLOCA:     [instty, opty, op, align]<br>
      FUNC_CODE_INST_LOAD        = 20, // LOAD:       [opty, op, align, vol]<br>
      // 21 is unused.<br>
      // 22 is unused.<br>
Index: lib/Bitcode/Reader/<u></u>BitcodeReader.cpp<br>
==============================<u></u>==============================<u></u>=======<br>
--- lib/Bitcode/Reader/<u></u>BitcodeReader.cpp<br>
+++ lib/Bitcode/Reader/<u></u>BitcodeReader.cpp<br>
@@ -2874,10 +2874,14 @@<br>
          dyn_cast_or_null<PointerType>(<u></u>getTypeByID(Record[0]));<br>
        Type *OpTy = getTypeByID(Record[1]);<br>
        Value *Size = getFnValueByID(Record[2], OpTy);<br>
-      unsigned Align = Record[3];<br>
+      unsigned AlignBits = Record[3];<br></div></div>
+      bool InAlloca = AlignBits&  (1<<  6);<br>
+      unsigned Align = AlignBits&  ((1<<  6) - 1);<div class=""><br>
        if (!Ty || !Size)<br>
          return Error(InvalidRecord);<br>
-      I = new AllocaInst(Ty->getElementType(<u></u>), Size, (1<<  Align)>>  1);<br>
+      AllocaInst *AI = new AllocaInst(Ty->getElementType(<u></u>), Size, (1<<  Align)>>  1);<br>
+      AI->setUsedWithInAlloca(<u></u>InAlloca);<br>
+      I = AI;<br>
        InstructionList.push_back(I);<br>
        break;<br>
      }<br>
Index: lib/Bitcode/Writer/<u></u>BitcodeWriter.cpp<br>
==============================<u></u>==============================<u></u>=======<br>
--- lib/Bitcode/Writer/<u></u>BitcodeWriter.cpp<br>
+++ lib/Bitcode/Writer/<u></u>BitcodeWriter.cpp<br>
@@ -1397,13 +1397,18 @@<br>
      break;<br>
    }<br>
<br>
-  case Instruction::Alloca:<br>
+  case Instruction::Alloca: {<br>
      Code = bitc::FUNC_CODE_INST_ALLOCA;<br>
      Vals.push_back(VE.getTypeID(I.<u></u>getType()));<br>
      Vals.push_back(VE.getTypeID(I.<u></u>getOperand(0)->getType()));<br>
      Vals.push_back(VE.getValueID(<u></u>I.getOperand(0))); // size.<br>
-    Vals.push_back(Log2_32(cast<<u></u>AllocaInst>(I).getAlignment())<u></u>+1);<br></div>
+    const AllocaInst&AI = cast<AllocaInst>(I);<div class=""><br>
+    unsigned AlignRecord = Log2_32(AI.getAlignment()) + 1;<br></div>
+    assert(AlignRecord<  1<<  6&&  "alignment greater than 1<<  64");<div><div class="h5"><br>
+    AlignRecord |= AI.isUsedWithInAlloca()<<  6;<br>
+    Vals.push_back(AlignRecord);<br>
      break;<br>
+  }<br>
<br>
    case Instruction::Load:<br>
      if (cast<LoadInst>(I).isAtomic()) {<br>
Index: test/Bitcode/inalloca.ll<br>
==============================<u></u>==============================<u></u>=======<br>
--- /dev/null<br>
+++ test/Bitcode/inalloca.ll<br>
@@ -0,0 +1,17 @@<br>
+; RUN: llvm-as<  %s | llvm-dis | FileCheck %s<br>
+<br>
+; inalloca should roundtrip.<br>
+<br>
+define void @foo(i32* inalloca %args) {<br>
+  ret void<br>
+}<br>
+; CHECK-LABEL: define void @foo(i32* inalloca %args)<br>
+<br>
+define void @bar() {<br>
+  %args = alloca inalloca i32<br>
+  call void @foo(i32* inalloca %args)<br>
+  ret void<br>
+}<br>
+; CHECK-LABEL: define void @bar() {<br>
+; CHECK: %args = alloca inalloca i32<br>
+; CHECK: call void @foo(i32* inalloca %args)<br>
<br>
<br>
<br></div></div>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</blockquote>
<br>
</blockquote></div><br></div></div>