@@ -1665,7 +1665,7 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
16651665 // execution instance, so emit an alloca instead of a global.
16661666 assert (BB && " OpVariable with Function storage class requires BB" );
16671667 IRBuilder<> Builder (BB);
1668- AllocaInst *AI = Builder.CreateAlloca (Ty, 0 , BV->getName ());
1668+ AllocaInst *AI = Builder.CreateAlloca (Ty, nullptr , BV->getName ());
16691669 if (Init) {
16701670 auto *Src = transValue (Init, F, BB);
16711671 const bool IsVolatile = BVar->hasDecorate (DecorationVolatile);
@@ -1779,8 +1779,9 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
17791779 auto *VLA = static_cast <SPIRVVariableLengthArrayINTEL *>(BV);
17801780 llvm::Type *Ty = transType (BV->getType ()->getPointerElementType ());
17811781 llvm::Value *ArrSize = transValue (VLA->getOperand (0 ), F, BB);
1782- return mapValue (
1783- BV, new AllocaInst (Ty, SPIRAS_Private, ArrSize, BV->getName (), BB));
1782+ return mapValue (BV,
1783+ new AllocaInst (Ty, M->getDataLayout ().getAllocaAddrSpace (),
1784+ ArrSize, BV->getName (), BB));
17841785 }
17851786
17861787 case OpRestoreMemoryINTEL: {
@@ -2248,9 +2249,9 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
22482249
22492250 case OpCopyObject: {
22502251 SPIRVCopyObject *CO = static_cast <SPIRVCopyObject *>(BV);
2251- auto Ty = transType (CO->getOperand ()->getType ());
2252+ auto * Ty = transType (CO->getOperand ()->getType ());
22522253 AllocaInst *AI =
2253- new AllocaInst (Ty, 0 , " " , BB);
2254+ new AllocaInst (Ty, M-> getDataLayout (). getAllocaAddrSpace () , " " , BB);
22542255 new StoreInst (transValue (CO->getOperand (), F, BB), AI, BB);
22552256 LoadInst *LI = new LoadInst (Ty, AI, " " , BB);
22562257 return mapValue (BV, LI);
@@ -2401,7 +2402,8 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
24012402 if (!HasRtValues)
24022403 return mapValue (BV, ConstantArray::get (AT, CV));
24032404
2404- AllocaInst *Alloca = new AllocaInst (AT, SPIRAS_Private, " " , BB);
2405+ AllocaInst *Alloca =
2406+ new AllocaInst (AT, M->getDataLayout ().getAllocaAddrSpace (), " " , BB);
24052407
24062408 // get pointer to the element of the array
24072409 // store the result of argument
@@ -2420,7 +2422,8 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
24202422 if (!HasRtValues)
24212423 return mapValue (BV, ConstantStruct::get (ST, CV));
24222424
2423- AllocaInst *Alloca = new AllocaInst (ST, SPIRAS_Private, " " , BB);
2425+ AllocaInst *Alloca =
2426+ new AllocaInst (ST, M->getDataLayout ().getAllocaAddrSpace (), " " , BB);
24242427
24252428 // get pointer to the element of structure
24262429 // store the result of argument
@@ -3020,7 +3023,8 @@ Value *SPIRVToLLVM::transFixedPointInst(SPIRVInstruction *BI, BasicBlock *BB) {
30203023 Args.reserve (8 );
30213024 if (RetTy->getIntegerBitWidth () > 64 ) {
30223025 llvm::PointerType *RetPtrTy = llvm::PointerType::get (RetTy, SPIRAS_Generic);
3023- Value *Alloca = new AllocaInst (RetTy, SPIRAS_Private, " " , BB);
3026+ Value *Alloca =
3027+ new AllocaInst (RetTy, M->getDataLayout ().getAllocaAddrSpace (), " " , BB);
30243028 Value *RetValPtr = new AddrSpaceCastInst (Alloca, RetPtrTy, " " , BB);
30253029 ArgTys.emplace_back (RetPtrTy);
30263030 Args.emplace_back (RetValPtr);
@@ -3144,7 +3148,8 @@ Value *SPIRVToLLVM::transArbFloatInst(SPIRVInstruction *BI, BasicBlock *BB,
31443148 if (RetTy->getIntegerBitWidth () > 64 ) {
31453149 llvm::PointerType *RetPtrTy = llvm::PointerType::get (RetTy, SPIRAS_Generic);
31463150 ArgTys.push_back (RetPtrTy);
3147- Value *Alloca = new AllocaInst (RetTy, SPIRAS_Private, " " , BB);
3151+ Value *Alloca =
3152+ new AllocaInst (RetTy, M->getDataLayout ().getAllocaAddrSpace (), " " , BB);
31483153 Value *RetValPtr = new AddrSpaceCastInst (Alloca, RetPtrTy, " " , BB);
31493154 Args.push_back (RetValPtr);
31503155 }
0 commit comments