brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.0 KiB · 8567417 Raw
287 lines · plain
1; RUN: rm -rf %t && split-file %s %t2; RUN: llvm-as %t/global-use-good.ll -o - | llvm-dis -o /dev/null3; RUN: not llvm-as %t/global-use-bad.ll -o /dev/null 2>&1 | FileCheck %t/global-use-bad.ll4; RUN: llvm-as %t/global-fwddecl-good.ll -o - | llvm-dis -o /dev/null5; RUN: not llvm-as %t/global-fwddecl-bad.ll -o /dev/null 2>&1 | FileCheck %t/global-fwddecl-bad.ll6; RUN: llvm-as %t/return-fwddecl-good.ll  -o - | llvm-dis -o /dev/null7; RUN: not llvm-as %t/return-fwddecl-bad.ll -o /dev/null 2>&1 | FileCheck %t/return-fwddecl-bad.ll8; RUN: llvm-as %t/return-self-good.ll  -o - | llvm-dis -o /dev/null9; RUN: not llvm-as %t/return-self-bad.ll -o /dev/null 2>&1 | FileCheck %t/return-self-bad.ll10; RUN: not llvm-as %t/return-self-bad-2.ll -o /dev/null 2>&1 | FileCheck %t/return-self-bad-2.ll11; RUN: not llvm-as %t/return-unknown-fn-bad.ll -o /dev/null 2>&1 | FileCheck %t/return-unknown-fn-bad.ll12; RUN: llvm-as %t/call-fwddecl-good.ll  -o - | llvm-dis -o /dev/null13; RUN: not llvm-as %t/call-fwddecl-bad.ll -o /dev/null 2>&1 | FileCheck %t/call-fwddecl-bad.ll14; RUN: llvm-as %t/phi-good.ll  -o - | llvm-dis -o /dev/null15; RUN: not llvm-as %t/phi-bad.ll -o /dev/null 2>&1 | FileCheck %t/phi-bad.ll16; RUN: llvm-as %t/fwddecl-phi-good.ll  -o - | llvm-dis -o /dev/null17; RUN: not llvm-as %t/fwddecl-phi-bad.ll -o /dev/null 2>&1 | FileCheck %t/fwddecl-phi-bad.ll18; RUN: not llvm-as %t/bad-type-not-ptr.ll -o /dev/null 2>&1 | FileCheck %t/bad-type-not-ptr.ll19; RUN: not llvm-as %t/bad-type-not-i8-ptr.ll -o /dev/null 2>&1 | FileCheck %t/bad-type-not-i8-ptr.ll20 21 22;--- global-use-good.ll23target datalayout = "P2"24define void @fn_in_prog_as_implicit() {25  unreachable26bb:27  ret void28}29define void @fn_in_prog_as_explicit() addrspace(2) {30  unreachable31bb:32  ret void33}34define void @fn_in_other_as() addrspace(1) {35  unreachable36bb:37  ret void38}39@global1 = constant ptr addrspace(2) blockaddress(@fn_in_prog_as_implicit, %bb)40@global2 = constant ptr addrspace(2) blockaddress(@fn_in_prog_as_explicit, %bb)41@global3 = constant ptr addrspace(1) blockaddress(@fn_in_other_as, %bb)42 43;--- global-use-bad.ll44define void @fn() addrspace(1) {45  unreachable46bb:47  ret void48}49@global1 = constant ptr addrspace(2) blockaddress(@fn, %bb)50; CHECK: [[#@LINE-1]]:38: error: constant expression type mismatch: got type 'ptr addrspace(1)' but expected 'ptr addrspace(2)'51 52; Check that a global blockaddress of a forward-declared function53; uses the type of the global variable address space for the forward declaration54;--- global-fwddecl-good.ll55@global = constant ptr addrspace(2) blockaddress(@fwddecl_in_prog_as, %bb)56define void @fwddecl_in_prog_as() addrspace(2) {57  unreachable58bb:59  ret void60}61 62;--- global-fwddecl-bad.ll63; This forward declaration does not match the actual function type so we should get an error:64@global = constant ptr addrspace(2) blockaddress(@fwddecl_in_unexpected_as, %bb)65; CHECK: [[#@LINE-1]]:77: error: 'bb' defined with type 'ptr addrspace(1)' but expected 'ptr addrspace(2)'66define void @fwddecl_in_unexpected_as() addrspace(1) {67  unreachable68bb:69  ret void70}71 72 73; When returning blockaddresses of forward-declared functions we74; can also use the type of the variable.75;--- return-fwddecl-good.ll76define ptr addrspace(2) @take_as2() {77  ret ptr addrspace(2) blockaddress(@fwddecl_as2, %bb)78}79define ptr addrspace(1) @take_as1() {80  ret ptr addrspace(1) blockaddress(@fwddecl_as1, %bb)81}82define void @fwddecl_as1() addrspace(1) {83  unreachable84bb:85  ret void86}87define void @fwddecl_as2() addrspace(2) {88  unreachable89bb:90  ret void91}92 93;--- return-fwddecl-bad.ll94define ptr addrspace(2) @take_bad() {95  ret ptr addrspace(2) blockaddress(@fwddecl_as1, %bb)96  ; CHECK: [[#@LINE-1]]:51: error: 'bb' defined with type 'ptr addrspace(1)' but expected 'ptr addrspace(2)'97}98define void @fwddecl_as1() addrspace(1) {99  unreachable100bb:101  ret void102}103 104;--- return-self-good.ll105target datalayout = "P2"106define ptr addrspace(0) @take_self_as0() addrspace(0) {107L1:108  br label %L2109L2:110  ret ptr addrspace(0) blockaddress(@take_self_as0, %L3)111L3:112  unreachable113}114define ptr addrspace(2) @take_self_prog_as() {115L1:116  br label %L2117L2:118  ret ptr addrspace(2) blockaddress(@take_self_prog_as, %L3)119L3:120  unreachable121}122define ptr addrspace(1) @take_self_as1() addrspace(1) {123L1:124  br label %L2125L2:126  ret ptr addrspace(1) blockaddress(@take_self_as1, %L3)127L3:128  unreachable129}130define ptr addrspace(2) @take_self_as2() addrspace(2) {131L1:132  br label %L2133L2:134  ret ptr addrspace(2) blockaddress(@take_self_as2, %L3)135L3:136  unreachable137}138 139;--- return-self-bad.ll140target datalayout = "P2"141define ptr addrspace(2) @take_self_bad() addrspace(1) {142L1:143  br label %L2144L2:145  ret ptr addrspace(2) blockaddress(@take_self_bad, %L3)146  ; CHECK: [[#@LINE-1]]:24: error: constant expression type mismatch: got type 'ptr addrspace(1)' but expected 'ptr addrspace(2)'147L3:148  unreachable149}150;--- return-self-bad-2.ll151target datalayout = "P2"152define ptr @take_self_bad_prog_as() {153L1:154  br label %L2155L2:156  ret ptr blockaddress(@take_self_bad_prog_as, %L3)157  ; CHECK: [[#@LINE-1]]:11: error: constant expression type mismatch: got type 'ptr addrspace(2)' but expected 'ptr'158L3:159  unreachable160}161 162;--- return-unknown-fn-bad.ll163target datalayout = "P2"164define ptr addrspace(1) @return_unknown_fn() addrspace(1) {165  ret ptr addrspace(1) blockaddress(@undefined, %bb)166  ; CHECK: [[#@LINE-1]]:37: error: expected function name in blockaddress167}168 169 170;--- call-fwddecl-good.ll171target datalayout = "P2"172define void @call_from_fn_in_as2() addrspace(2) {173  call addrspace(2) void blockaddress(@fwddecl_as2, %bb)()174  ret void175}176define void @call_from_fn_in_as1() addrspace(1) {177  call addrspace(1) void blockaddress(@fwddecl_as1, %bb)()178  ret void179}180define void @fwddecl_as2() addrspace(2) {181  unreachable182bb:183  ret void184}185define void @fwddecl_as1() addrspace(1) {186  unreachable187bb:188  ret void189}190 191;--- call-fwddecl-bad.ll192target datalayout = "P2"193define void @call_from_fn_in_as2_explicit() addrspace(2) {194  call addrspace(2) void blockaddress(@fwddecl_as1, %bb)()195  ; CHECK: [[#@LINE-1]]:53: error: 'bb' defined with type 'ptr addrspace(1)' but expected 'ptr addrspace(2)'196  ret void197}198define void @fwddecl_as1() addrspace(1) {199  unreachable200bb:201  ret void202}203 204;--- phi-good.ll205target datalayout = "P2"206define ptr addrspace(1) @f1() addrspace(1) {207L1:208  br label %L3209L2:210  br label %L3211L3:212  %p = phi ptr addrspace(1) [ blockaddress(@f1, %L4), %L2 ], [ null, %L1 ]213  ret ptr addrspace(1) %p214L4:215  unreachable216}217define ptr addrspace(2) @f2() {218L1:219  br label %L3220L2:221  br label %L3222L3:223  %p = phi ptr addrspace(2) [ blockaddress(@f2, %L4), %L2 ], [ null, %L1 ]224  ret ptr addrspace(2) %p225L4:226  unreachable227}228 229;--- phi-bad.ll230target datalayout = "P2"231define ptr @f() {232L1:233  br label %L3234L2:235  br label %L3236L3:237  %p = phi ptr [ blockaddress(@f, %L4), %L2 ], [ null, %L1 ]238  ; CHECK: [[#@LINE-1]]:18: error: constant expression type mismatch: got type 'ptr addrspace(2)' but expected 'ptr'239  ret ptr %p240}241 242; A blockaddress function forward-declaration used in a phi node should243; create the forward declaration in the same address space as the current function244;--- fwddecl-phi-good.ll245define ptr addrspace(1) @f() addrspace(1) {246L1:247  br label %L3248L2:249  br label %L3250L3:251  %p = phi ptr addrspace(1) [ blockaddress(@fwddecl_as1, %bb), %L2 ], [ null, %L1 ]252  ret ptr addrspace(1) %p253L4:254  unreachable255}256define void @fwddecl_as1() addrspace(1) {257  unreachable258bb:259  ret void260}261 262;--- fwddecl-phi-bad.ll263define ptr addrspace(2) @f() addrspace(2) {264L1:265  br label %L3266L2:267  br label %L3268L3:269  %p = phi ptr addrspace(2) [ blockaddress(@fwddecl_as1, %bb), %L2 ], [ null, %L1 ]270  ; CHECK: [[#@LINE-1]]:58: error: 'bb' defined with type 'ptr addrspace(1)' but expected 'ptr addrspace(2)'271  ret ptr addrspace(2) %p272L4:273  unreachable274}275define void @fwddecl_as1() addrspace(1) {276  unreachable277bb:278  ret void279}280 281;--- bad-type-not-ptr.ll282@global = constant i8 blockaddress(@unknown_fn, %bb)283; CHECK: [[#@LINE-1]]:23: error: type of blockaddress must be a pointer and not 'i8'284;--- bad-type-not-i8-ptr.ll285@global = constant ptr blockaddress(@unknown_fn, %bb)286; CHECK: [[#@LINE-1]]:37: error: expected function name in blockaddress287