| ... | @@ -661,7 +661,11 @@ pub const DeclGen = struct { | ... | @@ -661,7 +661,11 @@ pub const DeclGen = struct { |
| 661 | new_global.setUnnamedAddr(global.getUnnamedAddress()); | 661 | new_global.setUnnamedAddr(global.getUnnamedAddress()); |
| 662 | new_global.setAlignment(global.getAlignment()); | 662 | new_global.setAlignment(global.getAlignment()); |
| 663 | new_global.setInitializer(llvm_init); | 663 | new_global.setInitializer(llvm_init); |
| 664 | global.replaceAllUsesWith(new_global); | 664 | // replaceAllUsesWith requires the type to be unchanged. So we bitcast |
| | 665 | // the new global to the old type and use that as the thing to replace |
| | 666 | // old uses. |
| | 667 | const new_global_ptr = new_global.constBitCast(global.typeOf()); |
| | 668 | global.replaceAllUsesWith(new_global_ptr); |
| 665 | dg.object.decl_map.putAssumeCapacity(decl, new_global); | 669 | dg.object.decl_map.putAssumeCapacity(decl, new_global); |
| 666 | new_global.takeName(global); | 670 | new_global.takeName(global); |
| 667 | global.deleteGlobal(); | 671 | global.deleteGlobal(); |