Unverified Commit ba3d7a59 authored by Aiden Grossman's avatar Aiden Grossman Committed by GitHub
Browse files

[NewPM] Wire up gc-empty-basic-blocks into pipeline (#194179)

Same setup as the old pipeline and resolves a testing TODO now that we
have a full pipeline for x86.
parent 6ac432bd
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include "llvm/CodeGen/FEntryInserter.h"
#include "llvm/CodeGen/FinalizeISel.h"
#include "llvm/CodeGen/FixupStatepointCallerSaved.h"
#include "llvm/CodeGen/GCEmptyBasicBlocks.h"
#include "llvm/CodeGen/GCMetadata.h"
#include "llvm/CodeGen/GlobalMerge.h"
#include "llvm/CodeGen/GlobalMergeFunctions.h"
@@ -1076,6 +1077,9 @@ Error CodeGenPassBuilder<Derived, TargetMachineT>::addMachinePasses(
    }
  }

  if (Opt.EnableGCEmptyBlocks)
    addMachineFunctionPass(GCEmptyBasicBlocksPass(), PMW);

  derived().addPostBBSections(PMW);

  addMachineFunctionPass(StackFrameLayoutAnalysisPass(), PMW);
+1 −0
Original line number Diff line number Diff line
;; This test verifies that -enable-gc-empty-basic-blocks removes regular empty
;; blocks but does not remove empty blocks which have their address taken.
; RUN: llc < %s -mtriple=x86_64 -O0 -enable-gc-empty-basic-blocks | FileCheck %s
; RUN: llc < %s -mtriple=x86_64 -O0 -enable-gc-empty-basic-blocks -enable-new-pm | FileCheck %s

;; This function has a regular empty block.
define void @foo(i1 zeroext %0) nounwind {
+0 −51
Original line number Diff line number Diff line
# TODO(boomanaiden154): Remove this and use gc-empty-basic-blocks.ll directly.
# This should be trivial once we have an asm printer setup for X86 and at least
# a pipeline skeleton.
# RUN: llc %s -mtriple=x86_64 -passes=gc-empty-basic-blocks -o - | FileCheck %s
--- |
  define void @foo(i1 zeroext %0) #0 {
    br i1 %0, label %2, label %empty_block
  
  2:                                                ; preds = %1
    %3 = call i32 @baz()
    br label %4
  
  empty_block:                                      ; preds = %1
    unreachable
  
  4:                                                ; preds = %2
    ret void
  }

  declare i32 @baz()
  
  attributes #0 = { nounwind }
...
---
name:            foo
alignment:       16
body:             |
  bb.0:
    successors: %bb.1(0x40000000), %bb.2(0x40000000)
    liveins: $edi
  
    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
    $al = MOV8rr $dil, implicit killed $edi
    TEST8ri killed renamable $al, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit killed $eflags
    JMP_1 %bb.2
  
  bb.1:
    successors: %bb.3(0x80000000)
  
    CALL64pcrel32 target-flags(x86-plt) @baz, csr_64, implicit $rsp, implicit $ssp, implicit-def $eax
    JMP_1 %bb.3
  
  bb.2.empty_block:
    successors:
  
  bb.3:
    $rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp
    RET64
...
# CHECK-NOT: bb.2.empty_block: