Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled parts of the LLVM IR #678

Open
5 of 11 tasks
delcypher opened this issue Jun 14, 2017 · 8 comments
Open
5 of 11 tasks

Unhandled parts of the LLVM IR #678

delcypher opened this issue Jun 14, 2017 · 8 comments
Labels
Feature Request New feature that should be implemented in KLEE LLVM upgrade

Comments

@delcypher
Copy link
Contributor

delcypher commented Jun 14, 2017

This issues tracks LLVM instructions, intrinsics, etc. that KLEE is known not to handle. Each item is checked once support has been added.

@ccadar
Copy link
Contributor

ccadar commented Jul 17, 2017

Added blockaddress and indirectbr, reported in #615

@ccadar ccadar changed the title Unhandled LLVM intrinsics Unhandled parts of the LLVM assembly language Jul 17, 2017
@ccadar ccadar added Feature Request New feature that should be implemented in KLEE LLVM upgrade labels Jul 26, 2017
@ccadar ccadar changed the title Unhandled parts of the LLVM assembly language Unhandled parts of the LLVM IR May 15, 2018
@251
Copy link
Contributor

251 commented Oct 31, 2019

LLVM8: sha256sum runs into:

ERROR: Code generator does not support intrinsic function 'llvm.is.constant.i32'

https://llvm.org/docs/LangRef.html#llvm-is-constant-intrinsic

This should be lowered before execution.

@arrowd
Copy link
Contributor

arrowd commented Oct 31, 2019

I also bumped into llvm.is.constant.i32 when fiddling with FreeBSD libc support.

@arrowd
Copy link
Contributor

arrowd commented Nov 1, 2019

I did a bit of research on llvm.is.constant. It seems to be handled in lib/Analysis/ConstantFolding.cpp and boils down to this:

static bool isManifestConstant(const Constant *c) {
  if (isa<ConstantData>(c)) {
    return true;
  } else if (isa<ConstantAggregate>(c) || isa<ConstantExpr>(c)) {
    for (const Value *subc : c->operand_values()) {
      if (!isManifestConstant(cast<Constant>(subc)))
        return false;
    }
    return true;
  }
  return false;
}

There is a user-facing API to perform this lowering - llvm::ConstantFoldInstruction. Calls to llvm.is.constant that are still present after ConstantFoldInstruction are lowered in the backend lands with

case Intrinsic::is_constant: {
  // If is_constant hasn't folded away yet, lower it to false now.
  Constant *RetVal = ConstantInt::get(II->getType(), 0);
  resetIteratorIfInvalidatedWhileCalling(BB, [&]() {
    replaceAndRecursivelySimplify(CI, RetVal, TLInfo, nullptr);
  });
  return true;
}

So, my plan is to apply llvm::ConstantFoldInstruction to each call @llvm.is.constant.*() instruction in the bitcode and if the call is untouched, replace it with i1 0. Sounds good?

@jyn514
Copy link

jyn514 commented Jul 16, 2020

Another unsupported intrinsic:

KLEE: output directory is "/home/joshua/src/rust/saltwater/klee-out-0"
KLEE: Using STP solver backend
LLVM ERROR: Code generator does not support intrinsic function 'llvm.x86.sse2.pmovmskb.128'!

swcc.zip

@ccadar
Copy link
Contributor

ccadar commented Jul 30, 2020

@jyn514 Thanks, I added it to the list. We need to understand why these are not eliminated like other vectorized intrinsics.
@MartinNowack any thoughts?

@operasfantom
Copy link
Contributor

Another interesting group of intrinsics llvm.x86.sse42.crc32.* is not supported either. I would propose to use C++ equivalent based on Google's implementation .

@ccadar
Copy link
Contributor

ccadar commented Feb 18, 2021

@operasfantom thanks, I added them to the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature that should be implemented in KLEE LLVM upgrade
Development

No branches or pull requests

6 participants