This repository was archived by the owner on Oct 21, 2024. It is now read-only.
Commit 52255a1
ARROW-7819: [C++][Gandiva] Add DumpIR to Filter/Projector object
The following patch exposes the generated IR as a method of the objects
for further inspection. This is a breaking change for the internal
method `FinalizeModule` which doesn't take the dump_ir and optimize
flags, it receives `optimize` from Configuration now.
- Refactored Engine, notably removed dead code, organized init in a single
function and simplified LLVMGenerator.
- Dumping IR should not write to stdout, but instead return it as a
string in the `DumpIR` method.
- Refactored Types, fixing some bad methods type.
- Added the optimize field to `Configuration` class.
- Simplified some unit tests.
But more importantly, we can now inspect dynamically:
```python
>>> filter = gandiva.make_filter(table.schema, condition)
>>> print(filter.ir)
; ModuleID = 'codegen'
source_filename = "codegen"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer
@_ZN5arrow7BitUtilL8kBitmaskE = internal unnamed_addr constant [8 x i8] c"\01\02\04\08\10 @\80", align 1
; Function Attrs: norecurse nounwind
define i32 @expr_0_0(i64* nocapture readonly %args, i64* nocapture readonly %arg_addr_offsets, i64* nocapture readnone %local_bitmaps, i16* nocapture readnone %selection_vector, i64 %context_ptr, i64 %nrecords) local_unnamed_addr #0 {
entry:
%0 = bitcast i64* %args to i8**
%cond_mem56 = load i8*, i8** %0, align 8
%1 = getelementptr i64, i64* %arg_addr_offsets, i64 3
%2 = load i64, i64* %1, align 8
%a_mem_addr = getelementptr i64, i64* %args, i64 3
%3 = bitcast i64* %a_mem_addr to double**
%a_mem7 = load double*, double** %3, align 8
%scevgep = getelementptr double, double* %a_mem7, i64 %2
br label %loop
loop: ; preds = %loop, %entry
%loop_var = phi i64 [ 0, %entry ], [ %"loop_var+1", %loop ]
%scevgep8 = getelementptr double, double* %scevgep, i64 %loop_var
%a = load double, double* %scevgep8, align 8
%4 = fcmp olt double %a, 1.000000e+03
%5 = sext i1 %4 to i8
```
Closes apache#6417 from fsaintjacques/ARROW-7819-gandiva-dump-ir-tool and squashes the following commits:
c8d274f <François Saint-Jacques> Address comments
0bcebc8 <François Saint-Jacques> ARROW-7819: Add DumpIR to Filter/Projector object
Authored-by: François Saint-Jacques <fsaintjacques@gmail.com>
Signed-off-by: Wes McKinney <wesm+git@apache.org>1 parent 6e14384 commit 52255a1
File tree
16 files changed
+286
-285
lines changed- cpp/src/gandiva
- python/pyarrow
- includes
- tests
16 files changed
+286
-285
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
61 | 66 | | |
62 | 67 | | |
63 | 68 | | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| 73 | + | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 80 | + | |
| 81 | + | |
77 | 82 | | |
78 | | - | |
79 | 83 | | |
80 | | - | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
86 | | - | |
87 | 90 | | |
88 | 91 | | |
89 | | - | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
119 | 106 | | |
120 | | - | |
| 107 | + | |
121 | 108 | | |
122 | | - | |
123 | | - | |
| 109 | + | |
| 110 | + | |
124 | 111 | | |
125 | | - | |
126 | | - | |
127 | | - | |
| 112 | + | |
| 113 | + | |
128 | 114 | | |
129 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
130 | 150 | | |
131 | 151 | | |
132 | 152 | | |
| |||
191 | 211 | | |
192 | 212 | | |
193 | 213 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 214 | + | |
| 215 | + | |
201 | 216 | | |
202 | | - | |
| 217 | + | |
203 | 218 | | |
204 | 219 | | |
205 | 220 | | |
| |||
222 | 237 | | |
223 | 238 | | |
224 | 239 | | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | 240 | | |
| 241 | + | |
234 | 242 | | |
235 | 243 | | |
236 | 244 | | |
| |||
249 | 257 | | |
250 | 258 | | |
251 | 259 | | |
252 | | - | |
253 | | - | |
254 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
255 | 264 | | |
256 | 265 | | |
257 | 266 | | |
258 | 267 | | |
259 | 268 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
264 | 272 | | |
265 | | - | |
| 273 | + | |
266 | 274 | | |
267 | 275 | | |
268 | 276 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
38 | | - | |
39 | 36 | | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
44 | | - | |
| 41 | + | |
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
49 | 46 | | |
50 | 47 | | |
51 | | - | |
| 48 | + | |
52 | 49 | | |
53 | 50 | | |
54 | 51 | | |
| |||
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
62 | | - | |
| 59 | + | |
63 | 60 | | |
64 | 61 | | |
65 | 62 | | |
| |||
68 | 65 | | |
69 | 66 | | |
70 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
75 | 78 | | |
76 | | - | |
77 | 79 | | |
78 | | - | |
79 | 80 | | |
80 | | - | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | 93 | | |
96 | 94 | | |
97 | | - | |
98 | 95 | | |
99 | | - | |
100 | | - | |
| 96 | + | |
| 97 | + | |
101 | 98 | | |
102 | 99 | | |
103 | 100 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 101 | + | |
| 102 | + | |
109 | 103 | | |
110 | 104 | | |
111 | 105 | | |
| |||
0 commit comments