[llvm-dev] Expressions in vector constants

Bret Taylor via llvm-dev llvm-dev at lists.llvm.org
Sun Jan 3 19:17:51 PST 2016


I am working on a project that uses integer vectors fairly extensively.
Some values in the vectors came from constant pointers cast to 64-bit
integers, and the LLVM optimizer would often end up folding values into
instructions that looked like this:

store <2 x i64> <i64 ptrtoint (... constant_pointer_value ... to i64), i64
0>, <2 x i64>* %f

ExecutionEngine would abort at runtime on all instructions like this
because ExecutionEngine::getConstantValue assumes all vector constants are
"simple constants" whose values are ConstantInts, not handling the case of
ConstantExpr. I attached a patch that fixes that issue and works as
intended from the limited scope of my project in case it is useful.

It certainly appears that this issue exists for other types besides Integer
and for other aggregate constant types. Is there ExecutionEngine doesn't
run the full-fledged getConstantValue on all subvalues of aggregate
constants instead of reaching into / directly casting subvalues?

Bret Taylor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160103/71bd213d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vector-constant-expressions.patch
Type: application/octet-stream
Size: 1212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160103/71bd213d/attachment.obj>


More information about the llvm-dev mailing list