Skip to content

Commit

Permalink
disasm-test: Add callbr test output for LLVM 15+
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott committed May 4, 2023
1 parent 416ebe1 commit 1b8b25b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
18 changes: 18 additions & 0 deletions disasm-test/tests/callbr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Adapted from the Clang test suite:
// (https://github.com/llvm/llvm-project/blob/32103608fc073700f04238872d8b22655ddec3fb/clang/test/CodeGen/asm-goto.c#L5-L20),
// which is licensed under the Apache License v2.0


int main(void) {
int cond = 0;
asm volatile goto("testl %0, %0; jne %l1;"
: /* No outputs */
: "r"(cond)
: /* No clobbers */
: label_true, loop);
return 0;
loop:
return 0;
label_true:
return 1;
}
47 changes: 47 additions & 0 deletions disasm-test/tests/callbr.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
; ModuleID = 'callbr.c'
source_filename = "callbr.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @main() #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 0, ptr %1, align 4
store i32 0, ptr %2, align 4
%3 = load i32, ptr %2, align 4
callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 %3) #1
to label %4 [label %6, label %5], !srcloc !7

4: ; preds = %0
store i32 0, ptr %1, align 4
br label %7

5: ; preds = %0
store i32 0, ptr %1, align 4
br label %7

6: ; preds = %0
store i32 1, ptr %1, align 4
br label %7

7: ; preds = %6, %5, %4
%8 = load i32, ptr %1, align 4
ret i32 %8
}

attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3, !4}
!llvm.ident = !{!5}
!llvm.commandline = !{!6}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 2}
!5 = !{!"clang version 15.0.6"}
!6 = !{!"/home/ryanglscott/Software/clang+llvm-15.0.6/bin/clang-15 -S -emit-llvm -frecord-command-line callbr.c -o callbr.ll"}
!7 = !{i64 272}

0 comments on commit 1b8b25b

Please sign in to comment.