[all-commits] [llvm/llvm-project] ab6a66: Reland: [MLIR][Transforms] Fix Mem2Reg removal ord...
Christian Ulmann via All-commits
all-commits at lists.llvm.org
Thu Oct 12 07:47:20 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ab6a66dbec61654d0962f6abf6d6c5b776937584
https://github.com/llvm/llvm-project/commit/ab6a66dbec61654d0962f6abf6d6c5b776937584
Author: Christian Ulmann <christian.ulmann at nextsilicon.com>
Date: 2023-10-12 (Thu, 12 Oct 2023)
Changed paths:
M mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
M mlir/include/mlir/Transforms/RegionUtils.h
M mlir/lib/Target/LLVMIR/CMakeLists.txt
M mlir/lib/Target/LLVMIR/Dialect/OpenACC/CMakeLists.txt
M mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp
M mlir/lib/Target/LLVMIR/Dialect/OpenMP/CMakeLists.txt
M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
M mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
M mlir/lib/Transforms/Mem2Reg.cpp
M mlir/lib/Transforms/Utils/RegionUtils.cpp
M mlir/test/Dialect/LLVMIR/mem2reg.mlir
Log Message:
-----------
Reland: [MLIR][Transforms] Fix Mem2Reg removal order to respect dominance (#68877)
This commit fixes a bug in the Mem2Reg operation erasure order.
Replacing the use-def based topological order with a dominance-based
weak order ensures that no operation is removed before all its uses have
been replaced. The order relation uses the topological order of blocks
and block internal ordering to determine a deterministic operation
order.
Additionally, the reliance on the `DenseMap` key order was eliminated by
switching to a `MapVector`, that gives a deterministic iteration order.
Example:
```
%ptr = alloca ...
...
%val0 = %load %ptr ... // LOAD0
store %val0 %ptr ...
%val1 = load %ptr ... // LOAD1
````
When promoting the slot backing %ptr, it can happen that the LOAD0 was
cleaned before LOAD1. This results in all uses of LOAD0 being replaced
by its reaching definition, before LOAD1's result is replaced by LOAD0's
result. The subsequent erasure of LOAD0 can thus not succeed, as it has
remaining usages.
More information about the All-commits
mailing list