[llvm] r358318 - [AArch64][GlobalISel] Enable copy elision in the pre-legalizer combine and fix a crash.
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 17:33:25 PDT 2019
Author: aemerson
Date: Fri Apr 12 17:33:25 2019
New Revision: 358318
URL: http://llvm.org/viewvc/llvm-project?rev=358318&view=rev
Log:
[AArch64][GlobalISel] Enable copy elision in the pre-legalizer combine and fix a crash.
This enables the simple copy combine that already exists in the CombinerHelper.
However, it exposed a bug in the GISelChangeObserver where it wouldn't clear a
set of MIs to process, and so would end up causing a crash when deleted MIs were
being added to the combiner worklist again.
Differential Revision: https://reviews.llvm.org/D60579
Added:
llvm/trunk/test/CodeGen/AArch64/GlobalISel/observer-change-crash.mir
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/GISelChangeObserver.cpp
llvm/trunk/lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalISel/GISelChangeObserver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/GISelChangeObserver.cpp?rev=358318&r1=358317&r2=358318&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/GISelChangeObserver.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/GISelChangeObserver.cpp Fri Apr 12 17:33:25 2019
@@ -26,6 +26,7 @@ void GISelChangeObserver::changingAllUse
void GISelChangeObserver::finishedChangingAllUsesOfReg() {
for (auto *ChangedMI : ChangingAllUsesOfReg)
changedInstr(*ChangedMI);
+ ChangingAllUsesOfReg.clear();
}
RAIIDelegateInstaller::RAIIDelegateInstaller(MachineFunction &MF,
Modified: llvm/trunk/lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp?rev=358318&r1=358317&r2=358318&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp Fri Apr 12 17:33:25 2019
@@ -43,6 +43,8 @@ bool AArch64PreLegalizerCombinerInfo::co
switch (MI.getOpcode()) {
default:
return false;
+ case TargetOpcode::COPY:
+ return Helper.tryCombineCopy(MI);
case TargetOpcode::G_LOAD:
case TargetOpcode::G_SEXTLOAD:
case TargetOpcode::G_ZEXTLOAD:
Added: llvm/trunk/test/CodeGen/AArch64/GlobalISel/observer-change-crash.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/observer-change-crash.mir?rev=358318&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/observer-change-crash.mir (added)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/observer-change-crash.mir Fri Apr 12 17:33:25 2019
@@ -0,0 +1,32 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner %s -o - | FileCheck %s
+--- |
+ target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
+ target triple = "arm64-apple-ios5.0.0"
+
+ define void @test() {
+ ret void
+ }
+
+...
+---
+name: test
+alignment: 2
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: _ }
+ - { id: 1, class: _ }
+ - { id: 2, class: _ }
+frameInfo:
+ maxCallFrameSize: 0
+body: |
+ bb.0:
+ ; CHECK-LABEL: name: test
+ ; CHECK: [[DEF:%[0-9]+]]:_(p0) = G_IMPLICIT_DEF
+ ; CHECK: $x0 = COPY [[DEF]](p0)
+ %0:_(p0) = G_IMPLICIT_DEF
+ %1:_(p0) = COPY %0(p0)
+ %2:_(p0) = COPY %1(p0)
+ $x0 = COPY %2(p0)
+
+...
More information about the llvm-commits
mailing list