This reverts commit 122efef8ee.
- Patch fixed to not reuse definitions from predecessors in EH landing pads.
- Late review suggestions (by MaskRay) have been addressed.
- M68k/pipeline.ll test updated.
- Init captures added in processBlock() to avoid capturing structured bindings.
- RISCV has this disabled for now.
Original commit message:
A new pass MachineLateInstrsCleanup is added to be run after PEI.
This is a simple pass that removes redundant and identical instructions
whenever found by scanning the MF once while keeping track of register
definitions in a map. These instructions are typically immediate loads
resulting from rematerialization, and address loads emitted by target in
eliminateFrameInde().
This is enabled by default, but a target could easily disable it by means of
'disablePass(&MachineLateInstrsCleanupID);'.
This late cleanup is naturally not "optimal" in removing instructions as it
is done by looking at phys-regs, but still quite effective. It would be
desirable to improve other parts of CodeGen and avoid these redundant
instructions in the first place, but there are no ideas for this yet.
Differential Revision: https://reviews.llvm.org/D123394
Reviewed By: RKSimon, foad, craig.topper, arsenm, asb
46 lines
1.2 KiB
LLVM
46 lines
1.2 KiB
LLVM
; RUN: llc -o - %s | FileCheck %s
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-apple-macosx"
|
|
|
|
; selectiondag stack protector uses a GuardReg which the fast-isel stack
|
|
; protection code did not but the state was not reset properly.
|
|
; The optnone attribute on @bar forces fast-isel.
|
|
|
|
; CHECK-LABEL: foo:
|
|
; CHECK: movq ___stack_chk_guard@GOTPCREL(%rip), %rax
|
|
define void @foo() #0 {
|
|
entry:
|
|
%_tags = alloca [3 x i32], align 4
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: bar:
|
|
; CHECK: movq ___stack_chk_guard@GOTPCREL(%rip), %{{r.x}}
|
|
; CHECK-DAG: movq ___stack_chk_guard@GOTPCREL(%rip), %[[GUARD:r.x]]
|
|
; CHECK-DAG: movq {{[0-9]+}}(%rsp), %[[CANARY:r.x]]
|
|
; CHECK: subq %[[CANARY]], %[[GUARD]]
|
|
define void @bar() #1 {
|
|
entry:
|
|
%vt = alloca [2 x double], align 16
|
|
br i1 undef, label %cleanup.4091, label %for.cond.3850
|
|
|
|
unreachable:
|
|
unreachable
|
|
|
|
for.cond.3850:
|
|
br i1 undef, label %land.rhs.3853, label %land.end.3857
|
|
|
|
land.rhs.3853:
|
|
br label %land.end.3857
|
|
|
|
land.end.3857:
|
|
%0 = phi i1 [ false, %for.cond.3850 ], [ false, %land.rhs.3853 ]
|
|
br i1 %0, label %unreachable, label %unreachable
|
|
|
|
cleanup.4091:
|
|
ret void
|
|
}
|
|
|
|
attributes #0 = { ssp }
|
|
attributes #1 = { noinline optnone ssp }
|