Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
COMPILERS
HW-1
Sawar Sagwal (2017013)
Question 1
The gcc version was found by using the following command:
gcc --version
Output:
Question 2
The basic LLVM (without any additional support took time to install: 8
3min 29sec
Code for LLVM is written in c++. It can be compiled using a c++ compiler, here it was g++
compiler.
Question 3
The following test.c file was used:
#include <stdio.h>
void main()
{
int sum = 0;
for(int i = 0 ; i < 10000 ; ++i)
{
sum = sum + i;
}
}
x86_64:
a.out file format: ELF 64-bit, x86-64
0000000000001129 <main>:
1129: f3 0f 1e fa endbr64
112d: 55 push %rbp
112e: 48 89 e5 mov %rsp,%rbp
1131: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%rbp)
1138: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
113f: eb 0a jmp 114b <main+0x22>
1141: 8b 45 fc mov -0x4(%rbp),%eax
1144: 01 45 f8 add %eax,-0x8(%rbp)
1147: 83 45 fc 01 addl $0x1,-0x4(%rbp)
114b: 81 7d fc 0f 27 00 00 cmpl $0x270f,-0x4(%rbp)
1152: 7e ed jle 1141 <main+0x18>
1154: 90 nop
1155: 90 nop
1156: 5d pop %rbp
1157: c3 retq
1158: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
115f: 00
ARM:
a.out file format: ELF 64-bit, ARM
000000000000071c <main>:
71c: d10043ff sub sp, sp, #0x10
720: b9000bff str wzr, [sp, #8]
724: b9000fff str wzr, [sp, #12]
728: 14000008 b 748 <main+0x2c>
72c: b9400be1 ldr w1, [sp, #8]
730: b9400fe0 ldr w0, [sp, #12]
734: 0b000020 add w0, w1, w0
738: b9000be0 str w0, [sp, #8]
73c: b9400fe0 ldr w0, [sp, #12]
740: 11000400 add w0, w0, #0x1
744: b9000fe0 str w0, [sp, #12]
2
Question 6
Microarchitecture of machine’s processor: s kylake
Question 7
The following test.c file was used:
#include <stdio.h>
void main()
{
int sum = 0;
for(int i = 0 ; i < 100000000 ; ++i)
{
sum = sum + i;
}
}
Running test-raw and test-march, it was found that they had comparable compilation and
execution time. This is because the performance boost by optimisation through the march
option is insignificant for small programs. This option can be useful for compiling code to
run on IoT devices.
3