Skip to content

Commit 2194201

Browse files
committed
LLVMCodeBuilder: Pass constant register to castConstValue()
1 parent e24fdd8 commit 2194201

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ void LLVMCodeBuilder::freeScopeHeap()
21702170
llvm::Value *LLVMCodeBuilder::castValue(LLVMRegister *reg, Compiler::StaticType targetType)
21712171
{
21722172
if (reg->isConst())
2173-
return castConstValue(reg->constValue(), targetType);
2173+
return castConstValue(static_cast<LLVMConstantRegister *>(reg), targetType);
21742174

21752175
if (reg->isRawValue)
21762176
return castRawValue(reg, targetType);
@@ -2322,8 +2322,10 @@ llvm::Value *LLVMCodeBuilder::castRawValue(LLVMRegister *reg, Compiler::StaticTy
23222322
}
23232323
}
23242324

2325-
llvm::Constant *LLVMCodeBuilder::castConstValue(const Value &value, Compiler::StaticType targetType)
2325+
llvm::Constant *LLVMCodeBuilder::castConstValue(LLVMConstantRegister *reg, Compiler::StaticType targetType)
23262326
{
2327+
const Value &value = reg->constValue();
2328+
23272329
switch (targetType) {
23282330
case Compiler::StaticType::Number: {
23292331
const double nan = std::numeric_limits<double>::quiet_NaN();
@@ -2885,7 +2887,7 @@ llvm::Value *LLVMCodeBuilder::createValue(LLVMRegister *reg)
28852887
{
28862888
if (reg->isConst()) {
28872889
// Create a constant ValueData instance and store it
2888-
llvm::Constant *value = castConstValue(reg->constValue(), TYPE_MAP[reg->constValue().type()]);
2890+
llvm::Constant *value = castConstValue(static_cast<LLVMConstantRegister *>(reg), TYPE_MAP[reg->constValue().type()]);
28892891
llvm::Value *ret = addAlloca(m_valueDataType);
28902892

28912893
switch (reg->constValue().type()) {

src/engine/internal/llvm/llvmcodebuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class LLVMCodeBuilder : public ICodeBuilder
140140
void freeScopeHeap();
141141
llvm::Value *castValue(LLVMRegister *reg, Compiler::StaticType targetType);
142142
llvm::Value *castRawValue(LLVMRegister *reg, Compiler::StaticType targetType);
143-
llvm::Constant *castConstValue(const Value &value, Compiler::StaticType targetType);
143+
llvm::Constant *castConstValue(LLVMConstantRegister *reg, Compiler::StaticType targetType);
144144
Compiler::StaticType optimizeRegisterType(LLVMRegister *reg) const;
145145
llvm::Type *getType(Compiler::StaticType type);
146146
Compiler::StaticType getProcedureArgType(BlockPrototype::ArgType type);

0 commit comments

Comments
 (0)