Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
52 views

I'm new to LLVM Backend development and I'm discovering some of its working by modifying an existing backend, compiling the llvm-project and observing the changes brought to the binaries and their ...
Ilyass's user avatar
  • 1
1 vote
0 answers
268 views

I have fetched LLVM-IR via clang -S -emit-llvm demo.c where demo.c is as follows int demo(int a, int b){ int c = a+b; return c; } The IR looks like define dso_local i32 @demo(i32 %0, i32 %1) #0 { %...
pralay das's user avatar
0 votes
1 answer
624 views

I'm relatively new to LLVM, and I'm attempting to generate LLVM IR that calls a C function (growDictionary). This is on x86_64 Linux, using llvm 12: $ llc-12 --version Ubuntu LLVM version 12.0.1 ...
Tudor Bosman's user avatar
2 votes
0 answers
559 views

I'm using the LLVM-C API for a compiler project and need to emit object code from IR to an in memory buffer. I'm aware the JIT can do this, but the resulting code will be executed many times with ...
muke's user avatar
  • 436
1 vote
1 answer
919 views

Trying to generate a very simple object file with LLVM-C. Unfortunately I'm still stuck on "TargetMachine can't emit a file of this type" tried reordering code and various things for CPU (x64-64, ...
Mirks's user avatar
  • 116
2 votes
0 answers
623 views

I have get an example llvm code from here. This code has some problems that I fixed them too. At this point, all it does is to dump the translated IR code. What I am after is to create an executable ...
ar2015's user avatar
  • 6,240
1 vote
0 answers
286 views

I have been trying to invoke my out-of-tree LLVM Function pass using clang (opt is not an option. Works fine with opt btw): clang -std=c99 -m64 -c -o file.o -DSPEC -DNDEBUG -Ispec_qsort -...
sk10's user avatar
  • 73
15 votes
1 answer
802 views

LLVM appears to ignore core::intrinsics::assume(..) calls. They do end up in the bytecode, but don't change the resulting machine code. For example take the following (nonsensical) code: pub fn one(...
llogiq's user avatar
  • 14.6k
7 votes
1 answer
664 views

I've written this very simple Rust function: fn iterate(nums: &Box<[i32]>) -> i32 { let mut total = 0; let len = nums.len(); for i in 0..len { if nums[i] > 0 { ...
Dathan's user avatar
  • 7,476
261 votes
2 answers
24k views

When running a sum loop over an array in Rust, I noticed a huge performance drop when CAPACITY >= 240. CAPACITY = 239 is about 80 times faster. Is there special compilation optimization Rust is ...
Guy Korland's user avatar
  • 9,598
422 votes
1 answer
54k views

As far as I know, reference/pointer aliasing can hinder the compiler's ability to generate optimized code, since they must ensure the generated binary behaves correctly in the case where the two ...
Zhiyao's user avatar
  • 4,514
575 votes
6 answers
42k views

I know that an "undefined behaviour" in C++ can pretty much allow the compiler to do anything it wants. However, I had a crash that surprised me, as I assumed that the code was safe enough. In this ...
Remz's user avatar
  • 3,428
2 votes
3 answers
669 views

The code is naive: use std::time; fn main() { const NUM_LOOP: u64 = std::u64::MAX; let mut sum = 0u64; let now = time::Instant::now(); for i in 0..NUM_LOOP { sum += i; } ...
Sanhu Li's user avatar
  • 457
10 votes
1 answer
564 views

I have a Box<dyn Any> and I know the underlying type so I want to optimize away the test in Box::downcast() (source). First I tried with std::hint::unreachable_unchecked(): pub unsafe fn ...
Tim Diekmann's user avatar
  • 8,604
1 vote
1 answer
148 views

If the loops are of the different type then I can easily identify them with the name but if there are multiple same type loops (say 5 while loops), how can I identify what basic block in the LLVM IR ...
Sanjit Kumar Mishra's user avatar
35 votes
3 answers
20k views

Executing rustc -C help shows (among other things): -C opt-level=val -- optimize with possible levels 0-3, s, or z The levels 0 to 3 are fairly intuitive, I think: the higher the level, the more ...
Lukas Kalbertodt's user avatar
16 votes
4 answers
6k views

I wrote a simple C++ function in order to check compiler optimization: bool f1(bool a, bool b) { return !a || (a && b); } After that I checked the equivalent in Rust: fn f1(a: bool, b: ...
Mariusz Jaskółka's user avatar
6 votes
4 answers
8k views

How can I ensure that a function with no side effects gets executed and doesn't get optimized away in stable Rust? Is there an attribute combination I could use, or must I call another function with ...
Doe's user avatar
  • 695
11 votes
3 answers
2k views

When writing integer functions in Rust which will run millions of times (think pixel processing), it's useful to use operations with the highest performance - similar to C/C++. While the reference ...
ideasman42's user avatar
  • 49.3k
142 votes
1 answer
36k views

Rust has an "inline" attribute that can be used in one of those three flavors: #[inline] #[inline(always)] #[inline(never)] When should they be used? In the Rust reference, we see an inline ...
WiSaGaN's user avatar
  • 48.3k
12 votes
1 answer
1k views

Starting with this simple C program: void nothing(void) {} int main() { int i; for (i = 0; i < 10; ++i) { nothing(); } return 0; } My passes output as follows: Note: IR statements ...
Ahmed Ghoneim's user avatar
21 votes
2 answers
4k views

I'm trying to benchmark some Rust code, but I can't figure out how to set the "ffast-math" option. % rustc -C opt-level=3 -C llvm-args='-enable-unsafe-fp-math' unrolled.rs rustc: Unknown command line ...
yong's user avatar
  • 3,643
13 votes
2 answers
4k views

I've got a compiler written with LLVM and I'm looking to up my ABI compliance. For example, I've found it hard to actually find specification documents for C ABI on Windows x86 or Linux. And the ones ...
Puppy's user avatar
  • 147k