strange assertion about CPU feature

Hi all,

I ran llc using this command

llc -march=abc -mcpu=cpu1 -mattr=+dummy x.bc -O0 -filetype=obj

And I got the following assertion:

Assertion `SubtargetFeatures::hasFlag(Feature) && “Feature flags should start with ‘+’ or ‘-’”’ failed.

I printed the features’ string (obtained from Feature inside the loop in llvm/lib/MC/MCSubtargetInfo.cpp:156 ) and these garbage characters got printed:

+dummy

+dummy

�����z

Then I used -mattr=+help to the command and I got the same assertion and this got printed

+help

Available CPUs for this target:

cpu1 - Select the generic processor.

Available features for this target:

dummy - dummy feature enabled.

Use +feature to enable a feature, or -feature to disable it.

For example, llc -mcpu=mycpu -mattr=+feature1,-feature2

+help

Available CPUs for this target:

cpu1 - Select the generic processor.

Available features for this target:

dummy - dummy feature enabled.

Use +feature to enable a feature, or -feature to disable it.

For example, llc -mcpu=mycpu -mattr=+feature1,-feature2

��W��z

In other words, the feature after -mattr is processed twice followed by a feature with random characters.

It started doing this after I upgraded from LLVM 7 to 8

Does anyone know how to fix this?
Thanks.

I've never seen the issue before, but since it looks like some kind of
memory corruption or array size issue have you tried building LLVM
with -fsanitize=address? If you're lucky that'll fail earlier and
there'll be something obviously iffy in the backtrace somewhere.

Tim.