llvm/llvm/test/CodeGen/X86/StackColoring-tbaa.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
# RUN: llc -run-pass=stack-coloring %s -o - | FileCheck %s

# We do not expect any stack coloring remappings in this test case.
# And then there should be no reason to drop the tbaa metadata on the
# MOV8rm instruction, so we check that the tbaa info is kept.

--- |
  source_filename = "test_case.cc"
  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-unknown-linux-gnu"

  %struct.Agg = type { [3 x i8], [3 x i8] }

  define i8 @main() {
    %padding = alloca %struct.Agg, align 8
    %agg = alloca %struct.Agg, align 8
    %a2 = getelementptr inbounds %struct.Agg, ptr %agg, i64 0, i32 1
    %a22 = getelementptr inbounds [3 x i8], ptr %a2, i64 0, i32 1
    %t0 = load i8, ptr %a22, align 1, !tbaa !2
    %tobool = icmp slt i8 %t0, 0
    %t1 = load ptr, ptr %a2, align 8
    %cond = select i1 %tobool, ptr %t1, ptr %a2
    %add.ptr.i = getelementptr inbounds i8, ptr %cond, i64 16
    %t2 = load i8, ptr %add.ptr.i, align 1, !tbaa !2
    ret i8 %t2
  }

  !llvm.module.flags = !{!0}
  !llvm.ident = !{!1}

  !0 = !{i32 1, !"wchar_size", i32 4}
  !1 = !{!"clang version 9.0.0"}
  !2 = !{!3, !3, i64 0}
  !3 = !{!"omnipotent char", !4, i64 0}
  !4 = !{!"Simple C++ TBAA"}

...
---
name:            main
alignment:       16
tracksRegLiveness: true
stack:
  - { id: 0, name: padding, type: default, offset: 0, size: 24, alignment: 16,
      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
  - { id: 1, name: agg, type: default, offset: 0, size: 48, alignment: 16,
      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
body:             |
  bb.0:
    ; CHECK-LABEL: name: main
    ; CHECK: [[LEA64r:%[0-9]+]]:gr64 = nuw LEA64r %stack.1.agg, 1, $noreg, 24, $noreg
    ; CHECK-NEXT: CMP8mi %stack.1.agg, 1, $noreg, 47, $noreg, 0, implicit-def $eflags :: (dereferenceable load (s8) from %ir.a22, !tbaa !2)
    ; CHECK-NEXT: [[CMOV64rm:%[0-9]+]]:gr64 = CMOV64rm [[LEA64r]], %stack.1.agg, 1, $noreg, 24, $noreg, 8, implicit $eflags :: (dereferenceable load (s64) from %ir.a2)
    ; CHECK-NEXT: [[MOV8rm:%[0-9]+]]:gr8 = MOV8rm killed [[CMOV64rm]], 1, $noreg, 16, $noreg :: (load (s8) from %ir.add.ptr.i, !tbaa !2)
    ; CHECK-NEXT: $al = COPY [[MOV8rm]]
    ; CHECK-NEXT: RET 0, $al
    LIFETIME_START %stack.0.padding
    LIFETIME_START %stack.1.agg
    %8:gr64 = nuw LEA64r %stack.1.agg, 1, $noreg, 24, $noreg
    CMP8mi %stack.1.agg, 1, $noreg, 47, $noreg, 0, implicit-def $eflags :: (dereferenceable load (s8) from %ir.a22, !tbaa !2)
    %13:gr64 = CMOV64rm %8, %stack.1.agg, 1, $noreg, 24, $noreg, 8, implicit $eflags :: (dereferenceable load (s64) from %ir.a2)
    %14:gr8 = MOV8rm killed %13, 1, $noreg, 16, $noreg :: (load (s8) from %ir.add.ptr.i, !tbaa !2)
    $al = COPY %14
    RET 0, $al

...