File tree 6 files changed +69
-0
lines changed
6 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* .ll
2
+ /* .o
3
+ /order-a
4
+ /order-b
5
+ /order-c
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ CLANG=clang++
4
+ COMPILE_OPTS=' -c -Wall -Werror -O3'
5
+
6
+ ${CLANG} -v
7
+
8
+ ${CLANG} ${COMPILE_OPTS} source-a.cpp -o source-a.o
9
+ ${CLANG} ${COMPILE_OPTS} source-b.cpp -o source-b.o
10
+ ${CLANG} ${COMPILE_OPTS} main.cpp -o main.o
11
+
12
+ ${CLANG} ${COMPILE_OPTS} source-a.cpp -emit-llvm -S -o source-a.ll
13
+ ${CLANG} ${COMPILE_OPTS} source-b.cpp -emit-llvm -S -o source-b.ll
14
+ ${CLANG} ${COMPILE_OPTS} main.cpp -emit-llvm -S -o main.ll
15
+
16
+ ${CLANG} main.o source-b.o source-a.o -o order-a
17
+ ${CLANG} main.o source-a.o source-b.o -o order-b
18
+ ${CLANG} source-a.o source-b.o main.o -o order-c
Original file line number Diff line number Diff line change
1
+ #ifndef __HEADER_HPP
2
+ #define __HEADER_HPP
3
+
4
+ #include < cstdint>
5
+
6
+ struct IntegerPair ;
7
+
8
+ bool always_false (unsigned );
9
+
10
+ inline unsigned __attribute__ ((noinline)) maybe_divide(unsigned *ptr) {
11
+ unsigned val = 500 / ptr[0 ];
12
+ if (always_false (val))
13
+ return val;
14
+ return (unsigned )((intptr_t )ptr);
15
+ }
16
+
17
+ #endif // __HEADER_HPP
Original file line number Diff line number Diff line change
1
+ #include < cstdlib>
2
+
3
+ unsigned caller_a (unsigned *ptr);
4
+
5
+ int main () {
6
+ unsigned *ptr = new unsigned [1 ];
7
+ ptr[0 ] = 0 ;
8
+ caller_a (ptr);
9
+ delete[] ptr;
10
+ return 0 ;
11
+ }
Original file line number Diff line number Diff line change
1
+ #include " header.hpp"
2
+
3
+ bool always_false (unsigned ) { return false ; }
4
+
5
+ unsigned caller_a (unsigned *ptr) {
6
+ ptr[0 ] = 10 ;
7
+ unsigned k = maybe_divide (ptr);
8
+ ptr[0 ] = 20 ;
9
+ return k;
10
+ }
Original file line number Diff line number Diff line change
1
+ #include " header.hpp"
2
+
3
+ unsigned caller_b (unsigned *ptr) {
4
+ ptr[0 ] = 10 ;
5
+ unsigned k = maybe_divide (ptr);
6
+ ptr[0 ] = 20 ;
7
+ return k;
8
+ }
You can’t perform that action at this time.
0 commit comments