[llvm] [SimplifyCFG] Don't hoist a musttail call separately from the terminator (PR #207094)
Henry Jiang via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 1 19:16:53 PDT 2026
================
@@ -101,3 +101,34 @@ if.else:
if.end:
ret void
}
+
+declare ptr @callee(ptr, i32, i32)
+
+define ptr @dont_hoist_musttail_past_pseudoprobe(ptr %a, i32 %b, i32 %c) {
+; CHECK-LABEL: @dont_hoist_musttail_past_pseudoprobe(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[C:%.*]], 0
+; CHECK-NEXT: br i1 [[COND]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: call void @llvm.pseudoprobe(i64 3, i64 1, i32 0, i64 -1)
+; CHECK-NEXT: [[CALL:%.*]] = musttail call ptr @callee(ptr [[A:%.*]], i32 [[B:%.*]], i32 [[C]])
+; CHECK-NEXT: ret ptr [[CALL]]
+; CHECK: if.else:
+; CHECK-NEXT: call void @llvm.pseudoprobe(i64 3, i64 2, i32 0, i64 -1)
+; CHECK-NEXT: [[CALL2:%.*]] = musttail call ptr @callee(ptr [[A]], i32 [[B]], i32 [[C]])
+; CHECK-NEXT: ret ptr [[CALL2]]
+;
+entry:
+ %cond = icmp eq i32 %c, 0
+ br i1 %cond, label %if.then, label %if.else
+
+if.then:
+ call void @llvm.pseudoprobe(i64 3, i64 1, i32 0, i64 -1)
+ %call = musttail call ptr @callee(ptr %a, i32 %b, i32 %c)
+ ret ptr %call
+
+if.else:
+ call void @llvm.pseudoprobe(i64 3, i64 2, i32 0, i64 -1)
+ %call2 = musttail call ptr @callee(ptr %a, i32 %b, i32 %c)
+ ret ptr %call2
+}
----------------
mustartt wrote:
There isn't any besides `switch_musttail_call`. Added 2 tests cases for `musttail`.
https://github.com/llvm/llvm-project/pull/207094
More information about the llvm-commits
mailing list