llvm / llvm/llvm-project

[mlir][mem2reg] operand does not dominate hit when processing llvm.intr.dbg.declare with type conversions

Open
#200,844 1 comment 0 reactions 1 assignee Claimed by @jeanPerier View on GitHub
mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```mlir
#di_basic_type = #llvm.di_basic_type
#di_file = #llvm.di_file<"test.ll" in "">
#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C_plus_plus_14, file = #di_file, producer = "clang", isOptimized = false, emissionKind = Full>
#di_subprogram = #llvm.di_subprogram
#di_local_variable = #llvm.di_local_variable
#di_local_variable_2 = #llvm.di_local_variable

llvm.func @crash_repro(%val : f32) -> i32 {
%0 = llvm.mlir.constant(1 : i32) : i32
%cst2 = llvm.mlir.constant(2 : i32) : i32
%1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr
llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr
llvm.store %val, %1 {alignment = 4 : i64} : f32, !llvm.ptr
%3 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32
llvm.return %3 : i32
}
```

`mlir-opt -mem2reg`:

```
repro.mlir:13:3: error: operand #0 does not dominate this use
llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr
```

Note that this is not a regression from #196924. I think the cause is that the insertion point is set after storing operations during mem2reg promotion [here](https://github.com/llvm/llvm-project/blob/dbeea291e5412c2d23a702078346ca894999bb92/mlir/lib/Transforms/Mem2Reg.cpp#L586), which breaks the expectation/invariant that visitReplacedValues values dominates the related storing operation.

I am planning to fix it as part of https://github.com/llvm/llvm-project/pull/198552 that fixes issues with `visitReplacedValues`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.