Skip to content

Commit 03cef62

Browse files
authored
[flang][NFC] turn (h)fir.declare side effect into debug ressource alloca (#113321)
See https://reviews.llvm.org/D157626 for the rational of declare having side effects. The write effect is to scary for passes that look for read/write effects without caring about the resource affected. I know Slava asked for it, but I think the creation of the `DebuggingResource` was enough and that a write is too much. The alloca effect is sufficient to prevent DCE to remove it, which is all we care about currently. This currently is flag as a reason for creating LHS temporary in assignment to vector subscripted entity with array constructor. There is a lot of read/write side effect analysis in the "lower-hlfir-ordered-assignments" pass, and I feel like we will just keep adding weird "debug ressource" bypassing here and there with these side effects.
1 parent d89c1db commit 03cef62

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

flang/include/flang/Optimizer/Dialect/FIROps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3078,7 +3078,7 @@ def fir_IsPresentOp : fir_SimpleOp<"is_present", [NoMemoryEffect]> {
30783078
// debug information so we would like to keep this around even if the value
30793079
// is not used.
30803080
def fir_DeclareOp : fir_Op<"declare", [AttrSizedOperandSegments,
3081-
MemoryEffects<[MemWrite<DebuggingResource>]>,
3081+
MemoryEffects<[MemAlloc<DebuggingResource>]>,
30823082
DeclareOpInterfaceMethods<fir_FortranVariableOpInterface>]> {
30833083
let summary = "declare a variable";
30843084

flang/include/flang/Optimizer/HLFIR/HLFIROps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class hlfir_Op<string mnemonic, list<Trait> traits>
3636
// from the declare operation can be used to generate debug information so we
3737
// don't want to remove it as dead code
3838
def hlfir_DeclareOp : hlfir_Op<"declare", [AttrSizedOperandSegments,
39-
MemoryEffects<[MemWrite<DebuggingResource>]>,
39+
MemoryEffects<[MemAlloc<DebuggingResource>]>,
4040
DeclareOpInterfaceMethods<fir_FortranVariableOpInterface>]> {
4141
let summary = "declare a variable and produce an SSA value that can be used as a variable in HLFIR operations";
4242

0 commit comments

Comments
 (0)