Comments (3)
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.
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.
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)
- Support for LLVM 15? HOT 9
- The `Name` field of `GlobalVariable` could be a `String` HOT 4
- Read bitcode casuses stack overflow HOT 5
- Function declarations HOT 1
- Feature: Type sizes HOT 2
- Indexed type of `GetElementPtr` HOT 4
- The `Name` field of `GlobalAlias` could be a `String` HOT 2
- Linking fails with LLVM 12 HOT 2
- Opaque pointer type on llvm-13 causes segmentation fault HOT 1
- Doc request and question regarding where and how to align LLVM versions HOT 5
- Support for LLVM 16 HOT 1
- Global variables can be named with numbers HOT 3
- Missing git tags for v0.8.2, v0.9.0 HOT 1
- Test failures from LLVM C API accessor issues HOT 3
- Producing LLVM IR files HOT 1
- Are optimization passes implemented? HOT 2
- Support for LLVM 17 HOT 4
- Module::ThinLTO Summary
- Panic while parsing in llvm-ir-0.10.0/src/constant.rs:1503 HOT 2
- New release for LLVM 17? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llvm-ir.