llvm-project/llvm
David Stenberg 74a72e6848 [DebugInfo] Stop describing imms in TargetInstrInfo's describeLoadedValue() impl
Summary:
The default implementation of the describeLoadedValue() hook uses the
MoveImm property to determine if an instruction moves an immediate. If
an instruction has that property the function returns the second
operand, assuming that that is the immediate value the instruction
moves. As far as I can tell, the MoveImm property does not imply that
the second operand is the immediate value, nor that any other operand
necessarily holds the immediate value; it just means that the
instruction moves some immediate value.

One example where the second operand is not the immediate is SystemZ's
LZER instruction, which moves a zero immediate implicitly: $f0S = LZER.

That case triggered an out-of-bound assertion when getting the operand.
I have added a test case for that instruction.

Another example is ARM's MVN instruction, which holds the logical
bitwise NOT'd value of the immediate that is moved. For the following
reproducer:

  extern void foo(int);
  int main() { foo(-11); }

an incorrect call site value would be emitted:

  $ clang --target=arm foo.c -O1 -g -Xclang -femit-debug-entry-values \
      -c -o - | ./build/bin/llvm-dwarfdump  - | \
      grep -A2 call_site_parameter

  0x00000058:       DW_TAG_GNU_call_site_parameter
                      DW_AT_location (DW_OP_reg0 R0)
                      DW_AT_GNU_call_site_value (DW_OP_lit10)

Another example is the A2_combineii instruction on Hexagon which moves
two immediates to a super-register: $d0 = A2_combineii 20, 10.

Perhaps these are rare exceptions, and most MoveImm instructions hold
the immediate in the second operand, but in my opinion the default
implementation of the hook should only describe values that it can, by
some contract, guarantee are safe to describe, rather than leaving it up
to the targets to override the exceptions, as that can silently result
in incorrect call site values.

This patch adds X86's relevant move immediate instructions to the
target's hook implementation, so this commit should be a NFC for that
target. We need to do the same for ARM and AArch64.

Reviewers: djtodoro, NikolaPrica, aprantl, vsk

Reviewed By: vsk

Subscribers: kristof.beyls, hiraditya, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D69109
2019-10-23 11:41:29 +02:00
..
benchmarks
bindings Reapply r374743 with a fix for the ocaml binding 2019-10-14 16:15:14 +00:00
cmake [CMake] [WinMsvc] Look for includes and libs in ${MSVC_BASE}/atlmfc 2019-10-22 06:36:27 +00:00
docs Fix broken sphinx link in CMake.rst. 2019-10-22 14:49:58 -07:00
examples [examples] Add a dependency on ExecutionEngine to LLJITWithObjectCache example. 2019-10-21 22:29:29 +00:00
include [DAGCombine][ARM] x ==/!= c -> (x - c) ==/!= 0 iff '-c' can be folded into the x node. 2019-10-22 22:56:35 +03:00
lib [DebugInfo] Stop describing imms in TargetInstrInfo's describeLoadedValue() impl 2019-10-23 11:41:29 +02:00
projects Add few docs and implementation of strcpy and strcat. 2019-10-04 17:30:54 +00:00
resources
runtimes Adding support for overriding LLVM_ENABLE_RUNTIMES for runtimes builds. 2019-09-24 22:38:18 +00:00
test [DebugInfo] Stop describing imms in TargetInstrInfo's describeLoadedValue() impl 2019-10-23 11:41:29 +02:00
tools Prune Pass.h include from DataLayout.h. NFCI 2019-10-21 17:51:54 +00:00
unittests [Alignment][NFC] Attributes use Align/MaybeAlign 2019-10-22 09:51:06 +00:00
utils Relax assertions when there's really no entries. [NFC] 2019-10-22 15:26:30 -04:00
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt Add few docs and implementation of strcpy and strcat. 2019-10-04 17:30:54 +00:00
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt Test commit. 2019-10-03 14:57:49 +00:00
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.