summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2012-02-29 17:57:18 +0000
committerSean Callanan <scallanan@apple.com>2012-02-29 17:57:18 +0000
commit3f548137d0639de6c28a07759e439f55733d961a (patch)
treed3d91184f43baba28d78b932b84d4e69aaab5290 /lldb
parent230e870df595a21449b53f741bc0230469100757 (diff)
downloadbcm5719-llvm-3f548137d0639de6c28a07759e439f55733d961a.tar.gz
bcm5719-llvm-3f548137d0639de6c28a07759e439f55733d961a.zip
Made the IR interpreter handle GetElementPtr instructions
with non-constant indexes. llvm-svn: 151734
Diffstat (limited to 'lldb')
-rw-r--r--lldb/source/Expression/IRInterpreter.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index 4656730ed92..514db9d3f25 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -1326,10 +1326,43 @@ IRInterpreter::runOnFunction (lldb::ClangExpressionVariableSP &result,
return false;
}
+ typedef SmallVector <Value *, 8> IndexVector;
+ typedef IndexVector::iterator IndexIterator;
+
SmallVector <Value *, 8> indices (gep_inst->idx_begin(),
gep_inst->idx_end());
- uint64_t offset = target_data.getIndexedOffset(pointer_type, indices);
+ SmallVector <Value *, 8> const_indices;
+
+ for (IndexIterator ii = indices.begin(), ie = indices.end();
+ ii != ie;
+ ++ii)
+ {
+ ConstantInt *constant_index = dyn_cast<ConstantInt>(*ii);
+
+ if (!constant_index)
+ {
+ lldb_private::Scalar I;
+
+ if (!frame.EvaluateValue(I, *ii, llvm_module))
+ {
+ if (log)
+ log->Printf("Couldn't evaluate %s", PrintValue(*ii).c_str());
+ err.SetErrorToGenericError();
+ err.SetErrorString(bad_value_error);
+ return false;
+ }
+
+ if (log)
+ log->Printf("Evaluated constant index %s as %llu", PrintValue(*ii).c_str(), I.ULongLong(LLDB_INVALID_ADDRESS));
+
+ constant_index = cast<ConstantInt>(ConstantInt::get((*ii)->getType(), I.ULongLong(LLDB_INVALID_ADDRESS)));
+ }
+
+ const_indices.push_back(constant_index);
+ }
+
+ uint64_t offset = target_data.getIndexedOffset(pointer_type, const_indices);
lldb_private::Scalar Poffset = P + offset;
OpenPOWER on IntegriCloud