access-softek / llvm-project

Other
0 stars 0 forks source link

[WIP] [CodeGen] Validate clobber constraint for inline asm #11

Closed atrosinenko closed 1 year ago

atrosinenko commented 4 years ago

This is an early draft fix of #10 w.r.t. clobber constraints (they seem to be quite trivial according to the LLVM IR reference). This PR does not cover any other constraint kinds.

It does not pass regression tests now. While it may indicate plainly incorrect implementation of this PR (and most probably this is the case), sometimes it triggers on suspicious parts of code. For example, CodeGen/X86/swifterror.ll fails when run as

llc -verify-machineinstrs -mtriple=i386-apple-darwin -disable-block-placement < swifterror.ll

due to usage of

  call void asm sideeffect "nop", "~{r12}"()

for testing on i386. Whether this is an error or not, I don't know. Still, this looks slightly suspicious.

Please note this PR is most probably very broken right now and is mostly here for discussion on what to check and what to ignore (and hopefully to produce some correct validation someday).

atrosinenko commented 4 years ago

Another random observation: llvm/test/CodeGen/AVR/no-print-operand-twice.ll contains a line

  tail call void asm sideeffect "/* result: ${0:c} */", "i,~{dirflag},~{fpsr},~{flags}"( i64 68719476738 )

This cleanly looks like an AVR assembly converted from an X86 one. This particular case is most probably harmless, though.