Skip to content

Commit ce73b16

Browse files
[CodeExtractor] Resolving the Inconsistency of Compiled Binary Files (#86497)
When the compiler enables ALSR by default, binary inconsistency occurs when the extractCodeRegion function is called. The reason is that the sequence of traversing ExitBlocks containers of the SmallPtrSet type is changed due to randomization of BasicBlock pointers. This fixes #86427
1 parent 9c8dd5e commit ce73b16

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/include/llvm/Transforms/Utils/CodeExtractor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class CodeExtractorAnalysisCache {
249249
Instruction *Addr, BasicBlock *ExitBlock) const;
250250

251251
void severSplitPHINodesOfEntry(BasicBlock *&Header);
252-
void severSplitPHINodesOfExits(const SmallPtrSetImpl<BasicBlock *> &Exits);
252+
void severSplitPHINodesOfExits(const SetVector<BasicBlock *> &Exits);
253253
void splitReturnBlocks();
254254

255255
Function *constructFunction(const ValueSet &inputs,

llvm/lib/Transforms/Utils/CodeExtractor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ void CodeExtractor::severSplitPHINodesOfEntry(BasicBlock *&Header) {
745745
/// and other with remaining incoming blocks; then first PHIs are placed in
746746
/// outlined region.
747747
void CodeExtractor::severSplitPHINodesOfExits(
748-
const SmallPtrSetImpl<BasicBlock *> &Exits) {
748+
const SetVector<BasicBlock *> &Exits) {
749749
for (BasicBlock *ExitBB : Exits) {
750750
BasicBlock *NewBB = nullptr;
751751

@@ -1751,7 +1751,7 @@ CodeExtractor::extractCodeRegion(const CodeExtractorAnalysisCache &CEAC,
17511751
// Calculate the exit blocks for the extracted region and the total exit
17521752
// weights for each of those blocks.
17531753
DenseMap<BasicBlock *, BlockFrequency> ExitWeights;
1754-
SmallPtrSet<BasicBlock *, 1> ExitBlocks;
1754+
SetVector<BasicBlock *> ExitBlocks;
17551755
for (BasicBlock *Block : Blocks) {
17561756
for (BasicBlock *Succ : successors(Block)) {
17571757
if (!Blocks.count(Succ)) {

0 commit comments

Comments
 (0)