ruby-llvm 17.0.0 → 18.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48dcc8621dc724981ca68f91f7daa86461fbe5a80c278d58d89645d3730f34cc
4
- data.tar.gz: a196abfcc5891316857476db99e8b734207d5dab498715ad8cd69bc8a1b69810
3
+ metadata.gz: 67a728c4318fe7c347dfc1d85e626c0c93c29011f329638585b8eac584cf0aff
4
+ data.tar.gz: 62e72a80da04ec235acc44fd6ef7027d3903e1b47ef59edc7e36e63b92a69296
5
5
  SHA512:
6
- metadata.gz: 735a272ae85c2a2a2a1d9cf1f13211a5404dfe7a0e118870f2335395f3e610f45b95c1212ffc3eceabc71e9e68aeb4d8140a416b42bb5918bd73319be723479d
7
- data.tar.gz: 11b93cfed8118fd90d0c885190c323dc2d61a404050385c62acb23fa900d8b7a39f8d5c61f78dd39be98979c9b7062f45b069c4185c8fec6a82337e8083a2d54
6
+ metadata.gz: 504c7b62dac6dbd58b072f53fc2a817b33ef6ac43a9234687c7f60ab62d29a1c9f4682cda8e0432aa96809989858c6028e5addb916997244283f249244e8b31c
7
+ data.tar.gz: 03a43636eeea68eb6a279a8f91d794704b8a572bb64b34baed9718778942863e461ae11d44107859264ffd6ede8d593217d3dab2eb8ebafb1bee4e9711122294
data/README.md CHANGED
@@ -14,7 +14,7 @@ computationally intensive algorithms on the fly.
14
14
  Current version
15
15
  ---------------
16
16
 
17
- This library currently binds to LLVM-15 (specifically llvm-c 15).
17
+ This library currently binds to LLVM-17 (specifically llvm-c 17).
18
18
 
19
19
  About version numbers
20
20
  ---------------------
@@ -30,10 +30,20 @@ extern "C" {
30
30
  llvm::InitializeNativeTargetAsmPrinter();
31
31
  }
32
32
 
33
+ // static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
34
+ // https://llvm.org/doxygen/classllvm_1_1Attribute.html
33
35
  const char* LLVMGetEnumAttributeNameForKind(const unsigned KindID) {
34
36
  const auto AttrKind = (llvm::Attribute::AttrKind) KindID;
35
37
  const auto S = llvm::Attribute::getNameFromAttrKind(AttrKind);
36
38
  return S.data();
37
39
  }
40
+
41
+ // std::string Attribute::getAsString(bool InAttrGrp = false) const
42
+ // https://llvm.org/doxygen/classllvm_1_1Attribute.html
43
+ // string must be disposed with LLVMDisposeMessage
44
+ const char* LLVMGetAttributeAsString(LLVMAttributeRef A) {
45
+ auto S = llvm::unwrap(A).getAsString();
46
+ return strdup(S.c_str());
47
+ }
38
48
  }
39
49
 
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
data/lib/llvm/config.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  # Generated by ruby-llvm. Please do not change this file by hand.
2
2
  module LLVM
3
3
  module CONFIG
4
- VERSION = "17.0.6"
5
- COMPONENTS = ["aarch64", "aarch64asmparser", "aarch64codegen", "aarch64desc", "aarch64disassembler", "aarch64info", "aarch64utils", "aggressiveinstcombine", "all", "all-targets", "amdgpu", "amdgpuasmparser", "amdgpucodegen", "amdgpudesc", "amdgpudisassembler", "amdgpuinfo", "amdgputargetmca", "amdgpuutils", "analysis", "arm", "armasmparser", "armcodegen", "armdesc", "armdisassembler", "arminfo", "armutils", "asmparser", "asmprinter", "avr", "avrasmparser", "avrcodegen", "avrdesc", "avrdisassembler", "avrinfo", "binaryformat", "bitreader", "bitstreamreader", "bitwriter", "bpf", "bpfasmparser", "bpfcodegen", "bpfdesc", "bpfdisassembler", "bpfinfo", "cfguard", "codegen", "codegentypes", "core", "coroutines", "coverage", "debuginfobtf", "debuginfocodeview", "debuginfodwarf", "debuginfogsym", "debuginfologicalview", "debuginfomsf", "debuginfopdb", "demangle", "dlltooldriver", "dwarflinker", "dwarflinkerparallel", "dwp", "engine", "executionengine", "extensions", "filecheck", "frontendhlsl", "frontendopenacc", "frontendopenmp", "fuzzercli", "fuzzmutate", "globalisel", "hexagon", "hexagonasmparser", "hexagoncodegen", "hexagondesc", "hexagondisassembler", "hexagoninfo", "instcombine", "instrumentation", "interfacestub", "interpreter", "ipo", "irprinter", "irreader", "jitlink", "lanai", "lanaiasmparser", "lanaicodegen", "lanaidesc", "lanaidisassembler", "lanaiinfo", "libdriver", "lineeditor", "linker", "loongarch", "loongarchasmparser", "loongarchcodegen", "loongarchdesc", "loongarchdisassembler", "loongarchinfo", "lto", "m68k", "m68kasmparser", "m68kcodegen", "m68kdesc", "m68kdisassembler", "m68kinfo", "mc", "mca", "mcdisassembler", "mcjit", "mcparser", "mips", "mipsasmparser", "mipscodegen", "mipsdesc", "mipsdisassembler", "mipsinfo", "mirparser", "msp430", "msp430asmparser", "msp430codegen", "msp430desc", "msp430disassembler", "msp430info", "native", "nativecodegen", "nvptx", "nvptxcodegen", "nvptxdesc", "nvptxinfo", "objcarcopts", "objcopy", "object", "objectyaml", "option", "orcjit", "orcshared", "orctargetprocess", "passes", "perfjitevents", "powerpc", "powerpcasmparser", "powerpccodegen", "powerpcdesc", "powerpcdisassembler", "powerpcinfo", "profiledata", "remarks", "riscv", "riscvasmparser", "riscvcodegen", "riscvdesc", "riscvdisassembler", "riscvinfo", "riscvtargetmca", "runtimedyld", "scalaropts", "selectiondag", "sparc", "sparcasmparser", "sparccodegen", "sparcdesc", "sparcdisassembler", "sparcinfo", "support", "symbolize", "systemz", "systemzasmparser", "systemzcodegen", "systemzdesc", "systemzdisassembler", "systemzinfo", "tablegen", "target", "targetparser", "textapi", "transformutils", "ve", "veasmparser", "vecodegen", "vectorize", "vedesc", "vedisassembler", "veinfo", "webassembly", "webassemblyasmparser", "webassemblycodegen", "webassemblydesc", "webassemblydisassembler", "webassemblyinfo", "webassemblyutils", "windowsdriver", "windowsmanifest", "x86", "x86asmparser", "x86codegen", "x86desc", "x86disassembler", "x86info", "x86targetmca", "xcore", "xcorecodegen", "xcoredesc", "xcoredisassembler", "xcoreinfo", "xray", "xtensa", "xtensaasmparser", "xtensacodegen", "xtensadesc", "xtensadisassembler", "xtensainfo"]
4
+ VERSION = "18.1.0"
5
+ COMPONENTS = ["aarch64", "aarch64asmparser", "aarch64codegen", "aarch64desc", "aarch64disassembler", "aarch64info", "aarch64utils", "aggressiveinstcombine", "all", "all-targets", "amdgpu", "amdgpuasmparser", "amdgpucodegen", "amdgpudesc", "amdgpudisassembler", "amdgpuinfo", "amdgputargetmca", "amdgpuutils", "analysis", "arm", "armasmparser", "armcodegen", "armdesc", "armdisassembler", "arminfo", "armutils", "asmparser", "asmprinter", "avr", "avrasmparser", "avrcodegen", "avrdesc", "avrdisassembler", "avrinfo", "binaryformat", "bitreader", "bitstreamreader", "bitwriter", "bpf", "bpfasmparser", "bpfcodegen", "bpfdesc", "bpfdisassembler", "bpfinfo", "cfguard", "codegen", "codegentypes", "core", "coroutines", "coverage", "debuginfobtf", "debuginfocodeview", "debuginfodwarf", "debuginfogsym", "debuginfologicalview", "debuginfomsf", "debuginfopdb", "demangle", "dlltooldriver", "dwarflinker", "dwarflinkerclassic", "dwarflinkerparallel", "dwp", "engine", "executionengine", "extensions", "filecheck", "frontenddriver", "frontendhlsl", "frontendoffloading", "frontendopenacc", "frontendopenmp", "fuzzercli", "fuzzmutate", "globalisel", "hexagon", "hexagonasmparser", "hexagoncodegen", "hexagondesc", "hexagondisassembler", "hexagoninfo", "hipstdpar", "instcombine", "instrumentation", "interfacestub", "interpreter", "ipo", "irprinter", "irreader", "jitlink", "lanai", "lanaiasmparser", "lanaicodegen", "lanaidesc", "lanaidisassembler", "lanaiinfo", "libdriver", "lineeditor", "linker", "loongarch", "loongarchasmparser", "loongarchcodegen", "loongarchdesc", "loongarchdisassembler", "loongarchinfo", "lto", "m68k", "m68kasmparser", "m68kcodegen", "m68kdesc", "m68kdisassembler", "m68kinfo", "mc", "mca", "mcdisassembler", "mcjit", "mcparser", "mips", "mipsasmparser", "mipscodegen", "mipsdesc", "mipsdisassembler", "mipsinfo", "mirparser", "msp430", "msp430asmparser", "msp430codegen", "msp430desc", "msp430disassembler", "msp430info", "native", "nativecodegen", "nvptx", "nvptxcodegen", "nvptxdesc", "nvptxinfo", "objcarcopts", "objcopy", "object", "objectyaml", "option", "orcdebugging", "orcjit", "orcshared", "orctargetprocess", "passes", "perfjitevents", "powerpc", "powerpcasmparser", "powerpccodegen", "powerpcdesc", "powerpcdisassembler", "powerpcinfo", "profiledata", "remarks", "riscv", "riscvasmparser", "riscvcodegen", "riscvdesc", "riscvdisassembler", "riscvinfo", "riscvtargetmca", "runtimedyld", "scalaropts", "selectiondag", "sparc", "sparcasmparser", "sparccodegen", "sparcdesc", "sparcdisassembler", "sparcinfo", "support", "symbolize", "systemz", "systemzasmparser", "systemzcodegen", "systemzdesc", "systemzdisassembler", "systemzinfo", "tablegen", "target", "targetparser", "textapi", "textapibinaryreader", "transformutils", "ve", "veasmparser", "vecodegen", "vectorize", "vedesc", "vedisassembler", "veinfo", "webassembly", "webassemblyasmparser", "webassemblycodegen", "webassemblydesc", "webassemblydisassembler", "webassemblyinfo", "webassemblyutils", "windowsdriver", "windowsmanifest", "x86", "x86asmparser", "x86codegen", "x86desc", "x86disassembler", "x86info", "x86targetmca", "xcore", "xcorecodegen", "xcoredesc", "xcoredisassembler", "xcoreinfo", "xray", "xtensa", "xtensaasmparser", "xtensacodegen", "xtensadesc", "xtensadisassembler", "xtensainfo"]
6
6
  TARGETS_BUILT = ["AArch64", "AMDGPU", "ARM", "AVR", "BPF", "Hexagon", "Lanai", "LoongArch", "Mips", "MSP430", "NVPTX", "PowerPC", "RISCV", "Sparc", "SystemZ", "VE", "WebAssembly", "X86", "XCore", "M68k", "Xtensa"]
7
7
  HOST_TARGET = "x86_64-pc-linux-gnu"
8
8
  BUILD_MODE = "RelWithDebInfo"
9
- CFLAGS = "-I/usr/lib/llvm-17/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
10
- CXXFLAGS = "-I/usr/lib/llvm-17/include -std=c++17 -fno-exceptions -funwind-tables -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
11
- LDFLAGS = "-L/usr/lib/llvm-17/lib"
9
+ CFLAGS = "-I/usr/lib/llvm-18/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
10
+ CXXFLAGS = "-I/usr/lib/llvm-18/include -std=c++17 -fno-exceptions -funwind-tables -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
11
+ LDFLAGS = "-L/usr/lib/llvm-18/lib"
12
12
  end
13
13
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLVM
4
+ # wrapper for LLVMAttributeRef
4
5
  class Attribute
5
6
 
6
7
  include PointerIdentity
@@ -98,7 +99,7 @@ module LLVM
98
99
  end
99
100
 
100
101
  def value
101
- return C.get_enum_attribute_value(self) if enum?
102
+ return enum_value if enum?
102
103
  return string_value if string?
103
104
  raise
104
105
  end
@@ -116,22 +117,52 @@ module LLVM
116
117
  end
117
118
 
118
119
  def inspect
119
- return "\"#{kind}\" = \"#{value}\"" if string?
120
- return "#{kind}(#{value})" if enum?
121
- super
120
+ to_s
122
121
  end
123
122
 
124
123
  def to_s
125
- return kind if enum?
126
- super
124
+ Support::C.get_attribute_as_string(self)
127
125
  end
128
126
 
129
127
  def kind_id
130
128
  enum_kind_id
131
129
  end
132
130
 
131
+ def ==(other)
132
+ super if self.class == other.class
133
+
134
+ # strings and symbols
135
+ return true if to_s == other.to_s
136
+
137
+ false
138
+ end
139
+
140
+ def readnone?
141
+ enum_kind == 'readnone' || (enum_kind == 'memory' && enum_value_mem_none?)
142
+ end
143
+
144
+ def readonly?
145
+ enum_kind == 'readonly' || (enum_kind == 'memory' && enum_value_mem_read?)
146
+ end
147
+
148
+ def writeonly?
149
+ enum_kind == 'writeonly' || (enum_kind == 'memory' && enum_value_mem_write?)
150
+ end
151
+
133
152
  private
134
153
 
154
+ def enum_value_mem_none?
155
+ (enum_value & 63).zero?
156
+ end
157
+
158
+ def enum_value_mem_read?
159
+ (enum_value & 21) != 0
160
+ end
161
+
162
+ def enum_value_mem_write?
163
+ (enum_value & 42) != 0
164
+ end
165
+
135
166
  def enum_kind_id
136
167
  C.get_enum_attribute_kind(self)
137
168
  end
@@ -140,6 +171,10 @@ module LLVM
140
171
  Support::C.get_enum_attribute_name_for_kind(enum_kind_id)
141
172
  end
142
173
 
174
+ def enum_value
175
+ C.get_enum_attribute_value(self)
176
+ end
177
+
143
178
  # wraps get_string_attribute_kind
144
179
  def string_kind
145
180
  FFI::MemoryPointer.new(:uint64) do |size_ptr|
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -189,7 +189,7 @@ module LLVM
189
189
  # Builds an unwind Instruction.
190
190
  # @LLVMinst unwind
191
191
  def unwind
192
- Instruction.from_ptr(C.build_unwind(self))
192
+ raise DeprecationError
193
193
  end
194
194
 
195
195
  # Generates an instruction with no defined semantics. Can be used to
@@ -24,6 +24,10 @@ module LLVM
24
24
  @ptr = nil
25
25
  end
26
26
 
27
+ def clone_module
28
+ Module.from_ptr(C.clone_module(self))
29
+ end
30
+
27
31
  def inspect
28
32
  {
29
33
  triple: triple,
@@ -60,6 +60,10 @@ module LLVM
60
60
  ConstantExpr.from_ptr(C.const_null(self))
61
61
  end
62
62
 
63
+ def poison
64
+ ConstantExpr.from_ptr(C.get_poison(self))
65
+ end
66
+
63
67
  # Creates a pointer type with this type and the given address space.
64
68
  def pointer(address_space = 0)
65
69
  Type.pointer(self, address_space)
@@ -364,8 +364,21 @@ module LLVM
364
364
  end
365
365
 
366
366
  # Creates a ConstantInt from an integer.
367
- def self.from_i(n, signed = true)
368
- from_ptr(C.const_int(type, n, signed ? 1 : 0))
367
+ def self.from_i(int, signed = true)
368
+ width = type.width
369
+ return type.poison if !fits_width?(int, width, signed)
370
+
371
+ from_ptr(C.const_int(type, int, signed ? 1 : 0))
372
+ end
373
+
374
+ # does int fit in width
375
+ # allow 1 for signed i1 (though really it's -1 to 0)
376
+ def self.fits_width?(int, width, signed)
377
+ if signed
378
+ int.bit_length < width || int == 1
379
+ else
380
+ int >= 0 && int.bit_length <= width
381
+ end
369
382
  end
370
383
 
371
384
  def self.parse(str, radix = 10)
@@ -442,22 +455,22 @@ module LLVM
442
455
 
443
456
  # Unsigned division.
444
457
  def udiv(rhs)
445
- raise "constant udiv removed in LLVM 15"
458
+ self.class.from_i(to_ui / rhs.to_ui, false)
446
459
  end
447
460
 
448
461
  # Signed division.
449
462
  def /(rhs)
450
- raise "constant sdiv removed in LLVM 15"
463
+ self.class.from_i(to_si / rhs.to_si, true)
451
464
  end
452
465
 
453
466
  # Unsigned remainder.
454
467
  def urem(rhs)
455
- raise "constant urem removed in LLVM 15"
468
+ self.class.from_i(to_ui % rhs.to_ui, false)
456
469
  end
457
470
 
458
471
  # Signed remainder.
459
472
  def rem(rhs)
460
- raise "constant srem removed in LLVM 15"
473
+ self.class.from_i(to_si % rhs.to_si, true)
461
474
  end
462
475
 
463
476
  # Boolean negation.
@@ -468,15 +481,16 @@ module LLVM
468
481
  alias not ~
469
482
 
470
483
  # Integer AND.
484
+ # was: self.class.from_ptr(C.const_and(self, rhs))
471
485
  def &(rhs)
472
- self.class.from_ptr(C.const_and(self, rhs))
486
+ self.class.from_i(to_i & rhs.to_i)
473
487
  end
474
488
 
475
489
  alias and &
476
490
 
477
491
  # Integer OR.
478
492
  def |(rhs)
479
- self.class.from_ptr(C.const_or(self, rhs))
493
+ self.class.from_i(to_i | rhs.to_i)
480
494
  end
481
495
 
482
496
  alias or |
@@ -528,25 +542,45 @@ module LLVM
528
542
  ConstantExpr.from_ptr(C.const_int_to_ptr(self, type))
529
543
  end
530
544
 
545
+ def to_ui
546
+ to_i(false)
547
+ end
548
+
549
+ def to_si
550
+ to_i(true)
551
+ end
552
+
531
553
  # constant zext
554
+ # was: self.class.from_ptr(C.const_z_ext(self, type))
532
555
  def zext(type)
533
- self.class.from_ptr(C.const_z_ext(self, type))
556
+ type.from_i(to_ui)
534
557
  end
535
558
 
536
559
  # constant sext
560
+ # was: self.class.from_ptr(C.const_s_ext(self, type))
537
561
  def sext(type)
538
- self.class.from_ptr(C.const_s_ext(self, type))
562
+ type.from_i(to_si)
539
563
  end
540
564
  alias_method :ext, :sext
541
565
 
542
566
  # constant trunc
567
+ # was: self.class.from_ptr(C.const_trunc(self, type))
543
568
  def trunc(type)
544
- self.class.from_ptr(C.const_trunc(self, type))
569
+ type.from_i(to_i)
545
570
  end
546
571
 
547
572
  # LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
573
+ # was: self.class.from_ptr(C.const_si_to_fp(self, type))
548
574
  def to_f(type)
549
- self.class.from_ptr(C.const_si_to_fp(self, type))
575
+ type.from_f(to_i.to_f)
576
+ end
577
+
578
+ def to_i(signed = true)
579
+ if signed
580
+ C.const_int_get_sext_value(self)
581
+ else
582
+ C.const_int_get_zext_value(self)
583
+ end
550
584
  end
551
585
  end
552
586
 
@@ -570,7 +604,7 @@ module LLVM
570
604
 
571
605
  # Native integer type
572
606
  bits = FFI.type_size(:int) * 8
573
- ::LLVM::Int = const_get("Int#{bits}")
607
+ ::LLVM::Int = const_get(:"Int#{bits}")
574
608
 
575
609
  # Creates a LLVM Int (subclass of ConstantInt) at the NATIVE_INT_SIZE from a integer (val).
576
610
  def self.Int(val)
@@ -600,27 +634,31 @@ module LLVM
600
634
 
601
635
  # Negation.
602
636
  def -@
603
- raise "constant fneg removed in LLVM 16"
637
+ self.class.from_f(-to_f)
604
638
  end
605
639
 
606
640
  # Returns the result of adding this ConstantReal to rhs.
607
641
  def +(rhs)
608
- raise "constant fadd removed in LLVM 15"
642
+ self.class.from_f(to_f + rhs.to_f)
643
+ end
644
+
645
+ def -(rhs)
646
+ self.class.from_f(to_f - rhs.to_f)
609
647
  end
610
648
 
611
649
  # Returns the result of multiplying this ConstantReal by rhs.
612
650
  def *(rhs)
613
- raise "constant fmul removed in LLVM 15"
651
+ self.class.from_f(to_f * rhs.to_f)
614
652
  end
615
653
 
616
654
  # Returns the result of dividing this ConstantReal by rhs.
617
655
  def /(rhs)
618
- raise "constant fdiv removed in LLVM 15"
656
+ self.class.from_f(to_f / rhs.to_f) # rubocop:disable Style/FloatDivision
619
657
  end
620
658
 
621
659
  # Remainder.
622
660
  def rem(rhs)
623
- raise "constant frem removed in LLVM 15"
661
+ self.class.from_f(to_f.divmod(rhs.to_f).last)
624
662
  end
625
663
 
626
664
  # Floating point comparison using the predicate specified via the first
@@ -647,19 +685,31 @@ module LLVM
647
685
 
648
686
  # constant FPToSI
649
687
  # LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
688
+ # was: self.class.from_ptr(C.const_fp_to_si(self, type))
650
689
  def to_i(type)
651
- self.class.from_ptr(C.const_fp_to_si(self, type))
690
+ type.from_i(to_f.to_i)
652
691
  end
653
692
 
654
693
  # Constant FPExt
655
694
  # this is a signed extension
695
+ # was: self.class.from_ptr(C.const_fp_ext(self, type))
656
696
  def ext(type)
657
- self.class.from_ptr(C.const_fp_ext(self, type))
697
+ type.from_f(to_f)
658
698
  end
659
699
  alias_method :sext, :ext
660
700
 
701
+ # was: self.class.from_ptr(C.const_fp_trunc(self, type))
661
702
  def trunc(type)
662
- self.class.from_ptr(C.const_fp_trunc(self, type))
703
+ type.from_f(to_f)
704
+ end
705
+
706
+ # get double from value
707
+ def to_f
708
+ double = nil
709
+ FFI::MemoryPointer.new(:bool, 1) do |loses_info|
710
+ double = C.const_real_get_double(self, loses_info)
711
+ end
712
+ double
663
713
  end
664
714
 
665
715
  end
@@ -846,6 +896,18 @@ module LLVM
846
896
  function_attributes.to_a
847
897
  end
848
898
 
899
+ def readnone?
900
+ attributes.detect(&:readnone?)
901
+ end
902
+
903
+ def readonly?
904
+ attributes.detect(&:readonly?)
905
+ end
906
+
907
+ def writeonly?
908
+ attributes.detect(&:writeonly?)
909
+ end
910
+
849
911
  def function_attributes
850
912
  AttributeCollection.new(self, -1)
851
913
  end
data/lib/llvm/core.rb CHANGED
@@ -195,6 +195,12 @@ module LLVM
195
195
  # * @see llvm::Value::getValueID()
196
196
  # */
197
197
  attach_function :get_value_kind, :LLVMGetValueKind, [:pointer], :value_kind
198
+
199
+ attach_function :get_poison, :LLVMGetPoison, [:pointer], :pointer
200
+
201
+ attach_function :const_int_get_sext_value, :LLVMConstIntGetSExtValue, [:pointer], :long_long
202
+
203
+ attach_function :const_int_get_zext_value, :LLVMConstIntGetZExtValue, [:pointer], :ulong_long
198
204
  end
199
205
 
200
206
  # Yields a pointer suitable for storing an LLVM output message.
data/lib/llvm/core_ffi.rb CHANGED
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -3049,24 +3049,6 @@ module LLVM::C
3049
3049
  # @scope class
3050
3050
  attach_function :const_nuw_mul, :LLVMConstNUWMul, [:pointer, :pointer], :pointer
3051
3051
 
3052
- # (Not documented)
3053
- #
3054
- # @method const_and(lhs_constant, rhs_constant)
3055
- # @param [FFI::Pointer(ValueRef)] lhs_constant
3056
- # @param [FFI::Pointer(ValueRef)] rhs_constant
3057
- # @return [FFI::Pointer(ValueRef)]
3058
- # @scope class
3059
- attach_function :const_and, :LLVMConstAnd, [:pointer, :pointer], :pointer
3060
-
3061
- # (Not documented)
3062
- #
3063
- # @method const_or(lhs_constant, rhs_constant)
3064
- # @param [FFI::Pointer(ValueRef)] lhs_constant
3065
- # @param [FFI::Pointer(ValueRef)] rhs_constant
3066
- # @return [FFI::Pointer(ValueRef)]
3067
- # @scope class
3068
- attach_function :const_or, :LLVMConstOr, [:pointer, :pointer], :pointer
3069
-
3070
3052
  # (Not documented)
3071
3053
  #
3072
3054
  # @method const_xor(lhs_constant, rhs_constant)
@@ -3105,24 +3087,6 @@ module LLVM::C
3105
3087
  # @scope class
3106
3088
  attach_function :const_shl, :LLVMConstShl, [:pointer, :pointer], :pointer
3107
3089
 
3108
- # (Not documented)
3109
- #
3110
- # @method const_l_shr(lhs_constant, rhs_constant)
3111
- # @param [FFI::Pointer(ValueRef)] lhs_constant
3112
- # @param [FFI::Pointer(ValueRef)] rhs_constant
3113
- # @return [FFI::Pointer(ValueRef)]
3114
- # @scope class
3115
- attach_function :const_l_shr, :LLVMConstLShr, [:pointer, :pointer], :pointer
3116
-
3117
- # (Not documented)
3118
- #
3119
- # @method const_a_shr(lhs_constant, rhs_constant)
3120
- # @param [FFI::Pointer(ValueRef)] lhs_constant
3121
- # @param [FFI::Pointer(ValueRef)] rhs_constant
3122
- # @return [FFI::Pointer(ValueRef)]
3123
- # @scope class
3124
- attach_function :const_a_shr, :LLVMConstAShr, [:pointer, :pointer], :pointer
3125
-
3126
3090
  # (Not documented)
3127
3091
  #
3128
3092
  # @method const_gep(constant_val, constant_indices, num_indices)
@@ -3152,78 +3116,6 @@ module LLVM::C
3152
3116
  # @scope class
3153
3117
  attach_function :const_trunc, :LLVMConstTrunc, [:pointer, :pointer], :pointer
3154
3118
 
3155
- # (Not documented)
3156
- #
3157
- # @method const_s_ext(constant_val, to_type)
3158
- # @param [FFI::Pointer(ValueRef)] constant_val
3159
- # @param [FFI::Pointer(TypeRef)] to_type
3160
- # @return [FFI::Pointer(ValueRef)]
3161
- # @scope class
3162
- attach_function :const_s_ext, :LLVMConstSExt, [:pointer, :pointer], :pointer
3163
-
3164
- # (Not documented)
3165
- #
3166
- # @method const_z_ext(constant_val, to_type)
3167
- # @param [FFI::Pointer(ValueRef)] constant_val
3168
- # @param [FFI::Pointer(TypeRef)] to_type
3169
- # @return [FFI::Pointer(ValueRef)]
3170
- # @scope class
3171
- attach_function :const_z_ext, :LLVMConstZExt, [:pointer, :pointer], :pointer
3172
-
3173
- # (Not documented)
3174
- #
3175
- # @method const_fp_trunc(constant_val, to_type)
3176
- # @param [FFI::Pointer(ValueRef)] constant_val
3177
- # @param [FFI::Pointer(TypeRef)] to_type
3178
- # @return [FFI::Pointer(ValueRef)]
3179
- # @scope class
3180
- attach_function :const_fp_trunc, :LLVMConstFPTrunc, [:pointer, :pointer], :pointer
3181
-
3182
- # (Not documented)
3183
- #
3184
- # @method const_fp_ext(constant_val, to_type)
3185
- # @param [FFI::Pointer(ValueRef)] constant_val
3186
- # @param [FFI::Pointer(TypeRef)] to_type
3187
- # @return [FFI::Pointer(ValueRef)]
3188
- # @scope class
3189
- attach_function :const_fp_ext, :LLVMConstFPExt, [:pointer, :pointer], :pointer
3190
-
3191
- # (Not documented)
3192
- #
3193
- # @method const_ui_to_fp(constant_val, to_type)
3194
- # @param [FFI::Pointer(ValueRef)] constant_val
3195
- # @param [FFI::Pointer(TypeRef)] to_type
3196
- # @return [FFI::Pointer(ValueRef)]
3197
- # @scope class
3198
- attach_function :const_ui_to_fp, :LLVMConstUIToFP, [:pointer, :pointer], :pointer
3199
-
3200
- # (Not documented)
3201
- #
3202
- # @method const_si_to_fp(constant_val, to_type)
3203
- # @param [FFI::Pointer(ValueRef)] constant_val
3204
- # @param [FFI::Pointer(TypeRef)] to_type
3205
- # @return [FFI::Pointer(ValueRef)]
3206
- # @scope class
3207
- attach_function :const_si_to_fp, :LLVMConstSIToFP, [:pointer, :pointer], :pointer
3208
-
3209
- # (Not documented)
3210
- #
3211
- # @method const_fp_to_ui(constant_val, to_type)
3212
- # @param [FFI::Pointer(ValueRef)] constant_val
3213
- # @param [FFI::Pointer(TypeRef)] to_type
3214
- # @return [FFI::Pointer(ValueRef)]
3215
- # @scope class
3216
- attach_function :const_fp_to_ui, :LLVMConstFPToUI, [:pointer, :pointer], :pointer
3217
-
3218
- # (Not documented)
3219
- #
3220
- # @method const_fp_to_si(constant_val, to_type)
3221
- # @param [FFI::Pointer(ValueRef)] constant_val
3222
- # @param [FFI::Pointer(TypeRef)] to_type
3223
- # @return [FFI::Pointer(ValueRef)]
3224
- # @scope class
3225
- attach_function :const_fp_to_si, :LLVMConstFPToSI, [:pointer, :pointer], :pointer
3226
-
3227
3119
  # (Not documented)
3228
3120
  #
3229
3121
  # @method const_ptr_to_int(constant_val, to_type)
@@ -3260,24 +3152,6 @@ module LLVM::C
3260
3152
  # @scope class
3261
3153
  attach_function :const_addr_space_cast, :LLVMConstAddrSpaceCast, [:pointer, :pointer], :pointer
3262
3154
 
3263
- # (Not documented)
3264
- #
3265
- # @method const_z_ext_or_bit_cast(constant_val, to_type)
3266
- # @param [FFI::Pointer(ValueRef)] constant_val
3267
- # @param [FFI::Pointer(TypeRef)] to_type
3268
- # @return [FFI::Pointer(ValueRef)]
3269
- # @scope class
3270
- attach_function :const_z_ext_or_bit_cast, :LLVMConstZExtOrBitCast, [:pointer, :pointer], :pointer
3271
-
3272
- # (Not documented)
3273
- #
3274
- # @method const_s_ext_or_bit_cast(constant_val, to_type)
3275
- # @param [FFI::Pointer(ValueRef)] constant_val
3276
- # @param [FFI::Pointer(TypeRef)] to_type
3277
- # @return [FFI::Pointer(ValueRef)]
3278
- # @scope class
3279
- attach_function :const_s_ext_or_bit_cast, :LLVMConstSExtOrBitCast, [:pointer, :pointer], :pointer
3280
-
3281
3155
  # (Not documented)
3282
3156
  #
3283
3157
  # @method const_trunc_or_bit_cast(constant_val, to_type)
@@ -3296,25 +3170,6 @@ module LLVM::C
3296
3170
  # @scope class
3297
3171
  attach_function :const_pointer_cast, :LLVMConstPointerCast, [:pointer, :pointer], :pointer
3298
3172
 
3299
- # (Not documented)
3300
- #
3301
- # @method const_int_cast(constant_val, to_type, is_signed)
3302
- # @param [FFI::Pointer(ValueRef)] constant_val
3303
- # @param [FFI::Pointer(TypeRef)] to_type
3304
- # @param [Integer] is_signed
3305
- # @return [FFI::Pointer(ValueRef)]
3306
- # @scope class
3307
- attach_function :const_int_cast, :LLVMConstIntCast, [:pointer, :pointer, :int], :pointer
3308
-
3309
- # (Not documented)
3310
- #
3311
- # @method const_fp_cast(constant_val, to_type)
3312
- # @param [FFI::Pointer(ValueRef)] constant_val
3313
- # @param [FFI::Pointer(TypeRef)] to_type
3314
- # @return [FFI::Pointer(ValueRef)]
3315
- # @scope class
3316
- attach_function :const_fp_cast, :LLVMConstFPCast, [:pointer, :pointer], :pointer
3317
-
3318
3173
  # (Not documented)
3319
3174
  #
3320
3175
  # @method const_select(constant_condition, constant_if_true, constant_if_false)
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
data/lib/llvm/lljit.rb ADDED
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'llvm/core'
4
+
5
+ module LLVM
6
+ # wrapper around LLVMOrcLLJITRef
7
+ class LLJit
8
+
9
+ # create lljit
10
+ # does not automatically dispose of lljit
11
+ # if lljit was disposed, that would dispose of builder
12
+ def initialize
13
+ builder = C.create_lljit_builder
14
+ FFI::MemoryPointer.new(FFI.type_size(:pointer)) do |ptr|
15
+ error = C.create_lljit(ptr, builder)
16
+ if error.null?
17
+ @ptr = ptr.read_pointer
18
+ else
19
+ message = C.get_error_message(error)
20
+ raise message
21
+ end
22
+ end
23
+ end
24
+
25
+ def triple_string
26
+ C.get_triple_string(ptr)
27
+ end
28
+
29
+ def data_layout
30
+ C.get_data_layout_str(ptr)
31
+ end
32
+
33
+ def global_prefix
34
+ gp = C.get_global_prefix(ptr)
35
+ gp.zero? ? "" : gp.chr
36
+ end
37
+
38
+ private
39
+
40
+ attr_reader :ptr
41
+
42
+ # currently returners pointer
43
+ def main_jit_dylib
44
+ C.main_jit_dylib(ptr)
45
+ end
46
+
47
+ module C
48
+ extend FFI::Library
49
+ ffi_lib_flags(:lazy, :global)
50
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
51
+
52
+ attach_function :create_lljit_builder, :LLVMOrcCreateLLJITBuilder, [], :pointer
53
+ attach_function :dispose_lljit_builder, :LLVMOrcDisposeLLJITBuilder, [:pointer], :void
54
+
55
+ # LLVMErrorRef LLVMOrcCreateLLJIT(LLVMOrcLLJITRef *Result, LLVMOrcLLJITBuilderRef Builder);
56
+ attach_function :create_lljit, :LLVMOrcCreateLLJIT, [:pointer, :pointer], :pointer
57
+
58
+ # LLVMErrorRef LLVMOrcDisposeLLJIT(LLVMOrcLLJITRef J);
59
+ attach_function :dispose_lljit, :LLVMOrcDisposeLLJIT, [:pointer], :pointer
60
+
61
+ # const char *LLVMOrcLLJITGetTripleString(LLVMOrcLLJITRef J);
62
+ attach_function :get_triple_string, :LLVMOrcLLJITGetTripleString, [:pointer], :string
63
+
64
+ # const char *LLVMOrcLLJITGetDataLayoutStr(LLVMOrcLLJITRef J);
65
+ attach_function :get_data_layout_str, :LLVMOrcLLJITGetDataLayoutStr, [:pointer], :string
66
+
67
+ # char LLVMOrcLLJITGetGlobalPrefix(LLVMOrcLLJITRef J);
68
+ attach_function :get_global_prefix, :LLVMOrcLLJITGetGlobalPrefix, [:pointer], :char
69
+
70
+ # LLVMOrcJITDylibRef LLVMOrcLLJITGetMainJITDylib(LLVMOrcLLJITRef J);
71
+ attach_function :get_main_jit_dylib, :LLVMOrcLLJITGetMainJITDylib, [:pointer], :pointer
72
+
73
+ # LLVMOrcResourceTrackerRef
74
+ # LLVMOrcJITDylibCreateResourceTracker(LLVMOrcJITDylibRef JD);
75
+ attach_function :dylib_create_resource_tracker, :LLVMOrcJITDylibCreateResourceTracker,
76
+ [:pointer], :pointer
77
+
78
+ # LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void);
79
+ attach_function :create_new_thread_safe_context, :LLVMOrcCreateNewThreadSafeContext,
80
+ [], :pointer
81
+
82
+ # LLVMOrcThreadSafeModuleRef
83
+ # LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M,
84
+ # LLVMOrcThreadSafeContextRef TSCtx);
85
+ attach_function :create_new_thread_safe_module, :LLVMOrcCreateNewThreadSafeContext,
86
+ [:pointer, :pointer], :pointer
87
+
88
+ # LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
89
+ # LLVMOrcJITDylibRef JD,
90
+ # LLVMOrcThreadSafeModuleRef TSM);
91
+ attach_function :add_llvm_ir_module, :LLVMOrcLLJITAddLLVMIRModule,
92
+ [:pointer, :pointer, :pointer], :pointer
93
+
94
+ # LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J,
95
+ # LLVMOrcResourceTrackerRef JD,
96
+ # LLVMOrcThreadSafeModuleRef TSM);
97
+ attach_function :add_llvm_ir_module_with_rt, :LLVMOrcLLJITAddLLVMIRModuleWithRT,
98
+ [:pointer, :pointer, :pointer], :pointer
99
+
100
+ # TODO: extract and combine with PassBuilder
101
+ attach_function(:get_error_message, :LLVMGetErrorMessage, [:pointer], :string)
102
+
103
+ attach_function(:dispose_error_message, :LLVMDisposeErrorMessage, [:string], :void)
104
+ end
105
+ end
106
+ end
data/lib/llvm/support.rb CHANGED
@@ -29,6 +29,7 @@ module LLVM
29
29
  :LLVMInitializeNativeAsmPrinter, [], :void
30
30
 
31
31
  attach_function :get_enum_attribute_name_for_kind, :LLVMGetEnumAttributeNameForKind, [:uint], :string
32
+ attach_function :get_attribute_as_string, :LLVMGetAttributeAsString, [:pointer], :string
32
33
  end
33
34
  end
34
35
 
data/lib/llvm/target.rb CHANGED
@@ -25,7 +25,7 @@ module LLVM
25
25
 
26
26
  module TargetModule
27
27
  extend FFI::Library
28
- ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
28
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
29
29
 
30
30
  def self.safe_attach_function(*args)
31
31
  attach_function(*args)
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -3,25 +3,26 @@
3
3
  module LLVM
4
4
  class PassBuilder # rubocop:disable Metrics/ClassLength
5
5
  extend FFI::Library
6
- ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
6
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
7
7
 
8
8
  attr_reader :passes
9
- attr_accessor :inliner_threshold
9
+ attr_accessor :inliner_threshold, :merge_functions
10
10
 
11
11
  # rubocop:disable Layout/LineLength
12
12
  OPT_PASSES = {
13
13
  '0' => 'always-inline,coro-cond(coro-early,cgscc(coro-split),coro-cleanup,globaldce),function(annotation-remarks),verify',
14
- '1' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline<only-mandatory>,inline,function-attrs<skip-non-recursive>,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,libcalls-shrinkwrap,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,memcpyopt,sccp,bdce,instcombine<max-iterations=1000;no-use-loop-info>,coro-elide,adce,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;vectorize-forced-only;>,loop-load-elim,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,vector-combine,instcombine<max-iterations=1000;no-use-loop-info>,loop-unroll<O1>,transform-warning,sroa<preserve-cfg>,instcombine<max-iterations=1000;no-use-loop-info>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
15
- '2' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline<only-mandatory>,inline,function-attrs<skip-non-recursive>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,aggressive-instcombine,constraint-elimination,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1000;no-use-loop-info>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,loop-load-elim,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,slp-vectorizer,vector-combine,instcombine<max-iterations=1000;no-use-loop-info>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,instcombine<max-iterations=1000;no-use-loop-info>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
16
- '3' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>,callsite-splitting),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline<only-mandatory>,inline,function-attrs<skip-non-recursive>,argpromotion,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,aggressive-instcombine,constraint-elimination,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1000;no-use-loop-info>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,loop-load-elim,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,slp-vectorizer,vector-combine,instcombine<max-iterations=1000;no-use-loop-info>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,instcombine<max-iterations=1000;no-use-loop-info>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
17
- 's' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline<only-mandatory>,inline,function-attrs<skip-non-recursive>,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,aggressive-instcombine,constraint-elimination,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1000;no-use-loop-info>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,loop-load-elim,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,slp-vectorizer,vector-combine,instcombine<max-iterations=1000;no-use-loop-info>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,instcombine<max-iterations=1000;no-use-loop-info>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
18
- 'z' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline<only-mandatory>,inline,function-attrs<skip-non-recursive>,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,aggressive-instcombine,constraint-elimination,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<no-header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1000;no-use-loop-info>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1000;no-use-loop-info>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<no-header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;vectorize-forced-only;>,loop-load-elim,instcombine<max-iterations=1000;no-use-loop-info>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,vector-combine,instcombine<max-iterations=1000;no-use-loop-info>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,instcombine<max-iterations=1000;no-use-loop-info>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
14
+ '1' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),always-inline,require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,libcalls-shrinkwrap,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,memcpyopt,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,coro-elide,adce,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O1>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
15
+ '2' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),always-inline,require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
16
+ '3' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>,callsite-splitting),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),always-inline,require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,argpromotion,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
17
+ 's' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),always-inline,require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,aggressive-instcombine,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
18
+ 'z' => 'annotation2metadata,forceattrs,inferattrs,coro-early,function<eager-inv>(lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,sroa<modify-cfg>,early-cse<>),openmp-opt,ipsccp,called-value-propagation,globalopt,function<eager-inv>(mem2reg,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),always-inline,require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,aggressive-instcombine,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<no-header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),deadargelim,coro-cleanup,globalopt,globaldce,elim-avail-extern,rpo-function-attrs,recompute-globalsaa,function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<no-header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>),globaldce,constmerge,cg-profile,rel-lookup-table-converter,function(annotation-remarks),verify',
19
19
  }.freeze
20
20
  # rubocop:enable Layout/LineLength
21
21
 
22
22
  def initialize
23
23
  @passes = []
24
24
  @inliner_threshold = nil
25
+ @merge_functions = nil
25
26
  end
26
27
 
27
28
  def add_function_pass
@@ -40,13 +41,21 @@ module LLVM
40
41
  # --Os - Like -O2 but size-conscious. Similar to clang -Os. Use -passes='default<Os>' for the new PM
41
42
  # --Oz - Like -O2 but optimize for code size above all else. Similar to clang -Oz. Use -passes='default<Oz>' for the new PM
42
43
  # @return self
43
- def o!(opt_level = '0')
44
+ def o!(opt_level = '0', options = {})
44
45
  opt_level = opt_level.to_s
45
- if inliner_threshold || !OPT_PASSES.key?(opt_level)
46
- add_pass("default<O#{opt_level}>")
47
- else
48
- add_pass(OPT_PASSES[opt_level].gsub(',inline,', ','))
46
+ expanded_pass = OPT_PASSES[opt_level]
47
+
48
+ if expanded_pass.nil?
49
+ return add_pass("default<O#{opt_level}>")
50
+ end
51
+
52
+ if options[:disable_inline]
53
+ expanded_pass = expanded_pass.gsub('devirt<4>(inline,', 'devirt<4>(')
49
54
  end
55
+ if options[:disable_always_inline]
56
+ expanded_pass = expanded_pass.gsub('always-inline,', '')
57
+ end
58
+ add_pass(expanded_pass)
50
59
  end
51
60
 
52
61
  # @return self
@@ -586,13 +595,13 @@ module LLVM
586
595
  def run(mod, target)
587
596
  return self if passes.empty?
588
597
 
589
- options = build_options
590
- error = C.run_passes(mod, pass_string, target, options)
598
+ error = with_options { |options| C.run_passes(mod, pass_string, target, options) }
591
599
  if !error.null?
592
- error_msg = get_error_message(error)
600
+ error_msg = C.get_error_message(error)
601
+ # TODO: clone then dispose of error_msg, currently produces "munmap_chunk(): invalid pointer"
593
602
  # save_message = error_msg.clone
594
- # dispose_error_message(error_msg)
595
- raise "There was an error: #{error_msg}"
603
+ # C.dispose_error_message(error_msg)
604
+ raise ArgumentError, error_msg
596
605
  end
597
606
  self
598
607
  end
@@ -636,23 +645,34 @@ module LLVM
636
645
 
637
646
  private
638
647
 
639
- def build_options
640
- options = C.create_pass_builder_options
648
+ attr_writer :passes
649
+
650
+ def deprecated(message)
651
+ warn message
652
+ self
653
+ end
641
654
 
655
+ # updates options parameter and returns it
656
+ def build_options!(options)
642
657
  if inliner_threshold
643
658
  C.set_inliner_threshold(options, inliner_threshold)
644
659
  end
645
660
 
661
+ if merge_functions
662
+ C.set_merge_functions(options, !!merge_functions)
663
+ end
664
+
646
665
  options
647
666
  end
648
667
 
649
- attr_writer :passes
650
-
651
- def deprecated(message)
652
- warn message
653
- self
668
+ # wraps creation and disposal of options in block
669
+ def with_options
670
+ options = C.create_pass_builder_options
671
+ build_options!(options)
672
+ yield options
673
+ ensure
674
+ C.dispose_pass_builder_options(options)
654
675
  end
655
-
656
676
  end
657
677
 
658
678
  module C
@@ -679,10 +699,14 @@ module LLVM
679
699
 
680
700
  attach_function :create_pass_builder_options, :LLVMCreatePassBuilderOptions, [], :pointer
681
701
 
702
+ attach_function :dispose_pass_builder_options, :LLVMDisposePassBuilderOptions, [:pointer], :void
703
+
682
704
  attach_function(:get_error_message, :LLVMGetErrorMessage, [:pointer], :string)
683
705
 
684
706
  attach_function(:dispose_error_message, :LLVMDisposeErrorMessage, [:string], :void)
685
707
 
686
708
  attach_function(:set_inliner_threshold, :LLVMPassBuilderOptionsSetInlinerThreshold, [:pointer, :int], :void)
709
+
710
+ attach_function(:set_merge_functions, :LLVMPassBuilderOptionsSetMergeFunctions, [:pointer, :bool], :void)
687
711
  end
688
712
  end
data/lib/llvm/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLVM
4
- LLVM_VERSION = "17"
5
- LLVM_REQUIRED_VERSION = "17.0"
6
- RUBY_LLVM_VERSION = "17.0.0"
4
+ LLVM_VERSION = "18"
5
+ LLVM_REQUIRED_VERSION = "18.1.3"
6
+ RUBY_LLVM_VERSION = "18.1.3"
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-llvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.0.0
4
+ version: 18.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Johnson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-02 00:00:00.000000000 Z
12
+ date: 2024-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -206,6 +206,7 @@ files:
206
206
  - lib/llvm/execution_engine_ffi.rb
207
207
  - lib/llvm/linker.rb
208
208
  - lib/llvm/linker_ffi.rb
209
+ - lib/llvm/lljit.rb
209
210
  - lib/llvm/support.rb
210
211
  - lib/llvm/target.rb
211
212
  - lib/llvm/target_ffi.rb