From 2db43213e5c343995f4b9fb977726fe42ebdac67 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 27 Jan 2023 01:57:18 +0000 Subject: gentoo auto-resync : 27:01:2023 - 01:57:17 --- dev-util/bpftrace/Manifest | 2 + dev-util/bpftrace/bpftrace-0.16.0-r2.ebuild | 93 +++++ .../files/bpftrace-0.16.0-opaquepointer.patch | 450 +++++++++++++++++++++ 3 files changed, 545 insertions(+) create mode 100644 dev-util/bpftrace/bpftrace-0.16.0-r2.ebuild create mode 100644 dev-util/bpftrace/files/bpftrace-0.16.0-opaquepointer.patch (limited to 'dev-util/bpftrace') diff --git a/dev-util/bpftrace/Manifest b/dev-util/bpftrace/Manifest index 6232a7d6bd27..96f77dc68b17 100644 --- a/dev-util/bpftrace/Manifest +++ b/dev-util/bpftrace/Manifest @@ -5,9 +5,11 @@ AUX bpftrace-0.15.0-dont-compress-man.patch 1885 BLAKE2B 89a327cef68fa838d5c04b3 AUX bpftrace-0.15.0-install-libs.patch 8206 BLAKE2B 9d8b193f422b0ee64301b7ea12791afdd5111cde487b904ec35750e6189fdd6faca9af36b8956058c820c2398bcabc7dcee6d26b93c55ff1e591b3259a682a27 SHA512 9721d8f3812855d7a9155d8e5ecac305dedb5c8326ccf8ea679048f920ca58a774576840c1b0bc2864a26c66c89bf0c81ed1a1ab30fb571a6cfaebc5b499c2b7 AUX bpftrace-0.15.0-llvm-15-pointers.patch 1023 BLAKE2B fc66196f11e9384878921309d09e3f205674a88041c93b0b353bf38ff345b4192b83cd1c80a15258b97710624b3341c9ed19b60beff38c163f677d644843ff54 SHA512 8282aa82eb867eed3378adc4ff2b73c6427d4f979cfb5268444bf122126c758229d680985e4ede7e8d011a14d4a122d6742650f57ee0e0759e3b1bfb9ba9458f AUX bpftrace-0.16.0-install-libs.patch 8507 BLAKE2B 84842c5c400e2921d40f32ccd27ec06174c517e35b3a413907231e128d636e7c4711d131682d3fbc75a861bf3cd0cf83de2ca1c4bfbf2606e69d32f898fbd3a4 SHA512 93341eca7566d1328cbd670685859803cc76869be2eb3d52d38e3956f30d28f63d73ba32ae7f111dfd01ccb95899be6e1834fe7e1f1ee3794a0b796b8f52574e +AUX bpftrace-0.16.0-opaquepointer.patch 20038 BLAKE2B beeda98ded230a8bb22d2a32dd0e839f138ca9c9fec10402d039f4385016b4330ce94756641e4f24a5a1e294ce08d282cbf4f7e01ef0c817dda21d2324f7cf60 SHA512 4b61fe7d21a42493590e5e6bc7507852d6a1f0d685d78958d6aa2c1602211d99bbccced25a2c118ecdedd802ccfdd009b940ccb81573b28b010a476952bd1da7 DIST bpftrace-0.14.1-llvm14.patch.gz 7377 BLAKE2B 69b3b74bce74a8d4d8d9cc74de352dc33875ae905d8a88c776bbe80862a4f4ac2d450bcb6190da8be880bcc8fb751e3b8172df5454f31dc4bcd3e41edb02e396 SHA512 3269132981a7d2c0263fe9003bbcd2348e186ca0cdc95ada368331fc6e2495ae126c7bd68676438ccb575aafdafa3d17604a28fdc11d8b629eeaee130c1fd614 DIST bpftrace-0.15.0.tar.gz 1006735 BLAKE2B 3ef4bb5f13aa6dea5140b5362e6fc3de21baa1192e2218307895bf29ddeba8d69543e32c2b769bf3456076095ba661b66e1625f2696631d22628311d7f6ec1a4 SHA512 916e9afeab301e62472e570ef77a3b9b27b43251880b64f1c5f151583c59a6c61e9ede50f3607044b27c5a6ce1a654f290153bf3f9237ebc0a823b5e6356187a DIST bpftrace-0.16.0.gh.tar.gz 1023480 BLAKE2B 20fa877adeaada655462004142a80f107f82a3fa73fd7a7675a477d45ecd3a28115af5d612da2b06e2d760cfa3e574583e4cc4d62f4175c49ecc9d9b3fcceb6e SHA512 52ca4fea4e2f8d2cbf0f9f1bc69af0ee3408201f019006dd2e838b9458cfc01761eba3df24c39e05cf93220d85d0cecc69bb44ec72f9f44cec0eb94479bff734 EBUILD bpftrace-0.15.0-r2.ebuild 2008 BLAKE2B c947ed7d7ffe63e6d8f67b8de5a62ff5053aa3ffeffde602c32aac7dace1916d9ec288c3f1a3077cf6833b8ff32459f6c4e2879bf6f8e392535d3527029a4660 SHA512 f1ca5e2650bb0caa191f65af578fe52126777080ce852cefc21af513ae77103c9ef555902eda60675234e7632651621ff4c8f68fcb4b83491c411834014d9875 EBUILD bpftrace-0.16.0-r1.ebuild 1740 BLAKE2B b798c92e0e80396c069d83b1f9d55d019382a4f3615c4a064d9b0c196c010c4399d488c41ef403702a5e3ccdff14d1cd4466a8b0d6cdb25902b48498197120b7 SHA512 0b252876bcd309520eb3daa4216cf21e1d8b1eb2ea0e33f5abe3b5d48cf32e8c5e5739f46c395f4678c64e39841e87093b829269563eadd51bdb10acf0b51d3c +EBUILD bpftrace-0.16.0-r2.ebuild 1791 BLAKE2B bd0db18452f6d36ea37658b477219fc10edb329b17aa0fb6f26bce4578c9ddba88915e0a026fd190fcb5eba8bf005d930d6fcda590da623725a8254e8f224f30 SHA512 569974b254bd1ffc50018bc66edac49bb0f2c07a8990caded28fdf24f5728b16df08cc20157f07e248eb960291ecf9c8f5782bc4e1701ce2e8631f0abcbd8164 MISC metadata.xml 499 BLAKE2B ce7c46f4c5e49f2f779ff6584053f7fc78dffaeee432ac46a8881b3d49dc569e309af95aaf9d6e77a36ebc87be0cd2f86a5db7b733463e4252d3a242d914f293 SHA512 dfb827afd47feb8204ef40c940ebcc7d1b3217cdf0f24425e4ab32195309d727225e942d777871565e47a2c02244d053f46ed25165e9728c94e0683ff61bf4ce diff --git a/dev-util/bpftrace/bpftrace-0.16.0-r2.ebuild b/dev-util/bpftrace/bpftrace-0.16.0-r2.ebuild new file mode 100644 index 000000000000..dca9044e1ff0 --- /dev/null +++ b/dev-util/bpftrace/bpftrace-0.16.0-r2.ebuild @@ -0,0 +1,93 @@ +# Copyright 2019-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LLVM_MAX_SLOT=16 + +inherit llvm linux-info cmake + +DESCRIPTION="High-level tracing language for eBPF" +HOMEPAGE="https://github.com/iovisor/bpftrace" +MY_PV="${PV//_/}" +SRC_URI="https://github.com/iovisor/${PN}/archive/v${MY_PV}.tar.gz -> ${P}.gh.tar.gz" +S="${WORKDIR}/${PN}-${MY_PV:-${PV}}" + +LICENSE="Apache-2.0" +SLOT="0" + +# remove keywords until build works: +# https://github.com/iovisor/bpftrace/issues/2349 +KEYWORDS="~amd64 ~arm64 ~x86" +IUSE="fuzzing test" + +# lots of fixing needed +RESTRICT="test" + +RDEPEND=" + >=dev-libs/libbpf-1.0:= + >=dev-util/bcc-0.25.0:= + +Date: Mon Oct 10 14:26:38 2022 +0200 + + IR builder: get rid of getPointerElementType calls + + Usage of Value::getPointerElementType is deprecated and will be dropped + in LLVM 16 [1]. + + There are several places where we use this method: + - function (value) calls - the called function type is usually + available, so just pass it to createCall, the only exception is + CreateProbeReadStr which must have been refactored + - getting the type of alloca instruction - there is a dedicated + AllocaInst::getAllocatedType method that can be used instead + - strncmp - pass sizes of the strings to CreateStrncmp to be able to get + the correct string type (which is array of uint8) + + [1] https://llvm.org/docs/OpaquePointers.html + +diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp +index 09ae1c5e..da120ba1 100644 +--- a/src/ast/irbuilderbpf.cpp ++++ b/src/ast/irbuilderbpf.cpp +@@ -291,17 +291,16 @@ CallInst *IRBuilderBPF::CreateHelperCall(libbpf::bpf_func_id func_id, + Constant *helper_func = ConstantExpr::getCast(Instruction::IntToPtr, + getInt64(func_id), + helper_ptr_type); +- return createCall(helper_func, args, Name); ++ return createCall(helper_type, helper_func, args, Name); + } + +-CallInst *IRBuilderBPF::createCall(Value *callee, ++CallInst *IRBuilderBPF::createCall(FunctionType *callee_type, ++ Value *callee, + ArrayRef args, + const Twine &Name) + { + #if LLVM_VERSION_MAJOR >= 11 +- auto *calleePtrType = cast(callee->getType()); +- auto *calleeType = cast(calleePtrType->getPointerElementType()); +- return CreateCall(calleeType, callee, args, Name); ++ return CreateCall(callee_type, callee, args, Name); + #else + return CreateCall(callee, args, Name); + #endif +@@ -310,7 +309,7 @@ CallInst *IRBuilderBPF::createCall(Value *callee, + CallInst *IRBuilderBPF::CreateBpfPseudoCallId(int mapid) + { + Function *pseudo_func = module_.getFunction("llvm.bpf.pseudo"); +- return createCall(pseudo_func, ++ return CreateCall(pseudo_func, + { getInt64(BPF_PSEUDO_MAP_FD), getInt64(mapid) }, + "pseudo"); + } +@@ -349,7 +348,8 @@ CallInst *IRBuilderBPF::createMapLookup(int mapid, Value *key) + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_map_lookup_elem), + lookup_func_ptr_type); +- return createCall(lookup_func, { map_ptr, key }, "lookup_elem"); ++ return createCall( ++ lookup_func_type, lookup_func, { map_ptr, key }, "lookup_elem"); + } + + CallInst *IRBuilderBPF::CreateGetJoinMap(Value *ctx, const location &loc) +@@ -400,8 +400,7 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx, + CREATE_MEMCPY(value, call, type.GetSize(), 1); + else + { +- assert(value->getType()->isPointerTy() && +- (value->getType()->getPointerElementType() == getInt64Ty())); ++ assert(value->getAllocatedType() == getInt64Ty()); + // createMapLookup returns an u8* + auto *cast = CreatePointerCast(call, value->getType(), "cast"); + CreateStore(CreateLoad(getInt64Ty(), cast), value); +@@ -451,7 +450,8 @@ void IRBuilderBPF::CreateMapUpdateElem(Value *ctx, + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_map_update_elem), + update_func_ptr_type); +- CallInst *call = createCall(update_func, ++ CallInst *call = createCall(update_func_type, ++ update_func, + { map_ptr, key, val, flags }, + "update_elem"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_map_update_elem, loc); +@@ -475,7 +475,8 @@ void IRBuilderBPF::CreateMapDeleteElem(Value *ctx, + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_map_delete_elem), + delete_func_ptr_type); +- CallInst *call = createCall(delete_func, { map_ptr, key }, "delete_elem"); ++ CallInst *call = createCall( ++ delete_func_type, delete_func, { map_ptr, key }, "delete_elem"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_map_delete_elem, loc); + } + +@@ -501,72 +502,53 @@ void IRBuilderBPF::CreateProbeRead(Value *ctx, + Constant *proberead_func = ConstantExpr::getCast(Instruction::IntToPtr, + getInt64(read_fn), + proberead_func_ptr_type); +- CallInst *call = createCall(proberead_func, ++ CallInst *call = createCall(proberead_func_type, ++ proberead_func, + { dst, size, src }, + probeReadHelperName(read_fn)); + CreateHelperErrorCond(ctx, call, read_fn, loc); + } + +-Constant *IRBuilderBPF::createProbeReadStrFn(llvm::Type *dst, +- llvm::Type *src, +- AddrSpace as) +-{ +- assert(src && (src->isIntegerTy() || src->isPointerTy())); +- // int bpf_probe_read_str(void *dst, int size, const void *unsafe_ptr) +- FunctionType *probereadstr_func_type = FunctionType::get( +- getInt64Ty(), { dst, getInt32Ty(), src }, false); +- PointerType *probereadstr_func_ptr_type = PointerType::get( +- probereadstr_func_type, 0); +- return ConstantExpr::getCast(Instruction::IntToPtr, +- getInt64(selectProbeReadHelper(as, true)), +- probereadstr_func_ptr_type); +-} +- + CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx, +- AllocaInst *dst, ++ Value *dst, + size_t size, + Value *src, + AddrSpace as, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); + return CreateProbeReadStr(ctx, dst, getInt32(size), src, as, loc); + } + + CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx, + Value *dst, +- size_t size, +- Value *src, +- AddrSpace as, +- const location &loc) +-{ +- assert(ctx && ctx->getType() == getInt8PtrTy()); +- Constant *fn = createProbeReadStrFn(dst->getType(), src->getType(), as); +- auto read_fn = selectProbeReadHelper(as, true); +- CallInst *call = createCall(fn, +- { dst, getInt32(size), src }, +- probeReadHelperName(read_fn)); +- CreateHelperErrorCond(ctx, call, read_fn, loc); +- return call; +-} +- +-CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx, +- AllocaInst *dst, + llvm::Value *size, + Value *src, + AddrSpace as, + const location &loc) + { + assert(ctx && ctx->getType() == getInt8PtrTy()); +- assert(dst && dst->getAllocatedType()->isArrayTy() && +- dst->getAllocatedType()->getArrayElementType() == getInt8Ty()); + assert(size && size->getType()->isIntegerTy()); ++ if (auto *dst_alloca = dyn_cast(dst)) ++ { ++ assert(dst_alloca->getAllocatedType()->isArrayTy() && ++ dst_alloca->getAllocatedType()->getArrayElementType() == ++ getInt8Ty()); ++ } + +- auto *size_i32 = CreateIntCast(size, getInt32Ty(), false); ++ auto *size_i32 = size; ++ if (size_i32->getType()->getScalarSizeInBits() != 32) ++ size_i32 = CreateIntCast(size_i32, getInt32Ty(), false); + +- Constant *fn = createProbeReadStrFn(dst->getType(), src->getType(), as); + auto read_fn = selectProbeReadHelper(as, true); +- CallInst *call = createCall(fn, ++ // int bpf_probe_read_str(void *dst, int size, const void *unsafe_ptr) ++ FunctionType *probereadstr_func_type = FunctionType::get( ++ getInt64Ty(), { dst->getType(), getInt32Ty(), src->getType() }, false); ++ PointerType *probereadstr_func_ptr_type = PointerType::get( ++ probereadstr_func_type, 0); ++ Constant *probereadstr_callee = ConstantExpr::getCast( ++ Instruction::IntToPtr, getInt64(read_fn), probereadstr_func_ptr_type); ++ CallInst *call = createCall(probereadstr_func_type, ++ probereadstr_callee, + { dst, size_i32, src }, + probeReadHelperName(read_fn)); + CreateHelperErrorCond(ctx, call, read_fn, loc); +@@ -725,8 +707,10 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx, + return result; + } + +-Value *IRBuilderBPF::CreateStrncmp(Value *val1, +- Value *val2, ++Value *IRBuilderBPF::CreateStrncmp(Value *str1, ++ uint64_t str1_size, ++ Value *str2, ++ uint64_t str2_size, + uint64_t n, + bool inverse) + { +@@ -755,40 +739,21 @@ Value *IRBuilderBPF::CreateStrncmp(Value *val1, + // Check if the compared strings are literals. + // If so, we can avoid storing the literal in memory. + std::optional literal1; +- if (auto constString1 = dyn_cast(val1)) ++ if (auto constString1 = dyn_cast(str1)) + literal1 = constString1->getAsString(); +- else if (isa(val1)) ++ else if (isa(str1)) + literal1 = ""; + else + literal1 = std::nullopt; + + std::optional literal2; +- if (auto constString2 = dyn_cast(val2)) ++ if (auto constString2 = dyn_cast(str2)) + literal2 = constString2->getAsString(); +- else if (isa(val2)) ++ else if (isa(str2)) + literal2 = ""; + else + literal2 = std::nullopt; + +- auto *val1p = dyn_cast(val1->getType()); +- auto *val2p = dyn_cast(val2->getType()); +-#ifndef NDEBUG +- if (!literal1) +- { +- assert(val1p); +- assert(val1p->getPointerElementType()->isArrayTy() && +- val1p->getPointerElementType()->getArrayElementType() == +- getInt8Ty()); +- } +- if (!literal2) +- { +- assert(val2p); +- assert(val2p->getPointerElementType()->isArrayTy() && +- val2p->getPointerElementType()->getArrayElementType() == +- getInt8Ty()); +- } +-#endif +- + Function *parent = GetInsertBlock()->getParent(); + AllocaInst *store = CreateAllocaBPF(getInt1Ty(), "strcmp.result"); + BasicBlock *str_ne = BasicBlock::Create(module_.getContext(), +@@ -815,8 +780,8 @@ Value *IRBuilderBPF::CreateStrncmp(Value *val1, + l = getInt8(literal1->c_str()[i]); + else + { +- auto *ptr_l = CreateGEP(val1p->getPointerElementType(), +- val1, ++ auto *ptr_l = CreateGEP(ArrayType::get(getInt8Ty(), str1_size), ++ str1, + { getInt32(0), getInt32(i) }); + l = CreateLoad(getInt8Ty(), ptr_l); + } +@@ -826,8 +791,8 @@ Value *IRBuilderBPF::CreateStrncmp(Value *val1, + r = getInt8(literal2->c_str()[i]); + else + { +- auto *ptr_r = CreateGEP(val2p->getPointerElementType(), +- val2, ++ auto *ptr_r = CreateGEP(ArrayType::get(getInt8Ty(), str2_size), ++ str2, + { getInt32(0), getInt32(i) }); + r = CreateLoad(getInt8Ty(), ptr_r); + } +@@ -987,11 +952,9 @@ void IRBuilderBPF::CreateGetCurrentComm(Value *ctx, + size_t size, + const location &loc) + { +- assert(buf->getType()->getPointerElementType()->isArrayTy() && +- buf->getType()->getPointerElementType()->getArrayNumElements() >= +- size && +- buf->getType()->getPointerElementType()->getArrayElementType() == +- getInt8Ty()); ++ assert(buf->getAllocatedType()->isArrayTy() && ++ buf->getAllocatedType()->getArrayNumElements() >= size && ++ buf->getAllocatedType()->getArrayElementType() == getInt8Ty()); + + // long bpf_get_current_comm(char *buf, int size_of_buf) + // Return: 0 on success or negative error +@@ -1070,7 +1033,7 @@ void IRBuilderBPF::CreateSignal(Value *ctx, Value *sig, const location &loc) + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_send_signal), + signal_func_ptr_type); +- CallInst *call = createCall(signal_func, { sig }, "signal"); ++ CallInst *call = createCall(signal_func_type, signal_func, { sig }, "signal"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_send_signal, loc); + } + +@@ -1084,7 +1047,7 @@ void IRBuilderBPF::CreateOverrideReturn(Value *ctx, Value *rc) + Constant *override_func = ConstantExpr::getCast(Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_override_return), + override_func_ptr_type); +- createCall(override_func, { ctx, rc }, "override"); ++ createCall(override_func_type, override_func, { ctx, rc }, "override"); + } + + CallInst *IRBuilderBPF::CreateSkbOutput(Value *skb, +@@ -1119,7 +1082,8 @@ CallInst *IRBuilderBPF::CreateSkbOutput(Value *skb, + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_skb_output), + skb_output_func_ptr_type); +- CallInst *call = createCall(skb_output_func, ++ CallInst *call = createCall(skb_output_func_type, ++ skb_output_func, + { skb, map_ptr, flags, data, size_val }, + "skb_output"); + return call; +@@ -1328,7 +1292,8 @@ void IRBuilderBPF::CreateSeqPrintf(Value *ctx, + CreateGEP(getInt64Ty(), meta, getInt64(0)), + "seq"); + +- CallInst *call = createCall(seq_printf_func, ++ CallInst *call = createCall(seq_printf_func_type, ++ seq_printf_func, + { seq, fmt, fmt_size, data, data_len }, + "seq_printf"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_seq_printf, loc); +diff --git a/src/ast/irbuilderbpf.h b/src/ast/irbuilderbpf.h +index b6a06778..19b28180 100644 +--- a/src/ast/irbuilderbpf.h ++++ b/src/ast/irbuilderbpf.h +@@ -106,17 +106,11 @@ public: + bool isVolatile = false, + std::optional addrSpace = std::nullopt); + CallInst *CreateProbeReadStr(Value *ctx, +- AllocaInst *dst, ++ Value *dst, + llvm::Value *size, + Value *src, + AddrSpace as, + const location &loc); +- CallInst *CreateProbeReadStr(Value *ctx, +- AllocaInst *dst, +- size_t size, +- Value *src, +- AddrSpace as, +- const location &loc); + CallInst *CreateProbeReadStr(Value *ctx, + Value *dst, + size_t size, +@@ -131,7 +125,12 @@ public: + pid_t pid, + AddrSpace as, + const location &loc); +- Value *CreateStrncmp(Value *val1, Value *val2, uint64_t n, bool inverse); ++ Value *CreateStrncmp(Value *str1, ++ uint64_t str1_size, ++ Value *str2, ++ uint64_t str2_size, ++ uint64_t n, ++ bool inverse); + CallInst *CreateGetNs(bool boot_time, const location &loc); + CallInst *CreateGetPidTgid(const location &loc); + CallInst *CreateGetCurrentCgroupId(const location &loc); +@@ -147,7 +146,10 @@ public: + ArrayRef args, + const Twine &Name, + const location *loc = nullptr); +- CallInst *createCall(Value *callee, ArrayRef args, const Twine &Name); ++ CallInst *createCall(FunctionType *callee_type, ++ Value *callee, ++ ArrayRef args, ++ const Twine &Name); + void CreateGetCurrentComm(Value *ctx, AllocaInst *buf, size_t size, const location& loc); + void CreatePerfEventOutput(Value *ctx, + Value *data, +@@ -205,9 +207,6 @@ private: + AddrSpace as, + const location &loc); + CallInst *createMapLookup(int mapid, Value *key); +- Constant *createProbeReadStrFn(llvm::Type *dst, +- llvm::Type *src, +- AddrSpace as); + libbpf::bpf_func_id selectProbeReadHelper(AddrSpace as, bool str); + + llvm::Type *getKernelPointerStorageTy(); +diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp +index d4a5e1c7..0703d196 100644 +--- a/src/ast/passes/codegen_llvm.cpp ++++ b/src/ast/passes/codegen_llvm.cpp +@@ -1152,8 +1152,12 @@ void CodegenLLVM::visit(Call &call) + auto left_string = getString(left_arg); + auto right_string = getString(right_arg); + +- expr_ = b_.CreateStrncmp( +- left_string.first, right_string.first, size, false); ++ expr_ = b_.CreateStrncmp(left_string.first, ++ left_string.second, ++ right_string.first, ++ right_string.second, ++ size, ++ false); + } + else if (call.func == "override") + { +@@ -1284,8 +1288,7 @@ void CodegenLLVM::visit(Variable &var) + else + { + auto *var_alloca = variables_[var.ident]; +- expr_ = b_.CreateLoad(var_alloca->getType()->getPointerElementType(), +- var_alloca); ++ expr_ = b_.CreateLoad(var_alloca->getAllocatedType(), var_alloca); + } + } + +@@ -1325,7 +1328,12 @@ void CodegenLLVM::binop_string(Binop &binop) + auto right_string = getString(binop.right); + + size_t len = std::min(left_string.second, right_string.second); +- expr_ = b_.CreateStrncmp(left_string.first, right_string.first, len, inverse); ++ expr_ = b_.CreateStrncmp(left_string.first, ++ left_string.second, ++ right_string.first, ++ right_string.second, ++ len, ++ inverse); + } + + void CodegenLLVM::binop_buf(Binop &binop) +@@ -1349,7 +1357,12 @@ void CodegenLLVM::binop_buf(Binop &binop) + + size_t len = std::min(binop.left->type.GetSize(), + binop.right->type.GetSize()); +- expr_ = b_.CreateStrncmp(left_string, right_string, len, inverse); ++ expr_ = b_.CreateStrncmp(left_string, ++ binop.left->type.GetSize(), ++ right_string, ++ binop.right->type.GetSize(), ++ len, ++ inverse); + } + + void CodegenLLVM::binop_int(Binop &binop) +@@ -3498,9 +3511,8 @@ void CodegenLLVM::createIncDec(Unop &unop) + else if (unop.expr->is_variable) + { + Variable &var = static_cast(*unop.expr); +- Value *oldval = b_.CreateLoad( +- variables_[var.ident]->getType()->getPointerElementType(), +- variables_[var.ident]); ++ Value *oldval = b_.CreateLoad(variables_[var.ident]->getAllocatedType(), ++ variables_[var.ident]); + Value *newval; + if (is_increment) + newval = b_.CreateAdd(oldval, b_.GetIntSameSize(step, oldval)); -- cgit v1.2.3