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

Commitae3e75a

Browse files
committed
llvmjit: Also copy parameter / return value attributes from template functions.
Previously we only copied the function attributes. That caused problems atleast on s390x: Because we didn't copy the 'zeroext' attribute forExecAggTransReparent()'s *IsNull parameters, expressions invoking it didn'tensure that the upper bytes of the registers were zeroed. In the - relativelyrare - cases where not, ExecAggTransReparent() wrongly ended up in thenewValueIsNull branch due to the register not being zero. Subsequently causinga crash.It's quite possible that this would cause problems on other platforms, and inother places than just ExecAggTransReparent() on s390x.Thanks to Christoph (and the Debian project) for providing me with access to as390x machine, allowing me to debug this.Reported-By: Christoph BergAuthor: Andres FreundDiscussion:https://postgr.es/m/20201015083246.kie5726xerdt3ael@alap3.anarazel.deBackpatch: 11-, where JIT was added
1 parent264e517 commitae3e75a

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

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

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -324,26 +324,46 @@ llvm_pg_func(LLVMModuleRef mod, const char *funcname)
324324
}
325325

326326
/*
327-
* Copy attributes from one function to another.
327+
* Copy attributes from one function to another, for a specific index (an
328+
* index can reference return value, function and parameter attributes).
328329
*/
329-
void
330-
llvm_copy_attributes(LLVMValueRefv_from,LLVMValueRefv_to)
330+
staticvoid
331+
llvm_copy_attributes_at_index(LLVMValueRefv_from,LLVMValueRefv_to,uint32index)
331332
{
332333
intnum_attributes;
333-
intattno;
334334
LLVMAttributeRef*attrs;
335335

336-
num_attributes=
337-
LLVMGetAttributeCountAtIndex(v_from,LLVMAttributeFunctionIndex);
336+
num_attributes=LLVMGetAttributeCountAtIndex(v_from,index);
338337

339338
attrs=palloc(sizeof(LLVMAttributeRef)*num_attributes);
340-
LLVMGetAttributesAtIndex(v_from,LLVMAttributeFunctionIndex,attrs);
339+
LLVMGetAttributesAtIndex(v_from,index,attrs);
341340

342-
for (attno=0;attno<num_attributes;attno++)
343-
{
344-
LLVMAddAttributeAtIndex(v_to,LLVMAttributeFunctionIndex,
345-
attrs[attno]);
346-
}
341+
for (intattno=0;attno<num_attributes;attno++)
342+
LLVMAddAttributeAtIndex(v_to,index,attrs[attno]);
343+
344+
pfree(attrs);
345+
}
346+
347+
/*
348+
* Copy all attributes from one function to another. I.e. function, return and
349+
* parameters will be copied.
350+
*/
351+
void
352+
llvm_copy_attributes(LLVMValueRefv_from,LLVMValueRefv_to)
353+
{
354+
uint32param_count;
355+
356+
/* copy function attributes */
357+
llvm_copy_attributes_at_index(v_from,v_to,LLVMAttributeFunctionIndex);
358+
359+
/* and the return value attributes */
360+
llvm_copy_attributes_at_index(v_from,v_to,LLVMAttributeReturnIndex);
361+
362+
/* and each function parameter's attribute */
363+
param_count=LLVMCountParams(v_from);
364+
365+
for (intparamidx=1;paramidx <=param_count;paramidx++)
366+
llvm_copy_attributes_at_index(v_from,v_to,paramidx);
347367
}
348368

349369
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp