[PATCH] D142834: [X86][MC][bugfix] Report error for mismatched modifier in inline asm and remove function getX86SubSuperRegisterOrZero

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 07:07:06 PST 2023


skan added inline comments.


================
Comment at: llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp:748
   switch (Size) {
   default: return X86::NoRegister;
   case 8:
----------------
pengfei wrote:
> skan wrote:
> > skan wrote:
> > > craig.topper wrote:
> > > > Why do we allow invalid sizes?
> > > I think the previous author was overly conservative here. Let's use a `llvm_unreachable` here.
> > > Why do we allow invalid sizes?
> > 
> > The test  `CodeGen/X86/asm-reject-reg-type-mismatch.ll` will fail if we use `llvm_unreachable` here.
> > 
> > ```
> > ; CHECK: error: couldn't allocate output register for constraint '{ax}'
> > define i128 @blup() {
> >   %v = tail call i128 asm "", "={ax},0"(i128 0)
> >   ret i128 %v
> > }
> > ```
> > 
> > See more details here https://reviews.llvm.org/D10813 
> Is it caused by error message not match?
> Is it caused by error message not match?

It is caused by the crash due to the `llvm_unreachable` at line 748.

```
UNREACHABLE executed at llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp:748!

```
`getX86SubSuperRegister` is called with `Size`  128, and an inline asm error is emitted in `SelectionDAGBuilder.cpp` when the returned register is not valid.
If we used "llvm_unreachable" at line 748, the llc would crash before emitting an error.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142834/new/

https://reviews.llvm.org/D142834



More information about the llvm-commits mailing list