1; Source 2; int square(unsigned short a) { 3; return a * a; 4; } 5; Command 6; clang -cc1 -triple spir -emit-llvm -O2 -o NoSignedUnsignedWrap.ll test.cl 7; 8; Positive tests: 9; 10; RUN: llvm-as %s -o %t.bc 11; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV 12; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -o %t.spv 13; RUN: spirv-val %t.spv 14; RUN: llvm-spirv -r %t.spv --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -o %t.rev.bc 15; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM 16; 17; During consumption, any SPIR-V extension must be accepted by default 18; 19; RUN: llvm-spirv -r %t.spv -o %t.rev.bc 20; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM 21; 22; Negative tests: 23; 24; Check that translator is able to reject SPIR-V if extension is disallowed 25; 26; RUN: not llvm-spirv -r %t.spv --spirv-ext=-SPV_KHR_no_integer_wrap_decoration -o - 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID-SPIRV 27; 28; Check that translator is able to skip nsw/nuw attributes if extension is disabled implicitly or explicitly 29; 30; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV-NOEXT 31; RUN: llvm-spirv %t.bc -o %t.spv 32; RUN: llvm-spirv -r %t.spv -o %t.rev.bc 33; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-NOEXT 34; 35; RUN: llvm-spirv %t.bc --spirv-ext=-SPV_KHR_no_integer_wrap_decoration -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV-NOEXT 36; RUN: llvm-spirv %t.bc --spirv-ext=-SPV_KHR_no_integer_wrap_decoration -o %t.spv 37; RUN: llvm-spirv -r %t.spv -o %t.rev.bc 38; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-NOEXT 39 40; CHECK-SPIRV: Extension "SPV_KHR_no_integer_wrap_decoration" 41; CHECK-SPIRV: Decorate {{[0-9]+}} NoSignedWrap 42; CHECK-SPIRV: Decorate {{[0-9]+}} NoUnsignedWrap 43; 44; CHECK-SPIRV-NOEXT-NOT: Extension "SPV_KHR_no_integer_wrap_decoration" 45; CHECK-SPIRV-NOEXT-NOT: Decorate {{[0-9]+}} NoSignedWrap 46; CHECK-SPIRV-NOEXT-NOT: Decorate {{[0-9]+}} NoUnsignedWrap 47; 48; CHECK-INVALID-SPIRV: input SPIR-V module uses extension 'SPV_KHR_no_integer_wrap_decoration' which were disabled 49 50target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" 51target triple = "spir" 52 53; Function Attrs: norecurse nounwind readnone 54define spir_func i32 @square(i16 zeroext %a) local_unnamed_addr #0 { 55entry: 56 %conv = zext i16 %a to i32 57 ; CHECK-LLVM: mul nuw nsw 58 ; CHECK-LLVM-NOEXT: mul i32 59 %mul = mul nuw nsw i32 %conv, %conv 60 ret i32 %mul 61} 62 63attributes #0 = { norecurse nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 64 65!llvm.module.flags = !{!0} 66!opencl.ocl.version = !{!1} 67!opencl.spir.version = !{!2} 68 69!0 = !{i32 1, !"wchar_size", i32 4} 70!1 = !{i32 1, i32 0} 71!2 = !{i32 1, i32 2} 72