@@ -136,17 +136,6 @@ class InterpreterStackFrame {
136
136
137
137
~InterpreterStackFrame () = default ;
138
138
139
- bool MemoryMatchesIRElementOrder () {
140
- lldb::TargetSP target_sp = m_execution_unit.GetTarget ();
141
- if (target_sp) {
142
- const auto *arch_plugin = target_sp->GetArchitecturePlugin ();
143
- if (arch_plugin) {
144
- return arch_plugin->GetVectorElementOrder () == lldb::eByteOrderLittle;
145
- }
146
- }
147
- return true ;
148
- }
149
-
150
139
void Jump (const BasicBlock *bb) {
151
140
m_prev_bb = m_bb;
152
141
m_bb = bb;
@@ -185,7 +174,7 @@ class InterpreterStackFrame {
185
174
}
186
175
187
176
bool EvaluateValue (lldb_private::Scalar &scalar, const Value *value,
188
- Module &module ) {
177
+ Module &module , lldb_private::ExecutionContext &exe_ctx ) {
189
178
const Constant *constant = dyn_cast<Constant>(value);
190
179
191
180
if (constant) {
@@ -209,7 +198,7 @@ class InterpreterStackFrame {
209
198
return AssignToMatchType (scalar, value_apint, value->getType ());
210
199
}
211
200
212
- lldb::addr_t process_address = ResolveValue (value, module );
201
+ lldb::addr_t process_address = ResolveValue (value, module , exe_ctx );
213
202
size_t value_size = m_target_data.getTypeStoreSize (value->getType ());
214
203
215
204
lldb_private::DataExtractor value_extractor;
@@ -241,8 +230,8 @@ class InterpreterStackFrame {
241
230
}
242
231
243
232
bool AssignValue (const Value *value, lldb_private::Scalar scalar,
244
- Module &module ) {
245
- lldb::addr_t process_address = ResolveValue (value, module );
233
+ Module &module , lldb_private::ExecutionContext &exe_ctx ) {
234
+ lldb::addr_t process_address = ResolveValue (value, module , exe_ctx );
246
235
247
236
if (process_address == LLDB_INVALID_ADDRESS)
248
237
return false ;
@@ -391,7 +380,8 @@ class InterpreterStackFrame {
391
380
}
392
381
393
382
bool ResolveVectorConstant (lldb::addr_t process_address,
394
- const Constant *constant) {
383
+ const Constant *constant,
384
+ lldb_private::ExecutionContext &exe_ctx) {
395
385
auto *vector_type = dyn_cast<FixedVectorType>(constant->getType ());
396
386
if (!vector_type)
397
387
return false ;
@@ -400,7 +390,7 @@ class InterpreterStackFrame {
400
390
unsigned num_elements = vector_type->getNumElements ();
401
391
size_t element_size = m_target_data.getTypeStoreSize (element_type);
402
392
size_t total_size = element_size * num_elements;
403
- bool reverse_elements = !MemoryMatchesIRElementOrder ();
393
+ bool reverse_elements = !MemoryMatchesIRElementOrder (exe_ctx );
404
394
405
395
lldb_private::DataBufferHeap buf (total_size, 0 );
406
396
uint8_t *data_ptr = buf.GetBytes ();
@@ -442,11 +432,12 @@ class InterpreterStackFrame {
442
432
return false ;
443
433
}
444
434
445
- bool ResolveConstant (lldb::addr_t process_address, const Constant *constant) {
435
+ bool ResolveConstant (lldb::addr_t process_address, const Constant *constant,
436
+ lldb_private::ExecutionContext &exe_ctx) {
446
437
// Handle vector constants specially since they can't be represented as a
447
438
// single APInt
448
439
if (constant->getType ()->isVectorTy ()) {
449
- return ResolveVectorConstant (process_address, constant);
440
+ return ResolveVectorConstant (process_address, constant, exe_ctx );
450
441
}
451
442
452
443
APInt resolved_value;
@@ -517,7 +508,8 @@ class InterpreterStackFrame {
517
508
return std::string (ss.GetString ());
518
509
}
519
510
520
- lldb::addr_t ResolveValue (const Value *value, Module &module ) {
511
+ lldb::addr_t ResolveValue (const Value *value, Module &module ,
512
+ lldb_private::ExecutionContext &exe_ctx) {
521
513
ValueMap::iterator i = m_values.find (value);
522
514
523
515
if (i != m_values.end ())
@@ -528,7 +520,7 @@ class InterpreterStackFrame {
528
520
lldb::addr_t data_address = Malloc (value->getType ());
529
521
530
522
if (const Constant *constant = dyn_cast<Constant>(value)) {
531
- if (!ResolveConstant (data_address, constant)) {
523
+ if (!ResolveConstant (data_address, constant, exe_ctx )) {
532
524
lldb_private::Status free_error;
533
525
m_execution_unit.Free (data_address, free_error);
534
526
return LLDB_INVALID_ADDRESS;
@@ -906,13 +898,13 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
906
898
lldb_private::Scalar L;
907
899
lldb_private::Scalar R;
908
900
909
- if (!frame.EvaluateValue (L, lhs, module )) {
901
+ if (!frame.EvaluateValue (L, lhs, module , exe_ctx )) {
910
902
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (lhs).c_str ());
911
903
error = lldb_private::Status::FromErrorString (bad_value_error);
912
904
return false ;
913
905
}
914
906
915
- if (!frame.EvaluateValue (R, rhs, module )) {
907
+ if (!frame.EvaluateValue (R, rhs, module , exe_ctx )) {
916
908
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (rhs).c_str ());
917
909
error = lldb_private::Status::FromErrorString (bad_value_error);
918
910
return false ;
@@ -979,7 +971,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
979
971
break ;
980
972
}
981
973
982
- frame.AssignValue (inst, result, module );
974
+ frame.AssignValue (inst, result, module , exe_ctx );
983
975
984
976
if (log) {
985
977
LLDB_LOGF (log, " Interpreted a %s" , inst->getOpcodeName ());
@@ -1054,13 +1046,13 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1054
1046
1055
1047
lldb_private::Scalar S;
1056
1048
1057
- if (!frame.EvaluateValue (S, source, module )) {
1049
+ if (!frame.EvaluateValue (S, source, module , exe_ctx )) {
1058
1050
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (source).c_str ());
1059
1051
error = lldb_private::Status::FromErrorString (bad_value_error);
1060
1052
return false ;
1061
1053
}
1062
1054
1063
- frame.AssignValue (inst, S, module );
1055
+ frame.AssignValue (inst, S, module , exe_ctx );
1064
1056
} break ;
1065
1057
case Instruction::SExt: {
1066
1058
const CastInst *cast_inst = cast<CastInst>(inst);
@@ -1069,7 +1061,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1069
1061
1070
1062
lldb_private::Scalar S;
1071
1063
1072
- if (!frame.EvaluateValue (S, source, module )) {
1064
+ if (!frame.EvaluateValue (S, source, module , exe_ctx )) {
1073
1065
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (source).c_str ());
1074
1066
error = lldb_private::Status::FromErrorString (bad_value_error);
1075
1067
return false ;
@@ -1079,7 +1071,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1079
1071
1080
1072
lldb_private::Scalar S_signextend (S.SLongLong ());
1081
1073
1082
- frame.AssignValue (inst, S_signextend, module );
1074
+ frame.AssignValue (inst, S_signextend, module , exe_ctx );
1083
1075
} break ;
1084
1076
case Instruction::Br: {
1085
1077
const BranchInst *br_inst = cast<BranchInst>(inst);
@@ -1089,7 +1081,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1089
1081
1090
1082
lldb_private::Scalar C;
1091
1083
1092
- if (!frame.EvaluateValue (C, condition, module )) {
1084
+ if (!frame.EvaluateValue (C, condition, module , exe_ctx )) {
1093
1085
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (condition).c_str ());
1094
1086
error = lldb_private::Status::FromErrorString (bad_value_error);
1095
1087
return false ;
@@ -1127,12 +1119,12 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1127
1119
1128
1120
Value *value = phi_inst->getIncomingValueForBlock (frame.m_prev_bb );
1129
1121
lldb_private::Scalar result;
1130
- if (!frame.EvaluateValue (result, value, module )) {
1122
+ if (!frame.EvaluateValue (result, value, module , exe_ctx )) {
1131
1123
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (value).c_str ());
1132
1124
error = lldb_private::Status::FromErrorString (bad_value_error);
1133
1125
return false ;
1134
1126
}
1135
- frame.AssignValue (inst, result, module );
1127
+ frame.AssignValue (inst, result, module , exe_ctx );
1136
1128
1137
1129
if (log) {
1138
1130
LLDB_LOGF (log, " Interpreted a %s" , inst->getOpcodeName ());
@@ -1148,7 +1140,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1148
1140
1149
1141
lldb_private::Scalar P;
1150
1142
1151
- if (!frame.EvaluateValue (P, pointer_operand, module )) {
1143
+ if (!frame.EvaluateValue (P, pointer_operand, module , exe_ctx )) {
1152
1144
LLDB_LOGF (log, " Couldn't evaluate %s" ,
1153
1145
PrintValue (pointer_operand).c_str ());
1154
1146
error = lldb_private::Status::FromErrorString (bad_value_error);
@@ -1170,7 +1162,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1170
1162
if (!constant_index) {
1171
1163
lldb_private::Scalar I;
1172
1164
1173
- if (!frame.EvaluateValue (I, *ii, module )) {
1165
+ if (!frame.EvaluateValue (I, *ii, module , exe_ctx )) {
1174
1166
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (*ii).c_str ());
1175
1167
error = lldb_private::Status::FromErrorString (bad_value_error);
1176
1168
return false ;
@@ -1191,7 +1183,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1191
1183
1192
1184
lldb_private::Scalar Poffset = P + offset;
1193
1185
1194
- frame.AssignValue (inst, Poffset, module );
1186
+ frame.AssignValue (inst, Poffset, module , exe_ctx );
1195
1187
1196
1188
if (log) {
1197
1189
LLDB_LOGF (log, " Interpreted a GetElementPtrInst" );
@@ -1212,13 +1204,13 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1212
1204
lldb_private::Scalar L;
1213
1205
lldb_private::Scalar R;
1214
1206
1215
- if (!frame.EvaluateValue (L, lhs, module )) {
1207
+ if (!frame.EvaluateValue (L, lhs, module , exe_ctx )) {
1216
1208
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (lhs).c_str ());
1217
1209
error = lldb_private::Status::FromErrorString (bad_value_error);
1218
1210
return false ;
1219
1211
}
1220
1212
1221
- if (!frame.EvaluateValue (R, rhs, module )) {
1213
+ if (!frame.EvaluateValue (R, rhs, module , exe_ctx )) {
1222
1214
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (rhs).c_str ());
1223
1215
error = lldb_private::Status::FromErrorString (bad_value_error);
1224
1216
return false ;
@@ -1291,7 +1283,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1291
1283
break ;
1292
1284
}
1293
1285
1294
- frame.AssignValue (inst, result, module );
1286
+ frame.AssignValue (inst, result, module , exe_ctx );
1295
1287
1296
1288
if (log) {
1297
1289
LLDB_LOGF (log, " Interpreted an ICmpInst" );
@@ -1307,13 +1299,13 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1307
1299
1308
1300
lldb_private::Scalar I;
1309
1301
1310
- if (!frame.EvaluateValue (I, src_operand, module )) {
1302
+ if (!frame.EvaluateValue (I, src_operand, module , exe_ctx )) {
1311
1303
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (src_operand).c_str ());
1312
1304
error = lldb_private::Status::FromErrorString (bad_value_error);
1313
1305
return false ;
1314
1306
}
1315
1307
1316
- frame.AssignValue (inst, I, module );
1308
+ frame.AssignValue (inst, I, module , exe_ctx );
1317
1309
1318
1310
if (log) {
1319
1311
LLDB_LOGF (log, " Interpreted an IntToPtr" );
@@ -1328,13 +1320,13 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1328
1320
1329
1321
lldb_private::Scalar I;
1330
1322
1331
- if (!frame.EvaluateValue (I, src_operand, module )) {
1323
+ if (!frame.EvaluateValue (I, src_operand, module , exe_ctx )) {
1332
1324
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (src_operand).c_str ());
1333
1325
error = lldb_private::Status::FromErrorString (bad_value_error);
1334
1326
return false ;
1335
1327
}
1336
1328
1337
- frame.AssignValue (inst, I, module );
1329
+ frame.AssignValue (inst, I, module , exe_ctx );
1338
1330
1339
1331
if (log) {
1340
1332
LLDB_LOGF (log, " Interpreted a PtrToInt" );
@@ -1349,13 +1341,13 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1349
1341
1350
1342
lldb_private::Scalar I;
1351
1343
1352
- if (!frame.EvaluateValue (I, src_operand, module )) {
1344
+ if (!frame.EvaluateValue (I, src_operand, module , exe_ctx )) {
1353
1345
LLDB_LOGF (log, " Couldn't evaluate %s" , PrintValue (src_operand).c_str ());
1354
1346
error = lldb_private::Status::FromErrorString (bad_value_error);
1355
1347
return false ;
1356
1348
}
1357
1349
1358
- frame.AssignValue (inst, I, module );
1350
+ frame.AssignValue (inst, I, module , exe_ctx );
1359
1351
1360
1352
if (log) {
1361
1353
LLDB_LOGF (log, " Interpreted a Trunc" );
@@ -1374,8 +1366,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1374
1366
1375
1367
const Value *pointer_operand = load_inst->getPointerOperand ();
1376
1368
1377
- lldb::addr_t D = frame.ResolveValue (load_inst, module );
1378
- lldb::addr_t P = frame.ResolveValue (pointer_operand, module );
1369
+ lldb::addr_t D = frame.ResolveValue (load_inst, module , exe_ctx );
1370
+ lldb::addr_t P = frame.ResolveValue (pointer_operand, module , exe_ctx );
1379
1371
1380
1372
if (D == LLDB_INVALID_ADDRESS) {
1381
1373
LLDB_LOGF (log, " LoadInst's value doesn't resolve to anything" );
@@ -1443,8 +1435,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1443
1435
const Value *value_operand = store_inst->getValueOperand ();
1444
1436
const Value *pointer_operand = store_inst->getPointerOperand ();
1445
1437
1446
- lldb::addr_t D = frame.ResolveValue (value_operand, module );
1447
- lldb::addr_t P = frame.ResolveValue (pointer_operand, module );
1438
+ lldb::addr_t D = frame.ResolveValue (value_operand, module , exe_ctx );
1439
+ lldb::addr_t P = frame.ResolveValue (pointer_operand, module , exe_ctx );
1448
1440
1449
1441
if (D == LLDB_INVALID_ADDRESS) {
1450
1442
LLDB_LOGF (log, " StoreInst's value doesn't resolve to anything" );
@@ -1537,7 +1529,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1537
1529
lldb_private::Scalar I;
1538
1530
const llvm::Value *val = call_inst->getCalledOperand ();
1539
1531
1540
- if (!frame.EvaluateValue (I, val, module )) {
1532
+ if (!frame.EvaluateValue (I, val, module , exe_ctx )) {
1541
1533
error = lldb_private::Status::FromErrorString (
1542
1534
" unable to get address of function" );
1543
1535
return false ;
@@ -1576,7 +1568,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1576
1568
1577
1569
// Extract the arguments value
1578
1570
lldb_private::Scalar tmp_op = 0 ;
1579
- if (!frame.EvaluateValue (tmp_op, arg_op, module )) {
1571
+ if (!frame.EvaluateValue (tmp_op, arg_op, module , exe_ctx )) {
1580
1572
error = lldb_private::Status::FromErrorStringWithFormat (
1581
1573
" unable to evaluate argument %d" , i);
1582
1574
return false ;
@@ -1671,7 +1663,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1671
1663
returnVal = value.GetScalar ();
1672
1664
1673
1665
// Push the return value as the result
1674
- frame.AssignValue (inst, returnVal, module );
1666
+ frame.AssignValue (inst, returnVal, module , exe_ctx );
1675
1667
}
1676
1668
} break ;
1677
1669
case Instruction::ExtractElement: {
@@ -1682,7 +1674,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1682
1674
const Value *index_operand = extract_inst->getIndexOperand ();
1683
1675
1684
1676
// Get the vector address
1685
- lldb::addr_t vector_addr = frame.ResolveValue (vector_operand, module );
1677
+ lldb::addr_t vector_addr =
1678
+ frame.ResolveValue (vector_operand, module , exe_ctx);
1686
1679
1687
1680
if (vector_addr == LLDB_INVALID_ADDRESS) {
1688
1681
LLDB_LOGF (log, " ExtractElement's vector doesn't resolve to anything" );
@@ -1692,7 +1685,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1692
1685
1693
1686
// Evaluate the index
1694
1687
lldb_private::Scalar index_scalar;
1695
- if (!frame.EvaluateValue (index_scalar, index_operand, module )) {
1688
+ if (!frame.EvaluateValue (index_scalar, index_operand, module , exe_ctx )) {
1696
1689
LLDB_LOGF (log, " Couldn't evaluate index %s" ,
1697
1690
PrintValue (index_operand).c_str ());
1698
1691
error = lldb_private::Status::FromErrorString (bad_value_error);
@@ -1731,7 +1724,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
1731
1724
size_t element_offset = target_index * element_size;
1732
1725
1733
1726
// Allocate space for the result element
1734
- lldb::addr_t result_addr = frame.ResolveValue (extract_inst, module );
1727
+ lldb::addr_t result_addr =
1728
+ frame.ResolveValue (extract_inst, module , exe_ctx);
1735
1729
if (result_addr == LLDB_INVALID_ADDRESS) {
1736
1730
LLDB_LOGF (log, " ExtractElement's result doesn't resolve to anything" );
1737
1731
error = lldb_private::Status::FromErrorString (bad_value_error);
0 commit comments