GithubHelp home page GithubHelp logo

Comments (3)

cdisselkoen avatar cdisselkoen commented on August 21, 2024

A great question, thanks for reporting!

Currently, llvm-ir relies on the LLVM C API function LLVMConstIntGetZExtValue(), which in turn calls the C++ function llvm::ConstantInt::getZExtValue(), which fails with assert() if the constant value doesn't fit in 64 bits. (Larger constants are fine if they have all zeroes in the bits higher than 64.) So, to answer the "what happens" question, I believe that if your 128-bit constant integer has all zeroes in the upper 64 bits (so, if it is less than 2^64) then the value in the Constant::Int represents the true 128-bit constant value; but if the 128-bit constant integer doesn't fit in 64 bits, then Module::from_bc_path() will fail.

I may be missing something, but it looks to me at first glance that the LLVM C API doesn't have a function to get the values of larger constant integers. This may be part of the same family of problems discussed in our README in the Limitations section (see also LLVM bug 42692). If that is indeed the case, then the fix here will have to be to submit a patch to LLVM adding a function or functions to the LLVM C API. On first glace, I think the C API function should probably use llvm::ConstantInt::getValue() and then somehow expose the resulting llvm::APInt over the C interface. If you're interested in working on this, by all means go for it!

from llvm-ir.

phi-go avatar phi-go commented on August 21, 2024

Thank you for the fast and comprehensive answer!
For my use case this is actually a reasonable state of things.

If my project, that I'm using this library for, works out, I will probably take some time to look at removing some limitations.
However, until then I can't promise that I will find time to do so.

I guess we should leave this issue open, until someone gets around to it.

from llvm-ir.

cdisselkoen avatar cdisselkoen commented on August 21, 2024

I'm happy leaving this open until someone gets around to it (doesn't have to be you). I might make a note in our Limitations section or in the Constant docs. Thanks for the report!

from llvm-ir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.