From: Quentin Colombet Date: Thu, 12 Nov 2015 18:13:42 +0000 (+0000) Subject: [ShrinkWrap] Make sure we do not mess up with EH funclet lowering. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=88d45c68013ffcdb96635f7c3c8acc56a9c5f7cb;p=oota-llvm.git [ShrinkWrap] Make sure we do not mess up with EH funclet lowering. ShrinkWrapping does not understand exception handling constraints for now, so make sure we do not mess with them by aborting on functions that use EH funclets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252917 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/ShrinkWrap.cpp b/lib/CodeGen/ShrinkWrap.cpp index 8261caa4f84..368f138f959 100644 --- a/lib/CodeGen/ShrinkWrap.cpp +++ b/lib/CodeGen/ShrinkWrap.cpp @@ -63,11 +63,13 @@ #include "llvm/CodeGen/Passes.h" // To know about callee-saved. #include "llvm/CodeGen/RegisterClassInfo.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/Support/Debug.h" // To query the target about frame lowering. #include "llvm/Target/TargetFrameLowering.h" // To know about frame setup operation. #include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetMachine.h" // To access TargetInstrInfo. #include "llvm/Target/TargetSubtargetInfo.h" @@ -377,6 +379,11 @@ bool ShrinkWrap::runOnMachineFunction(MachineFunction &MF) { DEBUG(dbgs() << "Look into: " << MBB.getNumber() << ' ' << MBB.getName() << '\n'); + if (MBB.isEHFuncletEntry()) { + DEBUG(dbgs() << "EH Funclets are not supported yet.\n"); + return false; + } + for (const MachineInstr &MI : MBB) { if (!useOrDefCSROrFI(MI)) continue; @@ -458,7 +465,10 @@ bool ShrinkWrap::isShrinkWrapEnabled(const MachineFunction &MF) { switch (EnableShrinkWrapOpt) { case cl::BOU_UNSET: - return TFI->enableShrinkWrapping(MF); + return TFI->enableShrinkWrapping(MF) && + // Windows with CFI has some limitations that makes it impossible + // to use shrink-wrapping. + !MF.getTarget().getMCAsmInfo()->usesWindowsCFI(); // If EnableShrinkWrap is set, it takes precedence on whatever the // target sets. The rational is that we assume we want to test // something related to shrink-wrapping. diff --git a/test/CodeGen/X86/late-address-taken.ll b/test/CodeGen/X86/late-address-taken.ll index 7d4dde80bbd..8f85393b67c 100644 --- a/test/CodeGen/X86/late-address-taken.ll +++ b/test/CodeGen/X86/late-address-taken.ll @@ -1,4 +1,6 @@ -; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s +; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s -enable-shrink-wrap=false | FileCheck %s +; Make sure shrink-wrapping does not break the lowering of exception handling. +; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s -enable-shrink-wrap=true | FileCheck %s ; Repro cases from PR25168