[DebugInfo]Crash during building openmpi4.0.0

Hi folks,

While building openmpi.4.0.0(Optimized debug build), using trunk clang we encountered a crash(assertion failure).

Initially assertion seems trivial:


void llvm::DwarfExpression::addFragmentOffset(const llvm::DIExpression*): Assertion `FragmentOffset >= OffsetInBits && “overlapping or duplicate fragments”’ failed.


But, narrowing to RC. We discovered “-O3 -enable-partial-inlining” pass which is doing some DebugInfo manipulation, later triggering this.


$ wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.0.tar.bz2

$ tar -xf openmpi-4.0.0

$ cd openmpi-4.0.0

$ ./configure --enable-mpi-fortran=no OMPI_CC=/home/sourabh/mirror-upstream/build/release/bin/clang OMPI_CXX=clang++ CXX=clang++ CC=clang CFLAGS="="-g -O3 -mllvm -enable-partial-inlining " CXXFLAGS="-g -O3 -mllvm -enable-partial-inlining" AR=llvm-ar RANLIB=llvm-ranlib NM=llvm-nm

$ make -jN


Details of Narrowing:

$ cd ompi/mca/vprotocol/pessimist

$ clang -DHAVE_CONFIG_H -I. -I…/…/…/…/opal/include -I…/…/…/…/ompi/include -I…/…/…/…/oshmem/include -I…/…/…/…/opal/mca/hwloc/hwloc201/hwloc/include/private/autogen -I…/…/…/…/opal/mca/hwloc/hwloc201/hwloc/include/hwloc/autogen -I…/…/…/…/ompi/mpiext/cuda/c -I…/…/…/… -I…/…/…/…/orte/include -I/home/regressions/openmpi-4.0.0/opal/mca/event/libevent2022/libevent -I/home/regressions/openmpi-4.0.0/opal/mca/event/libevent2022/libevent/include -I/home/regressions/openmpi-4.0.0/opal/mca/hwloc/hwloc201/hwloc/include -DNDEBUG -g -O3 -mllvm -enable-partial-inlining -finline-functions -fno-strict-aliasing -mcx16 -pthread -MT vprotocol_pessimist_recv.lo -MD -MP -MF .deps/vprotocol_pessimist_recv.Tpo -c vprotocol_pessimist_recv.c -S


Note: Entire application and above file compiling fine if we remove “—enable-partial-inlining”.

I attempted to come-up with a more reduced case but that was in vain. This pass “-partial-inliner” is disabled by default(even at O3) and not much of content or sample test cases as to what this transformation actually do.

I’ll be filing a BUG, as soon as someone from community confirms this.

Thanks You,


A good way to start is to let Clang generate a crash reproducer, then you have a single file on which to run delta or creduce on. Once you have a reduced testcase, we can try and help you figure out what is triggering the assertion.

-- adrian

Thank You for suggestion Adrian!

Generated reproducer for the crash using clang reproducer and CReduce.

::Attachment:: C file.

NIT: some clean up is done on this file just to silent some compiler warnings(like implicit declaration etc.)

Crash can be reproduced using above test case with following commandline:

$clang -g -O3 -mllvm –enable-partial-inlining creducegenerated-cleaned.c -c


$clang -g -O3 creducegenerated-cleaned.c -c

Working fine.

Or you may also try as:

$opt -partial-inliner creduce-O3.ll -S | llc >/dev/null


Thank You,


creducegenerated-cleaned.c (384 Bytes)

Hi Sourabh,

Thanks for the reproducer; it crashes for me too with a recent clang.
It looks like the cause is duplicate dbg.declare intrinsics in the
"k.1.if.then" function (I'm not familiar with partial inlining alas).
There are two instances of:

  call void @llvm.dbg.declare(metadata i32* %h.sroa.2.i, metadata
!123, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32)) #4, !dbg

In different blocks (the first operand differs). When emitting the
variable location, this is interpreted as that fragment having
multiple locations specified, causing the assertion. Commenting either
of the duplicate dbg.declares out avoids the crash.

Hi Jeremy,

Thanks for reply, my observation was also same. But it's just for understanding/hackish to remove the call, we need to get to the root-cause or drop the debug-info for such cases(like this).

It seems to me that, some incorrect debug info manipulation is being done by "fixupDebugInfoPostExtraction".

"k.1.if.then" is an outlined function(seems like partial inliner pass is doing this). "CodeExtractor" utility is used for outlining and " fixupDebugInfoPostExtraction" for updating appropriate debug info post outlining.

Thank You,