-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 9244 |
| Resolution | DUPLICATE |
| Resolved on | Feb 18, 2011 21:14 |
| Version | 2.8 |
| OS | MacOS X |
| Attachments | the bitcode for the failure case |
| CC | @asl |
Extended Description
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_allocatorllvm::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
- Running pass 'Function Pass Manager' on module 'simple.bc'.
- 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.