[LLVMbugs] [Bug 21673] New: OpenCL vector ternary selection triggers internal error (invalid LLVM IR?)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 26 02:26:00 PST 2014


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

            Bug ID: 21673
           Summary: OpenCL vector ternary selection triggers internal
                    error (invalid LLVM IR?)
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bruno-llvm at defraine.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13399
  --> http://llvm.org/bugs/attachment.cgi?id=13399&action=edit
test.cl

Hello,

The attached simple OpenCL file triggers a compiler internal error (using O2
for target x86_64):

$ clang -O2 -c llvm.cl
0  libLLVM-3.5.so  0x00002b1eddf6bae2 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  libLLVM-3.5.so  0x00002b1eddf6b619
2  libpthread.so.0 0x00002b1edfb94b70
3  libLLVM-3.5.so  0x00002b1ede55249c llvm::SelectionDAG::getNode(unsigned int,
llvm::SDLoc, llvm::EVT, llvm::SDValue, llvm::SDValue, bool, bool, bool) + 172
4  libLLVM-3.5.so  0x00002b1ede4ea247
5  libLLVM-3.5.so  0x00002b1ede4ee4a8
6  libLLVM-3.5.so  0x00002b1ede4f5a84
7  libLLVM-3.5.so  0x00002b1ede4f63ea llvm::SelectionDAG::LegalizeTypes() + 922
8  libLLVM-3.5.so  0x00002b1ede5aa683
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 211
9  libLLVM-3.5.so  0x00002b1ede5b0dfa
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 1018
10 libLLVM-3.5.so  0x00002b1ede5b247a
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 586
11 libLLVM-3.5.so  0x00002b1ede35be00
12 libLLVM-3.5.so  0x00002b1edded46df
llvm::FPPassManager::runOnFunction(llvm::Function&) + 607
13 libLLVM-3.5.so  0x00002b1edded471b
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
14 libLLVM-3.5.so  0x00002b1edded4357
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 759
15 clang           0x000000000073ef26
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) +
3110
16 clang           0x0000000000739761
17 clang           0x00000000008ce9da clang::ParseAST(clang::Sema&, bool, bool)
+ 522
18 clang           0x00000000005af38e clang::FrontendAction::Execute() + 142
19 clang           0x000000000058cb15
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 245
20 clang           0x000000000057549d
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1917
21 clang           0x000000000056d398 cc1_main(char const**, char const**, char
const*, void*) + 1208
22 clang           0x0000000000574187 main + 8455
23 libc.so.6       0x00002b1ee0bca994 __libc_start_main + 244
24 clang           0x000000000056c299
Stack dump:
0.      Program arguments:
/slowfs/de02asip01/sgasip/ipd/install/RedHatEnterpriseClient-5.7/llvm/bin/clang
-cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier
-main-file-name llvm.cl -mrelocation-model static -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.17.50.0.6 -momit-leaf-frame-pointer -dwarf-column-info -coverage-file
/slowfs/de02asip01/brunodf/llvm.s -resource-dir
/slowfs/de02asip01/sgasip/ipd/install/RedHatEnterpriseClient-5.7/llvm/bin/../lib/clang/3.5.0
-internal-isystem /usr/local/include -internal-isystem
/slowfs/de02asip01/sgasip/ipd/install/RedHatEnterpriseClient-5.7/llvm/bin/../lib/clang/3.5.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdebug-compilation-dir /slowfs/de02asip01/brunodf -ferror-limit 19
-fmessage-length 144 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o llvm.s -x cl llvm.cl 
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'llvm.cl'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/llvm-48d3d9.cl
clang: note: diagnostic msg: /tmp/llvm-48d3d9.sh
clang: note: diagnostic msg: 

********************

This is the generated LLVM IR:

; ModuleID = 'llvm.cl'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind readnone uwtable
define <4 x i32> @foo(double %a.coerce, <4 x i32> %b, <4 x i32> %c) #0 {
  %1 = bitcast double %a.coerce to <4 x i16>
  %.lobit = ashr <4 x i16> %1, <i16 15, i16 15, i16 15, i16 15>
  %2 = xor <4 x i16> %.lobit, <i16 -1, i16 -1, i16 -1, i16 -1>
  %3 = and <4 x i32> %c, <4 x i16> %2
  %4 = and <4 x i16> %.lobit, <4 x i32> %b
  %5 = or <4 x i32> %3, %4
  ret <4 x i32> %5
}

attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false"
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
"no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
"unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.ident = !{!0}

!0 = metadata !{metadata !"clang version 3.5.0 (tags/RELEASE_350/final)"}


The operation "and <4 x i16> %.lobit, <4 x i32> %b" does not look correct
(different argument types).

Note: this may be illegal code that can be rejected:
- The OpenCL specification, section 6.3.i on the ternary selection operator
"exp1 ? exp2 : exp3" states "If the result [of evaluating exp1] is a vector
value, then this is equivalent to calling select(exp3, exp2, exp1)".
- In table 6.14, for "gentype select (gentype a, gentype b, igentype c)" it is
stated that "igentype [and ugentype] must have the same number of elements and
bits as gentype".
- In this example, "igentype" (short4) and "gentype" (int4) have the same
number of elements, but a different number of bits.
- While the requirement of the same number of elements is essential for the
semantics of "select", the requirement of the same number of bits is not
strictly needed, the semantics of "select" is clear.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141126/9780e608/attachment.html>


More information about the llvm-bugs mailing list