From a4d487fc1e2f95f4b47ad472071bfdd484eb3b40 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 27 May 2011 18:02:04 +0000 Subject: [PATCH] Fix a silly mistake (which trips over an assertion) in r132099. rdar://9515076 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132194 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMFastISel.cpp | 2 ++ lib/Transforms/Scalar/LICM.cpp | 15 ++++++--------- test/CodeGen/ARM/fast-isel-crash2.ll | 9 +++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 test/CodeGen/ARM/fast-isel-crash2.ll diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp index 2d2ac670b01..fc0b8d23c71 100644 --- a/lib/Target/ARM/ARMFastISel.cpp +++ b/lib/Target/ARM/ARMFastISel.cpp @@ -1981,6 +1981,8 @@ bool ARMFastISel::SelectIntCast(const Instruction *I) { unsigned Opc; bool isZext = isa(I); bool isBoolZext = false; + if (!SrcVT.isSimple()) + return false; switch (SrcVT.getSimpleVT().SimpleTy) { default: return false; case MVT::i16: diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index d42d4ff837b..935cd5d1ee4 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -372,7 +372,11 @@ bool LICM::canSinkOrHoistInst(Instruction &I) { return !pointerInvalidatedByLoop(LI->getOperand(0), Size, LI->getMetadata(LLVMContext::MD_tbaa)); } else if (CallInst *CI = dyn_cast(&I)) { - // Handle obvious cases efficiently. + // Don't sink or hoist dbg info; it's legal, but not useful. + if (isa(I)) + return false; + + // Handle simple cases by querying alias analysis. AliasAnalysis::ModRefBehavior Behavior = AA->getModRefBehavior(CI); if (Behavior == AliasAnalysis::DoesNotAccessMemory) return true; @@ -522,14 +526,7 @@ void LICM::sink(Instruction &I) { SSA.AddAvailableValue(ExitBlock, New); } - // If the instruction doesn't dominate any exit blocks, it must be dead. - if (NumInserted == 0) { - CurAST->deleteValue(&I); - if (!I.use_empty()) - I.replaceAllUsesWith(UndefValue::get(I.getType())); - I.eraseFromParent(); - return; - } + assert(NumInserted && "We shouldn't see dead instructions here!"); // Next, rewrite uses of the instruction, inserting PHI nodes as needed. for (Value::use_iterator UI = I.use_begin(), UE = I.use_end(); UI != UE; ) { diff --git a/test/CodeGen/ARM/fast-isel-crash2.ll b/test/CodeGen/ARM/fast-isel-crash2.ll new file mode 100644 index 00000000000..273e67e7e4b --- /dev/null +++ b/test/CodeGen/ARM/fast-isel-crash2.ll @@ -0,0 +1,9 @@ +; RUN: llc < %s -O0 -mtriple=thumbv7-apple-darwin +; rdar://9515076 +; (Make sure this doesn't crash.) + +define i32 @test(i32 %i) { + %t = trunc i32 %1 to i4 + %r = sext i4 %t to i32 + ret i32 %r +} -- 2.11.0