[PATCH] D116531: [LangRef] Require elementtype attribute for indirect inline asm operands

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 3 03:49:12 PST 2022


nikic created this revision.
nikic added reviewers: opaque-pointers, lebedev.ri.
Herald added subscribers: dexonsmith, jdoerfert, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Indirect inline asm operands may require the materialization of a memory access according to the pointer element type. As this will no longer be available with opaque pointers, we require it to be explicitly annotated using the `elementtype` attribute, for example:

  define void @test(i32* %p, i32 %x) {
    call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32 %x)
    ret void
  }

This patch only includes the LangRef change and Verifier updates to allow adding the elementtype attribute in this position. It does not yet enforce this, as this will require changes on the clang side (and test updates) first.

Something I'm a bit unsure about is whether we really need the elementtype for all indirect constraints, rather than only indirect register constraints. I think indirect memory constraints might not need it (though the backend code is written in a way that does require it). I think it's okay to just make this a general requirement though, as this means we don't need to carefully deal with multiple or alternative constraints. In addition, I believe that MemorySanitizer benefits from having the element type even in cases where it may not be strictly necessary for normal lowering (https://github.com/llvm/llvm-project/blob/cd2b050fa4995b75b9c36fae16c0d9f105b67585/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp#L4066).


https://reviews.llvm.org/D116531

Files:
  llvm/docs/LangRef.rst
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/elementtype.ll
  llvm/test/Verifier/inline-asm-indirect-operand.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116531.397036.patch
Type: text/x-patch
Size: 6357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220103/e247f30d/attachment.bin>


More information about the llvm-commits mailing list