Merge two Attribute lists

Whats the best way to merge two AttributeLists (maintaining semantics after inlining)?

What I have at the moment is
result = AttributeSet::get(gIR->context(), {a,b});
but this (completely reliably - no races) segfaults on certain input, but only whenever
our logging code is turned OFF (a runtime switch).
The attributes when logging is on are
attributes #0 = { “less-precise-fpmad”=“false” “no-frame-pointer-elim”=“false”
“no-infs-fp-math”=“false” “no-nans-fp-math”=“false” “unsafe-fp-math”=“false”
}

Any advice?
Also how do you print an attribute list?

Fixed it: https://reviews.llvm.org/D33627