mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
[stack protector] Set edge weights for newly created basic blocks.
This commit fixes a bug in stack protector pass where edge weights were not set when new basic blocks were added to lists of successor basic blocks. Differential Revision: http://reviews.llvm.org/D5766 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222987 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include "llvm/CodeGen/StackProtector.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/BranchProbabilityInfo.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/CodeGen/Analysis.h"
|
||||
#include "llvm/CodeGen/Passes.h"
|
||||
@ -31,6 +32,7 @@
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Intrinsics.h"
|
||||
#include "llvm/IR/MDBuilder.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
@ -459,7 +461,13 @@ bool StackProtector::InsertStackProtectors() {
|
||||
LoadInst *LI1 = B.CreateLoad(StackGuardVar);
|
||||
LoadInst *LI2 = B.CreateLoad(AI);
|
||||
Value *Cmp = B.CreateICmpEQ(LI1, LI2);
|
||||
B.CreateCondBr(Cmp, NewBB, FailBB);
|
||||
unsigned SuccessWeight =
|
||||
BranchProbabilityInfo::getBranchWeightStackProtector(true);
|
||||
unsigned FailureWeight =
|
||||
BranchProbabilityInfo::getBranchWeightStackProtector(false);
|
||||
MDNode *Weights = MDBuilder(F->getContext())
|
||||
.createBranchWeights(SuccessWeight, FailureWeight);
|
||||
B.CreateCondBr(Cmp, NewBB, FailBB, Weights);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user