Blame SOURCES/bpftrace-0.13.1-Fix-LLVM-13-warnings.patch

573668
From fed7014be999f6437ebfd8a6465a76f459be0e1b Mon Sep 17 00:00:00 2001
573668
From: Viktor Malik <viktor.malik@gmail.com>
573668
Date: Mon, 10 Jan 2022 16:41:05 +0100
573668
Subject: [PATCH 6/6] Fix LLVM 13 warnings
573668
573668
Since LLVM 13, CreateGEP and CreateLoad require explicit types.
573668
---
573668
 src/ast/codegen_llvm.cpp | 265 ++++++++++++++++++++++++---------------
573668
 src/ast/irbuilderbpf.cpp |  56 +++++----
573668
 2 files changed, 200 insertions(+), 121 deletions(-)
573668
573668
diff --git a/src/ast/codegen_llvm.cpp b/src/ast/codegen_llvm.cpp
573668
index d30327a2..0bd23276 100644
573668
--- a/src/ast/codegen_llvm.cpp
573668
+++ b/src/ast/codegen_llvm.cpp
573668
@@ -224,9 +224,10 @@ void CodegenLLVM::visit(Builtin &builtin)
573668
     // LLVM optimization is possible to transform `(uint64*)ctx` into
573668
     // `(uint8*)ctx`, but sometimes this causes invalid context access.
573668
     // Mark every context acess to supporess any LLVM optimization.
573668
-    expr_ = b_.CreateLoad(b_.getInt64Ty(),
573668
-                          b_.CreateGEP(ctx, b_.getInt64(offset)),
573668
-                          builtin.ident);
573668
+    expr_ = b_.CreateLoad(
573668
+	    b_.getInt64Ty(),
573668
+	    b_.CreateGEP(b_.getInt64Ty(), ctx, b_.getInt64(offset)),
573668
+	    builtin.ident);
573668
     // LLVM 7.0 <= does not have CreateLoad(*Ty, *Ptr, isVolatile, Name),
573668
     // so call setVolatile() manually
573668
     dyn_cast<LoadInst>(expr_)->setVolatile(true);
573668
@@ -249,16 +250,17 @@ void CodegenLLVM::visit(Builtin &builtin)
573668
 
573668
     int arg_num = atoi(builtin.ident.substr(4).c_str());
573668
     Value *ctx = b_.CreatePointerCast(ctx_, b_.getInt64Ty()->getPointerTo());
573668
-    Value *sp = b_.CreateLoad(b_.getInt64Ty(),
573668
-                              b_.CreateGEP(ctx, b_.getInt64(sp_offset)),
573668
-                              "reg_sp");
573668
+    Value *sp = b_.CreateLoad(
573668
+        b_.getInt64Ty(),
573668
+        b_.CreateGEP(b_.getInt64Ty(), ctx, b_.getInt64(sp_offset)),
573668
+        "reg_sp");
573668
     dyn_cast<LoadInst>(sp)->setVolatile(true);
573668
     AllocaInst *dst = b_.CreateAllocaBPF(builtin.type, builtin.ident);
573668
     Value *src = b_.CreateAdd(sp,
573668
                               b_.getInt64((arg_num + arch::arg_stack_offset()) *
573668
                                           sizeof(uintptr_t)));
573668
     b_.CreateProbeRead(ctx_, dst, 8, src, builtin.type.GetAS(), builtin.loc);
573668
-    expr_ = b_.CreateLoad(dst);
573668
+    expr_ = b_.CreateLoad(b_.GetType(builtin.type), dst);
573668
     b_.CreateLifetimeEnd(dst);
573668
   }
573668
   else if (builtin.ident == "probe")
573668
@@ -526,8 +528,12 @@ void CodegenLLVM::visit(Call &call)
573668
     b_.CREATE_MEMSET(buf, b_.getInt8(0), bpftrace_.strlen_, 1);
573668
     auto arg0 = call.vargs->front();
573668
     auto scoped_del = accept(call.vargs->front());
573668
-    b_.CreateProbeReadStr(
573668
-        ctx_, buf, b_.CreateLoad(strlen), expr_, arg0->type.GetAS(), call.loc);
573668
+    b_.CreateProbeReadStr(ctx_,
573668
+                          buf,
573668
+                          b_.CreateLoad(b_.getInt64Ty(), strlen),
573668
+                          expr_,
573668
+                          arg0->type.GetAS(),
573668
+                          call.loc);
573668
     b_.CreateLifetimeEnd(strlen);
573668
 
573668
     expr_ = buf;
573668
@@ -569,12 +575,14 @@ void CodegenLLVM::visit(Call &call)
573668
                                               false);
573668
     AllocaInst *buf = b_.CreateAllocaBPF(buf_struct, "buffer");
573668
 
573668
-    Value *buf_len_offset = b_.CreateGEP(buf,
573668
+    Value *buf_len_offset = b_.CreateGEP(buf_struct,
573668
+                                         buf,
573668
                                          { b_.getInt32(0), b_.getInt32(0) });
573668
     length = b_.CreateIntCast(length, buf_struct->getElementType(0), false);
573668
     b_.CreateStore(length, buf_len_offset);
573668
 
573668
-    Value *buf_data_offset = b_.CreateGEP(buf,
573668
+    Value *buf_data_offset = b_.CreateGEP(buf_struct,
573668
+                                          buf,
573668
                                           { b_.getInt32(0), b_.getInt32(1) });
573668
     b_.CREATE_MEMSET(buf_data_offset,
573668
                      b_.GetIntSameSize(0, elements.at(0)),
573668
@@ -664,14 +672,14 @@ void CodegenLLVM::visit(Call &call)
573668
     b_.SetInsertPoint(notzero);
573668
     b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::join)), perfdata);
573668
     b_.CreateStore(b_.getInt64(join_id_),
573668
-                   b_.CreateGEP(perfdata, b_.getInt64(8)));
573668
+                   b_.CreateGEP(b_.getInt8Ty(), perfdata, b_.getInt64(8)));
573668
     join_id_++;
573668
     AllocaInst *arr = b_.CreateAllocaBPF(b_.getInt64Ty(), call.func + "_r0");
573668
     b_.CreateProbeRead(ctx_, arr, 8, expr_, addrspace, call.loc);
573668
     b_.CreateProbeReadStr(ctx_,
573668
                           b_.CreateAdd(perfdata, b_.getInt64(8 + 8)),
573668
                           bpftrace_.join_argsize_,
573668
-                          b_.CreateLoad(arr),
573668
+                          b_.CreateLoad(b_.getInt64Ty(), arr),
573668
                           addrspace,
573668
                           call.loc);
573668
 
573668
@@ -679,14 +687,18 @@ void CodegenLLVM::visit(Call &call)
573668
     {
573668
       // argi
573668
       b_.CreateStore(b_.CreateAdd(expr_, b_.getInt64(8 * i)), first);
573668
-      b_.CreateProbeRead(
573668
-          ctx_, second, 8, b_.CreateLoad(first), addrspace, call.loc);
573668
+      b_.CreateProbeRead(ctx_,
573668
+                         second,
573668
+                         8,
573668
+                         b_.CreateLoad(b_.getInt64Ty(), first),
573668
+                         addrspace,
573668
+                         call.loc);
573668
       b_.CreateProbeReadStr(
573668
           ctx_,
573668
           b_.CreateAdd(perfdata,
573668
                        b_.getInt64(8 + 8 + i * bpftrace_.join_argsize_)),
573668
           bpftrace_.join_argsize_,
573668
-          b_.CreateLoad(second),
573668
+          b_.CreateLoad(b_.getInt64Ty(), second),
573668
           addrspace,
573668
           call.loc);
573668
     }
573668
@@ -729,7 +741,9 @@ void CodegenLLVM::visit(Call &call)
573668
 
573668
     AllocaInst *buf = b_.CreateAllocaBPF(inet_struct, "inet");
573668
 
573668
-    Value *af_offset = b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) });
573668
+    Value *af_offset = b_.CreateGEP(inet_struct,
573668
+                                    buf,
573668
+                                    { b_.getInt64(0), b_.getInt32(0) });
573668
     Value *af_type;
573668
 
573668
     auto inet = call.vargs->at(0);
573668
@@ -752,7 +766,9 @@ void CodegenLLVM::visit(Call &call)
573668
     }
573668
     b_.CreateStore(af_type, af_offset);
573668
 
573668
-    Value *inet_offset = b_.CreateGEP(buf, {b_.getInt32(0), b_.getInt32(1)});
573668
+    Value *inet_offset = b_.CreateGEP(inet_struct,
573668
+                                      buf,
573668
+                                      { b_.getInt32(0), b_.getInt32(1) });
573668
     b_.CREATE_MEMSET(inet_offset, b_.getInt8(0), 16, 1);
573668
 
573668
     auto scoped_del = accept(inet);
573668
@@ -785,9 +801,10 @@ void CodegenLLVM::visit(Call &call)
573668
     }
573668
 
573668
     Value *ctx = b_.CreatePointerCast(ctx_, b_.getInt64Ty()->getPointerTo());
573668
-    expr_ = b_.CreateLoad(b_.getInt64Ty(),
573668
-                          b_.CreateGEP(ctx, b_.getInt64(offset)),
573668
-                          call.func + "_" + reg_name);
573668
+    expr_ = b_.CreateLoad(
573668
+        b_.getInt64Ty(),
573668
+        b_.CreateGEP(b_.getInt64Ty(), ctx, b_.getInt64(offset)),
573668
+        call.func + "_" + reg_name);
573668
     dyn_cast<LoadInst>(expr_)->setVolatile(true);
573668
   }
573668
   else if (call.func == "printf")
573668
@@ -812,8 +829,10 @@ void CodegenLLVM::visit(Call &call)
573668
         auto scoped_del = accept(&arg;;
573668
 
573668
         // and store it to data area
573668
-        Value *offset = b_.CreateGEP(
573668
-            data, { b_.getInt64(0), b_.getInt64((i - 1) * ptr_size) });
573668
+        Value *offset = b_.CreateGEP(b_.GetType(data_type),
573668
+                                     data,
573668
+                                     { b_.getInt64(0),
573668
+                                       b_.getInt64((i - 1) * ptr_size) });
573668
         b_.CreateStore(expr_, offset);
573668
 
573668
         // keep the expression alive, so it's still there
573668
@@ -901,7 +920,9 @@ void CodegenLLVM::visit(Call &call)
573668
     AllocaInst *buf = b_.CreateAllocaBPF(event_struct,
573668
                                          call.func + "_" + map.ident);
573668
 
573668
-    auto aa_ptr = b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) });
573668
+    auto aa_ptr = b_.CreateGEP(event_struct,
573668
+                               buf,
573668
+                               { b_.getInt64(0), b_.getInt32(0) });
573668
     if (call.func == "clear")
573668
       b_.CreateStore(b_.GetIntSameSize(asyncactionint(AsyncAction::clear),
573668
                                        elements.at(0)),
573668
@@ -912,7 +933,9 @@ void CodegenLLVM::visit(Call &call)
573668
                      aa_ptr);
573668
 
573668
     auto id = bpftrace_.maps[map.ident].value()->id;
573668
-    auto *ident_ptr = b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) });
573668
+    auto *ident_ptr = b_.CreateGEP(event_struct,
573668
+                                   buf,
573668
+                                   { b_.getInt64(0), b_.getInt32(1) });
573668
     b_.CreateStore(b_.GetIntSameSize(id, elements.at(1)), ident_ptr);
573668
 
573668
     b_.CreatePerfEventOutput(ctx_, buf, getStructSize(event_struct));
573668
@@ -928,12 +951,13 @@ void CodegenLLVM::visit(Call &call)
573668
 
573668
     AllocaInst *buf = b_.CreateAllocaBPF(time_struct, call.func + "_t");
573668
 
573668
-    b_.CreateStore(b_.GetIntSameSize(asyncactionint(AsyncAction::time),
573668
-                                     elements.at(0)),
573668
-                   b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
+    b_.CreateStore(
573668
+        b_.GetIntSameSize(asyncactionint(AsyncAction::time), elements.at(0)),
573668
+        b_.CreateGEP(time_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
 
573668
-    b_.CreateStore(b_.GetIntSameSize(time_id_, elements.at(1)),
573668
-                   b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
+    b_.CreateStore(
573668
+        b_.GetIntSameSize(time_id_, elements.at(1)),
573668
+        b_.CreateGEP(time_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
 
573668
     time_id_++;
573668
     b_.CreatePerfEventOutput(ctx_, buf, getStructSize(time_struct));
573668
@@ -948,13 +972,15 @@ void CodegenLLVM::visit(Call &call)
573668
                                                    true);
573668
 
573668
     AllocaInst *buf = b_.CreateAllocaBPF(strftime_struct, call.func + "_args");
573668
-    b_.CreateStore(b_.GetIntSameSize(strftime_id_, elements.at(0)),
573668
-                   b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
+    b_.CreateStore(
573668
+        b_.GetIntSameSize(strftime_id_, elements.at(0)),
573668
+        b_.CreateGEP(strftime_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
     strftime_id_++;
573668
     Expression *arg = call.vargs->at(1);
573668
     auto scoped_del = accept(arg);
573668
-    b_.CreateStore(expr_,
573668
-                   b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
+    b_.CreateStore(
573668
+        expr_,
573668
+        b_.CreateGEP(strftime_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
     expr_ = buf;
573668
   }
573668
   else if (call.func == "kstack" || call.func == "ustack")
573668
@@ -1068,11 +1094,12 @@ void CodegenLLVM::visit(Call &call)
573668
     AllocaInst *buf = b_.CreateAllocaBPF(unwatch_struct, "unwatch");
573668
     size_t struct_size = datalayout().getTypeAllocSize(unwatch_struct);
573668
 
573668
-    b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::watchpoint_detach)),
573668
-                   b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
+    b_.CreateStore(
573668
+        b_.getInt64(asyncactionint(AsyncAction::watchpoint_detach)),
573668
+        b_.CreateGEP(unwatch_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
     b_.CreateStore(
573668
         b_.CreateIntCast(expr_, b_.getInt64Ty(), false /* unsigned */),
573668
-        b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
+        b_.CreateGEP(unwatch_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
     b_.CreatePerfEventOutput(ctx_, buf, struct_size);
573668
     b_.CreateLifetimeEnd(buf);
573668
     expr_ = nullptr;
573668
@@ -1102,7 +1129,8 @@ void CodegenLLVM::visit(Variable &var)
573668
   }
573668
   else
573668
   {
573668
-    expr_ = b_.CreateLoad(variables_[var.ident]);
573668
+    auto *var_alloca = variables_[var.ident];
573668
+    expr_ = b_.CreateLoad(var_alloca->getType()->getElementType(), var_alloca);
573668
   }
573668
 }
573668
 
573668
@@ -1379,13 +1407,15 @@ void CodegenLLVM::visit(Unop &unop)
573668
           if (unop.is_post_op)
573668
             expr_ = oldval;
573668
           else
573668
-            expr_ = b_.CreateLoad(newval);
573668
+            expr_ = b_.CreateLoad(b_.GetType(map.type), newval);
573668
           b_.CreateLifetimeEnd(newval);
573668
         }
573668
         else if (unop.expr->is_variable)
573668
         {
573668
           Variable &var = static_cast<Variable&>(*unop.expr);
573668
-          Value *oldval = b_.CreateLoad(variables_[var.ident]);
573668
+          Value *oldval = b_.CreateLoad(
573668
+		  variables_[var.ident]->getType()->getElementType(),
573668
+		  variables_[var.ident]);
573668
           Value *newval;
573668
           if (is_increment)
573668
             newval = b_.CreateAdd(oldval, b_.getInt64(1));
573668
@@ -1411,9 +1441,10 @@ void CodegenLLVM::visit(Unop &unop)
573668
                                   : type.GetSize();
573668
         auto as =  type.GetAS();
573668
 
573668
-        AllocaInst *dst = b_.CreateAllocaBPF(SizedType(type.type, size), "deref");
573668
+	auto dst_type = SizedType(type.type, size);
573668
+        AllocaInst *dst = b_.CreateAllocaBPF(dst_type, "deref");
573668
         b_.CreateProbeRead(ctx_, dst, size, expr_, as, unop.loc);
573668
-        expr_ = b_.CreateIntCast(b_.CreateLoad(dst),
573668
+        expr_ = b_.CreateIntCast(b_.CreateLoad(b_.GetType(dst_type), dst),
573668
                                  b_.getInt64Ty(),
573668
                                  type.IsSigned());
573668
         b_.CreateLifetimeEnd(dst);
573668
@@ -1434,7 +1465,7 @@ void CodegenLLVM::visit(Unop &unop)
573668
           int size = unop.type.IsIntegerTy() ? et->GetIntBitWidth() / 8 : 8;
573668
           AllocaInst *dst = b_.CreateAllocaBPF(*et, "deref");
573668
           b_.CreateProbeRead(ctx_, dst, size, expr_, type.GetAS(), unop.loc);
573668
-          expr_ = b_.CreateIntCast(b_.CreateLoad(dst),
573668
+          expr_ = b_.CreateIntCast(b_.CreateLoad(b_.GetType(*et), dst),
573668
                                    b_.getInt64Ty(),
573668
                                    unop.type.IsSigned());
573668
           b_.CreateLifetimeEnd(dst);
573668
@@ -1492,7 +1523,7 @@ void CodegenLLVM::visit(Ternary &ternary)
573668
     b_.CreateBr(done);
573668
 
573668
     b_.SetInsertPoint(done);
573668
-    expr_ = b_.CreateLoad(result);
573668
+    expr_ = b_.CreateLoad(b_.GetType(ternary.type), result);
573668
   }
573668
   else if (ternary.type.IsStringTy())
573668
   {
573668
@@ -1549,7 +1580,8 @@ void CodegenLLVM::visit(FieldAccess &acc)
573668
   }
573668
   else if (type.IsTupleTy())
573668
   {
573668
-    Value *src = b_.CreateGEP(expr_,
573668
+    Value *src = b_.CreateGEP(b_.GetType(type),
573668
+                              expr_,
573668
                               { b_.getInt32(0), b_.getInt32(acc.index) });
573668
     SizedType &elem_type = type.GetFields()[acc.index].type;
573668
 
573668
@@ -1596,10 +1628,12 @@ void CodegenLLVM::visit(FieldAccess &acc)
573668
       if (field.is_bitfield)
573668
       {
573668
         Value *raw;
573668
+        auto field_type = b_.GetType(field.type);
573668
         if (type.IsCtxAccess())
573668
-          raw = b_.CreateLoad(
573668
-              b_.CreateIntToPtr(src, b_.GetType(field.type)->getPointerTo()),
573668
-              true);
573668
+          raw = b_.CreateLoad(field_type,
573668
+                              b_.CreateIntToPtr(src,
573668
+                                                field_type->getPointerTo()),
573668
+                              true);
573668
         else
573668
         {
573668
           AllocaInst *dst = b_.CreateAllocaBPF(field.type,
573668
@@ -1610,7 +1644,7 @@ void CodegenLLVM::visit(FieldAccess &acc)
573668
           b_.CREATE_MEMSET(dst, b_.getInt8(0), field.type.GetSize(), 1);
573668
           b_.CreateProbeRead(
573668
               ctx_, dst, field.bitfield.read_bytes, src, type.GetAS(), acc.loc);
573668
-          raw = b_.CreateLoad(dst);
573668
+          raw = b_.CreateLoad(field_type, dst);
573668
           b_.CreateLifetimeEnd(dst);
573668
         }
573668
         size_t rshiftbits;
573668
@@ -1638,7 +1672,8 @@ void CodegenLLVM::visit(FieldAccess &acc)
573668
         // offset which we add to the start of the tracepoint struct.
573668
         expr_ = b_.CreateLoad(
573668
             b_.getInt32Ty(),
573668
-            b_.CreateGEP(b_.CreatePointerCast(ctx_,
573668
+            b_.CreateGEP(b_.getInt32Ty(),
573668
+                         b_.CreatePointerCast(ctx_,
573668
                                               b_.getInt32Ty()->getPointerTo()),
573668
                          b_.getInt64(field.offset / 4)));
573668
         expr_ = b_.CreateIntCast(expr_, b_.getInt64Ty(), false);
573668
@@ -1757,7 +1792,9 @@ void CodegenLLVM::visit(Tuple &tuple)
573668
     Expression *elem = tuple.elems->at(i);
573668
     auto scoped_del = accept(elem);
573668
 
573668
-    Value *dst = b_.CreateGEP(buf, { b_.getInt32(0), b_.getInt32(i) });
573668
+    Value *dst = b_.CreateGEP(tuple_ty,
573668
+                              buf,
573668
+                              { b_.getInt32(0), b_.getInt32(i) });
573668
 
573668
     if (onStack(elem->type))
573668
       b_.CREATE_MEMCPY(dst, expr_, elem->type.GetSize(), 1);
573668
@@ -2357,6 +2394,7 @@ std::tuple<Value *, CodegenLLVM::ScopedExprDeleter> CodegenLLVM::getMapKey(
573668
         size += expr->type.GetSize();
573668
       }
573668
       key = b_.CreateAllocaBPF(size, map.ident + "_key");
573668
+      auto *key_type = ArrayType::get(b_.getInt8Ty(), size);
573668
 
573668
       int offset = 0;
573668
       // Construct a map key in the stack
573668
@@ -2364,7 +2402,8 @@ std::tuple<Value *, CodegenLLVM::ScopedExprDeleter> CodegenLLVM::getMapKey(
573668
       {
573668
         auto scoped_del = accept(expr);
573668
         Value *offset_val = b_.CreateGEP(
573668
-            key, { b_.getInt64(0), b_.getInt64(offset) });
573668
+		key_type, key,
573668
+		{ b_.getInt64(0), b_.getInt64(offset) });
573668
 
573668
         if (onStack(expr->type))
573668
           b_.CREATE_MEMCPY(offset_val, expr_, expr->type.GetSize(), 1);
573668
@@ -2417,18 +2456,19 @@ AllocaInst *CodegenLLVM::getHistMapKey(Map &map, Value *log2)
573668
       size += expr->type.GetSize();
573668
     }
573668
     key = b_.CreateAllocaBPF(size, map.ident + "_key");
573668
+    auto *key_type = ArrayType::get(b_.getInt8Ty(), size);
573668
 
573668
     int offset = 0;
573668
     for (Expression *expr : *map.vargs) {
573668
       auto scoped_del = accept(expr);
573668
-      Value *offset_val = b_.CreateGEP(key, {b_.getInt64(0), b_.getInt64(offset)});
573668
+      Value *offset_val = b_.CreateGEP(key_type, key, {b_.getInt64(0), b_.getInt64(offset)});
573668
       if (shouldBeOnStackAlready(expr->type))
573668
         b_.CREATE_MEMCPY(offset_val, expr_, expr->type.GetSize(), 1);
573668
       else
573668
         b_.CreateStore(expr_, offset_val);
573668
       offset += expr->type.GetSize();
573668
     }
573668
-    Value *offset_val = b_.CreateGEP(key, {b_.getInt64(0), b_.getInt64(offset)});
573668
+    Value *offset_val = b_.CreateGEP(key_type, key, {b_.getInt64(0), b_.getInt64(offset)});
573668
     b_.CreateStore(log2, offset_val);
573668
   }
573668
   else
573668
@@ -2475,7 +2515,7 @@ Value *CodegenLLVM::createLogicalAnd(Binop &binop)
573668
   b_.CreateBr(merge_block);
573668
 
573668
   b_.SetInsertPoint(merge_block);
573668
-  return b_.CreateLoad(result);
573668
+  return b_.CreateLoad(b_.getInt64Ty(), result);
573668
 }
573668
 
573668
 Value *CodegenLLVM::createLogicalOr(Binop &binop)
573668
@@ -2514,7 +2554,7 @@ Value *CodegenLLVM::createLogicalOr(Binop &binop)
573668
   b_.CreateBr(merge_block);
573668
 
573668
   b_.SetInsertPoint(merge_block);
573668
-  return b_.CreateLoad(result);
573668
+  return b_.CreateLoad(b_.getInt64Ty(), result);
573668
 }
573668
 
573668
 Function *CodegenLLVM::createLog2Function()
573668
@@ -2558,34 +2598,37 @@ Function *CodegenLLVM::createLog2Function()
573668
   // test for less than zero
573668
   BasicBlock *is_less_than_zero = BasicBlock::Create(module_->getContext(), "hist.is_less_than_zero", log2_func);
573668
   BasicBlock *is_not_less_than_zero = BasicBlock::Create(module_->getContext(), "hist.is_not_less_than_zero", log2_func);
573668
-  b_.CreateCondBr(b_.CreateICmpSLT(b_.CreateLoad(n_alloc), b_.getInt64(0)),
573668
+  b_.CreateCondBr(b_.CreateICmpSLT(b_.CreateLoad(b_.getInt64Ty(), n_alloc),
573668
+                                   b_.getInt64(0)),
573668
                   is_less_than_zero,
573668
                   is_not_less_than_zero);
573668
   b_.SetInsertPoint(is_less_than_zero);
573668
-  createRet(b_.CreateLoad(result));
573668
+  createRet(b_.CreateLoad(b_.getInt64Ty(), result));
573668
   b_.SetInsertPoint(is_not_less_than_zero);
573668
 
573668
   // test for equal to zero
573668
   BasicBlock *is_zero = BasicBlock::Create(module_->getContext(), "hist.is_zero", log2_func);
573668
   BasicBlock *is_not_zero = BasicBlock::Create(module_->getContext(), "hist.is_not_zero", log2_func);
573668
-  b_.CreateCondBr(b_.CreateICmpEQ(b_.CreateLoad(n_alloc), b_.getInt64(0)),
573668
+  b_.CreateCondBr(b_.CreateICmpEQ(b_.CreateLoad(b_.getInt64Ty(), n_alloc),
573668
+                                  b_.getInt64(0)),
573668
                   is_zero,
573668
                   is_not_zero);
573668
   b_.SetInsertPoint(is_zero);
573668
   b_.CreateStore(b_.getInt64(1), result);
573668
-  createRet(b_.CreateLoad(result));
573668
+  createRet(b_.CreateLoad(b_.getInt64Ty(), result));
573668
   b_.SetInsertPoint(is_not_zero);
573668
 
573668
   // power-of-2 index, offset by +2
573668
   b_.CreateStore(b_.getInt64(2), result);
573668
   for (int i = 4; i >= 0; i--)
573668
   {
573668
-    Value *n = b_.CreateLoad(n_alloc);
573668
+    Value *n = b_.CreateLoad(b_.getInt64Ty(), n_alloc);
573668
     Value *shift = b_.CreateShl(b_.CreateIntCast(b_.CreateICmpSGE(b_.CreateIntCast(n, b_.getInt64Ty(), false), b_.getInt64(1 << (1<
573668
     b_.CreateStore(b_.CreateLShr(n, shift), n_alloc);
573668
-    b_.CreateStore(b_.CreateAdd(b_.CreateLoad(result), shift), result);
573668
+    b_.CreateStore(b_.CreateAdd(b_.CreateLoad(b_.getInt64Ty(), result), shift),
573668
+                   result);
573668
   }
573668
-  createRet(b_.CreateLoad(result));
573668
+  createRet(b_.CreateLoad(b_.getInt64Ty(), result));
573668
   b_.restoreIP(ip);
573668
   return module_->getFunction("log2");
573668
 }
573668
@@ -2635,8 +2678,8 @@ Function *CodegenLLVM::createLinearFunction()
573668
 
573668
   // algorithm
573668
   {
573668
-    Value *min = b_.CreateLoad(min_alloc);
573668
-    Value *val = b_.CreateLoad(value_alloc);
573668
+    Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc);
573668
+    Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc);
573668
     cmp = b_.CreateICmpSLT(val, min);
573668
   }
573668
   BasicBlock *lt_min = BasicBlock::Create(module_->getContext(), "lhist.lt_min", linear_func);
573668
@@ -2648,8 +2691,8 @@ Function *CodegenLLVM::createLinearFunction()
573668
 
573668
   b_.SetInsertPoint(ge_min);
573668
   {
573668
-    Value *max = b_.CreateLoad(max_alloc);
573668
-    Value *val = b_.CreateLoad(value_alloc);
573668
+    Value *max = b_.CreateLoad(b_.getInt64Ty(), max_alloc);
573668
+    Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc);
573668
     cmp = b_.CreateICmpSGT(val, max);
573668
   }
573668
   BasicBlock *le_max = BasicBlock::Create(module_->getContext(), "lhist.le_max", linear_func);
573668
@@ -2658,22 +2701,22 @@ Function *CodegenLLVM::createLinearFunction()
573668
 
573668
   b_.SetInsertPoint(gt_max);
573668
   {
573668
-    Value *step = b_.CreateLoad(step_alloc);
573668
-    Value *min = b_.CreateLoad(min_alloc);
573668
-    Value *max = b_.CreateLoad(max_alloc);
573668
+    Value *step = b_.CreateLoad(b_.getInt64Ty(), step_alloc);
573668
+    Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc);
573668
+    Value *max = b_.CreateLoad(b_.getInt64Ty(), max_alloc);
573668
     Value *div = b_.CreateUDiv(b_.CreateSub(max, min), step);
573668
     b_.CreateStore(b_.CreateAdd(div, b_.getInt64(1)), result_alloc);
573668
-    createRet(b_.CreateLoad(result_alloc));
573668
+    createRet(b_.CreateLoad(b_.getInt64Ty(), result_alloc));
573668
   }
573668
 
573668
   b_.SetInsertPoint(le_max);
573668
   {
573668
-    Value *step = b_.CreateLoad(step_alloc);
573668
-    Value *min = b_.CreateLoad(min_alloc);
573668
-    Value *val = b_.CreateLoad(value_alloc);
573668
+    Value *step = b_.CreateLoad(b_.getInt64Ty(), step_alloc);
573668
+    Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc);
573668
+    Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc);
573668
     Value *div3 = b_.CreateUDiv(b_.CreateSub(val, min), step);
573668
     b_.CreateStore(b_.CreateAdd(div3, b_.getInt64(1)), result_alloc);
573668
-    createRet(b_.CreateLoad(result_alloc));
573668
+    createRet(b_.CreateLoad(b_.getInt64Ty(), result_alloc));
573668
   }
573668
 
573668
   b_.restoreIP(ip);
573668
@@ -2711,14 +2754,18 @@ void CodegenLLVM::createFormatStringCall(Call &call, int &id, CallArgs &call_arg
573668
   // as the struct is not packed we need to memset it.
573668
   b_.CREATE_MEMSET(fmt_args, b_.getInt8(0), struct_size, 1);
573668
 
573668
-  Value *id_offset = b_.CreateGEP(fmt_args, {b_.getInt32(0), b_.getInt32(0)});
573668
+  Value *id_offset = b_.CreateGEP(fmt_struct,
573668
+                                  fmt_args,
573668
+                                  { b_.getInt32(0), b_.getInt32(0) });
573668
   b_.CreateStore(b_.getInt64(id + asyncactionint(async_action)), id_offset);
573668
 
573668
   for (size_t i=1; i<call.vargs->size(); i++)
573668
   {
573668
     Expression &arg = *call.vargs->at(i);
573668
     auto scoped_del = accept(&arg;;
573668
-    Value *offset = b_.CreateGEP(fmt_args, {b_.getInt32(0), b_.getInt32(i)});
573668
+    Value *offset = b_.CreateGEP(fmt_struct,
573668
+                                 fmt_args,
573668
+                                 { b_.getInt32(0), b_.getInt32(i) });
573668
     if (needMemcpy(arg.type))
573668
       b_.CREATE_MEMCPY(offset, expr_, arg.type.GetSize(), 1);
573668
     else if (arg.type.IsIntegerTy() && arg.type.GetSize() < 8)
573668
@@ -2758,10 +2805,12 @@ void CodegenLLVM::generateWatchpointSetupProbe(
573668
   // Pull out function argument
573668
   Value *ctx = func->arg_begin();
573668
   int offset = arch::arg_offset(arg_num);
573668
-  Value *addr = b_.CreateLoad(
573668
-      b_.getInt64Ty(),
573668
-      b_.CreateGEP(ctx, b_.getInt64(offset * sizeof(uintptr_t))),
573668
-      "arg" + std::to_string(arg_num));
573668
+  Value *arg = b_.CreateGEP(b_.getInt8Ty(),
573668
+                            ctx,
573668
+                            b_.getInt64(offset * sizeof(uintptr_t)));
573668
+  Value *addr = b_.CreateLoad(b_.getInt64Ty(),
573668
+                              arg,
573668
+                              "arg" + std::to_string(arg_num));
573668
 
573668
   // Tell userspace to setup the real watchpoint
573668
   auto elements = AsyncEvent::Watchpoint().asLLVMType(b_);
573668
@@ -2772,12 +2821,16 @@ void CodegenLLVM::generateWatchpointSetupProbe(
573668
   size_t struct_size = datalayout().getTypeAllocSize(watchpoint_struct);
573668
 
573668
   // Fill in perf event struct
573668
-  b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::watchpoint_attach)),
573668
-                 b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
-  b_.CreateStore(b_.getInt64(watchpoint_id_),
573668
-                 b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
+  b_.CreateStore(
573668
+      b_.getInt64(asyncactionint(AsyncAction::watchpoint_attach)),
573668
+      b_.CreateGEP(watchpoint_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
+  b_.CreateStore(
573668
+      b_.getInt64(watchpoint_id_),
573668
+      b_.CreateGEP(watchpoint_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
   watchpoint_id_++;
573668
-  b_.CreateStore(addr, b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(2) }));
573668
+  b_.CreateStore(
573668
+      addr,
573668
+      b_.CreateGEP(watchpoint_struct, buf, { b_.getInt64(0), b_.getInt32(2) }));
573668
   b_.CreatePerfEventOutput(ctx, buf, struct_size);
573668
   b_.CreateLifetimeEnd(buf);
573668
 
573668
@@ -2796,11 +2849,14 @@ void CodegenLLVM::createPrintMapCall(Call &call)
573668
                                        call.func + "_" + map.ident);
573668
 
573668
   // store asyncactionid:
573668
-  b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::print)),
573668
-                 b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
+  b_.CreateStore(
573668
+      b_.getInt64(asyncactionint(AsyncAction::print)),
573668
+      b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
 
573668
   auto id = bpftrace_.maps[map.ident].value()->id;
573668
-  auto *ident_ptr = b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) });
573668
+  auto *ident_ptr = b_.CreateGEP(print_struct,
573668
+                                 buf,
573668
+                                 { b_.getInt64(0), b_.getInt32(1) });
573668
   b_.CreateStore(b_.GetIntSameSize(id, elements.at(1)), ident_ptr);
573668
 
573668
   // top, div
573668
@@ -2812,14 +2868,16 @@ void CodegenLLVM::createPrintMapCall(Call &call)
573668
     auto scoped_del = accept(call.vargs->at(arg_idx));
573668
 
573668
     b_.CreateStore(b_.CreateIntCast(expr_, elements.at(arg_idx), false),
573668
-                   b_.CreateGEP(buf,
573668
+                   b_.CreateGEP(print_struct,
573668
+                                buf,
573668
                                 { b_.getInt64(0), b_.getInt32(arg_idx + 1) }));
573668
   }
573668
 
573668
   for (; arg_idx < 3; arg_idx++)
573668
   {
573668
     b_.CreateStore(b_.GetIntSameSize(0, elements.at(arg_idx)),
573668
-                   b_.CreateGEP(buf,
573668
+                   b_.CreateGEP(print_struct,
573668
+                                buf,
573668
                                 { b_.getInt64(0), b_.getInt32(arg_idx + 1) }));
573668
   }
573668
 
573668
@@ -2844,15 +2902,19 @@ void CodegenLLVM::createPrintNonMapCall(Call &call, int &id)
573668
   size_t struct_size = datalayout().getTypeAllocSize(print_struct);
573668
 
573668
   // Store asyncactionid:
573668
-  b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::print_non_map)),
573668
-                 b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
+  b_.CreateStore(
573668
+      b_.getInt64(asyncactionint(AsyncAction::print_non_map)),
573668
+      b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
573668
 
573668
   // Store print id
573668
-  b_.CreateStore(b_.getInt64(id),
573668
-                 b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
+  b_.CreateStore(
573668
+      b_.getInt64(id),
573668
+      b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
573668
 
573668
   // Store content
573668
-  Value *content_offset = b_.CreateGEP(buf, { b_.getInt32(0), b_.getInt32(2) });
573668
+  Value *content_offset = b_.CreateGEP(print_struct,
573668
+                                       buf,
573668
+                                       { b_.getInt32(0), b_.getInt32(2) });
573668
   b_.CREATE_MEMSET(content_offset, b_.getInt8(0), arg.type.GetSize(), 1);
573668
   if (needMemcpy(arg.type))
573668
   {
573668
@@ -3023,7 +3085,9 @@ void CodegenLLVM::readDatastructElemFromStack(Value *src_data,
573668
     src_data = b_.CreateIntToPtr(src_data,
573668
                                  b_.GetType(data_type)->getPointerTo());
573668
 
573668
-  Value *src = b_.CreateGEP(src_data, { b_.getInt32(0), index });
573668
+  Value *src = b_.CreateGEP(b_.GetType(data_type),
573668
+                            src_data,
573668
+                            { b_.getInt32(0), index });
573668
 
573668
   // It may happen that the result pointer type is not correct, in such case
573668
   // do a typecast
573668
@@ -3034,7 +3098,7 @@ void CodegenLLVM::readDatastructElemFromStack(Value *src_data,
573668
   if (elem_type.IsIntegerTy() || elem_type.IsPtrTy())
573668
   {
573668
     // Load the correct type from src
573668
-    expr_ = b_.CreateLoad(src, true);
573668
+    expr_ = b_.CreateLoad(b_.GetType(elem_type), src, true);
573668
   }
573668
   else
573668
   {
573668
@@ -3101,7 +3165,8 @@ void CodegenLLVM::probereadDatastructElem(Value *src_data,
573668
     // Read data onto stack
573668
     if (data_type.IsCtxAccess())
573668
     {
573668
-      expr_ = b_.CreateLoad(b_.CreateIntToPtr(src, dst_type->getPointerTo()),
573668
+      expr_ = b_.CreateLoad(dst_type,
573668
+                            b_.CreateIntToPtr(src, dst_type->getPointerTo()),
573668
                             true);
573668
       expr_ = b_.CreateIntCast(expr_, b_.getInt64Ty(), elem_type.IsSigned());
573668
 
573668
@@ -3132,7 +3197,7 @@ void CodegenLLVM::probereadDatastructElem(Value *src_data,
573668
       AllocaInst *dst = b_.CreateAllocaBPF(elem_type, temp_name);
573668
       b_.CreateProbeRead(
573668
           ctx_, dst, elem_type.GetSize(), src, data_type.GetAS(), loc);
573668
-      expr_ = b_.CreateIntCast(b_.CreateLoad(dst),
573668
+      expr_ = b_.CreateIntCast(b_.CreateLoad(b_.GetType(elem_type), dst),
573668
                                b_.getInt64Ty(),
573668
                                elem_type.IsSigned());
573668
       b_.CreateLifetimeEnd(dst);
573668
diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp
573668
index ab1464d3..59771e91 100644
573668
--- a/src/ast/irbuilderbpf.cpp
573668
+++ b/src/ast/irbuilderbpf.cpp
573668
@@ -94,8 +94,8 @@ AllocaInst *IRBuilderBPF::CreateUSym(llvm::Value *val)
573668
   Value *pid = CreateLShr(CreateGetPidTgid(), 32);
573668
 
573668
   // The extra 0 here ensures the type of addr_offset will be int64
573668
-  Value *addr_offset = CreateGEP(buf, { getInt64(0), getInt32(0) });
573668
-  Value *pid_offset = CreateGEP(buf, { getInt64(0), getInt32(1) });
573668
+  Value *addr_offset = CreateGEP(usym_t, buf, { getInt64(0), getInt32(0) });
573668
+  Value *pid_offset = CreateGEP(usym_t, buf, { getInt64(0), getInt32(1) });
573668
 
573668
   CreateStore(val, addr_offset);
573668
   CreateStore(pid, pid_offset);
573668
@@ -401,7 +401,8 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx,
573668
   if (needMemcpy(type))
573668
     return value;
573668
 
573668
-  Value *ret = CreateLoad(value);
573668
+  // value is a pointer to i64
573668
+  Value *ret = CreateLoad(getInt64Ty(), value);
573668
   CreateLifetimeEnd(value);
573668
   return ret;
573668
 }
573668
@@ -621,7 +622,10 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx,
573668
     // bpftrace's args are internally represented as 64 bit integers. However,
573668
     // the underlying argument (of the target program) may be less than 64
573668
     // bits. So we must be careful to zero out unused bits.
573668
-    Value* reg = CreateGEP(ctx, getInt64(offset * sizeof(uintptr_t)), "load_register");
573668
+    Value *reg = CreateGEP(getInt8Ty(),
573668
+                           ctx,
573668
+                           getInt64(offset * sizeof(uintptr_t)),
573668
+                           "load_register");
573668
     AllocaInst *dst = CreateAllocaBPF(builtin.type, builtin.ident);
573668
     Value *index_offset = nullptr;
573668
     if (argument->valid & BCC_USDT_ARGUMENT_INDEX_REGISTER_NAME)
573668
@@ -632,7 +636,8 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx,
573668
         LOG(FATAL) << "offset for register " << argument->index_register_name
573668
                    << " not known";
573668
       }
573668
-      index_offset = CreateGEP(ctx,
573668
+      index_offset = CreateGEP(getInt8Ty(),
573668
+                               ctx,
573668
                                getInt64(ioffset * sizeof(uintptr_t)),
573668
                                "load_register");
573668
       index_offset = CreateLoad(getInt64Ty(), index_offset);
573668
@@ -754,7 +759,7 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx __attribute__((unused)),
573668
                                                "strcmp.loop",
573668
                                                parent);
573668
 
573668
-      auto *ptr = CreateGEP(val, { getInt32(0), getInt32(i) });
573668
+      auto *ptr = CreateGEP(valp->getElementType(), val, { getInt32(0), getInt32(i) });
573668
       Value *l = CreateLoad(getInt8Ty(), ptr);
573668
       Value *r = getInt8(c_str[i]);
573668
       Value *cmp = CreateICmpNE(l, r, "strcmp.cmp");
573668
@@ -767,7 +772,8 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx __attribute__((unused)),
573668
   CreateBr(str_ne);
573668
 
573668
   SetInsertPoint(str_ne);
573668
-  Value *result = CreateLoad(store);
573668
+  // store is a pointer to bool (i1 *)
573668
+  Value *result = CreateLoad(getInt1Ty(), store);
573668
   CreateLifetimeEnd(store);
573668
   result = CreateIntCast(result, getInt64Ty(), false);
573668
   return result;
573668
@@ -817,9 +823,11 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx,
573668
      }
573668
   */
573668
 
573668
+  auto *val1p = dyn_cast<PointerType>(val1->getType());
573668
+  auto *val2p = dyn_cast<PointerType>(val2->getType());
573668
 #ifndef NDEBUG
573668
-  PointerType *val1p = cast<PointerType>(val1->getType());
573668
-  PointerType *val2p = cast<PointerType>(val2->getType());
573668
+  assert(val1p);
573668
+  assert(val2p);
573668
 
573668
   assert(val1p->getElementType()->isArrayTy() &&
573668
          val1p->getElementType()->getArrayElementType() == getInt8Ty());
573668
@@ -852,11 +860,11 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx,
573668
                                                      "strcmp.loop_null_cmp",
573668
                                                      parent);
573668
 
573668
-    auto *ptr1 = CreateGEP(val1, { getInt32(0), getInt32(i) });
573668
+    auto *ptr1 = CreateGEP(val1p->getElementType(), val1, { getInt32(0), getInt32(i) });
573668
     CreateProbeRead(ctx, val_l, 1, ptr1, as1, loc);
573668
     Value *l = CreateLoad(getInt8Ty(), val_l);
573668
 
573668
-    auto *ptr2 = CreateGEP(val2, { getInt32(0), getInt32(i) });
573668
+    auto *ptr2 = CreateGEP(val2p->getElementType(), val2, { getInt32(0), getInt32(i) });
573668
     CreateProbeRead(ctx, val_r, 1, ptr2, as2, loc);
573668
     Value *r = CreateLoad(getInt8Ty(), val_r);
573668
 
573668
@@ -878,7 +886,8 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx,
573668
   CreateBr(str_ne);
573668
   SetInsertPoint(str_ne);
573668
 
573668
-  Value *result = CreateLoad(store);
573668
+  // store is a pointer to bool (i1 *)
573668
+  Value *result = CreateLoad(getInt1Ty(), store);
573668
   CreateLifetimeEnd(store);
573668
   CreateLifetimeEnd(val_l);
573668
   CreateLifetimeEnd(val_r);
573668
@@ -1107,7 +1116,7 @@ Value *IRBuilderBPF::CreatKFuncArg(Value *ctx,
573668
 {
573668
   ctx = CreatePointerCast(ctx, getInt64Ty()->getPointerTo());
573668
   Value *expr = CreateLoad(getInt64Ty(),
573668
-                           CreateGEP(ctx, getInt64(type.kfarg_idx)),
573668
+                           CreateGEP(getInt64Ty(), ctx, getInt64(type.kfarg_idx)),
573668
                            name);
573668
 
573668
   // LLVM 7.0 <= does not have CreateLoad(*Ty, *Ptr, isVolatile, Name),
573668
@@ -1161,12 +1170,15 @@ void IRBuilderBPF::CreateHelperError(Value *ctx,
573668
                                                   elements,
573668
                                                   true);
573668
   AllocaInst *buf = CreateAllocaBPF(helper_error_struct, "helper_error_t");
573668
-  CreateStore(GetIntSameSize(asyncactionint(AsyncAction::helper_error),
573668
-                             elements.at(0)),
573668
-              CreateGEP(buf, { getInt64(0), getInt32(0) }));
573668
-  CreateStore(GetIntSameSize(error_id, elements.at(1)),
573668
-              CreateGEP(buf, { getInt64(0), getInt32(1) }));
573668
-  CreateStore(return_value, CreateGEP(buf, { getInt64(0), getInt32(2) }));
573668
+  CreateStore(
573668
+      GetIntSameSize(asyncactionint(AsyncAction::helper_error), elements.at(0)),
573668
+      CreateGEP(helper_error_struct, buf, { getInt64(0), getInt32(0) }));
573668
+  CreateStore(
573668
+      GetIntSameSize(error_id, elements.at(1)),
573668
+      CreateGEP(helper_error_struct, buf, { getInt64(0), getInt32(1) }));
573668
+  CreateStore(
573668
+      return_value,
573668
+      CreateGEP(helper_error_struct, buf, { getInt64(0), getInt32(2) }));
573668
 
573668
   auto &layout = module_.getDataLayout();
573668
   auto struct_size = layout.getTypeAllocSize(helper_error_struct);
573668
@@ -1256,11 +1268,13 @@ void IRBuilderBPF::CreateSeqPrintf(Value *ctx,
573668
 
573668
   ctx = CreatePointerCast(ctx, getInt8Ty()->getPointerTo());
573668
   Value *meta = CreateLoad(getInt64Ty()->getPointerTo(),
573668
-                           CreateGEP(ctx, getInt64(0)),
573668
+                           CreateGEP(getInt8Ty(), ctx, getInt64(0)),
573668
                            "meta");
573668
   dyn_cast<LoadInst>(meta)->setVolatile(true);
573668
 
573668
-  Value *seq = CreateLoad(getInt64Ty(), CreateGEP(meta, getInt64(0)), "seq");
573668
+  Value *seq = CreateLoad(getInt64Ty(),
573668
+                          CreateGEP(getInt64Ty(), meta, getInt64(0)),
573668
+                          "seq");
573668
 
573668
   CallInst *call = createCall(seq_printf_func,
573668
                               { seq, fmt, fmt_size, data, data_len },
573668
-- 
573668
2.35.3
573668