aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Writer/SlotCalculator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bytecode/Writer/SlotCalculator.cpp')
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index cc7d4e56df..0ac371cbce 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -223,11 +223,13 @@ int SlotCalculator::getValSlot(const Value *D) const {
int SlotCalculator::insertValue(const Value *D) {
- if (const ConstPoolVal *CPV = D->castConstant()) {
+ if (D->isConstant() || D->isGlobal()) {
+ const User *U = (const User *)D;
// This makes sure that if a constant has uses (for example an array
- // of const ints), that they are inserted also.
+ // of const ints), that they are inserted also. Same for global variable
+ // initializers.
//
- for_each(CPV->op_begin(), CPV->op_end(),
+ for_each(U->op_begin(), U->op_end(),
bind_obj(this, &SlotCalculator::insertValue));
}