llvm-project/llvm/lib
Petar Jovanovic e2a585dddc Reland "Correct dwarf unwind information in function epilogue for X86"
Reland r317100 with minor fix regarding ComputeCommonTailLength function in
BranchFolding.cpp. Skipping top CFI instructions block needs to executed on
several more return points in ComputeCommonTailLength().

Original r317100 message:

"Correct dwarf unwind information in function epilogue for X86"

This patch aims to provide correct dwarf unwind information in function
epilogue for X86.

It consists of two parts. The first part inserts CFI instructions that set
appropriate cfa offset and cfa register in emitEpilogue() in
X86FrameLowering. This part is X86 specific.

The second part is platform independent and ensures that:

- CFI instructions do not affect code generation
- Unwind information remains correct when a function is modified by
  different passes. This is done in a late pass by analyzing information
  about cfa offset and cfa register in BBs and inserting additional CFI
  directives where necessary.

Changed CFI instructions so that they:

- are duplicable
- are not counted as instructions when tail duplicating or tail merging
- can be compared as equal

Added CFIInstrInserter pass:

- analyzes each basic block to determine cfa offset and register valid at
  its entry and exit
- verifies that outgoing cfa offset and register of predecessor blocks match
  incoming values of their successors
- inserts additional CFI directives at basic block beginning to correct the
  rule for calculating CFA

Having CFI instructions in function epilogue can cause incorrect CFA
calculation rule for some basic blocks. This can happen if, due to basic
block reordering, or the existence of multiple epilogue blocks, some of the
blocks have wrong cfa offset and register values set by the epilogue block
above them.

CFIInstrInserter is currently run only on X86, but can be used by any target
that implements support for adding CFI instructions in epilogue.

Patch by Violeta Vukobrat.

llvm-svn: 317579
2017-11-07 14:40:27 +00:00
..
Analysis [ValueTracking] readonly (const) is a requirement for converting sqrt to llvm.sqrt; nnan is not 2017-11-06 22:40:09 +00:00
AsmParser [IR] redefine 'UnsafeAlgebra' / 'reassoc' fast-math-flags and add 'trans' fast-math-flag 2017-11-06 16:27:15 +00:00
BinaryFormat Simplify. 2017-10-19 01:32:18 +00:00
Bitcode [IR] redefine 'UnsafeAlgebra' / 'reassoc' fast-math-flags and add 'trans' fast-math-flag 2017-11-06 16:27:15 +00:00
CodeGen Reland "Correct dwarf unwind information in function epilogue for X86" 2017-11-07 14:40:27 +00:00
DebugInfo Fix warnings discovered by rL317076. [-Wunused-private-field] 2017-11-01 13:47:55 +00:00
Demangle [ItaniumDemangle] Fix a exponential string copying bug 2017-05-28 23:24:52 +00:00
ExecutionEngine ExecutionEngine: make COFF Thumb2 assertions non-tautological 2017-10-22 20:51:25 +00:00
FuzzMutate FuzzMutate: Fix arch parsing in FuzzerCLI 2017-10-17 02:39:40 +00:00
Fuzzer [libFuzzer] Delete llvm/lib/Fuzzer 2017-10-16 20:48:19 +00:00
IR Make DIExpression::createFragmentExpression() return an Optional. 2017-11-07 00:45:34 +00:00
IRReader Move the stripping of invalid debug info from the Verifier to AutoUpgrade. 2017-10-02 18:31:29 +00:00
LTO [LTO][ThinLTO] Use the linker resolutions to mark global values as dso_local. 2017-11-04 17:04:39 +00:00
LineEditor
Linker Linker: Create a function declaration when moving a non-prevailing alias of function type. 2017-08-10 01:07:44 +00:00
MC [AsmPrinterDwarf] Add support for .cfi_restore directive 2017-11-02 12:00:58 +00:00
Object Revert r317046, "Object: Move some code from ELF.h into ELF.cpp." 2017-11-03 21:30:06 +00:00
ObjectYAML [ObjectYAML] Map relocation types for COFF ARMNT and ARM64 2017-11-06 07:20:58 +00:00
Option Reverting r315590; it did not include changes for llvm-tblgen, which is causing link errors for several people. 2017-10-15 14:32:27 +00:00
Passes [PassManager, SimplifyCFG] Revert r316908 and r316869. 2017-11-06 00:32:01 +00:00
ProfileData GCOV: Move GCOV from IR & Support into ProfileData to fix layering 2017-11-03 20:57:10 +00:00
Support [GlobalISel] Enable legalizing non-power-of-2 sized types. 2017-11-07 10:34:34 +00:00
TableGen [globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash. 2017-11-01 22:13:05 +00:00
Target Reland "Correct dwarf unwind information in function epilogue for X86" 2017-11-07 14:40:27 +00:00
Testing Force #define GTEST_LANG_CXX11. 2017-10-27 21:12:28 +00:00
ToolDrivers [COFF] Improve the check for functions that should get an extra underscore 2017-10-23 09:08:13 +00:00
Transforms Make DIExpression::createFragmentExpression() return an Optional. 2017-11-07 00:45:34 +00:00
WindowsManifest Fix bug 34608 by moving private header out of public header. 2017-09-14 23:01:13 +00:00
XRay [XRay][tools] Support arg1 logging entries in the basic logging mode 2017-10-05 05:18:17 +00:00
CMakeLists.txt Moving libFuzzer from LLVM to compiler-rt. 2017-08-21 23:25:12 +00:00
LLVMBuild.txt Re-apply "Introduce FuzzMutate library" 2017-08-21 22:57:06 +00:00