So, based on the info that I got from Devang, I was able to solve the problem with the duplicate assembly symbols, although I still don’t quite understand why it was generating erroneous metadata in the first place. For example, through trial and error I discovered that the problem disappeared if I passed my DICompileUnit to CreateLocation() rather than my DISubprogram, but I don’t know why.
The new API introduces a number of new parameters in DIFactory where I am not sure what the correct value to pass is. CreateLocation() is one example - I don’t know if the context should be the compile unit, or the subprogram/region. The latter makes more sense, but is somewhat inconvenient in the face of templates, macros, where you have generated code within a function whose original source lines are from a different source file. It means that a source location (which is attached to every expression node) can’t consist of merely [file, offset, length] but now has to carry other contextual baggage around as well, since conceivably any subtree of an expression could originate from outside the function. Alternatively, passing in the compile unit makes sense, except that now there’s no way to tell the IRBuilder about regions.
Also, even though my code now assembles correctly, gdb gets very unhappy when I try to debug it - it prints “/build/buildd/gdb-7.0/gdb/dwarf2-frame.c:983: internal-error: Unknown CFA rule.” and then asks me if I want to generate a core file of gdb.