@@ -1003,19 +1003,17 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack) {
10031003
10041004 // Attaching this metadata is crucial to both properly interpret this locations as stack based ond to inline it.
10051005 // Because these are stack locations we can safely inline them even with optimizations disabled (O0).
1006- auto DbgUses = llvm::FindDbgAddrUses (pAI);
1007- for (auto Use : DbgUses) {
1008- if (auto DbgDcl = dyn_cast_or_null<DbgDeclareInst>(Use)) {
1009- unsigned scalarBufferOffset = m_ModAllocaInfo->getBufferOffset (pAI);
1010- unsigned bufferSize = m_ModAllocaInfo->getBufferStride (pAI);
1011-
1012- // Attach metadata to instruction containing offset of storage
1013- auto OffsetMD =
1014- MDNode::get (builder.getContext (), ConstantAsMetadata::get (builder.getInt32 (scalarBufferOffset)));
1015- DbgDcl->setMetadata (" StorageOffset" , OffsetMD);
1016- auto SizeMD = MDNode::get (builder.getContext (), ConstantAsMetadata::get (builder.getInt32 (bufferSize)));
1017- DbgDcl->setMetadata (" StorageSize" , SizeMD);
1018- }
1006+ auto DbgDcls = llvm::FindDbgDeclareUses (pAI);
1007+ for (auto DbgDcl : DbgDcls) {
1008+ unsigned scalarBufferOffset = m_ModAllocaInfo->getBufferOffset (pAI);
1009+ unsigned bufferSize = m_ModAllocaInfo->getBufferStride (pAI);
1010+
1011+ // Attach metadata to instruction containing offset of storage
1012+ auto OffsetMD =
1013+ MDNode::get (builder.getContext (), ConstantAsMetadata::get (builder.getInt32 (scalarBufferOffset)));
1014+ DbgDcl->setMetadata (" StorageOffset" , OffsetMD);
1015+ auto SizeMD = MDNode::get (builder.getContext (), ConstantAsMetadata::get (builder.getInt32 (bufferSize)));
1016+ DbgDcl->setMetadata (" StorageSize" , SizeMD);
10191017 }
10201018 }
10211019 // Replace all uses of original alloca with the bitcast
@@ -1307,15 +1305,13 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack) {
13071305 // We can only safely inline such locations with optimizations disabled.
13081306 // On O2 we have no guarantee the offsets in registers are gonna be valid throughout the entire variable lifetime.
13091307 if (modMD->compOpt .OptDisable ) {
1310- auto DbgUses = llvm::FindDbgAddrUses (pAI);
1311- for (auto Use : DbgUses) {
1312- if (auto DbgDcl = dyn_cast_or_null<DbgDeclareInst>(Use)) {
1313- // Attach metadata to instruction containing offset of storage
1314- unsigned int scalarBufferOffset = m_ModAllocaInfo->getBufferOffset (pAI);
1315- auto OffsetMD =
1316- MDNode::get (builder.getContext (), ConstantAsMetadata::get (builder.getInt32 (scalarBufferOffset)));
1317- DbgDcl->setMetadata (" StorageOffset" , OffsetMD);
1318- }
1308+ auto DbgDcls = llvm::FindDbgDeclareUses (pAI);
1309+ for (auto DbgDcl : DbgDcls) {
1310+ // Attach metadata to instruction containing offset of storage
1311+ unsigned int scalarBufferOffset = m_ModAllocaInfo->getBufferOffset (pAI);
1312+ auto OffsetMD =
1313+ MDNode::get (builder.getContext (), ConstantAsMetadata::get (builder.getInt32 (scalarBufferOffset)));
1314+ DbgDcl->setMetadata (" StorageOffset" , OffsetMD);
13191315 }
13201316 }
13211317
0 commit comments