aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-05-22 17:19:45 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-05-22 17:19:45 +0000
commitdef18494b97f554ea0d95db75627c3e77b74307f (patch)
tree2207c6057d204b9b591770eae96465d8d7bbe8bd /lib/CodeGen
parentbfbfee51ec8f20f3f1b9f8329705d816b67438e7 (diff)
wire -fbounds-checking to the new LLVM bounds checking pass
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/BackendUtil.cpp14
-rw-r--r--lib/CodeGen/CGExpr.cpp2
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp1
3 files changed, 15 insertions, 2 deletions
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp
index 9633dec1fe..f889606475 100644
--- a/lib/CodeGen/BackendUtil.cpp
+++ b/lib/CodeGen/BackendUtil.cpp
@@ -121,6 +121,12 @@ static void addObjCARCOptPass(const PassManagerBuilder &Builder, PassManagerBase
PM.add(createObjCARCOptPass());
}
+static unsigned BoundsChecking;
+static void addBoundsCheckingPass(const PassManagerBuilder &Builder,
+ PassManagerBase &PM) {
+ PM.add(createBoundsCheckingPass(BoundsChecking));
+}
+
static void addAddressSanitizerPass(const PassManagerBuilder &Builder,
PassManagerBase &PM) {
PM.add(createAddressSanitizerPass());
@@ -160,6 +166,14 @@ void EmitAssemblyHelper::CreatePasses() {
addObjCARCOptPass);
}
+ if (CodeGenOpts.BoundsChecking > 0) {
+ BoundsChecking = CodeGenOpts.BoundsChecking;
+ PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
+ addBoundsCheckingPass);
+ PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
+ addBoundsCheckingPass);
+ }
+
if (LangOpts.AddressSanitizer) {
PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
addAddressSanitizerPass);
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 11b8ed254c..190855d3a0 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -517,7 +517,7 @@ unsigned CodeGenFunction::getAccessedFieldNo(unsigned Idx,
}
void CodeGenFunction::EmitCheck(llvm::Value *Address, unsigned Size) {
- if (BoundsChecking <= 0)
+ if (!CatchUndefined)
return;
// This needs to be to the standard address space.
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 5d108be273..dfb04b42aa 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -41,7 +41,6 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)
CXXVTTValue(0), OutermostConditional(0), TerminateLandingPad(0),
TerminateHandler(0), TrapBB(0) {
- BoundsChecking = getContext().getLangOpts().BoundsChecking;
CatchUndefined = getContext().getLangOpts().CatchUndefined;
CGM.getCXXABI().getMangleContext().startNewFunction();
}