summaryrefslogtreecommitdiff
path: root/tools/llvm-c-test
diff options
context:
space:
mode:
authorAmaury Sechet <deadalnix@gmail.com>2016-06-12 06:17:24 +0000
committerAmaury Sechet <deadalnix@gmail.com>2016-06-12 06:17:24 +0000
commitca669104bfa390d36d1657d4f84147c8f27711c7 (patch)
treea5fd2b19fbd02eb3ff77102d968d4d18bacce75b /tools/llvm-c-test
parent5f6317b29370f4f63f1e1f13155e211fa084c04f (diff)
Make sure we have a Add/Remove/Has function for various thing that can have attribute.
Summary: This also deprecated the get attribute function familly. Reviewers: Wallbraker, whitequark, joker.eph, echristo, rafael, jyknight Subscribers: axw, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D19181 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-c-test')
-rw-r--r--tools/llvm-c-test/echo.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/llvm-c-test/echo.cpp b/tools/llvm-c-test/echo.cpp
index 2c2a6dae803..73444b46d93 100644
--- a/tools/llvm-c-test/echo.cpp
+++ b/tools/llvm-c-test/echo.cpp
@@ -782,13 +782,28 @@ FunDecl:
return;
}
+ auto Ctx = LLVMGetModuleContext(M);
+
Cur = Begin;
Next = nullptr;
while (true) {
const char *Name = LLVMGetValueName(Cur);
if (LLVMGetNamedFunction(M, Name))
report_fatal_error("Function already cloned");
- LLVMAddFunction(M, Name, LLVMGetElementType(TypeCloner(M).Clone(Cur)));
+ auto Ty = LLVMGetElementType(TypeCloner(M).Clone(Cur));
+ auto F = LLVMAddFunction(M, Name, Ty);
+
+ // Copy attributes
+ for (int i = LLVMAttributeFunctionIndex, c = LLVMCountParams(F);
+ i <= c; ++i) {
+ for (unsigned k = 0, e = LLVMGetLastEnumAttributeKind(); k < e; ++k) {
+ if (auto SrcA = LLVMGetEnumAttributeAtIndex(Cur, i, k)) {
+ auto Val = LLVMGetEnumAttributeValue(SrcA);
+ auto DstA = LLVMCreateEnumAttribute(Ctx, k, Val);
+ LLVMAddAttributeAtIndex(F, i, DstA);
+ }
+ }
+ }
Next = LLVMGetNextFunction(Cur);
if (Next == nullptr) {