[llvm-dev] Creating int8** Pointer - Debug build works but not Release

Lorenz Braun via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 21 03:27:36 PDT 2017


Here the solution to my problem. Maybe someone else has the same problem 
in the future.

As it seems using ArrayRef to store the types in caused the error. As 
the documentation [0] states it is not safe to store data in ArrayRef. I 
just used a normal std::vector and everything worked fine:
-  ArrayRef<Type*> reg_var_arg_ty = {TypeBuilder<int8_t**, 
false>::get(ctx), Type::getInt8PtrTy(ctx), ... }
+  vector<Type*> reg_var_arg_ty = 
{Type::getInt8PtrTy(ctx)->getPointerTo(), Type::getInt8PtrTy(ctx), ... }

Regards
Lorenz

[0] http://llvm.org/doxygen/classllvm_1_1ArrayRef.html#details

Am 20.07.17 um 16:21 schrieb Lorenz Braun via llvm-dev:
> Hello everyone,
>
> i am writing an transformation pass where i want to insert a specific 
> function call. To get this function i need to create a functionType. 
> This type has an int** as first argument. It all worked fine until i 
> build my pass as release build.
>
> The culprit is probably the creation of the int** type. With the debug 
> build getTypeID() give me 15, which is what i expect according to [0]. 
> With the release build getTypeID() yields 72. Which is probably why i 
> get segmentation faults when i try to use it or simply call dump().
>
> I tried creating the Type in different ways:
>
> Type::getInt8PtrTy(ctx)->getPointerTo()
> TypeBuilder<int8_t**, false>::get(ctx)
> PointerType::get(Type::getInt8PtrTy(ctx), 0)
>
> All seem to give me the same result. Might this be some kind of bug? 
> Any suggestions how to work around this problem?
>
> Best Regards
>
> Lorenz
>
>
> [0] 
> http://llvm.org/doxygen/classllvm_1_1Type.html#a5e9e1c0dd93557be1b4ad72860f3cbda
>

-- 
Lorenz Braun
Research Associate
Institute of Computer Engineering (ZITI)
B6, 26, Building B, Office B2.20
68131 Mannheim

Phone: +49-621-181-2696
lorenz.braun at ziti.uni-heidelberg.de



More information about the llvm-dev mailing list