From 29f9ff0ae72cc0a0f4bd599c95571cc2894ff200 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Tue, 19 Jan 2016 17:08:38 -0500 Subject: [PATCH] 1-bit types consume one byte of space, not zero Integer division was rounding off `i1` to take 0 bytes. Closes #173 --- lib/Target/AVR/AVRISelLowering.cpp | 4 ++-- test/CodeGen/AVR/lower-formal-arguments-assertion.ll | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/Target/AVR/AVRISelLowering.cpp b/lib/Target/AVR/AVRISelLowering.cpp index 2fa03ad7b0a..d8235b4b7fa 100644 --- a/lib/Target/AVR/AVRISelLowering.cpp +++ b/lib/Target/AVR/AVRISelLowering.cpp @@ -835,8 +835,8 @@ bool AVRTargetLowering::isOffsetFoldingLegal( static void parseFunctionArgs(const Function *F, const DataLayout *TD, SmallVectorImpl &Out) { for (Argument const &Arg : F->args()) { - unsigned Bytes = TD->getTypeSizeInBits(Arg.getType()) / 8; - Out.push_back(((Bytes == 1) || (Bytes == 2)) ? 1 : Bytes / 2); + unsigned Bytes = (TD->getTypeSizeInBits(Arg.getType()) + 7) / 8; + Out.push_back((Bytes + 1) / 2); } } diff --git a/test/CodeGen/AVR/lower-formal-arguments-assertion.ll b/test/CodeGen/AVR/lower-formal-arguments-assertion.ll index d4325fbcfe3..4c1a5ef939b 100644 --- a/test/CodeGen/AVR/lower-formal-arguments-assertion.ll +++ b/test/CodeGen/AVR/lower-formal-arguments-assertion.ll @@ -1,14 +1,7 @@ ; RUN: llc < %s -march=avr | FileCheck %s -; XFAIL: - -; Test case for an assertion error. -; -; Error: -; ``` -; "LowerFormalArguments didn't emit the correct number of values!" -; ``` -; in `lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp` define void @foo(i1) { +; CHECK-LABEL: foo: +; CHECK: ret ret void }