Skip to main content

All Questions

Filter by
Sorted by
Tagged with
-3 votes
2 answers
78 views

does new compilers turn the source code into a binary or do they just transpile and hand it over to another compiler [closed]

does new compilers (e.g. the rust compiler or zig compiler) turn the source code into another language (e.g. C) and let that languages compiler (e.g. gcc) spit out the exe or do they do everything all ...
gone wrong help's user avatar
0 votes
3 answers
144 views

When inlining a C function, can an optimizing compiler dereference a pointer more times than explicitly written in the source code?

Consider the following code: int y = 1; int* p = &y; inline int f(int x) { return x + x; } int g(void) { return f(*p); } In this code, there is one explicit dereference. Is a C compiler ...
john smith's user avatar
0 votes
0 answers
21 views

why in calling a function by GCC convention , the passed parameters are stored in a reversed order in the stack

Can you help me answer this question. I have tried to figure this out by myself but didn't succeed. Is it because we don't know the amount of memory the function will use ?
sallyaaa's user avatar
1 vote
1 answer
134 views

What is the reasoning behind this boilerplate start-up code?

Here's a snippet from disassembled output of a simple program with gcc on Linux: 400478: ff 15 6a 0b 20 00 callq *0x200b6a(%rip) # 600fe8 <__libc_start_main@GLIBC_2.2.5> ...
user129393192's user avatar
0 votes
0 answers
267 views

How to compile to RISC-V?

I'm writing the final stage for my compiler to riscv; however, I have run into a minor issue of figuring out what the start point of the program is. Are we guaranteed that the PC starts execution with ...
user129393192's user avatar
1 vote
0 answers
58 views

Unknown type name ‘Node’ in the parser file. (Yacc program)

I've been working on a Yacc program (parser.y) to develop a small compiler that handles arithmetic operations. I'm using Yacc (Bison) and Lex tools to generate the parser and lexical analyzer, ...
Don R's user avatar
  • 41
0 votes
1 answer
33 views

Where can I find the body of the function pointed to by the function pointer of cfg_hooks in gcc source code?

In gcc cfghooks.cc void predict_edge (edge e, enum br_predictor predictor, int probability) { if (!cfg_hooks->predict_edge) internal_error ("%s does not support predict_edge", ...
yinghao's user avatar
2 votes
0 answers
137 views

Write a gcc plugin that inserts macros at the beginning of each function

I understand that I can use __cyg_profile_func_enter and -finstrument-functions to insert code, but is it possible to insert macros by writing a gcc plugin? Is there any documentation or possibly an ...
Coloda's user avatar
  • 39
3 votes
0 answers
90 views

With gcc -O3 optimization, why does the loop index's type affect gcc's internal GIMPLE vector constants (but not the final asm)?

I created a struct array, and here is my source code. #include <stdio.h> #include <stdlib.h> #define N 256 typedef struct arc { int num; } arc_t; typedef double cost_t; typedef ...
Daisy G's user avatar
  • 31
6 votes
3 answers
525 views

Why don't compilers inline everything, analyze it and then generate their own optimized functions?

Problem summary I'm trying to do an in-memory database with transactions. I'm reaching bottlenecks on compiler level, specifically inlining limit. I don't have much knowledge about compilers and I ...
user1576055's user avatar
0 votes
0 answers
37 views

Which gcc O2 option do this constant folding?

I am not familiar with gcc,this code: int a=145;int b=267+a; printf("%d/n",b); if comiple with no optimize option,will use the "addl" command,but if open O2 option,it will show me ...
wang kai's user avatar
  • 1,747
0 votes
1 answer
271 views

DWARF output differs between compiler versions

I compile an ELF file including debug info and then read the debug-info back and parse it to get a list of all variables (global variables and class variables) in the RAM. This already works with the ...
Martin's user avatar
  • 31
1 vote
1 answer
105 views

Why doesn't the generated GCC code for array allocation and access follow the `movl (%rdx, %rcx, 4), %eax` formula?

I am thinking about how to compile arrays in x86-64 assembly. I am reading "Computer Systems - A Programmer's Perspective" and the authors give the following formula: E[i] -> `movl (%rdx,...
chez93's user avatar
  • 157
2 votes
3 answers
498 views

Why do compilers perform aliasing if it slows runtime performance?

I've been learning C and computer science topics out of pure interest and it's led me to becoming interested in compilers. Everything I've read tells me that aliasing results in slower assembly output ...
eyeseaevan's user avatar
1 vote
0 answers
118 views

Why does the compiler need the intermediate representations for link time optimization?

My professor mentioned that gcc can be run with -flto. I am wondering why the intermediary (GIMPLE in GCC case) are needed. Why is the assembly not sufficient? He mentioned that this allows the ...
cspurposesonly's user avatar

15 30 50 per page
1
2 3 4 5
13