Skip to content

Commit 2a7a989

Browse files
committed
[LLVM-C] Add bindings for addCoroutinePassesToExtensionPoints
This patch adds bindings to C and Go for addCoroutinePassesToExtensionPoints, which is used to add coroutine passes to the correct locations in PassManagerBuilder. Differential Revision: https://reviews.llvm.org/D51642
1 parent 53b597c commit 2a7a989

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

llvm/bindings/go/llvm/transforms_pmbuilder.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ package llvm
1414

1515
/*
1616
#include "llvm-c/Transforms/PassManagerBuilder.h"
17+
#include "llvm-c/Transforms/Coroutines.h"
1718
*/
1819
import "C"
1920

@@ -65,3 +66,7 @@ func (pmb PassManagerBuilder) SetDisableSimplifyLibCalls(val bool) {
6566
func (pmb PassManagerBuilder) UseInlinerWithThreshold(threshold uint) {
6667
C.LLVMPassManagerBuilderUseInlinerWithThreshold(pmb.C, C.uint(threshold))
6768
}
69+
70+
func (pmb PassManagerBuilder) AddCoroutinePassesToExtensionPoints() {
71+
C.LLVMPassManagerBuilderAddCoroutinePassesToExtensionPoints(pmb.C);
72+
}

llvm/include/llvm-c/Transforms/Coroutines.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "llvm-c/ExternC.h"
2323
#include "llvm-c/Types.h"
24+
#include "llvm-c/Transforms/PassManagerBuilder.h"
2425

2526
LLVM_C_EXTERN_C_BEGIN
2627

@@ -43,6 +44,9 @@ void LLVMAddCoroElidePass(LLVMPassManagerRef PM);
4344
/** See llvm::createCoroCleanupLegacyPass function. */
4445
void LLVMAddCoroCleanupPass(LLVMPassManagerRef PM);
4546

47+
/** See llvm::addCoroutinePassesToExtensionPoints. */
48+
void LLVMPassManagerBuilderAddCoroutinePassesToExtensionPoints(LLVMPassManagerBuilderRef PMB);
49+
4650
/**
4751
* @}
4852
*/

llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_TRANSFORMS_IPO_PASSMANAGERBUILDER_H
1515
#define LLVM_TRANSFORMS_IPO_PASSMANAGERBUILDER_H
1616

17+
#include "llvm-c/Transforms/PassManagerBuilder.h"
1718
#include <functional>
1819
#include <memory>
1920
#include <string>
@@ -251,5 +252,13 @@ class RegisterStandardPasses {
251252
}
252253
};
253254

255+
inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
256+
return reinterpret_cast<PassManagerBuilder*>(P);
257+
}
258+
259+
inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
260+
return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
261+
}
262+
254263
} // end namespace llvm
255264
#endif

llvm/lib/Transforms/Coroutines/Coroutines.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,9 @@ void LLVMAddCoroElidePass(LLVMPassManagerRef PM) {
649649
void LLVMAddCoroCleanupPass(LLVMPassManagerRef PM) {
650650
unwrap(PM)->add(createCoroCleanupLegacyPass());
651651
}
652+
653+
void
654+
LLVMPassManagerBuilderAddCoroutinePassesToExtensionPoints(LLVMPassManagerBuilderRef PMB) {
655+
PassManagerBuilder *Builder = unwrap(PMB);
656+
addCoroutinePassesToExtensionPoints(*Builder);
657+
}

llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,14 +1125,6 @@ void PassManagerBuilder::populateLTOPassManager(legacy::PassManagerBase &PM) {
11251125
PM.add(createVerifierPass());
11261126
}
11271127

1128-
inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
1129-
return reinterpret_cast<PassManagerBuilder*>(P);
1130-
}
1131-
1132-
inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
1133-
return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
1134-
}
1135-
11361128
LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() {
11371129
PassManagerBuilder *PMB = new PassManagerBuilder();
11381130
return wrap(PMB);

0 commit comments

Comments
 (0)