[all-commits] [llvm/llvm-project] 055f2f: [mem2reg][debuginfo] Handle op_deref when converti...
Felipe de Azevedo Piovezan via All-commits
all-commits at lists.llvm.org
Mon Jan 30 08:17:59 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 055f2f04e658c7dddd1fc261e5e0c0bd136cc2b5
https://github.com/llvm/llvm-project/commit/055f2f04e658c7dddd1fc261e5e0c0bd136cc2b5
Author: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: 2023-01-30 (Mon, 30 Jan 2023)
Changed paths:
M llvm/include/llvm/IR/DebugInfoMetadata.h
M llvm/lib/IR/DebugInfoMetadata.cpp
M llvm/lib/Transforms/Utils/Local.cpp
A llvm/test/Transforms/Mem2Reg/dbg_declare_to_value_conversions.ll
Log Message:
-----------
[mem2reg][debuginfo] Handle op_deref when converting dbg.declare
The conversion of dbg.declare into dbg.values doesn't take into account
the DIExpression attached to the intrinsic. In particular, when
converting:
```
store %val, ptr %alloca
dbg.declare(ptr %alloca, !SomeVar, !DIExpression())
```
Mem2Reg will try to figure out if `%val` has the size of `!SomeVar`. If
it does, then a non-undef dbg.value is inserted:
```
dbg.value(%val, !SomeVar, !DIExpression())
```
This makes sense: the alloca is _the_ address of the variable. So a
store to the alloca is a store to the variable. However, if the
expression in the original intrinsic is a `DW_OP_deref`, this logic is
not applicable:
```
store ptr %val, ptr %alloca
dbg.declare(ptr %alloca, !SomeVar, !DIExpression(DW_OP_deref))
```
Here, the alloca is *not* the address of the variable. A store to the
alloca is *not* a store to the variable. As such, querying whether
`%val` has the same size as `!SomeVar` is meaningless.
This patch addresses the issue by:
1. Allowing the conversion when the expression is _only_ a `DW_OP_deref`
without any other expressions (see code comment).
2. Checking that the expression does not start with a `DW_OP_deref`
before applying the logic that checks whether the value being stored and
the variable have the same length.
Differential Revision: https://reviews.llvm.org/D142160
More information about the All-commits
mailing list