summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorTyler Nowicki <tyler.nowicki@gmail.com>2014-10-12 20:46:07 +0000
committerTyler Nowicki <tyler.nowicki@gmail.com>2014-10-12 20:46:07 +0000
commitc724a83e2054d65a26141bc7518450519dd9b4c7 (patch)
tree53d2c2d4e4708e8af6bf1c36bc267bda153b5ecc /clang/lib/CodeGen/CGStmt.cpp
parent7000ca3f55b87a26883f3aca4855c93ada74b749 (diff)
downloadbcm5719-llvm-c724a83e2054d65a26141bc7518450519dd9b4c7.tar.gz
bcm5719-llvm-c724a83e2054d65a26141bc7518450519dd9b4c7.zip
Allow constant expressions in pragma loop hints.
Previously loop hints such as #pragma loop vectorize_width(#) required a constant. This patch allows a constant expression to be used as well. Such as a non-type template parameter or an expression (2 * c + 1). Reviewed by Richard Smith llvm-svn: 219589
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index b970e4f1ab4..d4fd3b5178d 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -601,8 +601,6 @@ void CodeGenFunction::EmitCondBrHints(llvm::LLVMContext &Context,
LoopHintAttr::OptionType Option = LH->getOption();
LoopHintAttr::LoopHintState State = LH->getState();
- int ValueInt = LH->getValue();
-
const char *MetadataName;
switch (Option) {
case LoopHintAttr::Vectorize:
@@ -622,6 +620,15 @@ void CodeGenFunction::EmitCondBrHints(llvm::LLVMContext &Context,
MetadataName = "llvm.loop.unroll.count";
break;
}
+
+ Expr *ValueExpr = LH->getValue();
+ int ValueInt = 1;
+ if (ValueExpr) {
+ llvm::APSInt ValueAPS =
+ ValueExpr->EvaluateKnownConstInt(CGM.getContext());
+ ValueInt = static_cast<int>(ValueAPS.getSExtValue());
+ }
+
llvm::Value *Value;
llvm::MDString *Name;
switch (Option) {
OpenPOWER on IntegriCloud