OSDN Git Service

Reland "Correct dwarf unwind information in function epilogue for X86"
authorPetar Jovanovic <petar.jovanovic@mips.com>
Tue, 7 Nov 2017 14:40:27 +0000 (14:40 +0000)
committerPetar Jovanovic <petar.jovanovic@mips.com>
Tue, 7 Nov 2017 14:40:27 +0000 (14:40 +0000)
commit8cec6c49168a1b9f49f1391c4b4750a7271ff354
tree531432a9deace1e4aeaeca4486cf37ee617e476a
parentd142ab12fc9f790f2cb08eaafab765c2ed69309f
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317579 91177308-0d34-0410-b5e6-96231b3b80d8
101 files changed:
include/llvm/CodeGen/Passes.h
include/llvm/CodeGen/TargetFrameLowering.h
include/llvm/InitializePasses.h
include/llvm/Target/Target.td
lib/CodeGen/BranchFolding.cpp
lib/CodeGen/CFIInstrInserter.cpp [new file with mode: 0644]
lib/CodeGen/CMakeLists.txt
lib/CodeGen/CodeGen.cpp
lib/CodeGen/MachineInstr.cpp
lib/CodeGen/TailDuplicator.cpp
lib/CodeGen/TargetFrameLoweringImpl.cpp
lib/Target/X86/X86FrameLowering.cpp
lib/Target/X86/X86FrameLowering.h
lib/Target/X86/X86TargetMachine.cpp
test/CodeGen/X86/2009-03-16-PHIElimInLPad.ll
test/CodeGen/X86/2011-10-19-widen_vselect.ll
test/CodeGen/X86/GlobalISel/add-scalar.ll
test/CodeGen/X86/GlobalISel/brcond.ll
test/CodeGen/X86/GlobalISel/callingconv.ll
test/CodeGen/X86/GlobalISel/frameIndex.ll
test/CodeGen/X86/O0-pipeline.ll
test/CodeGen/X86/TruncAssertZext.ll
test/CodeGen/X86/avx512-mask-op.ll
test/CodeGen/X86/avx512-regcall-Mask.ll
test/CodeGen/X86/avx512-regcall-NoMask.ll
test/CodeGen/X86/avx512-schedule.ll
test/CodeGen/X86/avx512-select.ll
test/CodeGen/X86/avx512-vbroadcast.ll
test/CodeGen/X86/avx512bw-intrinsics-fast-isel.ll
test/CodeGen/X86/avx512bw-intrinsics-upgrade.ll
test/CodeGen/X86/avx512bw-intrinsics.ll
test/CodeGen/X86/avx512vl-intrinsics-fast-isel.ll
test/CodeGen/X86/avx512vl-vbroadcast.ll
test/CodeGen/X86/avx512vl-vec-masked-cmp.ll
test/CodeGen/X86/bitcast-and-setcc-256.ll
test/CodeGen/X86/bitcast-and-setcc-512.ll
test/CodeGen/X86/bitcast-int-to-vector-bool-zext.ll
test/CodeGen/X86/bitcast-setcc-256.ll
test/CodeGen/X86/bitcast-setcc-512.ll
test/CodeGen/X86/bool-vector.ll
test/CodeGen/X86/cmp.ll
test/CodeGen/X86/emutls-pie.ll
test/CodeGen/X86/emutls.ll
test/CodeGen/X86/epilogue-cfi-fp.ll [new file with mode: 0644]
test/CodeGen/X86/epilogue-cfi-no-fp.ll [new file with mode: 0644]
test/CodeGen/X86/fast-isel-int-float-conversion.ll
test/CodeGen/X86/fast-isel-store.ll
test/CodeGen/X86/frame-lowering-debug-intrinsic-2.ll
test/CodeGen/X86/frame-lowering-debug-intrinsic.ll
test/CodeGen/X86/haddsub-2.ll
test/CodeGen/X86/hipe-cc64.ll
test/CodeGen/X86/illegal-bitfield-loadstore.ll
test/CodeGen/X86/imul.ll
test/CodeGen/X86/lea-opt-cse1.ll
test/CodeGen/X86/lea-opt-cse2.ll
test/CodeGen/X86/lea-opt-cse3.ll
test/CodeGen/X86/lea-opt-cse4.ll
test/CodeGen/X86/legalize-shift-64.ll
test/CodeGen/X86/live-out-reg-info.ll
test/CodeGen/X86/load-combine.ll
test/CodeGen/X86/masked_gather_scatter.ll
test/CodeGen/X86/memset-nonzero.ll
test/CodeGen/X86/merge-consecutive-loads-128.ll
test/CodeGen/X86/movtopush.ll
test/CodeGen/X86/mul-constant-result.ll
test/CodeGen/X86/mul-i256.ll
test/CodeGen/X86/mul128.ll
test/CodeGen/X86/pr21792.ll
test/CodeGen/X86/pr29061.ll
test/CodeGen/X86/pr29112.ll
test/CodeGen/X86/pr30430.ll
test/CodeGen/X86/pr32241.ll
test/CodeGen/X86/pr32256.ll
test/CodeGen/X86/pr32282.ll
test/CodeGen/X86/pr32284.ll
test/CodeGen/X86/pr32329.ll
test/CodeGen/X86/pr32345.ll
test/CodeGen/X86/pr32451.ll
test/CodeGen/X86/pr34088.ll
test/CodeGen/X86/pr34653.ll
test/CodeGen/X86/pr9743.ll
test/CodeGen/X86/push-cfi-debug.ll
test/CodeGen/X86/push-cfi-obj.ll
test/CodeGen/X86/push-cfi.ll
test/CodeGen/X86/return-ext.ll
test/CodeGen/X86/rtm.ll
test/CodeGen/X86/select-mmx.ll
test/CodeGen/X86/setcc-lowering.ll
test/CodeGen/X86/shrink_vmul.ll
test/CodeGen/X86/statepoint-call-lowering.ll
test/CodeGen/X86/statepoint-gctransition-call-lowering.ll
test/CodeGen/X86/statepoint-invoke.ll
test/CodeGen/X86/throws-cfi-fp.ll [new file with mode: 0644]
test/CodeGen/X86/throws-cfi-no-fp.ll [new file with mode: 0644]
test/CodeGen/X86/vector-sext.ll
test/CodeGen/X86/vector-shuffle-avx512.ll
test/CodeGen/X86/vector-shuffle-v1.ll
test/CodeGen/X86/wide-integer-cmp.ll
test/CodeGen/X86/x86-framelowering-trap.ll
test/CodeGen/X86/x86-interleaved-access.ll
test/CodeGen/X86/x86-no_caller_saved_registers-preserve.ll