From a38396939c548f9ad8e94c9baa7198fdb26dedc2 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Mon, 9 Dec 2019 09:39:31 +0100 Subject: [PATCH] Revert 393dacacf7e7 "[ARM] Enable TypePromotion by default" This caused "Too many bits for uint64_t" asserts when building Chromium. See https://crbug.com/1031978#c2 for a reproducer. I'll follow up on the llvm-commits thread with a creduced version. > ARMCodeGenPrepare has already been generalized and renamed to > TypePromotion. We've had it enabled and tested downstream for a > while, so enable it by default. > > Differential Revision: https://reviews.llvm.org/D70998 --- llvm/lib/CodeGen/TypePromotion.cpp | 24 +++------------------- llvm/test/Transforms/TypePromotion/ARM/calls.ll | 2 +- llvm/test/Transforms/TypePromotion/ARM/casts.ll | 2 +- .../TypePromotion/ARM/clear-structures.ll | 2 +- llvm/test/Transforms/TypePromotion/ARM/icmps.ll | 2 +- llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll | 2 +- llvm/test/Transforms/TypePromotion/ARM/pointers.ll | 2 +- .../Transforms/TypePromotion/ARM/signed-icmps.ll | 2 +- llvm/test/Transforms/TypePromotion/ARM/signed.ll | 2 +- llvm/test/Transforms/TypePromotion/ARM/switch.ll | 2 +- llvm/test/Transforms/TypePromotion/ARM/wrapping.ll | 2 +- 11 files changed, 13 insertions(+), 31 deletions(-) diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp index 596ad0c..94fe7d2 100644 --- a/llvm/lib/CodeGen/TypePromotion.cpp +++ b/llvm/lib/CodeGen/TypePromotion.cpp @@ -45,7 +45,7 @@ using namespace llvm; static cl::opt -DisablePromotion("disable-type-promotion", cl::Hidden, cl::init(false), +DisablePromotion("disable-type-promotion", cl::Hidden, cl::init(true), cl::desc("Disable type promotion pass")); // The goal of this pass is to enable more efficient code generation for @@ -899,34 +899,16 @@ bool TypePromotion::TryToPromote(Value *V, unsigned PromotedWidth) { for (auto *I : CurrentVisited) I->dump(); ); - - // Check that promoting this at the IR level is most likely beneficial. It's - // more likely if we're operating over multiple blocks and handling wrapping - // instructions. unsigned ToPromote = 0; - unsigned NonFreeArgs = 0; - SmallPtrSet Blocks; for (auto *V : CurrentVisited) { - if (auto *I = dyn_cast(V)) - Blocks.insert(I->getParent()); - - if (Sources.count(V)) { - if (auto *Arg = dyn_cast(V)) { - if (!Arg->hasZExtAttr() && !Arg->hasSExtAttr()) - ++NonFreeArgs; - } + if (Sources.count(V)) continue; - } - if (Sinks.count(cast(V))) continue; - ++ToPromote; } - // DAG optimisations should be able to handle these cases better, especially - // for function arguments. - if (ToPromote < 2 || (Blocks.size() == 1 && (NonFreeArgs > SafeWrap.size()))) + if (ToPromote < 2) return false; Promoter->Mutate(OrigTy, PromotedWidth, CurrentVisited, Sources, Sinks, diff --git a/llvm/test/Transforms/TypePromotion/ARM/calls.ll b/llvm/test/Transforms/TypePromotion/ARM/calls.ll index 8c14a3a..cd273c0 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/calls.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/calls.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s define i8 @call_with_imms(i8* %arg) { ; CHECK-LABEL: @call_with_imms( diff --git a/llvm/test/Transforms/TypePromotion/ARM/casts.ll b/llvm/test/Transforms/TypePromotion/ARM/casts.ll index 66c713c..70fa617 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/casts.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/casts.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s define i16 @dsp_trunc(i32 %arg0, i32 %arg1, i16* %gep0, i16* %gep1) { ; CHECK-LABEL: @dsp_trunc( diff --git a/llvm/test/Transforms/TypePromotion/ARM/clear-structures.ll b/llvm/test/Transforms/TypePromotion/ARM/clear-structures.ll index aae729f..117c4c0 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/clear-structures.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/clear-structures.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s define i32 @clear_structures(i8* nocapture readonly %fmt, [1 x i32] %ap.coerce, i8* %out, void (i32, i8*)* nocapture %write) { ; CHECK-LABEL: @clear_structures( diff --git a/llvm/test/Transforms/TypePromotion/ARM/icmps.ll b/llvm/test/Transforms/TypePromotion/ARM/icmps.ll index 8d33c34..6dda15c 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/icmps.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/icmps.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s define i32 @test_ult_254_inc_imm(i8 zeroext %x) { ; CHECK-LABEL: @test_ult_254_inc_imm( diff --git a/llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll b/llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll index 12001a4..e79e4ff 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s ; Check that the arguments are extended but then nothing else is. ; This also ensures that the pass can handle loops. diff --git a/llvm/test/Transforms/TypePromotion/ARM/pointers.ll b/llvm/test/Transforms/TypePromotion/ARM/pointers.ll index 7369b18..3c5f097 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/pointers.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/pointers.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s define void @phi_pointers(i16* %a, i16* %b, i8 zeroext %M, i8 zeroext %N) { ; CHECK-LABEL: @phi_pointers( diff --git a/llvm/test/Transforms/TypePromotion/ARM/signed-icmps.ll b/llvm/test/Transforms/TypePromotion/ARM/signed-icmps.ll index 3655ff0..dfdd4c1 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/signed-icmps.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/signed-icmps.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s define i8 @eq_sgt(i8* %x, i8 *%y, i8 zeroext %z) { ; CHECK-LABEL: @eq_sgt( diff --git a/llvm/test/Transforms/TypePromotion/ARM/signed.ll b/llvm/test/Transforms/TypePromotion/ARM/signed.ll index e2fabb9..143220a 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/signed.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/signed.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s ; Test to check that ARMCodeGenPrepare doesn't optimised away sign extends. define i16 @test_signed_load(i16* %ptr) { diff --git a/llvm/test/Transforms/TypePromotion/ARM/switch.ll b/llvm/test/Transforms/TypePromotion/ARM/switch.ll index 058101f..6736ebe 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/switch.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/switch.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s define void @truncate_source_phi_switch(i8* %memblock, i8* %store, i16 %arg) { ; CHECK-LABEL: @truncate_source_phi_switch( diff --git a/llvm/test/Transforms/TypePromotion/ARM/wrapping.ll b/llvm/test/Transforms/TypePromotion/ARM/wrapping.ll index 346114a..23e50de 100644 --- a/llvm/test/Transforms/TypePromotion/ARM/wrapping.ll +++ b/llvm/test/Transforms/TypePromotion/ARM/wrapping.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=arm -type-promotion -verify -S %s -o - | FileCheck %s +; RUN: opt -mtriple=arm -type-promotion -verify -disable-type-promotion=false -S %s -o - | FileCheck %s define zeroext i16 @overflow_add(i16 zeroext %a, i16 zeroext %b) { ; CHECK-LABEL: @overflow_add( -- 2.7.4