summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-c-test/echo.cpp
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
commit5db224e1f041e2d21bbf4eb0db7a1e8c0cd8439d (patch)
treed3845b46a7856215e5d20896f5371b9b039de1f6 /llvm/tools/llvm-c-test/echo.cpp
parentadc79395252d2c417224985833ba70acf36e8318 (diff)
downloadbcm5719-llvm-5db224e1f041e2d21bbf4eb0db7a1e8c0cd8439d.tar.gz
bcm5719-llvm-5db224e1f041e2d21bbf4eb0db7a1e8c0cd8439d.zip
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 llvm-svn: 272504
Diffstat (limited to 'llvm/tools/llvm-c-test/echo.cpp')
-rw-r--r--llvm/tools/llvm-c-test/echo.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp
index 2c2a6dae803..73444b46d93 100644
--- a/llvm/tools/llvm-c-test/echo.cpp
+++ b/llvm/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) {
OpenPOWER on IntegriCloud