Skip to content

Commit f53085e

Browse files
adam-yangtex3d
authored andcommitted
Fixed a potential codegen difference with Zi (#3665)
(cherry picked from commit 1f6d1fa)
1 parent 79bbd7a commit f53085e

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

include/llvm/IR/BasicBlock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ class BasicBlock : public Value, // Basic blocks are data objects also
245245
inline const Instruction &back() const { return InstList.back(); }
246246
inline Instruction &back() { return InstList.back(); }
247247

248+
size_t compute_size_no_dbg() const; // HLSL Change - Get the size of the block without the debug insts
249+
248250
/// \brief Return the underlying instruction list container.
249251
///
250252
/// Currently you need to access the underlying instruction list container

lib/IR/BasicBlock.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ CallInst *BasicBlock::getTerminatingMustTailCall() {
168168
return nullptr;
169169
}
170170

171+
// HLSL Change - begin
172+
size_t BasicBlock::compute_size_no_dbg() const {
173+
size_t ret = 0;
174+
for (auto it = InstList.begin(), E = InstList.end(); it != E; it++) {
175+
if (isa<DbgInfoIntrinsic>(&*it))
176+
continue;
177+
ret++;
178+
}
179+
return ret;
180+
}
181+
// HLSL Change - end
182+
171183
Instruction* BasicBlock::getFirstNonPHI() {
172184
for (Instruction &I : *this)
173185
if (!isa<PHINode>(I))

lib/Transforms/Scalar/MergedLoadStoreMotion.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ bool MergedLoadStoreMotion::mergeLoads(BasicBlock *BB) {
359359
BasicBlock *Succ0 = BI->getSuccessor(0);
360360
BasicBlock *Succ1 = BI->getSuccessor(1);
361361
// #Instructions in Succ1 for Compile Time Control
362-
int Size1 = Succ1->size();
362+
// int Size1 = Succ1->size(); // HLSL Change
363+
int Size1 = Succ1->compute_size_no_dbg(); // HLSL Change
363364
int NLoads = 0;
364365
for (BasicBlock::iterator BBI = Succ0->begin(), BBE = Succ0->end();
365366
BBI != BBE;) {
@@ -529,7 +530,8 @@ bool MergedLoadStoreMotion::mergeStores(BasicBlock *T) {
529530
return false; // No. More than 2 predecessors.
530531

531532
// #Instructions in Succ1 for Compile Time Control
532-
int Size1 = Pred1->size();
533+
// int Size1 = Succ1->size(); // HLSL Change
534+
int Size1 = Pred1->compute_size_no_dbg(); // HLSL Change
533535
int NStores = 0;
534536

535537
for (BasicBlock::reverse_iterator RBI = Pred0->rbegin(), RBE = Pred0->rend();

0 commit comments

Comments
 (0)