67 lines · plain
1; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' < %s | FileCheck %s2; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' -addr-sink-using-gep=false < %s | FileCheck %s3 4; This target data layout is modified to have a non-integral addrspace(1),5; in order to verify that codegenprepare does not try to introduce illegal6; inttoptrs.7target datalayout =8"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-ni:1"9target triple = "x86_64-unknown-linux-gnu"10 11define void @test_simple(i1 %cond, ptr addrspace(1) %base) {12; CHECK-LABEL: @test_simple13; CHECK-NOT: inttoptr {{.*}} to ptr addrspace(1)14entry:15 %addr = getelementptr inbounds i64, ptr addrspace(1) %base, i64 516 br i1 %cond, label %if.then, label %fallthrough17 18if.then:19 %v = load i32, ptr addrspace(1) %addr, align 420 br label %fallthrough21 22fallthrough:23 ret void24}25 26 27define void @test_inttoptr_base(i1 %cond, i64 %base) {28; CHECK-LABEL: @test_inttoptr_base29; CHECK-NOT: inttoptr {{.*}} to ptr addrspace(1)30entry:31; Doing the inttoptr in the integral addrspace(0) followed by an explicit32; (frontend-introduced) addrspacecast is fine. We cannot however introduce33; a direct inttoptr to addrspace(1)34 %baseptr = inttoptr i64 %base to ptr35 %baseptrni = addrspacecast ptr %baseptr to ptr addrspace(1)36 %addr = getelementptr inbounds i64, ptr addrspace(1) %baseptrni, i64 537 br i1 %cond, label %if.then, label %fallthrough38 39if.then:40 %v = load i32, ptr addrspace(1) %addr, align 441 br label %fallthrough42 43fallthrough:44 ret void45}46 47define void @test_ptrtoint_base(i1 %cond, ptr addrspace(1) %base) {48; CHECK-LABEL: @test_ptrtoint_base49; CHECK-NOT: ptrtoint addrspace(1)* {{.*}} to i6450entry:51; This one is inserted by the frontend, so it's fine. We're not allowed to52; directly ptrtoint %base ourselves though53 %baseptr0 = addrspacecast ptr addrspace(1) %base to ptr54 %toint = ptrtoint ptr %baseptr0 to i6455 %added = add i64 %toint, 856 %toptr = inttoptr i64 %added to ptr57 %geped = getelementptr i64, ptr %toptr, i64 258 br i1 %cond, label %if.then, label %fallthrough59 60if.then:61 %v = load i64, ptr %geped, align 462 br label %fallthrough63 64fallthrough:65 ret void66}67