[llvm-bugs] [Bug 49083] New: Clang crashes with allocator aware coroutines

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 7 17:08:02 PST 2021


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

            Bug ID: 49083
           Summary: Clang crashes with allocator aware coroutines
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rst-mlngsts at protonmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 24495
  --> https://bugs.llvm.org/attachment.cgi?id=24495&action=edit
Test program 1

Attached test programs crash the compiler as such:

clang -cc1 -O2 -std=gnu++2a -emit-llvm corobug1.cpp

Instruction does not dominate all uses!
  %FramePtr = bitcast i8* %7 to %_ZN7derived9make_taskE12service_type.Frame*
  %service3.sroa.0.0.copyload53.spill.addr = getelementptr inbounds
%_ZN7derived9make_taskE12service_type.Frame,
%_ZN7derived9make_taskE12service_type.Frame* %FramePtr, i32 0, i32 8
fatal error: error in backend: Broken function

And the second:

clang -cc1 -O2 -std=gnu++2a -emit-llvm corobug2.cpp

Instruction does not dominate all uses!
  %FramePtr = bitcast i8* %6 to %_Z10make_task212service_type.Frame*
  %service1.sroa.0.0.copyload.spill.addr = getelementptr inbounds
%_Z10make_task212service_type.Frame, %_Z10make_task212service_type.Frame*
%FramePtr, i32 0, i32 7
fatal error: error in backend: Broken function

Affects versions 11.0.1 and 11.1.0-rc3 at least. Works fine in clang-10.0.1
however. But I had similar failures in 10.0.1 at some point and I could go
hunting for those if required.

These are creduce'd results that I hand edited a little bit of sense back into.
The common theme is that operator new of a coroutine promise is used to perform
custom memory allocation based on function parameters provided to the coroutine
function.

Issue appears under seemingly random conditions with -O2 and -O3. If you poke
around in the test programs and remove what looks like irrelevant things like
"int dummy" members or change the make_task method to be non-virtual (or remove
the base class), it suddenly passes.

The variadic operator new in corobug1.cpp seemed like a smoking gun at first.
You can replace that with a non-variadic definition to get it to pass also. But
then I found corobug2.cpp which depends on no such condition. This whole thing
feels like the optimizer has to be coaxed into just the right conditions to
break.

-- 
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/20210208/7ec9fcfd/attachment.html>


More information about the llvm-bugs mailing list