-
Notifications
You must be signed in to change notification settings - Fork 10
/
Todo.xml
1513 lines (1267 loc) · 43.9 KB
/
Todo.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml-stylesheet type="text/xsl" href="XSL/Todo.xsl" ?>
<topics
xmlns:r="http://www.r-project.org"
xmlns:c="http://www.C.org"
xmlns:sh="http://www.shell.org">
<title>Rllvm Todo List</title>
<topic>
<title>New</title>
<items>
<item>
Check sameType() and the extra check added to see if R_PointerType_hasSameElementTypeAs gives
the same results ALWAYS as the R code we have for ans = sameType(getElementType ....)
</item>
<item status="done">
Make certain all classes in llvm_class_of.h are exported
so getLLVMClassName() can get the class and put the right class on an Instruction.
See freeze.R.
<br/>
Issue was dependency of RLLVMClassName.o on llvm_classof_name.h. Fixed now.
</item>
<item>
Deal with MemIntrinsicBase - in llvm/IR/IntrinsicInst.h in TU/classof.R
</item>
<item>
MemMoveInst and the base classes.
See TU/.
MemMoveInst - MemTransferInst - MemTransferBase<MemIntrinsic> which is a TemplateC++Class.
But in RCIndex, MemTransferInst has an empty superClasses slot.
So have to fix this to get MemTransferBase.
MemTransferBase super class is the template parameter BaseCL. So MemIntrinsic.
MemIntrinsic's super class is MemIntrinsicBase<MemIntrinsic>.
Circular use of MemIntrinsic.
MemIntrinsicBase extends IntrinsicInst
</item>
<item>
Opaque pointers.
getElementType on a PointerType will fail.
See TU/R_createRef.R for an example.
</item>
<item>
Classes definitions for MemSetInst, MemCpyInst computed from the class hierarchy.
</item>
<item status="done">
get the default data layout and target machine for the current machine.
When read in a Module (parseIR or readBitcode), allow changing the data layout.
<br/>
getDataLayoutString() and createTargetMachine(). Can't easily get the DataLayout
as we get it from the TargetMachine_createDataLayout() method which returns a local object.
But the DataLayout string is probably sufficient for what we need.
<r:code>
a = parseIR("inst/IR/fib.ll")
b = parseIR("explorations/HowToUseLLJIT/fib.ir")
getDataLayout(b)
setDataLayout(a, getDataLayoutString())
getDataLayout(a)
</r:code>
</item>
<item>
Get the load (and install) time way down. Looks like it is not the enums but probably the classes.
Can we define them lazily.
<ol>
<li>Classes</li>
<li>size of .so</li>
<li>[done] number of symbols</li>
</ol>
</item>
<item>
Instead of changing SEXP types in copyFunction(),
what if when we read a Module, we swapped the sexp type in that
(if it exists) just once. Or just changed its name?
</item>
<item status="done">
See tests/coerceArgs.R.
When passing bool is 10L being sent as 0 because the last bit is 0. Yes, since passing 11 returns TRUE
for m$b0. Probably need to coerce to logical in R first.
<br/>
Coerce numeric to integer when Function being called shows that type! See RLLVMCompile/tests/select.R and
the commented out call to stopifnot(.llvm(gc, 20) == 4L). (line ~ 31).
</item>
<item status="done">
Have a return type of Int1Type be converted to a logical.
Rffi doesn't have such a type. So we have to arrange it here.
Currently we are mapping to and from Rllvm and Rffi the same in both directions.
Don't want to do this in this case. Get back a sint8 from Rffi but then convert to logical/Int1Type.
</item>
<item status="done">
Crashing in RLLVMCompile/tests/not.R when passing Int1Type. Fixed now
by mapping that to Rffi::uint32Type .
We'll see how portable and robust this is.
</item>
<item status="done">
Currently on a branch in Rlllvm to see if this works.
Also, turned off the message in src/library/methods/R/ for now.
See if we can import(RAutoGenRunTime) and export its operators for Enums.
EnumValue, GenericEnumValue
We don't actually use any functions other than these. | and &
</item>
<item>
Derived class and implementing methods.
compBook/ExportRCode/Subclass
</item>
<item status="low">
Instructions for CreateMalloc(), CreateFree(), etc. In Instructions.h in CallInst class.
These are not in IRBuilder so would have to create directly. Do we need them?
</item>
<item>
Build call graph for R source code. Show in D3.
</item>
<item>
Using LLJIT, we can call bar which calls foo.
Have to integrate this into the ExecutionEngine/.llvm framework.
<br/>
ExecutionSession
<br/>
Sort out getFunctionAddress(), twoMods.R and calling both bar and foo.
</item>
<item>
If use getFunctionAddress(), how do we lookup the Function to get the signature.
</item>
<item>
If use .llvm("foo", .ee = ee) can get the getFunctionAddress(), but how to get the Function
for the signature.
Think about better interface for .llvm and ee and routines. See mkEEFun.
<r:code>
ee = ExecEng(m, asFunction = TRUE)
ee("fun", arg1, arg2)
ee(fun, arg1, arg2) # fun as an assignment from fun = Function(...)
</r:code>
Need to be able to refer to global variables and find them with e[["var"]] or e$var
(although like to keep that to Functions, but maybe not necessary).
But a function is not subsettable so [[ doesn't work.
</item>
<item status="check">
Method for ExecutionEngine(list(mod1, mod2, mod3)) and add the other modules.
</item>
<item status="finish">
Build the table of routines for the R API so that we don't have to
define the functions but can copy the routines and the types into our modules
'passively'. createCall() now copies them for us.
<r:code>
r = readBitcode("~/R-4.1/build3/src/main/Rmain.bc")
m = Module()
sc = copyFunction(r$Rf_ScalarReal, m)
</r:code>
When building, have to deal with different versions, compiler flags, configuration options.
IRMakefile does this for us on each machine. But if we ship a prebuilt one, can be incompatabilities.
<br/>
Can build all the ir files and then combine them into one.
<sh:code>
cd Rllvm/src
R CMD make -f IRMakefile all.bc CFLAGS= CXXFLAGS=
</sh:code>
For R/src/main, says can't build xxxpr.ir (since no corresponding C file) so fails.
But we can link the all of the other .bc files
<sh:code>
llvm-link *.bc -o Rmain.bc
</sh:code>
<r:code>
r = readBitcode("~/R-4.1/build3/src/main/Rmain.bc")
</r:code>
There are 13475 entries in the Module (computed via names()) and 173 types.
</item>
<item status="done">
When creating a global string variable, allow specifying a name if the API allows it.
createConstant() doesn't take an id, but CreateStringGlobal allows it.
</item>
<item>
When generating accessor routines, generate R functions so that the user doesn't have to
explicitly call them .llvm() routines.
</item>
<item>
merge accessor generation from getrusageLLVM and generalize
routine to copy entire struct to R. Option to collapse type from list() if types are compatible.
Do this in compilation. compBook/getrusageLLVM/mkGlobalAccessors.R
</item>
<item>
See Chapter 7 of "Getting Started with LLVM Core Libraries book".
Note: llvmAddSymbol() doesn't seem necessary, at least for symbols in the the executable.
See if if llvm finds them automatically also for DLLs introduced into R session with dyn.load().
</item>
<item>
hide routines that are not defined but just declared, e.g. Rf_allocVector()
at least when printing Module, perhaps in
names() - no additional arguments, so only one setting.
ls() - extra argumemts.
Can we make them invisible in the module.
Perhaps use . prefix but map to regular name in llvmAddSymbol
</item>
<item status="check">
add offsets() and offset() functions to compute the offset into a struct.
Needs the names.
</item>
<item>
Allow R user to have an IRBuilder () object always
verify a Module() after each ir$create...
But don't want to warn about missing terminators.
So need to filter out some of the warnings.
Can we get them sequentially as a list()/character() and "class"ify them.
</item>
<item>
get attributes on parameters, e.g. byval
See tests/clang.ir and clangTraverseHandlers/clang.c
</item>
<item status="done">
Fix: remove the terminator and then setInsertPoint(ir, block), not on the last
instruction in the BasicBlock.
<br/>
Issue in clangTraverseHandlers/clang.R
with removing the terminator in a block and calling IRBuilder(block)
and then the new instructions go before the last call
</item>
<item status="done">
Changed Rffi to not define this generic but use RAutoGenRunTime's version.
<br/>
Fix setMethod for addFinalizer to specify where to avoid warnings.
Where is addFinalizer used within this package? Nowhere.
Coming from both Rffi and RAutoGenRunTime.
Can we get just the small collection of features from RAutoGenRunTime.
</item>
<item status="check">
Fix the class hierarchy programmatically. See TU/ 3 files. rclasses.R and rcheck.R are the closest.
<br/>
See TU/mkSetClass.R and the newly generated R/llvm*Classes.R files.
</item>
<item status="low">
Test what happens when returning, e.g. a REALSXPType.
In compBook/getrusage/mk.R, getting numeric vector that printed as ...-313
So not quite zero and not printing as zero.
See real.c to show this happens from C calls to numeric(2).
numeric() calls do_makevector and that Memzero's the result.
So we will need to do this or set all the values.
</item>
<item status="done">
Now checks the error message in the ExecutionEngine when calling
finalizeEngine() and if there is an error, raises an error.
When get the name of an external routine wrong and it doesn't exist (e.g. mkChar rather than Rf_mkChar)
then .llvm() call crashes R.
So test for these.
findCalledFunctions() now available to find all called functions.
Figure out what LLVM does before the first call to a routine in a Module in terms of
resolving the routines. MCJIT - chapter 7 of LLVM Core Libraries book.
If find made a mistake in name, can change all Uses of that routine.
See tests/noSymbol.R
That also shows how to check the names against R's bitcode module we made from src/main
and to guess the intended name if it is an R routine.
</item>
<item status="done">
Wasn't using the result of copyFunction() in createCall(), just creating it.
When copyFunction(), verifyModule() still gives errors about referencing a Function in another module.
See tests/noSymbol.R for sample code, but not quite the same
</item>
<item status="done">
Allow caller of .llvm to specify a more specific type, e.g. return type such as
pointerType(VoidType) to override pointerType(Int8Type) that the IR might generate
from C code. See tests/cifVoidPtr.R
</item>
<item status="ok">
Optimize() function fails. FunctionPassManager class now restored (was removed).
</item>
<item status="done">
Solution: when only a declaration, don't CloneFunctionInto - just create the declaration in the target module +
function. Seems to work. See compBook/getrusageLLVM/copyCrash.R and see explorations/copyCrash.R.
copyFunction failing in compBook/getrusageLLVM/mk.R.
Works in RSQLiteUDF/llvm4.R for simple fib function with basic types.
Perhaps the rusage and timeval structs?
</item>
<item status="done">
Implement getFunctionAddress() as replacement for getFunctionToPointer().
Calls finalizeObject() for ExecEngine for you.
</item>
<item status="done">
SEXPTypes.cpp-expt was the start of an experiment
to create subclasses of llvm::Type for the different SEXP types.
Bad idea.
</item>
<item status="check">
Implement handling second argument for dlsym.
Really should be using getNativeSymbolInfo if using an already loaded
DLL via dyn.load(), etc. and you have the DLLInfo or the handle.
Does make sense if character string, character vector (multiple entries and search sequentially),
and a DLL object.
</item>
<item status="done">
!! CloneFunctionInto
I was using the Argument and not their Type when creating the Function object before the clone.
+ *** Find out why cloneFunction.R segfaults. Could it be garbage collection and not our
CloneFunctionInto? Use different variable names to avoid garbage collecting and see if that
helps?
+ Is this a case
+ [verify seg fault is not ] Fix CloneFunctionInto in Function.cpp
</item>
<item status="done">fun.R and generating the code for llvm_type_classof_name.h.
Need to include VectorType as it is getting dropped out as it has sub-types.
</item>
<item status="done">
Get the names now. For DIDerivedType (e.g. typedef), getBaseType() gets the real type and
if that is a DICompositeType, we can get its elements and if the names are available
we use those for the names of the derived type's elements.
Why are there no names on the structs in Rmain.bc?
Actually, now 103 of thee 169 have no names, but 66 do, e.g. _DllInfo.
Some types are opaque, so okay not to have elements.
DIR is an example with no names when should. See platform.ir
DIR comes from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dirent.h
Looking at the debug nodes in platform.ir
<sh:output><![CDATA[
!2884 = !DIDerivedType(tag: DW_TAG_typedef, name: "DIR", file: !2885, line: 84, baseType: !2886)
!2885 = !DIFile(filename: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dirent.h", directory: "")
!2886 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !2885, line: 73, size: 1088, elements: !2887)
!2887 = !{!2888, !2889, !2890, !2891, !2892, !2893, !2894, !2895, !2896, !2906}
!2888 = !DIDerivedType(tag: DW_TAG_member, name: "__dd_fd", scope: !2886, file: !2885, line: 74, baseType: !19, size: 32)
]]></sh:output>
So DIR is a typedef, a derived type. The field/element names are on the struct to which the typedef points.
So !2884 gives the name DIR, but tag is typedef and baseType !2886.
!2886 is the struct type and the elements are !2887. And that array of debug pointers bring us first to
!2888 which is a field named __dd_fd.
<br/>
This raises the old issue which is do we want to keep DIR as a typedef and the struct to which
it refers separate or treat the struct as having name DIR.
Different occasions different needs, but here we want the field names from the struct
since we are connecting the fields to the name DIR.
<br/>
Problem with DICompositetype_getElements seg faulting
when getting the types of elements of a struct.
(Need to build the .ir/.bc files for Rmain.bc with -g. Fine if no debug info.)
Is this because the debug information is wrong as identified gcc! So different compilers. but probably versions of
clang?
No - still segfaults. (0x9)
But now I check whether the DINode is a DIType and only cast if it is to be able to get the name. Doesn't crash. But
no names. But still works for ~/compBook/getrusageLLVM/getrusage_info.ir. What's different about this? It is .bc
code. Were the llvm-link and the clang that generated the .ir and the llvm-as all the same version?
Yes. ~/local/bin/.
But maybe the .bc discards the names? No. Works on getrusage_info.bc
What about when we llvm-link. No, still seems to work.
<r:code>
r = readBitcode("~/R-4.1/build3/src/main/Rmain.bc")
rtypes = getTypes(r, TRUE)
</r:code>
lldb output:
<sh:output><![CDATA[
R_DICompositeType_getElements(r_obj=0x000000013dada0a0) at DebugInfoMeta.cpp:176:52
173 PROTECT(ans = NEW_LIST(nels));
174 PROTECT(names = NEW_CHARACTER(nels));
175 for(int i = 0; i < nels; i++) {
-> 176 const char *nm = ((llvm::DIType *)els[i])->getName().data();
^
177 if(nm)
178 SET_STRING_ELT(names, i, mkChar(nm));
179 SET_VECTOR_ELT(ans, i, R_createRef(els[i], "DINode"));
]]></sh:output>
</item>
</items>
</topic>
<topic>
<title>General</title>
<items>
<item status="check">
More specific classes for Type objects being returned. Same as Instruction class names.
</item>
<item>
Doubles as globals are printing as hexadecimal
</item>
<item>
Implement a getParamAttr() function.
</item>
<item>
Some of the scripts in tests/ are yielding
<r:output>
"This does not compile as-is for LLVM4.0 or higher"
</r:output>
</item>
<item>
tests/setGlobal.R When setting status to FALSE after setting to TRUE, not recovering the FALSE, but getting TRUE.
</item>
<item status="done">
Add the configure.in checks for the Pass.cpp and the HAVE_.....
</item>
<item status="done">
Add the configure.in checks for the Mem*Inst classes.
</item>
<item>
Version 7.0.1 - Value::dump() and Type::dump() symbols missing from the LLVM libraries when Rllvm.so is loaded.
</item>
<item status="works">
In tests/ addOne.R, getAssemblyCode(m) gives
<error>
"R_TargetMachine_addPassesToEmitFile" not resolved from current namespace (Rllvm)
</error>
It is #if 0'ed out in src/Target.cpp. Now reenabled and add a NULL value for the
third argument to addPassesToEmitFile() which is the raw_pwrite_stream *DwoOut parameter.
</item>
<item>
Is the subsetting for a BranchInst getting the target blocks in the wrong order?
<r:code>
m3 = parseIR("AnalyzeCCode/rpart.ir")
b = getBlocks(m3$rpart)
e = getTerminator(b[["for.body182"]], FALSE)
e[[2]]
e[[3]]
</r:code>
getSuccessors() gets them in the correct order.
But getOperands() puts them in the other order! It appears to just be that way. Use getSuccessors().
</item>
<item status="done">
See in Rllvm if we can run optimizer passes and then look at the resulting IR?
Does this even make sense? Specifically thinking of mem2reg and seeing the alloca disappear
and the phi nodes appear.
<br/>
Of course!
</item>
<item>
Compile the RCIndex collector update functions, e.g. readCppClasses. - Doesn't belong here.
</item>
</items>
</topic>
<topic>
<title>Things To Note</title>
<items>
<item>
Examine the assembler code generated. See tests/emitCode.R
</item>
<item status="done">
Compile against 3.9.1 - tests/addOne.R fails.
<br/>
Type of return doesn't match type of declared return type!
Is this a global context issue? No it is that the variable Add is not from
BinaryOps anymore but overwritten by a later enum.
<br/>
</item>
</items>
</topic>
<topic>
<title>LLVM 4.0</title>
<items>
<item>
Module.cpp and parseBitCodeFile - deal with the llvm::Expected object and error message.
</item>
</items>
</topic>
<topic>
<title>Main</title>
<items>
<item>
experiments/array.R doesn't seem to be working.
Getting the array "m" after calling foo() doesn't get the updated values.
</item>
<item status="done">
Should getTerminator() set the class from the actual class of the instruction or just use the generic TerminatorInst ?
<br/>
Now, Optionally done with genericClass = FALSE.
</item>
<item status="done">
Set the target on a module?
getDefaultTargetTriple() gets us the value. How to set it?
<br/>
setTargetTriple(mod, triple)
</item>
<item status="done">
<r:code>
str = getDataLayoutString()
setDataLayout(m, str)
</r:code>
<br/>
Add the target and datalayout string to a Module.
Needed for getAssemblyCode()
<br/>
getDefaultTargetTriple()
We can get the datalayout string with
tm = createTargetMachine()
.Call("R_TargetMachine_getDataLayoutString", tm)
Then how do we set it on the Module.
Do we set the DataLayout() itself. How do we get the DataLayout() as TargetMachine returns it not as a reference.
</item>
<item status="done">
Parsing a module from a string doesn't seem to want to work.
In the CompilerBook directory,
<r:code>
library(Rllvm)
m1 = parseIR("Rllvm/fib_basic_unoptimized.ll")
m2 = parseIR( as(m1, "character"), asText = TRUE)
</r:code>
We weren't release()'ing the unique pointer.
</item>
<item>
When printing a Function object (or Module, etc.) , check it is still valid.
</item>
<item status="done">
lapply/sapply methods for a block to loop over the instructions
</item>
<item status="done">
show() methods for Instructions and BasicBlock call llvmDump() ?
</item>
<item>
Allow putting comments on instructions, e.g., what the literal R type corresponds to symbolically STRSXP
<br/>
Use instruction-level metadata?
</item>
<item status="done">
parseIR() should raise an error if the file isn't there or the contents are empty or we don't get a Module back.
<br/>
Problem was system.file() returning "". So now check this.
</item>
<item status="verify">
getDataLayout - the C++ level object is on the stack so can't take its address and have it persist.
</item>
<item status="check">
Do we support putting metadata on an instruction. Appears not!
And on a function?
KindID, Kind and MDNode?
</item>
<item status="low">
Should setMetadata() return the NamedMDNode?
</item>
<item status="done">
Don't seem to be able to invoke routines with arbitrary signatures.
The runFunction routine in the MCJIT seems very limited.
We may have to use the Rffi/rdyncall package directly.
</item>
<item>
tests/metadata.R lists not working.
</item>
<item>
Avoid the duplicate enum variable names, e.g., Add in BinOp and BinaryOps. We need the second.
<br/>
Should we expose/include those for anonymous enums?
Which ones are actually used/needed? We can look through the methods we support and
their arguments and return types and look for enums.
<br/>
When there are duplicates, how do we want to handle this.
Consider the
BinaryOps::Add and BinOp::Add.
Clearly, we can have Add in the *Values vector for each.
The only issue is the "loose" variable Add for each which will conflict.
We could use the unusual/overloaded name
<r:code>
`BinOp::Add`
</r:code>
This is the name of a symbol in R
</item>
<item status="done">
parseIR("loop.ll") fails.
<br/>
Works fine if generated with the corresponding version of clang as the llvm used
by Rllvm.
<sh:code>
clang -S -emit-llvm loop.c -o loop.ll
</sh:code>
<c:code>
void
foo()
{
double x = 0;
while(1) {
x++;
}
}
</c:code>
</item>
<item status = "high">
tests/gep.R and uncomment the last line to create the GEP
<br/>
Works:
<pre>
tests/stringpointer.R
tests/stringpointer2.R
</pre>
</item>
<item status="check">
Verify we are using the MCJIT and machine code and not an interpreter.
<br/>
Use lldb? Compare speed?
<br/>
Sure seems like we are using it in terms of speed.
See the test code in src/mjit.c that we wrote to call test_fib multiple times.
We seem off by about 10%.
</item>
<item>
Sort out the new PassManager.
<br/>
<c:code><![CDATA[
llvm::PassManager<llvm::Function> PM;
]]></c:code>
</item>
<item>
Generate MIR code.
<br/>
See bottom of Module.cpp.
Do we need the new PassManager or the legacy::PassManager.
If the latter, then the add() method doesn't work since MIRPass is a FunctionPass, not a Pass.
If we use the new <![CDATA[PassManager<llvm::Function>]]>, then we
<br/>
Did we see this in llvm-src/tools/llc/llc.cpp? It seems to have been there, but not now.
See http://llvm-cs.pcc.me.uk/tools/llc/llc.cpp
</item>
<item>
Ensure enums are correct. (In RCIndex and RCUDA)
</item>
<item status="done">
Check the code that generates the raw assembler code (x86 instructions) properly terminates the string.
tests/emitCode.R or tests/addOne.R
<br/>
raw_svector_ostream doesn't ensure NULL terminated string. So we use mkCharLen().
</item>
<item status="check">
Fixed
<br/>
Some of the enums exceed the maximum integer size. Change how we generate the code to recognize this and leave them as
numeric. Change code that expects an integer to check and deal with the potentially larger values, i.e. don't convert
to int.
</item>
<item status="done">
accessor for a BranchInst object to be able to get the target block.
<br/>
Is this getSuccessors()
getOperands() or br[] gives the condition and blocks.
isConditional() determines whether this is a conditional branch
or a simple branch.
getCondition() gets the condition.
getNumSuccessors() counts the successors.
getSuccessors() gets all of them.
getSuccessor(b, i) gets the ith successor.
b[] gets all of the elements.
<br/>
ReturnInst doesn't have any successors.
</item>
<item status="check">
Implement R functions to call the Argument has* methods.
The C++ code exists. Added R functions and exported them.
</item>
<item>
Query parameters (or do we mean attributes?) on Argument.
</item>
<item>
Remove an attribute on a Argument or Function.
removeAttr() method in Argument.
Seems to need an AttributeList.
</item>
<item>
Methods to create the Instruction classes that were missing.
<r:output><![CDATA[
[1] "IndirectBrInst" "ResumeInst" "UnreachableInst"
[4] "FenceInst" "AtomicCmpXchgInst" "AtomicRMWInst"
[7] "TruncInst" "ZExtInst" "FPToUIInst"
[10] "FPToSIInst" "UIToFPInst" "SIToFPInst"
[13] "FPTruncInst" "FPExtInst" "PtrToIntInst"
[16] "IntToPtrInst" "BitCastInst" "ICmpInst"
[19] "FCmpInst" "PHINode" "SelectInst"
[22] "VAArgInst" "ExtractElementInst" "InsertElementInst"
[25] "ShuffleVectorInst" "ExtractValueInst" "InsertValueInst"
[28] "LandingPadInst"
]]></r:output>
</item>
<item status="done">
Do we need the specific methods for getOperands, etc.??
Don't think so!
</item>
<item>
Function[] returning too many values.
In RLLVMCompile in source("BML2.R"), the code
<r:code>
mapply(function(type, arg) {
if(isPointerType(type))
setParamAttributes(arg, LLVMAttributes["ReadOnly"])
}, argTypes[k], llvm.fun[idx])
</r:code>
gives different lengths for argTypes[k] and llvm.fun[idx].
</item>
<item>
Why does creating the passManager() with a module not
do the same thing as creating it with no module and then
call run(mgr, module)
</item>
<item>
test getCppClasses(). Use inst/TU/clang.R. Failing in assigning params for Links.
</item>
<item>
Setting attribute on an argument requires now to specify the
index of the argument, first argument starting at 1 in C++.
</item>
<item status="done">
Ways to get the specific instruction type,
e.g. when getOperand(), just get back generic Value object.
Could use dynamic casts and exhaustively find one that works!
<br/>
<r:code>
m = parseIR("findCalledFuns.ir")
b = getBlocks(m$opt)
sapply(b[], sapply, class)
sapply(getTerminator(b[[2]])[], class)
</r:code>
</item>
<item>
Build on Windows
</item>
<item status="done">
update the enums for 3.3. The TypeIDs were off. Manually fixed.
<br/>
Need to make the old ones for llvm 3.2 available for installation.
<br/>
BinaryOps, FuncAttributes, ICmpInst.Predicate (in ICmpEnums.R)
CastOps (Trunc, ZExt, etc.), IntrinsicIDs, TypeIDEnums,
LinkageType , CodeGenOpt, {VoidType, etc.} in typeDefs.R
</item>
<item>
See how to generate PTX from the IR.
http://llvm.org/docs/NVPTXUsage.html
</item>
<item status="done">
See how to generate C++ from the IR, and also PTX.
<br/>
Cannot do this.
</item>
<item>
reinforced random walk, BML examples
</item>
<item>
Make declareFunction accept a Type, list(Type, Type)
rather than just a single list() with the return type and parameter types.
</item>
<item>
When we read IR back into R, lose the specific SEXP type information on the function.
</item>
<item>
When converting SEXPs to and from GVs in C code,
use the actual target SEXP type and not just the generic type.
Similar/Related to registering routines with R and checking the types in a .Call().
</item>
<item>
When a parameter type is one of the SEXP types, then coerce the input to that type.
Perhaps too much overhead. Also, we just have the generic SEXPType
at this point. Could create derived C++ classes to represent the different types
or a single one that had the SEXP type(of). Then the types wouldn't necessarily be unique.
But can make it so. Just use a static method to get it for the different sexp types.
<br/>
Try to find a way to get the different SEXP types as their own
types but compatible with the generic SEXP type.
Could cast.
</item>
<item status="done">
How to handle a struct as a parameter.
Have to match the ABI.
Does it depend on the nature of the elements of the struct.
<br/>
See tests/struct.R and also the CXCursor example ( exists ? where?)
</item>
<item status="low">
[Needs to be implemented in LLVM]
Allow calling varargs functions directly.
See varargs.R
<r:code>
.llvm(pf, "result: %d ***\n", 34L)
</r:code>
Currently, runFunction in LLVM doesn't support this.
Assertion: "This doesn't support passing arguments through varargs (yet)!"
</item>
<item>
Add a finalizer routine to a Module and when we garbage collect it,
then we can call it.
This can release global variables in the module, e.g. regular expressions.
Have to ensure that no elements of the module are still assigned in R.
Maybe borrow code from RCIndex for reference counting.
</item>
<item status="finish">
R print method for Function to show the signature.
<r:func>getTypeName</r:func>.
Possibly for Module also, e.g. to show the names of the elements, perhaps their type.
</item>
<item>
get attributes for a Function object.
See funcAttributes.R.
Problem with a spurious number appearing at end 'nocapture align 1073741824'.
Are we setting these on the functions when we are supposed to be setting on a parameter.
If we just set NoUnwind, then things are fine.
really make sense.
Resulting IR cannot be read.
<br/>
[Done] How do we work with the AttrListPtr.
</item>
<item>
Allow Adding passes to the pass manager - e.g. the AlwaysInlinerPass.
addPass() function exists.
Constructors for different passes.
</item>
<item>
InitializeNVPTXTarget() and generating code for PTX.
See https://github.com/halide/Halide/blob/master/src/cllutil.c
<ol>
<li>initialize the NVPTXTarget.</li>
<li>set the triple on the module</li>
<li>lookupTarget(triple)</li>
<li>create and fill in a TargetOptions struct</li>
<li>create the TargetMachine object (TheTarget->createTargetMachine())</li>
<li>create, fill in and then run pass manager. Set targetLibraryInfo in the PassManager,
along with other information from the machine and module</li>
</ol>
How do we get the code back from LLVM so that we can pass it to CUDA?
How do we run the code on the GPU?
Can we use cuModuleLoadData?
Can we get the address of the function from the execution engine?
<br/>
See libNVVM.
</item>
<item status="done">
Should use the pointer for the global variable to set it,
just like we do when we get it. We need the type.
<r:code>
library(Rllvm)
InitializeNativeTarget()
mod = Module("global")
mod[["status"]] = TRUE
showModule(mod)
</r:code>
doesn't set the value if the variable has already been created.
It only sets it the first time.
Actually it creates a new variable with a 1 added to the name!
<r:code>
library(Rllvm)
InitializeNativeTarget()
mod = Module("global")
mod[["status"]] = TRUE
showModule(mod)
setInitializer(mod[["status"]], createLogicalConstant(FALSE))
showModule(mod)
mod[["status"]] = TRUE
</r:code>
<br/>
The getGlobalVariable() functions and the setting of these values
don't behave as expected. The get() function gets the initial value.
The set values don't set the variable if it already exists.
This will change in the future.
The get value doesn't get the new value, just the initialization value.
See tests/clone2.R
<br/>
This is probably just a mistaken understanding/analysis of the outcomes.
Need to use the same Execution Engine to see the changes.
</item>
<item status="done">
Fix getting function attributes for 3.2
(Getting back a list with an element for each attribute,
but each has the entire set.
Working on the slots.)
</item>
<item status="done">
[Basically done but ... and test with 3.2]
[need to update enums - AttrKind for FuncAttributes]
[configuration done]
sort out the changes to the Attributes and AttributeSet.
Determine in configure what we are dealing with and
set NEW_LLVM_ATTRIBUTES_SETUP appropriately