Index: lib/Transforms/Scalar/TailRecursionElimination.cpp =================================================================== --- lib/Transforms/Scalar/TailRecursionElimination.cpp +++ lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -230,7 +230,7 @@ Escaped = ESCAPED; CallInst *CI = dyn_cast(&I); - if (!CI || CI->isTailCall()) + if (!CI || CI->isTailCall() || isa(&I)) continue; bool IsNoTail = CI->isNoTailCall() || CI->hasOperandBundles(); Index: test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll =================================================================== --- test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll +++ test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll @@ -96,8 +96,8 @@ ; OPTIMIZATION_LEVEL_2: define i32 @maxB(i32 %x, i32 %y) ; OPTIMIZATION_LEVEL_2-NEXT: entry: -; OPTIMIZATION_LEVEL_2-NEXT: tail call void @llvm.dbg.value(metadata i32 %x, metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}} -; OPTIMIZATION_LEVEL_2-NEXT: tail call void @llvm.dbg.value(metadata i32 %y, metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}} +; OPTIMIZATION_LEVEL_2-NEXT: call void @llvm.dbg.value(metadata i32 %x, metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}} +; OPTIMIZATION_LEVEL_2-NEXT: call void @llvm.dbg.value(metadata i32 %y, metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}} ; OPTIMIZATION_LEVEL_2-NEXT: %0 = tail call i32 @maxA(i32 %x, i32 %y) #{{[0-9]+}}, !dbg !{{[0-9]+}} ; OPTIMIZATION_LEVEL_2-NEXT: ret i32 %0, !dbg !{{[0-9]+}} ; OPTIMIZATION_LEVEL_2-NEXT: }