[llvm] r325474 - [AVR] Fix a lowering bug in AVRISelLowering.cpp

Dylan McKay via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 00:28:38 PST 2018


Author: dylanmckay
Date: Mon Feb 19 00:28:38 2018
New Revision: 325474

URL: http://llvm.org/viewvc/llvm-project?rev=325474&view=rev
Log:
[AVR] Fix a lowering bug in AVRISelLowering.cpp

The parseFunctionArgs() method was directly reading the
arguments from a Function object, but is should have used the
arguments supplied by the SelectionDAGBuilder.

This was causing
the lowering code to only lower one argument, not two in some cases.

Thanks to @brainlag on GitHub for coming up with the working fix!

Patch-by: @brainlag on GitHub

Modified:
    llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp

Modified: llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp?rev=325474&r1=325473&r2=325474&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp Mon Feb 19 00:28:38 2018
@@ -867,10 +867,12 @@ bool AVRTargetLowering::isOffsetFoldingL
 
 /// For each argument in a function store the number of pieces it is composed
 /// of.
-static void parseFunctionArgs(const Function *F, const DataLayout *TD,
+static void parseFunctionArgs(const SmallVectorImpl<ISD::InputArg> &Ins,
                               SmallVectorImpl<unsigned> &Out) {
-  for (Argument const &Arg : F->args()) {
-    unsigned Bytes = (TD->getTypeSizeInBits(Arg.getType()) + 7) / 8;
+  for (const ISD::InputArg &Arg : Ins) {
+    if(Arg.PartOffset > 0) continue;
+    unsigned Bytes = ((Arg.ArgVT.getSizeInBits()) + 7) / 8;
+
     Out.push_back((Bytes + 1) / 2);
   }
 }
@@ -938,7 +940,7 @@ static void analyzeStandardArguments(Tar
     parseExternFuncCallArgs(*Outs, Args);
   } else {
     assert(F != nullptr && "function should not be null");
-    parseFunctionArgs(F, TD, Args);
+    parseFunctionArgs(*Ins, Args);
   }
 
   unsigned RegsLeft = array_lengthof(RegList8), ValNo = 0;




More information about the llvm-commits mailing list