Skip to content

JIT: uitofp on vector type hits assert in X86TargetLowering / SelectionDAG #9607

@llvmbot

Description

@llvmbot
Bugzilla Link 9235
Resolution FIXED
Resolved on Oct 22, 2011 07:55
Version trunk
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

Given this program:

define <4 x float> @​f_f(<4 x i32>) nounwind {
entry:
%uint2float.i = uitofp <4 x i32> %0 to <4 x float>
ret <4 x float> %uint2float.i
}

If I try to run it with the JIT with the test program below, then I hit the following assert. (Note that this happens in the dev branch, but it works fine with the 2.8 release).

SelectionDAG.cpp:2693: llvm::SDValue llvm::SelectionDAG::getNode(unsigned int, llvm::DebugLoc, llvm::EVT, llvm::SDValue, llvm::SDValue): Assertion `N1.getValueType() == N2.getValueType() && N1.getValueType() == VT && "Binary operator types must match!"' failed.

with the following stack trace:

(gdb) where
#​0 0x00002aaaab8d2a75 in *__GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#​1 0x00002aaaab8d65c0 in *__GI_abort () at abort.c:92
#​2 0x00002aaaab8cb941 in *__GI___assert_fail (
assertion=0xbc8220 "N1.getValueType() == N2.getValueType() && N1.getValueType() == VT && "Binary operator types must match!"", file=, line=2693,
function=0xbcf360 "llvm::SDValue llvm::SelectionDAG::getNode(unsigned int, llvm::DebugLoc, llvm::EVT, llvm::SDValue, llvm::SDValue)") at assert.c:81
#​3 0x00000000005c4bf4 in llvm::SelectionDAG::getNode (this=0x11ce000, Opcode=47, DL=..., VT=..., N1=..., N2=...)
at SelectionDAG.cpp:2693
#​4 0x00000000004df47d in PerformEXTRACT_VECTOR_ELTCombine (N=0x11f4b00, DAG=..., TLI=...)
at X86ISelLowering.cpp:10893
#​5 0x00000000004e8279 in llvm::X86TargetLowering::PerformDAGCombine (this=0x11afb48, N=0x11f4b00, DCI=...)
at X86ISelLowering.cpp:11948
#​6 0x000000000056a999 in combine (this=0x7fffffffd930, N=0x11f4b00) at DAGCombiner.cpp:1109
#​7 0x00000000005697c5 in Run (this=0x7fffffffd930, AtLevel=llvm::NoIllegalOperations) at DAGCombiner.cpp:966
#​8 0x00000000005a0ee8 in llvm::SelectionDAG::Combine (this=0x11ce000, Level=llvm::NoIllegalOperations, AA=...,
OptLevel=llvm::CodeGenOpt::Default) at DAGCombiner.cpp:7573
#​9 0x0000000000637ab9 in llvm::SelectionDAGISel::CodeGenAndEmitDAG (this=0x11ccaa0) at SelectionDAGISel.cpp:585
#​10 0x0000000000636bb4 in llvm::SelectionDAGISel::SelectBasicBlock (this=0x11ccaa0, Begin=..., End=...,
HadTailCall=@0x7fffffffddff) at SelectionDAGISel.cpp:439
#​11 0x000000000063917e in llvm::SelectionDAGISel::SelectAllBasicBlocks (this=0x11ccaa0, Fn=...)
at SelectionDAGISel.cpp:970
#​12 0x0000000000636121 in llvm::SelectionDAGISel::runOnMachineFunction (this=0x11ccaa0, mf=...)
at SelectionDAGISel.cpp:306
#​13 0x0000000000744a19 in llvm::MachineFunctionPass::runOnFunction (this=0x11ccaa0, F=...)
at MachineFunctionPass.cpp:33
#​14 0x0000000000a75679 in llvm::FPPassManager::runOnFunction (this=0x11a7dd0, F=...) at PassManager.cpp:1483
#​15 0x0000000000a75341 in llvm::FunctionPassManagerImpl::run (this=0x11a7a80, F=...) at PassManager.cpp:1434
#​16 0x0000000000a74ff1 in llvm::FunctionPassManager::run (this=0x11af3a0, F=...) at PassManager.cpp:1364
#​17 0x000000000041a57e in llvm::JIT::jitTheFunction (this=0x11a6d10, F=0x11a9160, locked=...) at JIT.cpp:661
#​18 0x000000000041a457 in llvm::JIT::runJITOnFunctionUnlocked (this=0x11a6d10, F=0x11a9160, locked=...)
at JIT.cpp:640
#​19 0x000000000041a84d in llvm::JIT::getPointerToFunction (this=0x11a6d10, F=0x11a9160) at JIT.cpp:697
#​20 0x0000000000417dff in main (argc=2, argv=0x7fffffffe5c8) at build/linux2-debug/test.cpp:42

(Sorry I couldn't get this to reproduce with lli, but the following short program will reproduce it.)

#include <stdio.h>

#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/DerivedTypes.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/ExecutionEngine/JIT.h>
#include <llvm/Target/TargetSelect.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/Target/TargetData.h>
#include <llvm/Analysis/Verifier.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Bitcode/ReaderWriter.h>
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/system_error.h>

int main(int argc, char *argv[]) {
const char *fn = argv[1];

llvm::InitializeNativeTarget();

llvm::LLVMContext *ctx = new llvm::LLVMContext;
llvm::OwningPtr<llvm::MemoryBuffer> buf;
llvm::error_code err = llvm::MemoryBuffer::getFileOrSTDIN(fn, buf);
if (err) {
    fprintf(stderr, "Unable to open file \"%s\": %s\n", fn, err.message().c_str());
    delete ctx;
    return 1;
}
std::string bcErr;
llvm::Module *module = llvm::ParseBitcodeFile(buf.get(), *ctx, &bcErr);
if (!module) {
    fprintf(stderr, "Bitcode reader failed for \"%s\": %s\n", fn, bcErr.c_str());
    delete ctx;
    return false;
}
llvm::ExecutionEngine *ee = llvm::ExecutionEngine::createJIT(module);
llvm::Function *func = module->getFunction("f_f");
assert(func != NULL);

void *ptr = ee->getPointerToFunction(func);

return 0;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions