[llvm-bugs] [Bug 48213] New: [compiler-rt][lli][halfType] lli segfaults while executing half type.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 18 04:14:11 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48213

            Bug ID: 48213
           Summary: [compiler-rt][lli][halfType] lli segfaults while
                    executing half type.
           Product: compiler-rt
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: builtins
          Assignee: unassignedbugs at nondot.org
          Reporter: vikram.tarikere at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 24180
  --> https://bugs.llvm.org/attachment.cgi?id=24180&action=edit
IR containing half type - fails to JIT-execute.

The attached bitcode file (addHalf.ll) contains half types (adds 1.0 and 2.0 to
return 3.0) and it segfaults while executing with lli. I think lli fails to
find the right rtlibs because if I compile with llc and link with compiler-rt,
then it executes successfully.

$llc addHalf.ll
$clang addHalf.s --rtlib=compiler-rt    // I need to link with compiler-rt due
to references for __gnu_h2f_ieee from half type conversions.
$./a.out
3.000000

Now, if I try to JIT-execute:
$lli addHalf.ll
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0.      Program arguments: lli addHalf.ll
#0 0x00007f7e210929f0 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/local-ssd/vtariker/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:0
#1 0x00007f7e21092a83 PrintStackTraceSignalHandler(void*)
/local-ssd/vtariker/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:625:0
#2 0x00007f7e21090b2e llvm::sys::RunSignalHandlers()
/local-ssd/vtariker/llvm/llvm-project/llvm/lib/Support/Signals.cpp:68:0
#3 0x00007f7e21092433 SignalHandler(int)
/local-ssd/vtariker/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:406:0
#4 0x00007f7e1e56c0c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
Segmentation fault
$

I have built the compiler-rt library. Maybe I need to tell lli to pick the
compiler-rt libs (just like in the llc case). If so, how do I do that?
A quick debug revealed that it segfaults at
lib/ExecutionEngine/MCJIT/MCJIT.cpp::runFunction() at line 583.



I used the below C-code to generate .ll and then edited it to convert single to
half type:
$cat addHalf.c
#include <stdio.h>

__attribute__((noinline)) float addHalf(float a, float b) {
    return a + b;
}


int main() {

    float a, b;
    float ans;

    a = 1.0;
    b = 2.0;
    ans = addHalf(a, b);
    printf("%f\n", ans);
    return 0;
}

$clang -emit-llvm addHalf.c -O0 -S -o addHalfO0.ll
$opt -mem2reg -instnamer addHalfO0.ll -S -o addHalf_single.ll        // Edited
addHalf_single.ll to get the attached addHalf.ll.

-- 
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/20201118/0bd725ff/attachment-0001.html>


More information about the llvm-bugs mailing list