I'm a little inexperienced here so, to save time, I thought I'd reach out to the community for advice.
I've got a new issue since I rebased my compiler patches onto 5.9.
When I'm compiling my stdlib, something is emitting a global with an empty name "", which then causes llvm to crash in the BitcodeWriter pass. This doesn't happen with the current 5.8 base when I'm compiling my code.
The actual crash is...
frame #4: 0x000000010dfeebc6 swift-frontend`llvm::StringRef::operator[](this="", Index=0) const at StringRef.h:231:7
228 /// @{
229
230 [[nodiscard]] char operator[](size_t Index) const {
-> 231 assert(Index < Length && "Invalid index!");
232 return Data[Index];
233 }
(lldb) e this
(llvm::StringRef *) $56 = 0x000000033d7f8828 ""
Here's a partial dump of the IR that is upsetting the BitcodeWriter...
(lldb) e Module->dump()
; ModuleID = 'bin/AVR/CoreOperators.bc'
source_filename = "bin/AVR/CoreOperators.bc"
target datalayout = "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"
target triple = "avr-atmel-linux-gnueabihf"
%struct._SwiftHashingParameters = type { i64, i64, i8 }
%swift.protocol_requirement = type { i32, i16 }
...snip...
%TSf = type <{ float }>
%Ts7Float16V = type <{ half }>
@_swift_stdlib_Hashing_parameters = external local_unnamed_addr global %struct._SwiftHashingParameters, align 1
@"$ss27ExpressibleByIntegerLiteralTL" = external global %swift.protocol_requirement, align 4
@"$s18IntegerLiteralTypes013ExpressibleByaB0PTl" = external global %swift.protocol_requirement, align 4
@0 = private unnamed_addr constant [1 x i16] [i16 1]
@"$ss27ExpressibleByIntegerLiteralP0cD4TypeAB_s01_ab7BuiltincD0Tn" = external global %swift.protocol_requirement, align 4
...snip...
I suspect the global @0 = private unnamed_addr constant [1 x i16] [i16 1]
may be the culprit.
I want to try and find the bit of compiler code that's emitting a global with the name "" and breakpoint in it to see. what's going on.
I tried putting a break in IRGenModule::getAddrOfSILGlobalVariable
to see if it was ever getting called with a SILGlobalVariable
with Name=="" but didn't see anything.
To save time with me bumbling around for days, I thought I'd ask on the community for advice? Is there some function I can breakpoint, perhaps add a conditional for name=="" to try and catch where this global is being created in the Swift compiler code?