Skip to content

Commit 7003df1

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents ff5b5cf + 4256146 commit 7003df1

File tree

14 files changed

+298
-59
lines changed

14 files changed

+298
-59
lines changed

.github/workflows/clang-format.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v2
1313
with:
14-
# checkout PR head
15-
ref: '${{github.event.pull_request.head.sha}}'
16-
- name: Fetch target branch
17-
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/${{github.base_ref}}:refs/remotes/origin/${{github.base_ref}}
14+
fetch-depth: 2
1815

1916
- name: Get clang-format first
2017
run: sudo apt-get install -yqq clang-format-9
2118

2219
- name: Run clang-format for the patch
2320
run: |
24-
git diff -U0 --no-color origin/${{github.base_ref}}...HEAD | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch
21+
git diff -U0 --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} -- | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch
2522
2623
# Add patch with formatting fixes to CI job artifacts
2724
- uses: actions/upload-artifact@v1

clang/test/CodeGenSYCL/hier_par.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//
1717
// This is compile-only test for now.
1818
//
19-
19+
// XFAIL:*
2020
#include "sycl.hpp"
2121

2222
using namespace cl::sycl;

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,12 @@ void LLVMToSPIRVDbgTran::transLocationInfo() {
201201
SPIRVString *DirAndFile = BM->getString(getFullPath(DL.get()));
202202
if (File != DirAndFile || LineNo != DL.getLine() ||
203203
Col != DL.getCol()) {
204+
V = SPIRVWriter->getTranslatedValue(&I);
205+
if (!V)
206+
continue;
204207
File = DirAndFile;
205208
LineNo = DL.getLine();
206209
Col = DL.getCol();
207-
V = SPIRVWriter->getTranslatedValue(&I);
208210
// According to the spec, OpLine for an OpBranch/OpBranchConditional
209211
// must precede the merge instruction and not the branch instruction
210212
auto *VPrev = static_cast<SPIRVInstruction *>(V)->getPrevious();

llvm-spirv/lib/SPIRV/OCLUtil.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "SPIRVInternal.h"
4343
#include "llvm/IR/DebugInfoMetadata.h"
4444
#include "llvm/IR/IRBuilder.h"
45+
#include "llvm/IR/Instructions.h"
4546
#include "llvm/Support/Path.h"
4647

4748
#include <functional>
@@ -984,6 +985,20 @@ template <> inline void SPIRVMap<std::string, Op, OCLOpaqueType>::init() {
984985
add("opencl.sampler_t", OpTypeSampler);
985986
}
986987

988+
typedef SPIRVMap<AtomicRMWInst::BinOp, Op> LLVMSPIRVAtomicRmwOpCodeMap;
989+
template <> inline void LLVMSPIRVAtomicRmwOpCodeMap::init() {
990+
add(llvm::AtomicRMWInst::Xchg, OpAtomicExchange);
991+
add(llvm::AtomicRMWInst::Add, OpAtomicIAdd);
992+
add(llvm::AtomicRMWInst::Sub, OpAtomicISub);
993+
add(llvm::AtomicRMWInst::And, OpAtomicAnd);
994+
add(llvm::AtomicRMWInst::Or, OpAtomicOr);
995+
add(llvm::AtomicRMWInst::Xor, OpAtomicXor);
996+
add(llvm::AtomicRMWInst::Max, OpAtomicSMax);
997+
add(llvm::AtomicRMWInst::Min, OpAtomicSMin);
998+
add(llvm::AtomicRMWInst::UMax, OpAtomicUMax);
999+
add(llvm::AtomicRMWInst::UMin, OpAtomicUMin);
1000+
}
1001+
9871002
} // namespace SPIRV
9881003

9891004
#endif // SPIRV_OCLUTIL_H

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,36 @@ SPIRVValue *LLVMToSPIRV::transValueWithoutDecoration(Value *V,
12231223
transValue(SF->getOperand(1), BB), Comp, BB));
12241224
}
12251225

1226+
if (AtomicRMWInst *ARMW = dyn_cast<AtomicRMWInst>(V)) {
1227+
AtomicRMWInst::BinOp Op = ARMW->getOperation();
1228+
if (!BM->getErrorLog().checkError(
1229+
!AtomicRMWInst::isFPOperation(Op) && Op != AtomicRMWInst::Nand,
1230+
SPIRVEC_InvalidInstruction,
1231+
OCLUtil::toString(V) + "\nAtomic " +
1232+
AtomicRMWInst::getOperationName(Op).str() +
1233+
" is not supported in SPIR-V!\n"))
1234+
return nullptr;
1235+
1236+
spv::Op OC = LLVMSPIRVAtomicRmwOpCodeMap::map(Op);
1237+
AtomicOrderingCABI Ordering = llvm::toCABI(ARMW->getOrdering());
1238+
auto MemSem = OCLMemOrderMap::map(static_cast<OCLMemOrderKind>(Ordering));
1239+
std::vector<Value *> Operands(4);
1240+
Operands[0] = ARMW->getPointerOperand();
1241+
// To get the memory scope argument we might use ARMW->getSyncScopeID(), but
1242+
// atomicrmw LLVM instruction is not aware of OpenCL(or SPIR-V) memory scope
1243+
// enumeration. And assuming the produced SPIR-V module will be consumed in
1244+
// an OpenCL environment, we can use the same memory scope as OpenCL atomic
1245+
// functions that don't have memory_scope argument i.e. memory_scope_device.
1246+
// See the OpenCL C specification p6.13.11. "Atomic Functions"
1247+
Operands[1] = getUInt32(M, spv::ScopeDevice);
1248+
Operands[2] = getUInt32(M, MemSem);
1249+
Operands[3] = ARMW->getValOperand();
1250+
std::vector<SPIRVId> Ops = BM->getIds(transValue(Operands, BB));
1251+
SPIRVType *Ty = transType(ARMW->getType());
1252+
1253+
return mapValue(V, BM->addInstTemplate(OC, Ops, BB, Ty));
1254+
}
1255+
12261256
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(V)) {
12271257
SPIRVValue *BV = transIntrinsicInst(II, BB);
12281258
return BV ? mapValue(V, BV) : nullptr;
@@ -1539,6 +1569,11 @@ SPIRVValue *LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II,
15391569
SPIRVValue *Op = transValue(II->getArgOperand(0), BB);
15401570
return BM->addUnaryInst(OpBitReverse, Ty, Op, BB);
15411571
}
1572+
case Intrinsic::sqrt: {
1573+
return BM->addExtInst(transType(II->getType()),
1574+
BM->getExtInstSetId(SPIRVEIS_OpenCL), OpenCLLIB::Sqrt,
1575+
{transValue(II->getOperand(0), BB)}, BB);
1576+
}
15421577
case Intrinsic::ctlz:
15431578
case Intrinsic::cttz: {
15441579
SPIRVWord ExtOp = II->getIntrinsicID() == Intrinsic::ctlz ? OpenCLLIB::Clz
@@ -1561,20 +1596,16 @@ SPIRVValue *LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II,
15611596
transValue(II->getArgOperand(2), BB), BB);
15621597
}
15631598
case Intrinsic::memset: {
1564-
// Generally memset can't be translated with current version of SPIRV spec.
1565-
// But in most cases it turns out that memset is emited by Clang to do
1566-
// zero-initializtion in default constructors.
1567-
// The code below handles only cases with val = 0 and constant len.
1599+
// Generally there is no direct mapping of memset to SPIR-V. But it turns
1600+
// out that memset is emitted by Clang for initialization in default
1601+
// constructors so we need some basic support. The code below only handles
1602+
// cases with constant value and constant length.
15681603
MemSetInst *MSI = cast<MemSetInst>(II);
15691604
Value *Val = MSI->getValue();
15701605
if (!isa<Constant>(Val)) {
15711606
assert(!"Can't translate llvm.memset with non-const `value` argument");
15721607
return nullptr;
15731608
}
1574-
if (!cast<Constant>(Val)->isZeroValue()) {
1575-
assert(!"Can't translate llvm.memset with non-zero `value` argument");
1576-
return nullptr;
1577-
}
15781609
Value *Len = MSI->getLength();
15791610
if (!isa<ConstantInt>(Len)) {
15801611
assert(!"Can't translate llvm.memset with non-const `length` argument");
@@ -1583,7 +1614,13 @@ SPIRVValue *LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II,
15831614
uint64_t NumElements = static_cast<ConstantInt *>(Len)->getZExtValue();
15841615
auto *AT = ArrayType::get(Val->getType(), NumElements);
15851616
SPIRVTypeArray *CompositeTy = static_cast<SPIRVTypeArray *>(transType(AT));
1586-
SPIRVValue *Init = BM->addNullConstant(CompositeTy);
1617+
SPIRVValue *Init;
1618+
if (cast<Constant>(Val)->isZeroValue()) {
1619+
Init = BM->addNullConstant(CompositeTy);
1620+
} else {
1621+
std::vector<SPIRVValue *> Elts{NumElements, transValue(Val, BB)};
1622+
Init = BM->addCompositeConstant(CompositeTy, Elts);
1623+
}
15871624
SPIRVType *VarTy = transType(PointerType::get(AT, SPIRV::SPIRAS_Constant));
15881625
SPIRVValue *Var =
15891626
BM->addVariable(VarTy, /*isConstant*/ true, spv::LinkageTypeInternal,

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVErrorEnum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ _SPIRV_OP(InvalidBitWidth, "Invalid bit width in input:")
1212
_SPIRV_OP(InvalidModule, "Invalid SPIR-V module:")
1313
_SPIRV_OP(UnimplementedOpCode, "Unimplemented opcode")
1414
_SPIRV_OP(FunctionPointers, "Can't translate function pointer:\n")
15+
_SPIRV_OP(InvalidInstruction, "Can't translate llvm instruction:\n")

llvm-spirv/test/atomicrmw.ll

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
; RUN: llvm-as < %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -o %t.spv
3+
; RUN: spirv-val %t.spv
4+
; RUN: llvm-spirv -to-text %t.spv -o - | FileCheck %s
5+
6+
; CHECK: TypeInt [[Int:[0-9]+]] 32 0
7+
; CHECK-DAG: Constant [[Int]] [[Scope_Device:[0-9]+]] 1 {{$}}
8+
; CHECK-DAG: Constant [[Int]] [[MemSem_Relaxed:[0-9]+]] 0
9+
; CHECK-DAG: Constant [[Int]] [[MemSem_Acquire:[0-9]+]] 2
10+
; CHECK-DAG: Constant [[Int]] [[MemSem_Release:[0-9]+]] 4 {{$}}
11+
; CHECK-DAG: Constant [[Int]] [[MemSem_AcquireRelease:[0-9]+]] 8
12+
; CHECK-DAG: Constant [[Int]] [[MemSem_SequentiallyConsistent:[0-9]+]] 16
13+
; CHECK-DAG: Constant [[Int]] [[Value:[0-9]+]] 42
14+
; CHECK: TypeFloat [[Float:[0-9]+]] 32
15+
; CHECK: Variable {{[0-9]+}} [[Pointer:[0-9]+]]
16+
; CHECK: Variable {{[0-9]+}} [[FPPointer:[0-9]+]]
17+
; CHECK: Constant [[Float]] [[FPValue:[0-9]+]] 1109917696
18+
19+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
20+
target triple = "spir64"
21+
22+
@ui = common dso_local addrspace(1) global i32 0, align 4
23+
@f = common dso_local local_unnamed_addr addrspace(1) global float 0.000000e+00, align 4
24+
25+
; Function Attrs: nounwind
26+
define dso_local spir_func void @test_atomicrmw() local_unnamed_addr #0 {
27+
entry:
28+
%0 = atomicrmw xchg i32 addrspace(1)* @ui, i32 42 acq_rel
29+
; CHECK: AtomicExchange [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_AcquireRelease]] [[Value]]
30+
31+
%1 = atomicrmw xchg float addrspace(1)* @f, float 42.000000e+00 seq_cst
32+
; CHECK: AtomicExchange [[Float]] {{[0-9]+}} [[FPPointer]] [[Scope_Device]] [[MemSem_SequentiallyConsistent]] [[FPValue]]
33+
34+
%2 = atomicrmw add i32 addrspace(1)* @ui, i32 42 monotonic
35+
; CHECK: AtomicIAdd [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_Relaxed]] [[Value]]
36+
37+
%3 = atomicrmw sub i32 addrspace(1)* @ui, i32 42 acquire
38+
; CHECK: AtomicISub [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_Acquire]] [[Value]]
39+
40+
%4 = atomicrmw or i32 addrspace(1)* @ui, i32 42 release
41+
; CHECK: AtomicOr [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_Release]] [[Value]]
42+
43+
%5 = atomicrmw xor i32 addrspace(1)* @ui, i32 42 acq_rel
44+
; CHECK: AtomicXor [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_AcquireRelease]] [[Value]]
45+
46+
%6 = atomicrmw and i32 addrspace(1)* @ui, i32 42 seq_cst
47+
; CHECK: AtomicAnd [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_SequentiallyConsistent]] [[Value]]
48+
49+
%7 = atomicrmw max i32 addrspace(1)* @ui, i32 42 monotonic
50+
; CHECK: AtomicSMax [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_Relaxed]] [[Value]]
51+
52+
%8 = atomicrmw min i32 addrspace(1)* @ui, i32 42 acquire
53+
; CHECK: AtomicSMin [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_Acquire]] [[Value]]
54+
55+
%9 = atomicrmw umax i32 addrspace(1)* @ui, i32 42 release
56+
; CHECK: AtomicUMax [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_Release]] [[Value]]
57+
58+
%10 = atomicrmw umin i32 addrspace(1)* @ui, i32 42 acq_rel
59+
; CHECK: AtomicUMin [[Int]] {{[0-9]+}} [[Pointer]] [[Scope_Device]] [[MemSem_AcquireRelease]] [[Value]]
60+
61+
ret void
62+
}
63+
64+
attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }
65+
66+
!llvm.module.flags = !{!0}
67+
!llvm.ident = !{!1}
68+
69+
!0 = !{i32 1, !"wchar_size", i32 4}
70+
!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 20c5968e0953d978be4d9d1062801e8758c393b5)"}

llvm-spirv/test/llvm.sqrt.ll

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
; RUN: llvm-as < %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -o %t.spv
3+
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s
4+
; RUN: spirv-val %t.spv
5+
6+
; CHECK: ExtInstImport [[ExtInstSetId:[0-9]+]] "OpenCL.std"
7+
; CHECK: TypeFloat [[Float:[0-9]+]] 32
8+
; CHECK: TypeFloat [[Double:[0-9]+]] 64
9+
; CHECK: TypeVector [[Double4:[0-9]+]] [[Double]] 4
10+
; CHECK: Constant [[Float]] [[FloatArg:[0-9]+]]
11+
; CHECK: Constant [[Double]] [[DoubleArg:[0-9]+]]
12+
; CHECK: ConstantComposite [[Double4]] [[Double4Arg:[0-9]+]]
13+
14+
target 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"
15+
target triple = "spir"
16+
17+
; Function Attrs: noinline nounwind optnone
18+
define spir_func void @test_sqrt() #0 {
19+
entry:
20+
%0 = call float @llvm.sqrt.f32(float 0x40091EB860000000)
21+
%1 = call double @llvm.sqrt.f64(double 2.710000e+00)
22+
%2 = call <4 x double> @llvm.sqrt.v4f64(<4 x double> <double 5.000000e-01, double 2.000000e-01, double 3.000000e-01, double 4.000000e-01>)
23+
; CHECK: ExtInst [[Float]] {{[0-9]+}} [[ExtInstSetId]] sqrt [[FloatArg]]
24+
; CHECK: ExtInst [[Double]] {{[0-9]+}} [[ExtInstSetId]] sqrt [[DoubleArg]]
25+
; CHECK: ExtInst [[Double4]] {{[0-9]+}} [[ExtInstSetId]] sqrt [[Double4Arg]]
26+
ret void
27+
}
28+
29+
; Function Attrs: nounwind readnone speculatable willreturn
30+
declare float @llvm.sqrt.f32(float) #1
31+
32+
; Function Attrs: nounwind readnone speculatable willreturn
33+
declare double @llvm.sqrt.f64(double) #1
34+
35+
; Function Attrs: nounwind readnone speculatable willreturn
36+
declare <4 x double> @llvm.sqrt.v4f64(<4 x double>) #1
37+
38+
attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }
39+
attributes #1 = { nounwind readnone speculatable willreturn }
40+
41+
!llvm.module.flags = !{!0}
42+
!llvm.ident = !{!1}
43+
44+
!0 = !{i32 1, !"wchar_size", i32 4}
45+
!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git b89131cdda5871731a9139664aef2b70c6d72bbd)"}
46+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; RUN: llvm-as < %s -o %t.bc
2+
; RUN: not --crash llvm-spirv %t.bc -o %t.spv 2>&1 | FileCheck %s
3+
4+
; CHECK: InvalidInstruction: Can't translate llvm instruction:
5+
; CHECK: atomicrmw nand i32 addrspace(1)* @ui, i32 42 acq_rel
6+
; CHECK: Atomic nand is not supported in SPIR-V!
7+
8+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
9+
target triple = "spir64"
10+
11+
@ui = common dso_local addrspace(1) global i32 0, align 4
12+
@f = common dso_local local_unnamed_addr addrspace(1) global float 0.000000e+00, align 4
13+
14+
; Function Attrs: nounwind
15+
define dso_local spir_func void @test_atomicrmw() local_unnamed_addr #0 {
16+
entry:
17+
%0 = atomicrmw nand i32 addrspace(1)* @ui, i32 42 acq_rel
18+
%1 = atomicrmw fadd float addrspace(1)* @f, float 42.000000e+00 seq_cst
19+
%2 = atomicrmw fsub float addrspace(1)* @f, float 42.000000e+00 seq_cst
20+
ret void
21+
}
22+
23+
attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }
24+
25+
!llvm.module.flags = !{!0}
26+
!llvm.ident = !{!1}
27+
28+
!0 = !{i32 1, !"wchar_size", i32 4}
29+
!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 20c5968e0953d978be4d9d1062801e8758c393b5)"}

llvm-spirv/test/transcoding/llvm.memset.ll

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,58 @@
1-
;; struct S1
2-
;; {
3-
;; int x;
4-
;; int y;
5-
;; int z;
6-
;; };
7-
;; S1 foo11()
8-
;; {
9-
;; return S1();
10-
;; }
11-
121
; RUN: llvm-as %s -o %t.bc
132
; RUN: llvm-spirv %t.bc -spirv-text -o %t.spt
143
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
154
; RUN: llvm-spirv %t.bc -o %t.spv
165
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
6+
; RUN: spirv-val %t.spv
177
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
188

199
; CHECK-SPIRV: TypeInt [[Int8:[0-9]+]] 8 0
20-
; CHECK-SPIRV: Constant {{[0-9]+}} [[Len:[0-9]+]] 12
10+
; CHECK-SPIRV: Constant {{[0-9]+}} [[Lenmemset21:[0-9]+]] 4
11+
; CHECK-SPIRV: Constant {{[0-9]+}} [[Lenmemset0:[0-9]+]] 12
12+
; CHECK-SPIRV: Constant {{[0-9]+}} [[Const21:[0-9]+]] 21
13+
; CHECK-SPIRV: TypeArray [[Int8x4:[0-9]+]] [[Int8]] [[Lenmemset21]]
2114
; CHECK-SPIRV: TypePointer [[Int8Ptr:[0-9]+]] 8 [[Int8]]
22-
; CHECK-SPIRV: TypeArray [[Int8x12:[0-9]+]] [[Int8]] [[Len]]
15+
; CHECK-SPIRV: TypeArray [[Int8x12:[0-9]+]] [[Int8]] [[Lenmemset0]]
2316
; CHECK-SPIRV: TypePointer [[Int8PtrConst:[0-9]+]] 0 [[Int8]]
17+
2418
; CHECK-SPIRV: ConstantNull [[Int8x12]] [[Init:[0-9]+]]
2519
; CHECK-SPIRV: Variable {{[0-9]+}} [[Val:[0-9]+]] 0 [[Init]]
20+
; CHECK-SPIRV: 7 ConstantComposite [[Int8x4]] [[InitComp:[0-9]+]] [[Const21]] [[Const21]] [[Const21]] [[Const21]]
21+
; CHECK-SPIRV: Variable {{[0-9]+}} [[ValComp:[0-9]+]] 0 [[InitComp]]
2622

2723
; CHECK-SPIRV: Bitcast [[Int8Ptr]] [[Target:[0-9]+]] {{[0-9]+}}
2824
; CHECK-SPIRV: Bitcast [[Int8PtrConst]] [[Source:[0-9]+]] [[Val]]
29-
; CHECK-SPIRV: CopyMemorySized [[Target]] [[Source]] [[Len]] 2 4
25+
; CHECK-SPIRV: CopyMemorySized [[Target]] [[Source]] [[Lenmemset0]] 2 4
3026

27+
; CHECK-SPIRV: Bitcast [[Int8PtrConst]] [[SourceComp:[0-9]+]] [[ValComp]]
28+
; CHECK-SPIRV: CopyMemorySized {{[0-9]+}} [[SourceComp]] [[Lenmemset21]] 2 4
3129

3230
target 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-n8:16:32:64"
3331
target triple = "spir"
3432

3533
%struct.S1 = type { i32, i32, i32 }
3634

35+
; CHECK-LLVM: internal unnamed_addr addrspace(2) constant [12 x i8] zeroinitializer
36+
; CHECK-LLVM: internal unnamed_addr addrspace(2) constant [4 x i8] c"\15\15\15\15"
37+
3738
; Function Attrs: nounwind
3839
define spir_func void @_Z5foo11v(%struct.S1 addrspace(4)* noalias nocapture sret %agg.result) #0 {
40+
%x = alloca [4 x i8]
41+
%x.bc = bitcast [4 x i8]* %x to i8*
3942
%1 = bitcast %struct.S1 addrspace(4)* %agg.result to i8 addrspace(4)*
4043
tail call void @llvm.memset.p4i8.i32(i8 addrspace(4)* align 4 %1, i8 0, i32 12, i1 false)
4144
; CHECK-LLVM: call void @llvm.memset.p4i8.i32(i8 addrspace(4)* align 4 %1, i8 0, i32 12, i1 false)
45+
tail call void @llvm.memset.p0i8.i32(i8* align 4 %x.bc, i8 21, i32 4, i1 false)
46+
; CHECK-LLVM: call void @llvm.memcpy.p0i8.p2i8.i32(i8* align 4 %x.bc, i8 addrspace(2)* align 4 %3, i32 4, i1 false)
4247
ret void
4348
}
4449

4550
; Function Attrs: nounwind
4651
declare void @llvm.memset.p4i8.i32(i8 addrspace(4)* nocapture, i8, i32, i1) #1
4752

53+
; Function Attrs: nounwind
54+
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1) #1
55+
4856
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
4957
attributes #1 = { nounwind }
5058

0 commit comments

Comments
 (0)