================ @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: test_asuint4_uint +// CHECK: ret i32 %0 +export uint test_asuint4_uint(uint p0) { + return asuint(p0); +} ---------------- bogner wrote:
This doesn't really test the function effectively, it just checks that we return an `i32`. We can use a couple of tools in FileCheck to do better, notably [capturing variables](https://llvm.org/docs/CommandGuide/FileCheck.html#filecheck-string-substitution-blocks) and [CHECK-NOT](https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-not-directive). Now, we want to make sure that the input of the function is returned, and that we don't see a bitcast in between. Take a look at the output of the test command by running it manually. Assuming we update the flags as I suggested above, we see something like this: ```llvm define noundef i32 @"?test_uint@@YAII@Z"(i32 noundef returned %p0) local_unnamed_addr #0 { entry: ret i32 %p0 } ``` Getting the name of the input variable is a little bit awkward because (1) we mangle the function name, and (2) we get some attributes applied that we don't really want the test to be sensitive to, so need a somewhat loose regex. Then we want to check that no bitcast occurs, and that we return the input directly: ```c++ // CHECK: define {{.*}}test_asuint4_uint{{.*}}(i32{{.*}} [[VAL:%.*]]) // CHECK-NOT: bitcast // CHECK: ret i32 [[VAL]] ``` https://github.com/llvm/llvm-project/pull/107292 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits