Skip to content

Improve generated isArgumentListValid in DxilInstructions.h #7962

@tex3d

Description

@tex3d

@bogner commented here. Edited relevant bits for issue:

using the result of llvm::dyn_cast without checking for null is asking for a segfault. If this is known to be the right type we should be using llvm::cast instead.

It turns out that this function is never even called in this project, though it is a shared header that drivers use, so I'd be hesitant to just remove it.

I think the point of this method was to guarantee you won't index outside the call operands when calling get_*/set_* methods.

This method could be generated like this:

  bool isArgumentListValid() const {
    if (llvm::CallInst *CI = llvm::dyn_cast<llvm::CallInst>(Instr))
      if (1 == CI->getNumArgOperands())
        return true;
    return false;
  }

Originally posted by @tex3d in #7947 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions