[PATCH] D11116: Expose setPersonalityFn to C and Go

Andrew Wilkins axwalk at gmail.com
Fri Jul 10 19:52:05 PDT 2015


axw created this revision.
axw added reviewers: pcc, majnemer.
axw added a subscriber: llvm-commits.
Herald added a subscriber: axw.

Add LLVMSetFunctionPersonality to the C API, and
Value.SetPersonality to the Go bindings. The Go
bindings' Builder.CreateLandingPad has been updated,
removing the obsolete personality argument.

Background

The personality attribute was removed from LandingPadInst
in r239940, and llvm::Function::setPersonalityFn introduced.

There was no corresponding change to either the C API or
Go bindings. The Go bindings were broken until r239940, but
that change was just to ignore the personality argument.
This broke llgo.

http://reviews.llvm.org/D11116

Files:
  bindings/go/llvm/ir.go
  include/llvm-c/Core.h
  lib/IR/Core.cpp

Index: lib/IR/Core.cpp
===================================================================
--- lib/IR/Core.cpp
+++ lib/IR/Core.cpp
@@ -1759,6 +1759,11 @@
   return (LLVMAttribute)PAL.Raw(AttributeSet::FunctionIndex);
 }
 
+void LLVMSetFunctionPersonality(LLVMValueRef Fn, LLVMValueRef P) {
+  Function *Func = unwrap<Function>(Fn);
+  Func->setPersonalityFn(unwrap<Constant>(P));
+}
+
 /*--.. Operations on parameters ............................................--*/
 
 unsigned LLVMCountParams(LLVMValueRef FnRef) {
Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h
+++ include/llvm-c/Core.h
@@ -1955,6 +1955,13 @@
 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
 
 /**
+ * Set the exception handling personality for a function.
+ *
+ * @see llvm::Function::setPersonalityFn()
+ */
+void LLVMSetFunctionPersonality(LLVMValueRef Fn, LLVMValueRef P);
+
+/**
  * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
  *
  * Functions in this group relate to arguments/parameters on functions.
Index: bindings/go/llvm/ir.go
===================================================================
--- bindings/go/llvm/ir.go
+++ bindings/go/llvm/ir.go
@@ -1054,6 +1054,9 @@
 	defer C.free(unsafe.Pointer(cvalue))
 	C.LLVMAddTargetDependentFunctionAttr(v.C, cattr, cvalue)
 }
+func (v Value) SetPersonality(p Value) {
+	C.LLVMSetFunctionPersonality(v.C, p.C)
+}
 
 // Operations on parameters
 func (v Value) ParamsCount() int { return int(C.LLVMCountParams(v.C)) }
@@ -1206,7 +1209,7 @@
 func (b Builder) SetCurrentDebugLocation(line, col uint, scope, inlinedAt Metadata) {
 	C.LLVMSetCurrentDebugLocation2(b.C, C.unsigned(line), C.unsigned(col), scope.C, inlinedAt.C)
 }
-func (b Builder) SetInstDebugLocation(v Value)    { C.LLVMSetInstDebugLocation(b.C, v.C) }
+func (b Builder) SetInstDebugLocation(v Value) { C.LLVMSetInstDebugLocation(b.C, v.C) }
 func (b Builder) InsertDeclare(module Module, storage Value, md Value) Value {
 	f := module.NamedFunction("llvm.dbg.declare")
 	if f.IsNil() {
@@ -1725,7 +1728,7 @@
 	return
 }
 
-func (b Builder) CreateLandingPad(t Type, personality Value, nclauses int, name string) (l Value) {
+func (b Builder) CreateLandingPad(t Type, nclauses int, name string) (l Value) {
 	cname := C.CString(name)
 	defer C.free(unsafe.Pointer(cname))
 	l.C = C.LLVMBuildLandingPad(b.C, t.C, C.unsigned(nclauses), cname)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11116.29507.patch
Type: text/x-patch
Size: 2442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150711/02ec3b06/attachment.bin>


More information about the llvm-commits mailing list