Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2111a48

Browse files
committed
Adapt expression JIT to stdbool.h introduction.
The LLVM JIT provider uses clang to synchronize types between normal Ccode and runtime generated code. Clang represents stdbool.h stylebooleans in return values & parameters differently from booleansstored in variables.Thus the expression compilation code from2a0faed needs to beadapted to9a95a77. Instead of hardcoding i8 as the type forbooleans (which already was wrong on some edge case platforms!), usepostgres' notion of a boolean as used for storage and for parameters.Per buildfarm animal xenodermus.Author: Andres Freund
1 parentfdb7894 commit2111a48

File tree

5 files changed

+132
-64
lines changed

5 files changed

+132
-64
lines changed

‎src/backend/jit/llvm/llvmjit.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ typedef struct LLVMJitHandle
4646

4747
/* types & functions commonly needed for JITing */
4848
LLVMTypeRefTypeSizeT;
49+
LLVMTypeRefTypeParamBool;
50+
LLVMTypeRefTypeStorageBool;
4951
LLVMTypeRefTypePGFunction;
5052
LLVMTypeRefStructHeapTupleFieldsField3;
5153
LLVMTypeRefStructHeapTupleFields;
@@ -682,7 +684,7 @@ llvm_shutdown(int code, Datum arg)
682684
}
683685
}
684686

685-
/* helper for llvm_create_types */
687+
/* helper for llvm_create_types, returning a global var's type */
686688
staticLLVMTypeRef
687689
load_type(LLVMModuleRefmod,constchar*name)
688690
{
@@ -702,6 +704,31 @@ load_type(LLVMModuleRef mod, const char *name)
702704
returntyp;
703705
}
704706

707+
/* helper for llvm_create_types, returning a function's return type */
708+
staticLLVMTypeRef
709+
load_return_type(LLVMModuleRefmod,constchar*name)
710+
{
711+
LLVMValueRefvalue;
712+
LLVMTypeReftyp;
713+
714+
/* this'll return a *pointer* to the function */
715+
value=LLVMGetNamedFunction(mod,name);
716+
if (!value)
717+
elog(ERROR,"function %s is unknown",name);
718+
719+
/* get type of function pointer */
720+
typ=LLVMTypeOf(value);
721+
Assert(typ!=NULL);
722+
/* dereference pointer */
723+
typ=LLVMGetElementType(typ);
724+
Assert(typ!=NULL);
725+
/* and look at return type */
726+
typ=LLVMGetReturnType(typ);
727+
Assert(typ!=NULL);
728+
729+
returntyp;
730+
}
731+
705732
/*
706733
* Load required information, types, function signatures from llvmjit_types.c
707734
* and make them available in global variables.
@@ -740,6 +767,8 @@ llvm_create_types(void)
740767
llvm_layout=pstrdup(LLVMGetDataLayoutStr(mod));
741768

742769
TypeSizeT=load_type(mod,"TypeSizeT");
770+
TypeParamBool=load_return_type(mod,"FunctionReturningBool");
771+
TypeStorageBool=load_type(mod,"TypeStorageBool");
743772
TypePGFunction=load_type(mod,"TypePGFunction");
744773
StructExprContext=load_type(mod,"StructExprContext");
745774
StructExprEvalStep=load_type(mod,"StructExprEvalStep");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp