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

Commitc8a2bb0

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 parentf915453 commitc8a2bb0

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
@@ -330,26 +330,46 @@ llvm_get_decl(LLVMModuleRef mod, LLVMValueRef v_src)
330330
}
331331

332332
/*
333-
* Copy attributes from one function to another.
333+
* Copy attributes from one function to another, for a specific index (an
334+
* index can reference return value, function and parameter attributes).
334335
*/
335-
void
336-
llvm_copy_attributes(LLVMValueRefv_from,LLVMValueRefv_to)
336+
staticvoid
337+
llvm_copy_attributes_at_index(LLVMValueRefv_from,LLVMValueRefv_to,uint32index)
337338
{
338339
intnum_attributes;
339-
intattno;
340340
LLVMAttributeRef*attrs;
341341

342-
num_attributes=
343-
LLVMGetAttributeCountAtIndex(v_from,LLVMAttributeFunctionIndex);
342+
num_attributes=LLVMGetAttributeCountAtIndex(v_from,index);
344343

345344
attrs=palloc(sizeof(LLVMAttributeRef)*num_attributes);
346-
LLVMGetAttributesAtIndex(v_from,LLVMAttributeFunctionIndex,attrs);
345+
LLVMGetAttributesAtIndex(v_from,index,attrs);
347346

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

355375
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp