Index: llvm/lib/Target/ARM/ARMInstrThumb.td =================================================================== --- llvm/lib/Target/ARM/ARMInstrThumb.td +++ llvm/lib/Target/ARM/ARMInstrThumb.td @@ -592,6 +592,7 @@ [(ARMbrjt tGPR:$target, tjumptable:$jt)]>, Sched<[WriteBrTbl]> { let Size = 2; + let isNotDuplicable = 1; list Predicates = [IsThumb, IsThumb1Only]; } } @@ -1465,7 +1466,7 @@ // Thumb-1 doesn't have the TBB or TBH instructions, but we can synthesize them // and make use of the same compressed jump table format as Thumb-2. let Size = 2, isBranch = 1, isTerminator = 1, isBarrier = 1, - isIndirectBranch = 1 in { + isIndirectBranch = 1, isNotDuplicable = 1 in { def tTBB_JT : tPseudoInst<(outs), (ins tGPRwithpc:$base, tGPR:$index, i32imm:$jt, i32imm:$pclbl), 0, IIC_Br, []>, Sched<[WriteBr]>; Index: llvm/test/CodeGen/Thumb/pr42760.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/Thumb/pr42760.ll @@ -0,0 +1,30 @@ +; RUN: llc -tail-dup-placement-threshold=3 < %s +; We only check that this doesn't trigger an error due to duplicated jumptable. + +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "thumbv6m-none-unknown-eabi" + +define hidden void @test() { +entry: + br label %switch + +switch: ; preds = %bb2, %entry + switch i32 undef, label %dead2 [ + i32 0, label %dead + i32 1, label %bb2 + i32 2, label %dead + i32 3, label %bb + ] + +dead: ; preds = %bb2, %bb, %switch, %switch + unreachable + +dead2: ; preds = %switch + unreachable + +bb: ; preds = %switch + br i1 undef, label %dead, label %bb2 + +bb2: ; preds = %bb, %switch + br i1 undef, label %dead, label %switch +}