This is an archive of the discontinued LLVM Phabricator instance.

[MIParser] Make sure that getHexUint doesn't produce APInts with a bitwidth of 0
ClosedPublic

Authored by paquette on Sep 1 2017, 2:23 PM.

Details

Summary

If getHexUint reads in a 0 in hex, it will create an APInt A with a value of 0. It will then use that APInt to populate Result. It calculates the bitwidth of Result using A.getActiveBits(). This function returns the bitwidth of A - the number of leading zeroes in A.

A is 0, so all of its bits are leading 0s. Thus, we try to construct Result with a bitwidth of 0, hitting an assert.

This appeared originally by compiling test-suite/SingleSource/Benchmarks/Misc/mandel.c like so:

clang -Oz -mno-red-zone -S -emit-llvm test-suite/SingleSource/Benchmarks/Misc/mandel.c -o /tmp/mandel.ll
llc -march=aarch64 -stop-after=patchable-function /tmp/mandel.ll -o /tmp/mandel.mir
llc -march=aarch64 /tmp/mandel.mir

If you have asserts enabled, this blows up because of a successor basic block being tagged with a probability of 0.

Diff Detail

Event Timeline

paquette created this revision.Sep 1 2017, 2:23 PM
MatzeB accepted this revision.Sep 1 2017, 2:44 PM

LGTM.

This revision is now accepted and ready to land.Sep 1 2017, 2:44 PM
MatzeB closed this revision.Sep 26 2017, 2:13 PM

Looks like this was committed in r312387