]> granicus.if.org Git - llvm/commitdiff
[AArch64][GlobalISel] Enable copy elision in the pre-legalizer combine and fix a...
authorAmara Emerson <aemerson@apple.com>
Sat, 13 Apr 2019 00:33:25 +0000 (00:33 +0000)
committerAmara Emerson <aemerson@apple.com>
Sat, 13 Apr 2019 00:33:25 +0000 (00:33 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358318 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/GlobalISel/GISelChangeObserver.cpp
lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp
test/CodeGen/AArch64/GlobalISel/observer-change-crash.mir [new file with mode: 0644]

index 5a532c995ce2719ce68cdc99663cdb15d0382144..62b903c30b89db26e021f494a136eaa3c02d0f0d 100644 (file)
@@ -26,6 +26,7 @@ void GISelChangeObserver::changingAllUsesOfReg(
 void GISelChangeObserver::finishedChangingAllUsesOfReg() {
   for (auto *ChangedMI : ChangingAllUsesOfReg)
     changedInstr(*ChangedMI);
+  ChangingAllUsesOfReg.clear();
 }
 
 RAIIDelegateInstaller::RAIIDelegateInstaller(MachineFunction &MF,
index cffe7dbfe6632c3d7f7243ea3b06655b45aa05e4..fe8216a8d1f9472ea097e6c595bbcaf9dd241f43 100644 (file)
@@ -43,6 +43,8 @@ bool AArch64PreLegalizerCombinerInfo::combine(GISelChangeObserver &Observer,
   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:
diff --git a/test/CodeGen/AArch64/GlobalISel/observer-change-crash.mir b/test/CodeGen/AArch64/GlobalISel/observer-change-crash.mir
new file mode 100644 (file)
index 0000000..cfc990b
--- /dev/null
@@ -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)
+
+...