|
@@ -1565,6 +1565,10 @@ bool SROA_HLSL::performScalarRepl(Function &F, DxilTypeSystem &typeSys) {
|
|
|
std::function<bool(AllocaInst *, AllocaInst *)>>
|
|
|
WorkList(size_cmp);
|
|
|
std::unordered_map<AllocaInst*, DbgDeclareInst*> DDIMap;
|
|
|
+ // HLSL Change - Begin
|
|
|
+ std::unordered_map<AllocaInst*, unsigned> OffsetMap; // Map to keep track the offset of an alloca
|
|
|
+ // in the variable that it's a part of.
|
|
|
+ // HLSL Change - End
|
|
|
// Scan the entry basic block, adding allocas to the worklist.
|
|
|
BasicBlock &BB = F.getEntryBlock();
|
|
|
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
|
|
@@ -1654,6 +1658,12 @@ bool SROA_HLSL::performScalarRepl(Function &F, DxilTypeSystem &typeSys) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+// HLSL Change - Begin
|
|
|
+ unsigned parentOffset = 0;
|
|
|
+ auto offsetIt = OffsetMap.find(AI);
|
|
|
+ if (offsetIt != OffsetMap.end())
|
|
|
+ parentOffset = offsetIt->second;
|
|
|
+// HLSL Change - End
|
|
|
|
|
|
DbgDeclareInst *DDI = nullptr;
|
|
|
unsigned debugOffset = 0;
|
|
@@ -1668,8 +1678,21 @@ bool SROA_HLSL::performScalarRepl(Function &F, DxilTypeSystem &typeSys) {
|
|
|
if (DDI) {
|
|
|
Type *Ty = Elt->getAllocatedType();
|
|
|
unsigned size = DL.getTypeAllocSize(Ty);
|
|
|
+#if 0 // HLSL Change
|
|
|
DIExpression *DDIExp =
|
|
|
DIB.createBitPieceExpression(debugOffset, size);
|
|
|
+#else // HLSL Change
|
|
|
+
|
|
|
+ DIExpression *DDIExp = nullptr;
|
|
|
+ if (parentOffset+debugOffset == 0 && DL.getTypeAllocSize(AI->getAllocatedType()) == size) {
|
|
|
+ std::vector<uint64_t> args;
|
|
|
+ DDIExp = DIB.createExpression(args);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DDIExp = DIB.createBitPieceExpression(parentOffset+debugOffset, size);
|
|
|
+ }
|
|
|
+ OffsetMap[Elt] = parentOffset+debugOffset;
|
|
|
+#endif // HLSL Change
|
|
|
debugOffset += size;
|
|
|
DbgDeclareInst *EltDDI = cast<DbgDeclareInst>(DIB.insertDeclare(
|
|
|
Elt, DDI->getVariable(), DDIExp, DDI->getDebugLoc(), DDI));
|
|
@@ -5608,7 +5631,21 @@ void SROA_Parameter_HLSL::flattenArgument(
|
|
|
if (Ty->isPointerTy())
|
|
|
Ty = Ty->getPointerElementType();
|
|
|
unsigned size = DL.getTypeAllocSize(Ty);
|
|
|
+#if 0 // HLSL Change
|
|
|
DIExpression *DDIExp = DIB.createBitPieceExpression(debugOffset, size);
|
|
|
+#else // HLSL Change
|
|
|
+ Type *argTy = Arg->getType();
|
|
|
+ if (argTy->isPointerTy())
|
|
|
+ argTy = argTy->getPointerElementType();
|
|
|
+ DIExpression *DDIExp = nullptr;
|
|
|
+ if (debugOffset == 0 && DL.getTypeAllocSize(argTy) == size) {
|
|
|
+ std::vector<uint64_t> Addr;
|
|
|
+ DDIExp = DIB.createExpression(Addr);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DDIExp = DIB.createBitPieceExpression(debugOffset, size);
|
|
|
+ }
|
|
|
+#endif // HLSL Change
|
|
|
debugOffset += size;
|
|
|
DIB.insertDeclare(TmpV, DDI->getVariable(), DDIExp, DDI->getDebugLoc(),
|
|
|
Builder.GetInsertPoint());
|