summaryrefslogtreecommitdiffstats
path: root/polly/lib/Support/ScopHelper.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>2015-10-01 23:45:51 +0000
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>2015-10-01 23:45:51 +0000
commitf80f3b0449bff935aebab67025dd1d4526e2a7c1 (patch)
treec5e84fcc5deab25ae6178926e1f9a1d93fbf976d /polly/lib/Support/ScopHelper.cpp
parentcbe6411401e21d76d6d80997f62583c98822c518 (diff)
downloadbcm5719-llvm-f80f3b0449bff935aebab67025dd1d4526e2a7c1.tar.gz
bcm5719-llvm-f80f3b0449bff935aebab67025dd1d4526e2a7c1.zip
Allow user defined error functions
The user can provide function names with -polly-error-functions=name1,name2,name3 that will be treated as error functions. Any call to them is assumed not to be executed. This feature is mainly for developers to play around with the new "error block" feature. llvm-svn: 249098
Diffstat (limited to 'polly/lib/Support/ScopHelper.cpp')
-rw-r--r--polly/lib/Support/ScopHelper.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 9acfed661d8..89c4fa33dca 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "polly/Support/ScopHelper.h"
+#include "polly/Options.h"
#include "polly/ScopInfo.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/LoopInfo.h"
@@ -28,6 +29,11 @@ using namespace polly;
#define DEBUG_TYPE "polly-scop-helper"
+static cl::list<std::string>
+ ErrorFunctions("polly-error-functions",
+ cl::desc("A list of error functions"), cl::Hidden,
+ cl::ZeroOrMore, cl::CommaSeparated, cl::cat(PollyCategory));
+
Value *polly::getPointerOperand(Instruction &Inst) {
if (LoadInst *load = dyn_cast<LoadInst>(&Inst))
return load->getPointerOperand();
@@ -343,15 +349,21 @@ Value *polly::expandCodeFor(Scop &S, ScalarEvolution &SE, const DataLayout &DL,
bool polly::isErrorBlock(BasicBlock &BB) {
- for (Instruction &Inst : BB)
- if (CallInst *CI = dyn_cast<CallInst>(&Inst))
- if (Function *F = CI->getCalledFunction())
- if (F->getName().equals("__ubsan_handle_out_of_bounds"))
- return true;
-
if (isa<UnreachableInst>(BB.getTerminator()))
return true;
+ if (ErrorFunctions.empty())
+ return false;
+
+ for (Instruction &Inst : BB)
+ if (CallInst *CI = dyn_cast<CallInst>(&Inst))
+ if (Function *F = CI->getCalledFunction()) {
+ const auto &FnName = F->getName();
+ for (const auto &ErrorFn : ErrorFunctions)
+ if (FnName.equals(ErrorFn))
+ return true;
+ }
+
return false;
}
OpenPOWER on IntegriCloud