This is an archive of the discontinued LLVM Phabricator instance.

[DirectX] Fix crash on ShuffleVectorInst in DXILBitcodeWriter
ClosedPublic

Authored by python3kgae on Aug 17 2022, 11:40 PM.

Details

Summary

Use onstantDataSequential::getElementType to allow vector type.

Use getShuffleMaskForBitcode to get ShuffleMask.

Use old format for alloca Align.

Diff Detail

Event Timeline

python3kgae created this revision.Aug 17 2022, 11:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2022, 11:40 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
python3kgae requested review of this revision.Aug 17 2022, 11:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2022, 11:40 PM
beanz added inline comments.Aug 18 2022, 10:14 AM
llvm/test/tools/dxil-dis/shuffle.ll
7

The change impacts both the encoding of alloca and shufflevector instructions.

Your test should verify that those instructions are correctly encoded and decoded, not just that a given instruction name shows up in the output.

28

Please add newline.

Test alloca and shuffle are the same.

python3kgae marked 2 inline comments as done.Aug 18 2022, 10:22 AM
beanz accepted this revision.Aug 18 2022, 10:34 AM
This revision is now accepted and ready to land.Aug 18 2022, 10:34 AM
This revision was landed with ongoing or failed builds.Aug 18 2022, 11:46 PM
This revision was automatically updated to reflect the committed changes.
kuhar added a subscriber: kuhar.Aug 19 2022, 7:56 AM
kuhar added inline comments.
llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
2454

FYI, this produces compiler warnings for me:

/usr/local/google/home/kubak/llvm/llvm-project/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp:2454:20: warning: implicit conversion from 'const uint
64_t' (aka 'const unsigned long') to 'uint32_t' (aka 'unsigned int') changes value from 4294967296 to 0 [-Wconstant-conversion]                               
    assert(Log2_32(Value::MaximumAlignment) + 1 < 1 << 5 &&
           ~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
                          ^~~~
1 warning generated.