brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 03814ff Raw
34 lines · plain
1! RUN: bbc -emit-hlfir %s -o - | FileCheck %s2 3! CHECK-LABEL: func.func @_QPuse_dsecnds(4! CHECK-SAME: %[[arg0:.*]]: !fir.ref<f64>5function use_dsecnds(refTime) result(elapsed)6  double precision :: refTime, elapsed7  elapsed = dsecnds(refTime)8end function9 10! The argument is lowered with hlfir.declare, which returns two results.11! Capture it here to check that the correct SSA value (%...#0)12! is passed to the runtime call later13! CHECK: %[[DECL:.*]]:2 = hlfir.declare %[[arg0]] dummy_scope14 15! The file name and source line are also lowered and passed as runtime arguments16! Capture the constant line number and convert the file name to i8*.17! CHECK: %[[STRADDR:.*]] = fir.address_of(18! CHECK: %[[LINE:.*]] = arith.constant {{.*}} : i3219! CHECK: %[[FNAME8:.*]] = fir.convert %[[STRADDR]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>20 21! Verify the runtime call is made with:22!   - the declared refTime value (%[[DECL]]#0)23!   - the converted filename24!   - the source line constant25! CHECK: %[[CALL:.*]] = fir.call @_FortranADsecnds(%[[DECL]]#0, %[[FNAME8]], %[[LINE]]) {{.*}} : (!fir.ref<f64>, !fir.ref<i8>, i32) -> f6426 27! Ensure there is no illegal conversion of a value result into a reference28! CHECK-NOT: fir.convert {{.*}} : (f64) -> !fir.ref<f64>29 30! Confirm the function result is returned as a plain f6431! CHECK: return {{.*}} : f6432 33 34