[LLVMbugs] [Bug 9244] New: Sparc LowerVAARG introduces i64 load that Legalizer can't handle

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 17 23:35:50 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9244

           Summary: Sparc LowerVAARG introduces i64 load that Legalizer
                    can't handle
           Product: libraries
           Version: 2.8
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: Sparc
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: andrew-llvm at gizmolabs.org
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6175)
 --> (http://llvm.org/bugs/attachment.cgi?id=6175)
the bitcode for the failure case

Given the following C code (which produces the attached .bc file):

#include <stdarg.h>
// This function from:
//
http://en.wikipedia.org/w/index.php?title=Variadic_function&oldid=414416601#Variadic_functions_in_C.2C_Objective-C.2C_C.2B.2B.2C_and_D
double average(int count, ...)
{
    va_list ap;
    double tot = 0;
    va_start(ap, count);
    tot = va_arg(ap, double);
    va_end(ap);
    return tot;
}

Compiled with this command line on LLVM2.8 on Snow Leopard (Mac OS X 10.6):

clang -O0 -emit-llvm -c -o simple.bc simple.c -ccc-host-triple sparc

And then converted to sparc assembly with this command line:

llc -march=sparc simple.bc -o=simple.sparc

I get this assertion failure:



Assertion failed: ((isTypeLegal(Node->getOperand(i).getValueType()) ||
Node->getOperand(i).getOpcode() == ISD::TargetConstant) && "Unexpected illegal
type!"), function LegalizeOp, file LegalizeDAG.cpp, line 832.
0  llc               0x0000000100980937 PrintStackTrace(void*) + 38
1  llc               0x0000000100980ef2 SignalHandler(int) + 254
2  libSystem.B.dylib 0x00007fff8580767a _sigtramp + 26
3  llc               0x00000001004bcc9b llvm::SmallPtrSet<llvm::SDNode const*,
128u>::~SmallPtrSet() + 21
4  llc               0x000000010002f1b5 abort + 22
5  llc               0x000000010002f242
__gnu_cxx::new_allocator<llvm::sys::Path>::new_allocator() + 0
6  llc               0x0000000100410001 (anonymous
namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDValue) + 1049
7  llc               0x00000001004109bd (anonymous
namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDValue) + 3541
8  llc               0x0000000100411383 (anonymous
namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDValue) + 6043
9  llc               0x0000000100422822 (anonymous
namespace)::SelectionDAGLegalize::LegalizeDAG() + 192
10 llc               0x0000000100422967
llvm::SelectionDAG::Legalize(llvm::CodeGenOpt::Level) + 71
11 llc               0x0000000100507b31
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 2187
12 llc               0x00000001005097ac
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 230
13 llc               0x0000000100509e5e
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 1712
14 llc               0x000000010050a2be
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 746
15 llc               0x00000001005faa83
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 85
16 llc               0x00000001008c4b50
llvm::FPPassManager::runOnFunction(llvm::Function&) + 350
17 llc               0x00000001008c4d23
llvm::FPPassManager::runOnModule(llvm::Module&) + 81
18 llc               0x00000001008c4820
llvm::MPPassManager::runOnModule(llvm::Module&) + 384
19 llc               0x00000001008c5fd1
llvm::PassManagerImpl::run(llvm::Module&) + 111
20 llc               0x00000001008c6033 llvm::PassManager::run(llvm::Module&) +
33
21 llc               0x00000001000306b3 main + 2205
22 llc               0x000000010002f7fc start + 52
Stack dump:
0.    Program arguments: llc -march=sparc simple.bc -o=simple.sparc 
1.    Running pass 'Function Pass Manager' on module 'simple.bc'.
2.    Running pass 'SPARC DAG->DAG Pattern Instruction Selection' on function
'@average'


One issue is that LowerVAARG() in SparcISelLowering.cpp introduces an i64 load
if the type is an f64:

static SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) {
// snip

  // Otherwise, load it as i64, then do a bitconvert.
  SDValue V = DAG.getLoad(MVT::i64, dl, InChain, VAList, NULL, 0,
                          false, false, 0);

This seems to be where the illegal load comes from.

I'm too much an LLVM newbie to know how the legalizer is supposed to handle
this.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list