diff options
author | Amaury Sechet <deadalnix@gmail.com> | 2016-06-12 06:17:24 +0000 |
---|---|---|
committer | Amaury Sechet <deadalnix@gmail.com> | 2016-06-12 06:17:24 +0000 |
commit | ca669104bfa390d36d1657d4f84147c8f27711c7 (patch) | |
tree | a5fd2b19fbd02eb3ff77102d968d4d18bacce75b /tools/llvm-c-test | |
parent | 5f6317b29370f4f63f1e1f13155e211fa084c04f (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.cpp | 17 |
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) { |