Home | History | Annotate | Download | only in llvm2ice_tests
      1 ; Tests the integrated assembler for instructions with multiple
      2 ; relocations.
      3 
      4 ; RUN: %if --need=allow_dump --command %p2i -i %s --args -O2 \
      5 ; RUN:   -allow-externally-defined-symbols \
      6 ; RUN:   | %if --need=allow_dump --command FileCheck %s
      7 
      8 ; char global_char;
      9 ; char *p_global_char;
     10 ; void dummy();
     11 ; void store_immediate_to_global() { p_global_char = &global_char; }
     12 ; void add_in_place() { p_global_char += (int)&global_char; }
     13 ; void cmp_global_immediate() { if (p_global_char == &global_char) dummy(); }
     14 
     15 @global_char = internal global [1 x i8] zeroinitializer, align 1
     16 @p_global_char = internal global [4 x i8] zeroinitializer, align 4
     17 declare void @dummy()
     18 
     19 define internal void @store_immediate_to_global() {
     20 entry:
     21   %p_global_char.bc = bitcast [4 x i8]* @p_global_char to i32*
     22   %expanded1 = ptrtoint [1 x i8]* @global_char to i32
     23   store i32 %expanded1, i32* %p_global_char.bc, align 1
     24   ret void
     25 }
     26 ; CHECK-LABEL: store_immediate_to_global
     27 ; CHECK: .long p_global_char
     28 ; CHECK: .long global_char
     29 
     30 ; Also exercises the RMW add operation.
     31 define internal void @add_in_place() {
     32 entry:
     33   %p_global_char.bc = bitcast [4 x i8]* @p_global_char to i32*
     34   %0 = load i32, i32* %p_global_char.bc, align 1
     35   %expanded1 = ptrtoint [1 x i8]* @global_char to i32
     36   %gep = add i32 %0, %expanded1
     37   %p_global_char.bc3 = bitcast [4 x i8]* @p_global_char to i32*
     38   store i32 %gep, i32* %p_global_char.bc3, align 1
     39   ret void
     40 }
     41 ; CHECK-LABEL: add_in_place
     42 ; CHECK: .long p_global_char
     43 ; CHECK-NEXT: .long global_char
     44 
     45 define internal void @cmp_global_immediate() {
     46 entry:
     47   %p_global_char.bc = bitcast [4 x i8]* @p_global_char to i32*
     48   %0 = load i32, i32* %p_global_char.bc, align 1
     49   %expanded1 = ptrtoint [1 x i8]* @global_char to i32
     50   %cmp = icmp eq i32 %0, %expanded1
     51   br i1 %cmp, label %if.then, label %if.end
     52 
     53 if.then:                                          ; preds = %entry
     54   tail call void @dummy()
     55   br label %if.end
     56 
     57 if.end:                                           ; preds = %if.then, %entry
     58   ret void
     59 }
     60 ; CHECK-LABEL: cmp_global_immediate
     61 ; CHECK: .long p_global_char
     62 ; CHECK: .long global_char
     63 ; CHECK: .long dummy
     64