[PATCH] D32567: [ARM] Miscompilation on arrays promoted to constant pools
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 26 17:37:37 PDT 2017
efriedma added inline comments.
================
Comment at: lib/Target/ARM/ARMISelLowering.cpp:2972
+static bool usersAllowConstantPromotion(const Value *V, const Function *F,
+ bool IsCDAInit, unsigned InitSize) {
+ unsigned UsersCount = 0;
----------------
IsCDAInit seems a bit dubious; for example, you could have a struct which contains an array, or use a scalar as a one-element array, or type-pun a scalar into an array. Or you could even end up comparing the address of a constant against itself.
One use in the IR could lead to more than one use in the actual generated code; for example, consider the case where the only use is a GEP, which feeds into multiple instructions. I think we can solve this, though: since ISel doesn't work across basic blocks, all the uses of the address of the global will be replaced with the return value of promoteToConstantPool. We just need to prevent later passes from trying to rematerialize it, so we have only one instruction which references the constant pool entry by the time we get to the constant islands pass.
Repository:
rL LLVM
https://reviews.llvm.org/D32567
More information about the llvm-commits
mailing list