[PATCH] D26634: Make block placement determinisatic
Rong Xu via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 13:39:24 PST 2016
xur created this revision.
xur added reviewers: davidxl, chandlerc.
xur added a subscriber: llvm-commits.
We fail to produce bit-to-bit matching stage2 and stage3 compiler in PGO bootstrap build. The reason is because LoopBlockSet is of SmallPtrSet type whose iterating order depends on the pointer value.
This patch fixes this issue.
https://reviews.llvm.org/D26634
Files:
lib/CodeGen/MachineBlockPlacement.cpp
Index: lib/CodeGen/MachineBlockPlacement.cpp
===================================================================
--- lib/CodeGen/MachineBlockPlacement.cpp
+++ lib/CodeGen/MachineBlockPlacement.cpp
@@ -1491,8 +1491,13 @@
assert(LoopChain.UnscheduledPredecessors == 0);
UpdatedPreds.insert(&LoopChain);
- for (MachineBasicBlock *LoopBB : LoopBlockSet)
- fillWorkLists(LoopBB, UpdatedPreds, &LoopBlockSet);
+ // Add the basic blocks to LoopBlockSet. Note that we are NOT using the
+ // LoopBlockSet iterator here because its order depends on the pointer
+ // values. This nondeterministic order will fail to produce a bit-to-bit
+ // matching clang binary in bootstrap build.
+ for (MachineBasicBlock &LoopBB : *F)
+ if (LoopBlockSet.count(&LoopBB))
+ fillWorkLists(&LoopBB, UpdatedPreds, &LoopBlockSet);
buildChain(LoopTop, LoopChain, &LoopBlockSet);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26634.77876.patch
Type: text/x-patch
Size: 888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161114/052ce9cc/attachment.bin>
More information about the llvm-commits
mailing list