Code Snippets LLVM

Short texts LLVM 🧑‍💻 Code snippets LLVM ✍️ Reading lists LLVM 👀

SROA-input-11.ll

;*** IR Dump After Combine redundant instructions *** (function: _ZN8cuforces12forcesDeviceI13forces_paramsIL10KernelType3EL14SPHFormulation1EL20DensityDiffusionType3EL12BoundaryType4E12FullViscSpecIL12RheologyType0EL15TurbulenceModel1EL26ComputationalViscosityType0EL12ViscousModel0EL15AverageOperator0ELm517ELb0EELm517EL12ParticleType1ELSD_0EL7RunMode1ELb0ELb0ELb0ELb0E5emptyI18xsph_forces_paramsESF_I20volume_forces_paramsESF_I21grenier_forces_paramsESF_I25sa_boundary_forces_paramsESF_I28dummy_boundary_forces_paramsESF_I25water_depth_forces_paramsESF_I18keps_forces_paramsESF_I14tau_tex_paramsESF_I22eulerVel_forces_paramsESF_I29internal_energy_forces_paramsESF_I28effective_visc_forces_paramsEELS2_3ELS3_1ELS4_3ELS5_4ESC_Lm517ELSD_1ELSD_0EEEvT_) ; ModuleID = ‘reduced.ll.ll’ source_filename = “” target datalayout = “e-i64:64-i128:128-v16:16-v32:32-n16:32:64” target triple = “nvptx64-nvidia-cuda” %struct.char3 = type { i8, i8, i8 } %”class.cuneibs::neiblist_iterator_core” = type %struct.float4 = type { float, float, float, float } %struct.int3 = type { i32, i32, i32 } %struct.float3 = […]

https://github.com/ClangBuiltLinux/linux/issues/1302 reduction

long hweight_long_w; amd_numa_init_nb, amd_numa_init_base, amd_numa_init_limit; static hweight_long() { return __builtin_constant_p(hweight_long_w) ? (hweight_long_w & 1) + hweight_long_w + !(hweight_long_w & 2) + !(hweight_long_w & 3) + !!(hweight_long_w & 4) + !!hweight_long_w 8 > 3) + !(hweight_long_w >> 4) + 5 + !(hweight_long_w >> 6) + !(hweight_long_w >> 7) + hweight_long_w >> 6 & !(hweight_long_w >> 1) […]

main_O0.ll

; ModuleID = ‘main.c’ source_filename = “main.c” target datalayout = “e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128” target triple = “x86_64-unknown-linux-gnu” @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__sym_ctor, i8* null }] ; Function Attrs: noinline nounwind optnone sspstrong uwtable define i32 @main() #0 { […]

main_O3.ll

; ModuleID = ‘main.c’ source_filename = “main.c” target datalayout = “e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128” target triple = “x86_64-unknown-linux-gnu” @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__sym_ctor, i8* null }] ; Function Attrs: nounwind sspstrong uwtable define i32 @main() local_unnamed_addr #0 { call […]

stage2 generics demo

const std = @import(“std”); const expect = std.testing.expect; test “example” { var x: usize = 0; x += checkSize(i32); x += checkSize(bool); try expect(x == 5); } fn checkSize(comptime T: type) usize { return @sizeOf(T); } # Source bytes: 245B # Tokens: 68 (364B) # AST Nodes: 37 (601B) # Total ZIR bytes: 1.240234375KiB # […]