opencilk-project icon indicating copy to clipboard operation
opencilk-project copied to clipboard

Assertion failed: Referenced value not in value map!

Open VoxSciurorum opened this issue 8 months ago • 2 comments

This error is on dev/19.x. Compile the input file (text bitcode) -O1 -fopencilk. compress.txt The compiler crashes with

Assertion failed: ((Flags & RF_IgnoreMissingLocals) && "Referenced value not in value map!"), function remapInstruction, file /data/Cilk/opencilk-project/llvm/lib/Transforms/Utils/ValueMapper.cpp, line 979.

The bad instruction is

  %call55.otd1 = invoke noundef i32 @_Z21BZ2_compressBlockCilkP6EStateR16opencilk_reducerI6writerEPKhS6_(ptr noundef %retval.0.i.otd1, ptr noundef nonnull align 8 dereferenceable(56) %output.otd1, ptr noundef %base.066.otd1, ptr noundef %last.2.otd1)
          to label %invoke.cont54.otd1 unwind label %terminate.lpad.loopexit, !dbg !2514

and the bad value (not in map) is label %terminate.lpad.loopexit.

VoxSciurorum avatar Feb 18 '25 23:02 VoxSciurorum

The reduce utility reduced the input file to the following:

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-freebsd14.2"

define i32 @BZ2_compressDescriptorCilk() personality ptr null {
entry:
  %syncreg = call token @llvm.syncregion.start()
  br label %while.cond

while.cond:                                       ; preds = %invoke.cont54, %invoke.cont19, %entry
  %call20 = invoke ptr @_ZL22BZ2_bzCompressInitCilkiii(i32 0, i32 0, i32 0)
          to label %invoke.cont19 unwind label %terminate.lpad

invoke.cont19:                                    ; preds = %while.cond
  detach within %syncreg, label %det.achd, label %while.cond

det.achd:                                         ; preds = %invoke.cont19
  %call55 = invoke i32 @_Z21BZ2_compressBlockCilkP6EStateR16opencilk_reducerI6writerEPKhS6_(ptr null, ptr null, ptr null, ptr null)
          to label %invoke.cont54 unwind label %terminate.lpad

invoke.cont54:                                    ; preds = %det.achd
  reattach within %syncreg, label %while.cond

terminate.lpad:                                   ; preds = %det.achd, %while.cond
  %0 = landingpad { ptr, i32 }
          catch ptr null
  store volatile i32 0, ptr null, align 4
  unreachable
}

declare ptr @_ZL22BZ2_bzCompressInitCilkiii()

; Function Attrs: nounwind willreturn memory(argmem: readwrite)
declare token @llvm.syncregion.start() #0

declare i32 @_Z21BZ2_compressBlockCilkP6EStateR16opencilk_reducerI6writerEPKhS6_()

; uselistorder directives
uselistorder ptr null, { 1, 2, 3, 4, 5, 6, 7, 8, 0 }

attributes #0 = { nounwind willreturn memory(argmem: readwrite) }

VoxSciurorum avatar Feb 19 '25 00:02 VoxSciurorum

Here is a reduced C++ test case. The noexcept keyword is key.

extern bool more();
extern int f();

void g() noexcept
{
  while (more())
    cilk_spawn f();
}

VoxSciurorum avatar Feb 21 '25 15:02 VoxSciurorum

The latest release includes the fix for this issue.

neboat avatar May 12 '25 19:05 neboat