|
| 1 | +; RUN: llc -stop-after=yk-stackmaps --yk-insert-stackmaps < %s | FileCheck %s |
| 2 | + |
| 3 | +; Check whether `llvm.experimental.stackmap` calls are only inserted after normal calls, |
| 4 | +; and not after external calls. |
| 5 | + |
| 6 | +; CHECK-LABEL: define dso_local i32 @main |
| 7 | +; CHECK: %call = call i32 @foo(i32 noundef %0) |
| 8 | +; CHECK-NEXT: call void (i64, i32, ...) @llvm.experimental.stackmap(i64 0, i32 0, ptr %argc.addr, ptr %a, ptr %b, i32 %0) |
| 9 | +; CHECK: %call1 = call i32 @foo(i32 noundef %1) |
| 10 | +; CHECK-NEXT: call void (i64, i32, ...) @llvm.experimental.stackmap(i64 1, i32 0, ptr %argc.addr, ptr %a, ptr %b, i32 %1) |
| 11 | +; CHECK: %call2 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %2, i32 noundef %3, i32 noundef %4) |
| 12 | +; CHECK-NOT: call void (i64, i32, ...) @llvm.experimental.stackmap |
| 13 | + |
| 14 | +@.str = private unnamed_addr constant [10 x i8] c"%d %d %d\0A\00", align 1 |
| 15 | + |
| 16 | +; Function Attrs: noinline nounwind uwtable |
| 17 | +define dso_local i32 @foo(i32 noundef %x) #0 { |
| 18 | +entry: |
| 19 | + %x.addr = alloca i32, align 4 |
| 20 | + store i32 %x, ptr %x.addr, align 4 |
| 21 | + %0 = load i32, ptr %x.addr, align 4 |
| 22 | + %add = add nsw i32 %0, 10 |
| 23 | + ret i32 %add |
| 24 | +} |
| 25 | + |
| 26 | +; Function Attrs: noinline nounwind uwtable |
| 27 | +define dso_local i32 @main(i32 noundef %argc, ptr noundef %argv) #0 { |
| 28 | +entry: |
| 29 | + %retval = alloca i32, align 4 |
| 30 | + %argc.addr = alloca i32, align 4 |
| 31 | + %argv.addr = alloca ptr, align 8 |
| 32 | + %a = alloca i32, align 4 |
| 33 | + %b = alloca i32, align 4 |
| 34 | + store i32 0, ptr %retval, align 4 |
| 35 | + store i32 %argc, ptr %argc.addr, align 4 |
| 36 | + store ptr %argv, ptr %argv.addr, align 8 |
| 37 | + %0 = load i32, ptr %argc.addr, align 4 |
| 38 | + %call = call i32 @foo(i32 noundef %0) |
| 39 | + store i32 %call, ptr %a, align 4 |
| 40 | + %1 = load i32, ptr %a, align 4 |
| 41 | + %call1 = call i32 @foo(i32 noundef %1) |
| 42 | + store i32 %call1, ptr %b, align 4 |
| 43 | + %2 = load i32, ptr %argc.addr, align 4 |
| 44 | + %3 = load i32, ptr %a, align 4 |
| 45 | + %4 = load i32, ptr %b, align 4 |
| 46 | + %call2 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %2, i32 noundef %3, i32 noundef %4) |
| 47 | + ret i32 0 |
| 48 | +} |
| 49 | + |
| 50 | +declare dso_local i32 @printf(ptr noundef, ...) #1 |
| 51 | + |
| 52 | +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
| 53 | +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
0 commit comments