| ... | @@ -253,6 +253,353 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -253,6 +253,353 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 253 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type); | 253 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type); |
| 254 | static ResultLoc *no_result_loc(void); | 254 | static ResultLoc *no_result_loc(void); |
| 255 | | 255 | |
| | 256 | static void destroy_instruction(IrInstruction *inst) { |
| | 257 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| | 258 | const char *name = ir_instruction_type_str(inst->id); |
| | 259 | #else |
| | 260 | const char *name = nullptr; |
| | 261 | #endif |
| | 262 | switch (inst->id) { |
| | 263 | case IrInstructionIdInvalid: |
| | 264 | zig_unreachable(); |
| | 265 | case IrInstructionIdReturn: |
| | 266 | return destroy(reinterpret_cast<IrInstructionReturn *>(inst), name); |
| | 267 | case IrInstructionIdConst: |
| | 268 | return destroy(reinterpret_cast<IrInstructionConst *>(inst), name); |
| | 269 | case IrInstructionIdBinOp: |
| | 270 | return destroy(reinterpret_cast<IrInstructionBinOp *>(inst), name); |
| | 271 | case IrInstructionIdMergeErrSets: |
| | 272 | return destroy(reinterpret_cast<IrInstructionMergeErrSets *>(inst), name); |
| | 273 | case IrInstructionIdDeclVarSrc: |
| | 274 | return destroy(reinterpret_cast<IrInstructionDeclVarSrc *>(inst), name); |
| | 275 | case IrInstructionIdCast: |
| | 276 | return destroy(reinterpret_cast<IrInstructionCast *>(inst), name); |
| | 277 | case IrInstructionIdCallSrc: |
| | 278 | return destroy(reinterpret_cast<IrInstructionCallSrc *>(inst), name); |
| | 279 | case IrInstructionIdCallGen: |
| | 280 | return destroy(reinterpret_cast<IrInstructionCallGen *>(inst), name); |
| | 281 | case IrInstructionIdUnOp: |
| | 282 | return destroy(reinterpret_cast<IrInstructionUnOp *>(inst), name); |
| | 283 | case IrInstructionIdCondBr: |
| | 284 | return destroy(reinterpret_cast<IrInstructionCondBr *>(inst), name); |
| | 285 | case IrInstructionIdBr: |
| | 286 | return destroy(reinterpret_cast<IrInstructionBr *>(inst), name); |
| | 287 | case IrInstructionIdPhi: |
| | 288 | return destroy(reinterpret_cast<IrInstructionPhi *>(inst), name); |
| | 289 | case IrInstructionIdContainerInitList: |
| | 290 | return destroy(reinterpret_cast<IrInstructionContainerInitList *>(inst), name); |
| | 291 | case IrInstructionIdContainerInitFields: |
| | 292 | return destroy(reinterpret_cast<IrInstructionContainerInitFields *>(inst), name); |
| | 293 | case IrInstructionIdUnreachable: |
| | 294 | return destroy(reinterpret_cast<IrInstructionUnreachable *>(inst), name); |
| | 295 | case IrInstructionIdElemPtr: |
| | 296 | return destroy(reinterpret_cast<IrInstructionElemPtr *>(inst), name); |
| | 297 | case IrInstructionIdVarPtr: |
| | 298 | return destroy(reinterpret_cast<IrInstructionVarPtr *>(inst), name); |
| | 299 | case IrInstructionIdReturnPtr: |
| | 300 | return destroy(reinterpret_cast<IrInstructionReturnPtr *>(inst), name); |
| | 301 | case IrInstructionIdLoadPtr: |
| | 302 | return destroy(reinterpret_cast<IrInstructionLoadPtr *>(inst), name); |
| | 303 | case IrInstructionIdLoadPtrGen: |
| | 304 | return destroy(reinterpret_cast<IrInstructionLoadPtrGen *>(inst), name); |
| | 305 | case IrInstructionIdStorePtr: |
| | 306 | return destroy(reinterpret_cast<IrInstructionStorePtr *>(inst), name); |
| | 307 | case IrInstructionIdVectorStoreElem: |
| | 308 | return destroy(reinterpret_cast<IrInstructionVectorStoreElem *>(inst), name); |
| | 309 | case IrInstructionIdTypeOf: |
| | 310 | return destroy(reinterpret_cast<IrInstructionTypeOf *>(inst), name); |
| | 311 | case IrInstructionIdFieldPtr: |
| | 312 | return destroy(reinterpret_cast<IrInstructionFieldPtr *>(inst), name); |
| | 313 | case IrInstructionIdStructFieldPtr: |
| | 314 | return destroy(reinterpret_cast<IrInstructionStructFieldPtr *>(inst), name); |
| | 315 | case IrInstructionIdUnionFieldPtr: |
| | 316 | return destroy(reinterpret_cast<IrInstructionUnionFieldPtr *>(inst), name); |
| | 317 | case IrInstructionIdSetCold: |
| | 318 | return destroy(reinterpret_cast<IrInstructionSetCold *>(inst), name); |
| | 319 | case IrInstructionIdSetRuntimeSafety: |
| | 320 | return destroy(reinterpret_cast<IrInstructionSetRuntimeSafety *>(inst), name); |
| | 321 | case IrInstructionIdSetFloatMode: |
| | 322 | return destroy(reinterpret_cast<IrInstructionSetFloatMode *>(inst), name); |
| | 323 | case IrInstructionIdArrayType: |
| | 324 | return destroy(reinterpret_cast<IrInstructionArrayType *>(inst), name); |
| | 325 | case IrInstructionIdSliceType: |
| | 326 | return destroy(reinterpret_cast<IrInstructionSliceType *>(inst), name); |
| | 327 | case IrInstructionIdAnyFrameType: |
| | 328 | return destroy(reinterpret_cast<IrInstructionAnyFrameType *>(inst), name); |
| | 329 | case IrInstructionIdGlobalAsm: |
| | 330 | return destroy(reinterpret_cast<IrInstructionGlobalAsm *>(inst), name); |
| | 331 | case IrInstructionIdAsm: |
| | 332 | return destroy(reinterpret_cast<IrInstructionAsm *>(inst), name); |
| | 333 | case IrInstructionIdSizeOf: |
| | 334 | return destroy(reinterpret_cast<IrInstructionSizeOf *>(inst), name); |
| | 335 | case IrInstructionIdTestNonNull: |
| | 336 | return destroy(reinterpret_cast<IrInstructionTestNonNull *>(inst), name); |
| | 337 | case IrInstructionIdOptionalUnwrapPtr: |
| | 338 | return destroy(reinterpret_cast<IrInstructionOptionalUnwrapPtr *>(inst), name); |
| | 339 | case IrInstructionIdPopCount: |
| | 340 | return destroy(reinterpret_cast<IrInstructionPopCount *>(inst), name); |
| | 341 | case IrInstructionIdClz: |
| | 342 | return destroy(reinterpret_cast<IrInstructionClz *>(inst), name); |
| | 343 | case IrInstructionIdCtz: |
| | 344 | return destroy(reinterpret_cast<IrInstructionCtz *>(inst), name); |
| | 345 | case IrInstructionIdBswap: |
| | 346 | return destroy(reinterpret_cast<IrInstructionBswap *>(inst), name); |
| | 347 | case IrInstructionIdBitReverse: |
| | 348 | return destroy(reinterpret_cast<IrInstructionBitReverse *>(inst), name); |
| | 349 | case IrInstructionIdSwitchBr: |
| | 350 | return destroy(reinterpret_cast<IrInstructionSwitchBr *>(inst), name); |
| | 351 | case IrInstructionIdSwitchVar: |
| | 352 | return destroy(reinterpret_cast<IrInstructionSwitchVar *>(inst), name); |
| | 353 | case IrInstructionIdSwitchElseVar: |
| | 354 | return destroy(reinterpret_cast<IrInstructionSwitchElseVar *>(inst), name); |
| | 355 | case IrInstructionIdSwitchTarget: |
| | 356 | return destroy(reinterpret_cast<IrInstructionSwitchTarget *>(inst), name); |
| | 357 | case IrInstructionIdUnionTag: |
| | 358 | return destroy(reinterpret_cast<IrInstructionUnionTag *>(inst), name); |
| | 359 | case IrInstructionIdImport: |
| | 360 | return destroy(reinterpret_cast<IrInstructionImport *>(inst), name); |
| | 361 | case IrInstructionIdRef: |
| | 362 | return destroy(reinterpret_cast<IrInstructionRef *>(inst), name); |
| | 363 | case IrInstructionIdRefGen: |
| | 364 | return destroy(reinterpret_cast<IrInstructionRefGen *>(inst), name); |
| | 365 | case IrInstructionIdCompileErr: |
| | 366 | return destroy(reinterpret_cast<IrInstructionCompileErr *>(inst), name); |
| | 367 | case IrInstructionIdCompileLog: |
| | 368 | return destroy(reinterpret_cast<IrInstructionCompileLog *>(inst), name); |
| | 369 | case IrInstructionIdErrName: |
| | 370 | return destroy(reinterpret_cast<IrInstructionErrName *>(inst), name); |
| | 371 | case IrInstructionIdCImport: |
| | 372 | return destroy(reinterpret_cast<IrInstructionCImport *>(inst), name); |
| | 373 | case IrInstructionIdCInclude: |
| | 374 | return destroy(reinterpret_cast<IrInstructionCInclude *>(inst), name); |
| | 375 | case IrInstructionIdCDefine: |
| | 376 | return destroy(reinterpret_cast<IrInstructionCDefine *>(inst), name); |
| | 377 | case IrInstructionIdCUndef: |
| | 378 | return destroy(reinterpret_cast<IrInstructionCUndef *>(inst), name); |
| | 379 | case IrInstructionIdEmbedFile: |
| | 380 | return destroy(reinterpret_cast<IrInstructionEmbedFile *>(inst), name); |
| | 381 | case IrInstructionIdCmpxchgSrc: |
| | 382 | return destroy(reinterpret_cast<IrInstructionCmpxchgSrc *>(inst), name); |
| | 383 | case IrInstructionIdCmpxchgGen: |
| | 384 | return destroy(reinterpret_cast<IrInstructionCmpxchgGen *>(inst), name); |
| | 385 | case IrInstructionIdFence: |
| | 386 | return destroy(reinterpret_cast<IrInstructionFence *>(inst), name); |
| | 387 | case IrInstructionIdTruncate: |
| | 388 | return destroy(reinterpret_cast<IrInstructionTruncate *>(inst), name); |
| | 389 | case IrInstructionIdIntCast: |
| | 390 | return destroy(reinterpret_cast<IrInstructionIntCast *>(inst), name); |
| | 391 | case IrInstructionIdFloatCast: |
| | 392 | return destroy(reinterpret_cast<IrInstructionFloatCast *>(inst), name); |
| | 393 | case IrInstructionIdErrSetCast: |
| | 394 | return destroy(reinterpret_cast<IrInstructionErrSetCast *>(inst), name); |
| | 395 | case IrInstructionIdFromBytes: |
| | 396 | return destroy(reinterpret_cast<IrInstructionFromBytes *>(inst), name); |
| | 397 | case IrInstructionIdToBytes: |
| | 398 | return destroy(reinterpret_cast<IrInstructionToBytes *>(inst), name); |
| | 399 | case IrInstructionIdIntToFloat: |
| | 400 | return destroy(reinterpret_cast<IrInstructionIntToFloat *>(inst), name); |
| | 401 | case IrInstructionIdFloatToInt: |
| | 402 | return destroy(reinterpret_cast<IrInstructionFloatToInt *>(inst), name); |
| | 403 | case IrInstructionIdBoolToInt: |
| | 404 | return destroy(reinterpret_cast<IrInstructionBoolToInt *>(inst), name); |
| | 405 | case IrInstructionIdIntType: |
| | 406 | return destroy(reinterpret_cast<IrInstructionIntType *>(inst), name); |
| | 407 | case IrInstructionIdVectorType: |
| | 408 | return destroy(reinterpret_cast<IrInstructionVectorType *>(inst), name); |
| | 409 | case IrInstructionIdShuffleVector: |
| | 410 | return destroy(reinterpret_cast<IrInstructionShuffleVector *>(inst), name); |
| | 411 | case IrInstructionIdSplatSrc: |
| | 412 | return destroy(reinterpret_cast<IrInstructionSplatSrc *>(inst), name); |
| | 413 | case IrInstructionIdSplatGen: |
| | 414 | return destroy(reinterpret_cast<IrInstructionSplatGen *>(inst), name); |
| | 415 | case IrInstructionIdBoolNot: |
| | 416 | return destroy(reinterpret_cast<IrInstructionBoolNot *>(inst), name); |
| | 417 | case IrInstructionIdMemset: |
| | 418 | return destroy(reinterpret_cast<IrInstructionMemset *>(inst), name); |
| | 419 | case IrInstructionIdMemcpy: |
| | 420 | return destroy(reinterpret_cast<IrInstructionMemcpy *>(inst), name); |
| | 421 | case IrInstructionIdSliceSrc: |
| | 422 | return destroy(reinterpret_cast<IrInstructionSliceSrc *>(inst), name); |
| | 423 | case IrInstructionIdSliceGen: |
| | 424 | return destroy(reinterpret_cast<IrInstructionSliceGen *>(inst), name); |
| | 425 | case IrInstructionIdMemberCount: |
| | 426 | return destroy(reinterpret_cast<IrInstructionMemberCount *>(inst), name); |
| | 427 | case IrInstructionIdMemberType: |
| | 428 | return destroy(reinterpret_cast<IrInstructionMemberType *>(inst), name); |
| | 429 | case IrInstructionIdMemberName: |
| | 430 | return destroy(reinterpret_cast<IrInstructionMemberName *>(inst), name); |
| | 431 | case IrInstructionIdBreakpoint: |
| | 432 | return destroy(reinterpret_cast<IrInstructionBreakpoint *>(inst), name); |
| | 433 | case IrInstructionIdReturnAddress: |
| | 434 | return destroy(reinterpret_cast<IrInstructionReturnAddress *>(inst), name); |
| | 435 | case IrInstructionIdFrameAddress: |
| | 436 | return destroy(reinterpret_cast<IrInstructionFrameAddress *>(inst), name); |
| | 437 | case IrInstructionIdFrameHandle: |
| | 438 | return destroy(reinterpret_cast<IrInstructionFrameHandle *>(inst), name); |
| | 439 | case IrInstructionIdFrameType: |
| | 440 | return destroy(reinterpret_cast<IrInstructionFrameType *>(inst), name); |
| | 441 | case IrInstructionIdFrameSizeSrc: |
| | 442 | return destroy(reinterpret_cast<IrInstructionFrameSizeSrc *>(inst), name); |
| | 443 | case IrInstructionIdFrameSizeGen: |
| | 444 | return destroy(reinterpret_cast<IrInstructionFrameSizeGen *>(inst), name); |
| | 445 | case IrInstructionIdAlignOf: |
| | 446 | return destroy(reinterpret_cast<IrInstructionAlignOf *>(inst), name); |
| | 447 | case IrInstructionIdOverflowOp: |
| | 448 | return destroy(reinterpret_cast<IrInstructionOverflowOp *>(inst), name); |
| | 449 | case IrInstructionIdTestErrSrc: |
| | 450 | return destroy(reinterpret_cast<IrInstructionTestErrSrc *>(inst), name); |
| | 451 | case IrInstructionIdTestErrGen: |
| | 452 | return destroy(reinterpret_cast<IrInstructionTestErrGen *>(inst), name); |
| | 453 | case IrInstructionIdUnwrapErrCode: |
| | 454 | return destroy(reinterpret_cast<IrInstructionUnwrapErrCode *>(inst), name); |
| | 455 | case IrInstructionIdUnwrapErrPayload: |
| | 456 | return destroy(reinterpret_cast<IrInstructionUnwrapErrPayload *>(inst), name); |
| | 457 | case IrInstructionIdOptionalWrap: |
| | 458 | return destroy(reinterpret_cast<IrInstructionOptionalWrap *>(inst), name); |
| | 459 | case IrInstructionIdErrWrapCode: |
| | 460 | return destroy(reinterpret_cast<IrInstructionErrWrapCode *>(inst), name); |
| | 461 | case IrInstructionIdErrWrapPayload: |
| | 462 | return destroy(reinterpret_cast<IrInstructionErrWrapPayload *>(inst), name); |
| | 463 | case IrInstructionIdFnProto: |
| | 464 | return destroy(reinterpret_cast<IrInstructionFnProto *>(inst), name); |
| | 465 | case IrInstructionIdTestComptime: |
| | 466 | return destroy(reinterpret_cast<IrInstructionTestComptime *>(inst), name); |
| | 467 | case IrInstructionIdPtrCastSrc: |
| | 468 | return destroy(reinterpret_cast<IrInstructionPtrCastSrc *>(inst), name); |
| | 469 | case IrInstructionIdPtrCastGen: |
| | 470 | return destroy(reinterpret_cast<IrInstructionPtrCastGen *>(inst), name); |
| | 471 | case IrInstructionIdBitCastSrc: |
| | 472 | return destroy(reinterpret_cast<IrInstructionBitCastSrc *>(inst), name); |
| | 473 | case IrInstructionIdBitCastGen: |
| | 474 | return destroy(reinterpret_cast<IrInstructionBitCastGen *>(inst), name); |
| | 475 | case IrInstructionIdWidenOrShorten: |
| | 476 | return destroy(reinterpret_cast<IrInstructionWidenOrShorten *>(inst), name); |
| | 477 | case IrInstructionIdPtrToInt: |
| | 478 | return destroy(reinterpret_cast<IrInstructionPtrToInt *>(inst), name); |
| | 479 | case IrInstructionIdIntToPtr: |
| | 480 | return destroy(reinterpret_cast<IrInstructionIntToPtr *>(inst), name); |
| | 481 | case IrInstructionIdIntToEnum: |
| | 482 | return destroy(reinterpret_cast<IrInstructionIntToEnum *>(inst), name); |
| | 483 | case IrInstructionIdIntToErr: |
| | 484 | return destroy(reinterpret_cast<IrInstructionIntToErr *>(inst), name); |
| | 485 | case IrInstructionIdErrToInt: |
| | 486 | return destroy(reinterpret_cast<IrInstructionErrToInt *>(inst), name); |
| | 487 | case IrInstructionIdCheckSwitchProngs: |
| | 488 | return destroy(reinterpret_cast<IrInstructionCheckSwitchProngs *>(inst), name); |
| | 489 | case IrInstructionIdCheckStatementIsVoid: |
| | 490 | return destroy(reinterpret_cast<IrInstructionCheckStatementIsVoid *>(inst), name); |
| | 491 | case IrInstructionIdTypeName: |
| | 492 | return destroy(reinterpret_cast<IrInstructionTypeName *>(inst), name); |
| | 493 | case IrInstructionIdTagName: |
| | 494 | return destroy(reinterpret_cast<IrInstructionTagName *>(inst), name); |
| | 495 | case IrInstructionIdPtrType: |
| | 496 | return destroy(reinterpret_cast<IrInstructionPtrType *>(inst), name); |
| | 497 | case IrInstructionIdDeclRef: |
| | 498 | return destroy(reinterpret_cast<IrInstructionDeclRef *>(inst), name); |
| | 499 | case IrInstructionIdPanic: |
| | 500 | return destroy(reinterpret_cast<IrInstructionPanic *>(inst), name); |
| | 501 | case IrInstructionIdFieldParentPtr: |
| | 502 | return destroy(reinterpret_cast<IrInstructionFieldParentPtr *>(inst), name); |
| | 503 | case IrInstructionIdByteOffsetOf: |
| | 504 | return destroy(reinterpret_cast<IrInstructionByteOffsetOf *>(inst), name); |
| | 505 | case IrInstructionIdBitOffsetOf: |
| | 506 | return destroy(reinterpret_cast<IrInstructionBitOffsetOf *>(inst), name); |
| | 507 | case IrInstructionIdTypeInfo: |
| | 508 | return destroy(reinterpret_cast<IrInstructionTypeInfo *>(inst), name); |
| | 509 | case IrInstructionIdType: |
| | 510 | return destroy(reinterpret_cast<IrInstructionType *>(inst), name); |
| | 511 | case IrInstructionIdHasField: |
| | 512 | return destroy(reinterpret_cast<IrInstructionHasField *>(inst), name); |
| | 513 | case IrInstructionIdTypeId: |
| | 514 | return destroy(reinterpret_cast<IrInstructionTypeId *>(inst), name); |
| | 515 | case IrInstructionIdSetEvalBranchQuota: |
| | 516 | return destroy(reinterpret_cast<IrInstructionSetEvalBranchQuota *>(inst), name); |
| | 517 | case IrInstructionIdAlignCast: |
| | 518 | return destroy(reinterpret_cast<IrInstructionAlignCast *>(inst), name); |
| | 519 | case IrInstructionIdImplicitCast: |
| | 520 | return destroy(reinterpret_cast<IrInstructionImplicitCast *>(inst), name); |
| | 521 | case IrInstructionIdResolveResult: |
| | 522 | return destroy(reinterpret_cast<IrInstructionResolveResult *>(inst), name); |
| | 523 | case IrInstructionIdResetResult: |
| | 524 | return destroy(reinterpret_cast<IrInstructionResetResult *>(inst), name); |
| | 525 | case IrInstructionIdOpaqueType: |
| | 526 | return destroy(reinterpret_cast<IrInstructionOpaqueType *>(inst), name); |
| | 527 | case IrInstructionIdSetAlignStack: |
| | 528 | return destroy(reinterpret_cast<IrInstructionSetAlignStack *>(inst), name); |
| | 529 | case IrInstructionIdArgType: |
| | 530 | return destroy(reinterpret_cast<IrInstructionArgType *>(inst), name); |
| | 531 | case IrInstructionIdTagType: |
| | 532 | return destroy(reinterpret_cast<IrInstructionTagType *>(inst), name); |
| | 533 | case IrInstructionIdExport: |
| | 534 | return destroy(reinterpret_cast<IrInstructionExport *>(inst), name); |
| | 535 | case IrInstructionIdErrorReturnTrace: |
| | 536 | return destroy(reinterpret_cast<IrInstructionErrorReturnTrace *>(inst), name); |
| | 537 | case IrInstructionIdErrorUnion: |
| | 538 | return destroy(reinterpret_cast<IrInstructionErrorUnion *>(inst), name); |
| | 539 | case IrInstructionIdAtomicRmw: |
| | 540 | return destroy(reinterpret_cast<IrInstructionAtomicRmw *>(inst), name); |
| | 541 | case IrInstructionIdSaveErrRetAddr: |
| | 542 | return destroy(reinterpret_cast<IrInstructionSaveErrRetAddr *>(inst), name); |
| | 543 | case IrInstructionIdAddImplicitReturnType: |
| | 544 | return destroy(reinterpret_cast<IrInstructionAddImplicitReturnType *>(inst), name); |
| | 545 | case IrInstructionIdFloatOp: |
| | 546 | return destroy(reinterpret_cast<IrInstructionFloatOp *>(inst), name); |
| | 547 | case IrInstructionIdMulAdd: |
| | 548 | return destroy(reinterpret_cast<IrInstructionMulAdd *>(inst), name); |
| | 549 | case IrInstructionIdAtomicLoad: |
| | 550 | return destroy(reinterpret_cast<IrInstructionAtomicLoad *>(inst), name); |
| | 551 | case IrInstructionIdAtomicStore: |
| | 552 | return destroy(reinterpret_cast<IrInstructionAtomicStore *>(inst), name); |
| | 553 | case IrInstructionIdEnumToInt: |
| | 554 | return destroy(reinterpret_cast<IrInstructionEnumToInt *>(inst), name); |
| | 555 | case IrInstructionIdCheckRuntimeScope: |
| | 556 | return destroy(reinterpret_cast<IrInstructionCheckRuntimeScope *>(inst), name); |
| | 557 | case IrInstructionIdDeclVarGen: |
| | 558 | return destroy(reinterpret_cast<IrInstructionDeclVarGen *>(inst), name); |
| | 559 | case IrInstructionIdArrayToVector: |
| | 560 | return destroy(reinterpret_cast<IrInstructionArrayToVector *>(inst), name); |
| | 561 | case IrInstructionIdVectorToArray: |
| | 562 | return destroy(reinterpret_cast<IrInstructionVectorToArray *>(inst), name); |
| | 563 | case IrInstructionIdPtrOfArrayToSlice: |
| | 564 | return destroy(reinterpret_cast<IrInstructionPtrOfArrayToSlice *>(inst), name); |
| | 565 | case IrInstructionIdAssertZero: |
| | 566 | return destroy(reinterpret_cast<IrInstructionAssertZero *>(inst), name); |
| | 567 | case IrInstructionIdAssertNonNull: |
| | 568 | return destroy(reinterpret_cast<IrInstructionAssertNonNull *>(inst), name); |
| | 569 | case IrInstructionIdResizeSlice: |
| | 570 | return destroy(reinterpret_cast<IrInstructionResizeSlice *>(inst), name); |
| | 571 | case IrInstructionIdHasDecl: |
| | 572 | return destroy(reinterpret_cast<IrInstructionHasDecl *>(inst), name); |
| | 573 | case IrInstructionIdUndeclaredIdent: |
| | 574 | return destroy(reinterpret_cast<IrInstructionUndeclaredIdent *>(inst), name); |
| | 575 | case IrInstructionIdAllocaSrc: |
| | 576 | return destroy(reinterpret_cast<IrInstructionAllocaSrc *>(inst), name); |
| | 577 | case IrInstructionIdAllocaGen: |
| | 578 | return destroy(reinterpret_cast<IrInstructionAllocaGen *>(inst), name); |
| | 579 | case IrInstructionIdEndExpr: |
| | 580 | return destroy(reinterpret_cast<IrInstructionEndExpr *>(inst), name); |
| | 581 | case IrInstructionIdUnionInitNamedField: |
| | 582 | return destroy(reinterpret_cast<IrInstructionUnionInitNamedField *>(inst), name); |
| | 583 | case IrInstructionIdSuspendBegin: |
| | 584 | return destroy(reinterpret_cast<IrInstructionSuspendBegin *>(inst), name); |
| | 585 | case IrInstructionIdSuspendFinish: |
| | 586 | return destroy(reinterpret_cast<IrInstructionSuspendFinish *>(inst), name); |
| | 587 | case IrInstructionIdResume: |
| | 588 | return destroy(reinterpret_cast<IrInstructionResume *>(inst), name); |
| | 589 | case IrInstructionIdAwaitSrc: |
| | 590 | return destroy(reinterpret_cast<IrInstructionAwaitSrc *>(inst), name); |
| | 591 | case IrInstructionIdAwaitGen: |
| | 592 | return destroy(reinterpret_cast<IrInstructionAwaitGen *>(inst), name); |
| | 593 | case IrInstructionIdSpillBegin: |
| | 594 | return destroy(reinterpret_cast<IrInstructionSpillBegin *>(inst), name); |
| | 595 | case IrInstructionIdSpillEnd: |
| | 596 | return destroy(reinterpret_cast<IrInstructionSpillEnd *>(inst), name); |
| | 597 | case IrInstructionIdVectorExtractElem: |
| | 598 | return destroy(reinterpret_cast<IrInstructionVectorExtractElem *>(inst), name); |
| | 599 | } |
| | 600 | zig_unreachable(); |
| | 601 | } |
| | 602 | |
| 256 | static void ira_ref(IrAnalyze *ira) { | 603 | static void ira_ref(IrAnalyze *ira) { |
| 257 | ira->ref_count += 1; | 604 | ira->ref_count += 1; |
| 258 | } | 605 | } |
| ... | @@ -262,6 +609,22 @@ static void ira_deref(IrAnalyze *ira) { | ... | @@ -262,6 +609,22 @@ static void ira_deref(IrAnalyze *ira) { |
| 262 | return; | 609 | return; |
| 263 | } | 610 | } |
| 264 | assert(ira->ref_count != 0); | 611 | assert(ira->ref_count != 0); |
| | 612 | |
| | 613 | for (size_t bb_i = 0; bb_i < ira->old_irb.exec->basic_block_list.length; bb_i += 1) { |
| | 614 | IrBasicBlock *pass1_bb = ira->old_irb.exec->basic_block_list.items[bb_i]; |
| | 615 | for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) { |
| | 616 | IrInstruction *pass1_inst = pass1_bb->instruction_list.items[inst_i]; |
| | 617 | destroy_instruction(pass1_inst); |
| | 618 | } |
| | 619 | destroy(pass1_bb, "IrBasicBlock"); |
| | 620 | } |
| | 621 | ira->old_irb.exec->basic_block_list.deinit(); |
| | 622 | ira->old_irb.exec->tld_list.deinit(); |
| | 623 | // cannot destroy here because of var->owner_exec |
| | 624 | //destroy(ira->old_irb.exec, "IrExecutablePass1"); |
| | 625 | ira->src_implicit_return_type_list.deinit(); |
| | 626 | ira->resume_stack.deinit(); |
| | 627 | ira->exec_context.mem_slot_list.deinit(); |
| 265 | destroy(ira, "IrAnalyze"); | 628 | destroy(ira, "IrAnalyze"); |
| 266 | } | 629 | } |
| 267 | | 630 | |
| ... | @@ -4202,7 +4565,7 @@ static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -4202,7 +4565,7 @@ static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *nod |
| 4202 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 4565 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); |
| 4203 | incoming_values[0] = val1; | 4566 | incoming_values[0] = val1; |
| 4204 | incoming_values[1] = val2; | 4567 | incoming_values[1] = val2; |
| 4205 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2); | 4568 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); |
| 4206 | incoming_blocks[0] = post_val1_block; | 4569 | incoming_blocks[0] = post_val1_block; |
| 4207 | incoming_blocks[1] = post_val2_block; | 4570 | incoming_blocks[1] = post_val2_block; |
| 4208 | | 4571 | |
| ... | @@ -4292,7 +4655,7 @@ static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4292,7 +4655,7 @@ static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4292 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 4655 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); |
| 4293 | incoming_values[0] = null_result; | 4656 | incoming_values[0] = null_result; |
| 4294 | incoming_values[1] = unwrapped_payload; | 4657 | incoming_values[1] = unwrapped_payload; |
| 4295 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2); | 4658 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); |
| 4296 | incoming_blocks[0] = after_null_block; | 4659 | incoming_blocks[0] = after_null_block; |
| 4297 | incoming_blocks[1] = after_ok_block; | 4660 | incoming_blocks[1] = after_ok_block; |
| 4298 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 4661 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| ... | @@ -6057,7 +6420,7 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6057,7 +6420,7 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode |
| 6057 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 6420 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); |
| 6058 | incoming_values[0] = then_expr_result; | 6421 | incoming_values[0] = then_expr_result; |
| 6059 | incoming_values[1] = else_expr_result; | 6422 | incoming_values[1] = else_expr_result; |
| 6060 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2); | 6423 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); |
| 6061 | incoming_blocks[0] = after_then_block; | 6424 | incoming_blocks[0] = after_then_block; |
| 6062 | incoming_blocks[1] = after_else_block; | 6425 | incoming_blocks[1] = after_else_block; |
| 6063 | | 6426 | |
| ... | @@ -7409,7 +7772,7 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN | ... | @@ -7409,7 +7772,7 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN |
| 7409 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 7772 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); |
| 7410 | incoming_values[0] = then_expr_result; | 7773 | incoming_values[0] = then_expr_result; |
| 7411 | incoming_values[1] = else_expr_result; | 7774 | incoming_values[1] = else_expr_result; |
| 7412 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2); | 7775 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); |
| 7413 | incoming_blocks[0] = after_then_block; | 7776 | incoming_blocks[0] = after_then_block; |
| 7414 | incoming_blocks[1] = after_else_block; | 7777 | incoming_blocks[1] = after_else_block; |
| 7415 | | 7778 | |
| ... | @@ -7506,7 +7869,7 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -7506,7 +7869,7 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 7506 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 7869 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); |
| 7507 | incoming_values[0] = then_expr_result; | 7870 | incoming_values[0] = then_expr_result; |
| 7508 | incoming_values[1] = else_expr_result; | 7871 | incoming_values[1] = else_expr_result; |
| 7509 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2); | 7872 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); |
| 7510 | incoming_blocks[0] = after_then_block; | 7873 | incoming_blocks[0] = after_then_block; |
| 7511 | incoming_blocks[1] = after_else_block; | 7874 | incoming_blocks[1] = after_else_block; |
| 7512 | | 7875 | |
| ... | @@ -8102,7 +8465,7 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -8102,7 +8465,7 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode |
| 8102 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 8465 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); |
| 8103 | incoming_values[0] = err_result; | 8466 | incoming_values[0] = err_result; |
| 8104 | incoming_values[1] = unwrapped_payload; | 8467 | incoming_values[1] = unwrapped_payload; |
| 8105 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2); | 8468 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); |
| 8106 | incoming_blocks[0] = after_err_block; | 8469 | incoming_blocks[0] = after_err_block; |
| 8107 | incoming_blocks[1] = after_ok_block; | 8470 | incoming_blocks[1] = after_ok_block; |
| 8108 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 8471 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| ... | @@ -8690,7 +9053,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec | ... | @@ -8690,7 +9053,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 8690 | bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { | 9053 | bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { |
| 8691 | assert(fn_entry); | 9054 | assert(fn_entry); |
| 8692 | | 9055 | |
| 8693 | IrExecutable *ir_executable = &fn_entry->ir_executable; | 9056 | IrExecutable *ir_executable = fn_entry->ir_executable; |
| 8694 | AstNode *body_node = fn_entry->body_node; | 9057 | AstNode *body_node = fn_entry->body_node; |
| 8695 | | 9058 | |
| 8696 | assert(fn_entry->child_scope); | 9059 | assert(fn_entry->child_scope); |
| ... | @@ -11565,7 +11928,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -11565,7 +11928,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 11565 | if (expected_type != nullptr && type_is_invalid(expected_type)) | 11928 | if (expected_type != nullptr && type_is_invalid(expected_type)) |
| 11566 | return codegen->invalid_instruction->value; | 11929 | return codegen->invalid_instruction->value; |
| 11567 | | 11930 | |
| 11568 | IrExecutable *ir_executable = allocate<IrExecutable>(1); | 11931 | IrExecutable *ir_executable = allocate<IrExecutable>(1, "IrExecutablePass1"); |
| 11569 | ir_executable->source_node = source_node; | 11932 | ir_executable->source_node = source_node; |
| 11570 | ir_executable->parent_exec = parent_exec; | 11933 | ir_executable->parent_exec = parent_exec; |
| 11571 | ir_executable->name = exec_name; | 11934 | ir_executable->name = exec_name; |
| ... | @@ -11587,7 +11950,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -11587,7 +11950,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 11587 | ir_print(codegen, stderr, ir_executable, 2, IrPassSrc); | 11950 | ir_print(codegen, stderr, ir_executable, 2, IrPassSrc); |
| 11588 | fprintf(stderr, "}\n"); | 11951 | fprintf(stderr, "}\n"); |
| 11589 | } | 11952 | } |
| 11590 | IrExecutable *analyzed_executable = allocate<IrExecutable>(1); | 11953 | IrExecutable *analyzed_executable = allocate<IrExecutable>(1, "IrExecutablePass2"); |
| 11591 | analyzed_executable->source_node = source_node; | 11954 | analyzed_executable->source_node = source_node; |
| 11592 | analyzed_executable->parent_exec = parent_exec; | 11955 | analyzed_executable->parent_exec = parent_exec; |
| 11593 | analyzed_executable->source_exec = ir_executable; | 11956 | analyzed_executable->source_exec = ir_executable; |
| ... | @@ -15752,6 +16115,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15752,6 +16115,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15752 | assert(var->mem_slot_index < ira->exec_context.mem_slot_list.length); | 16115 | assert(var->mem_slot_index < ira->exec_context.mem_slot_list.length); |
| 15753 | ZigValue *mem_slot = ira->exec_context.mem_slot_list.at(var->mem_slot_index); | 16116 | ZigValue *mem_slot = ira->exec_context.mem_slot_list.at(var->mem_slot_index); |
| 15754 | copy_const_val(mem_slot, init_val, !is_comptime_var || var->gen_is_const); | 16117 | copy_const_val(mem_slot, init_val, !is_comptime_var || var->gen_is_const); |
| | 16118 | ira_ref(var->owner_exec->analysis); |
| 15755 | | 16119 | |
| 15756 | if (is_comptime_var || (var_class_requires_const && var->gen_is_const)) { | 16120 | if (is_comptime_var || (var_class_requires_const && var->gen_is_const)) { |
| 15757 | return ir_const_void(ira, &decl_var_instruction->base); | 16121 | return ir_const_void(ira, &decl_var_instruction->base); |
| ... | @@ -17522,8 +17886,8 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17522,8 +17886,8 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17522 | if (type_is_invalid(impl_fn->type_entry)) | 17886 | if (type_is_invalid(impl_fn->type_entry)) |
| 17523 | return ira->codegen->invalid_instruction; | 17887 | return ira->codegen->invalid_instruction; |
| 17524 | | 17888 | |
| 17525 | impl_fn->ir_executable.source_node = call_instruction->base.source_node; | 17889 | impl_fn->ir_executable->source_node = call_instruction->base.source_node; |
| 17526 | impl_fn->ir_executable.parent_exec = ira->new_irb.exec; | 17890 | impl_fn->ir_executable->parent_exec = ira->new_irb.exec; |
| 17527 | impl_fn->analyzed_executable.source_node = call_instruction->base.source_node; | 17891 | impl_fn->analyzed_executable.source_node = call_instruction->base.source_node; |
| 17528 | impl_fn->analyzed_executable.parent_exec = ira->new_irb.exec; | 17892 | impl_fn->analyzed_executable.parent_exec = ira->new_irb.exec; |
| 17529 | impl_fn->analyzed_executable.backward_branch_quota = ira->new_irb.exec->backward_branch_quota; | 17893 | impl_fn->analyzed_executable.backward_branch_quota = ira->new_irb.exec->backward_branch_quota; |