[LLVMbugs] [Bug 13251] New: SplitVectorResult llvm.x86.avx.round.ps.256: Do not know how to split the result of this operator

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jul 1 09:03:01 PDT 2012


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

             Bug #: 13251
           Summary: SplitVectorResult llvm.x86.avx.round.ps.256: Do not
                    know how to split the result of this operator
           Product: libraries
           Version: 3.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: llvm at henning-thielemann.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


I got a problem with calling some AVX intrinsics in the JIT from Haskell.
Whenever I called roundps256 the program terminated with

Stack dump:
0.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@round'

I extracted a C program that reproduces the problem. However, using the C
program I could reproduce the problem only when the program is run by valgrind.
SSE functions (i.e. roundps of SSE41) are not affected. See the outcommented
code for <4 x float>. The 'llc' compiler is also affected, but the problem can
be provoked only with valgrind.


$ cat src/avx-instruction-selection.c
#include <llvm-c/Core.h>
#include <llvm-c/Target.h>
#include <llvm-c/ExecutionEngine.h>
#include <llvm-c/BitWriter.h>
#include <llvm-c/Transforms/Scalar.h>

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/*
const int vectorSize = 4;
const char* roundName = "llvm.x86.sse41.round.ps";
*/
const int vectorSize = 8;
const char* roundName = "llvm.x86.avx.round.ps.256";

int main ()
{
  LLVMModuleRef module, emptyModule;
  LLVMModuleProviderRef provider, emptyProvider;
  LLVMExecutionEngineRef execEngine;
  LLVMTargetDataRef targetData;
  LLVMTypeRef floatType, vectorType, ptrType, voidType, funcType, roundType,
int32Type;
  LLVMValueRef func, roundFunc;
  LLVMValueRef param, loaded, const1, callRound;
  LLVMBuilderRef builder;
  LLVMBasicBlockRef block;
  const int false = 0;

  LLVMInitializeX86TargetInfo();
  LLVMInitializeX86Target();
  LLVMInitializeX86TargetMC();
  module = LLVMModuleCreateWithName("_module");
  floatType = LLVMFloatType();
  vectorType = LLVMVectorType(floatType, vectorSize);
  ptrType = LLVMPointerType(vectorType, 0);
  voidType = LLVMVoidType();
  LLVMTypeRef roundParams[] = { ptrType };
  roundType = LLVMFunctionType(voidType, roundParams, 1, false);
  func = LLVMAddFunction(module, "round", roundType);
  LLVMSetLinkage(func, LLVMExternalLinkage);
  builder = LLVMCreateBuilder();
  block = LLVMAppendBasicBlock(func, "_L1");
  LLVMPositionBuilderAtEnd(builder, block);
  param = LLVMGetParam(func, 0);
  loaded = LLVMBuildLoad(builder, param, "");
  int32Type = LLVMIntType(32);
  LLVMTypeRef funcParams[] = { vectorType, int32Type } ;
  funcType = LLVMFunctionType(vectorType, funcParams, 2, false);
  roundFunc = LLVMAddFunction(module, roundName, funcType);
  LLVMSetLinkage(roundFunc, LLVMExternalLinkage);
  const1 = LLVMConstInt(int32Type, 1, false);
  LLVMValueRef callParams [] = { loaded, const1 } ;
  callRound = LLVMBuildCall(builder, roundFunc, callParams, 2, "");
  LLVMSetInstructionCallConv(callRound, 0);
  LLVMAddInstrAttribute(callRound, 0, 0);
  LLVMBuildStore(builder, callRound, param);
  LLVMBuildRetVoid(builder);
  provider = LLVMCreateModuleProviderForExistingModule(module);
  LLVMWriteBitcodeToFile(module, "round-avx.bc");
  emptyModule = LLVMModuleCreateWithName("__empty__");
  emptyProvider = LLVMCreateModuleProviderForExistingModule(emptyModule);
  char *errorMsg;
  LLVMCreateExecutionEngine(&execEngine, emptyProvider, &errorMsg);
  LLVMAddModuleProvider(execEngine, provider);
  targetData = LLVMGetExecutionEngineTargetData(execEngine);
  size_t vectorSize0 = LLVMStoreSizeOfType(targetData, vectorType);
  size_t vectorAlign = LLVMABIAlignmentOfType(targetData, vectorType);
  float vector[vectorSize];
  printf("%lx, size %lx, align %lx\n", (size_t)vector, vectorSize0,
vectorAlign);
  LLVMGenericValueRef genericVector = LLVMCreateGenericValueOfPointer(vector);
  LLVMGenericValueRef runParams[] = { genericVector } ;
  LLVMRunFunction(execEngine, func, 1, runParams);
  return 0;
}

$ make src/avx-instruction-selection
gcc -Wall -o src/avx-instruction-selection src/avx-instruction-selection.c
`llvm-config --cflags --ldflags` -lLLVM-3.1

$ valgrind src/avx-instruction-selection
==3109== Memcheck, a memory error detector
==3109== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3109== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3109== Command: src/avx-instruction-selection
==3109== 
7fefffd30, size 20, align 20
SplitVectorResult #0: 0x7881900: v8f32 = llvm.x86.avx.round.ps.256 0x7881700,
0x7881600, 0x7881800 [ORD=2] [ID=0]

Do not know how to split the result of this operator!
UNREACHABLE executed at LegalizeVectorTypes.cpp:451!
Stack dump:
0.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@round'
==3109== 
==3109== HEAP SUMMARY:
==3109==     in use at exit: 337,912 bytes in 608 blocks
==3109==   total heap usage: 851 allocs, 243 frees, 681,650 bytes allocated
==3109== 
==3109== LEAK SUMMARY:
==3109==    definitely lost: 48 bytes in 1 blocks
==3109==    indirectly lost: 0 bytes in 0 blocks
==3109==      possibly lost: 876 bytes in 15 blocks
==3109==    still reachable: 336,988 bytes in 592 blocks
==3109==         suppressed: 0 bytes in 0 blocks
==3109== Rerun with --leak-check=full to see details of leaked memory
==3109== 
==3109== For counts of detected and suppressed errors, rerun with: -v
==3109== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
terminated - segmentation fault

$ llc <round-avx.bc
        .file   "<stdin>"
        .text
        .globl  round
        .align  16, 0x90
        .type   round, at function
round:                                  # @round
        .cfi_startproc
# BB#0:                                 # %_L1
        pushq   %rbp
.Ltmp2:
        .cfi_def_cfa_offset 16
.Ltmp3:
        .cfi_offset %rbp, -16
        movq    %rsp, %rbp
.Ltmp4:
        .cfi_def_cfa_register %rbp
        vroundps        $1, (%rdi), %ymm0
        vmovaps %ymm0, (%rdi)
        popq    %rbp
        vzeroupper
        ret
.Ltmp5:
        .size   round, .Ltmp5-round
        .cfi_endproc


        .section        ".note.GNU-stack","", at progbits

$ valgrind llc <round-avx.bc
==3222== Memcheck, a memory error detector
==3222== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3222== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3222== Command: llc
==3222== 
        .file   "<stdin>"
SplitVectorResult #0: 0x785e640: v8f32 = llvm.x86.avx.round.ps.256 0x785e440,
0x785e340, 0x785e540 [ORD=2] [ID=0]

Do not know how to split the result of this operator!
UNREACHABLE executed at LegalizeVectorTypes.cpp:451!
0  libLLVM-3.1.so  0x0000000005cc181f
1  libLLVM-3.1.so  0x0000000005cc1d29
2  libpthread.so.0 0x00000000067f2cb0
3  libc.so.6       0x0000000006d36445 gsignal + 53
4  libc.so.6       0x0000000006d39bab abort + 379
5  libLLVM-3.1.so  0x0000000005ca939c
6  libLLVM-3.1.so  0x0000000005b98d91
7  libLLVM-3.1.so  0x0000000005b802af
8  libLLVM-3.1.so  0x0000000005b810fe llvm::SelectionDAG::LegalizeTypes() + 494
9  libLLVM-3.1.so  0x0000000005c3a16f
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 639
10 libLLVM-3.1.so  0x0000000005c430d6
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 1622
11 libLLVM-3.1.so  0x0000000005c446a7
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1239
12 libLLVM-3.1.so  0x00000000056f3c0f
llvm::FPPassManager::runOnFunction(llvm::Function&) + 591
13 libLLVM-3.1.so  0x00000000056f3c83
llvm::FPPassManager::runOnModule(llvm::Module&) + 51
14 libLLVM-3.1.so  0x00000000056f3924
llvm::MPPassManager::runOnModule(llvm::Module&) + 532
15 libLLVM-3.1.so  0x00000000056f4eeb llvm::PassManagerImpl::run(llvm::Module&)
+ 171
16 llc             0x0000000000406ada main + 3466
17 libc.so.6       0x0000000006d2176d __libc_start_main + 237
18 llc             0x0000000000407191
Stack dump:
0.      Program arguments: llc 
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@round'
==3222== 
==3222== HEAP SUMMARY:
==3222==     in use at exit: 338,967 bytes in 654 blocks
==3222==   total heap usage: 1,268 allocs, 614 frees, 509,465 bytes allocated
==3222== 
==3222== LEAK SUMMARY:
==3222==    definitely lost: 0 bytes in 0 blocks
==3222==    indirectly lost: 0 bytes in 0 blocks
==3222==      possibly lost: 969 bytes in 18 blocks
==3222==    still reachable: 337,998 bytes in 636 blocks
==3222==         suppressed: 0 bytes in 0 blocks
==3222== Rerun with --leak-check=full to see details of leaked memory
==3222== 
==3222== For counts of detected and suppressed errors, rerun with: -v
==3222== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)

-- 
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