diff gen/irstate.h @ 1277:6bd5ce91b136

Add some attributes to runtime calls, to provide the standard LLVM optimization passes with more information.
author Frits van Bommel <fvbommel wxs.nl>
date Wed, 29 Apr 2009 17:47:24 +0200
parents 3d1b16dabd25
children 329e45865d84
line wrap: on
line diff
--- a/gen/irstate.h	Wed Apr 29 10:26:28 2009 +0200
+++ b/gen/irstate.h	Wed Apr 29 17:47:24 2009 +0200
@@ -182,16 +182,26 @@
         LLFunction* funcval = llvm::dyn_cast<LLFunction>(Callee);
         if (funcval && funcval->isIntrinsic())
         {
-            return ir->CreateCall(Callee, ArgBegin, ArgEnd, Name);
+            llvm::CallInst* call = ir->CreateCall(Callee, ArgBegin, ArgEnd, Name);
+            if (LLFunction* fn = llvm::dyn_cast<LLFunction>(Callee))
+                call->setAttributes(fn->getAttributes());
+            return call;
         }
 
         llvm::BasicBlock* postinvoke = llvm::BasicBlock::Create("postinvoke", topfunc(), scopeend());
         llvm::InvokeInst* invoke = ir->CreateInvoke(Callee, postinvoke, pad, ArgBegin, ArgEnd, Name);
+        if (LLFunction* fn = llvm::dyn_cast<LLFunction>(Callee))
+            invoke->setAttributes(fn->getAttributes());
         scope() = IRScope(postinvoke, scopeend());
         return invoke;
     }
     else
-        return ir->CreateCall(Callee, ArgBegin, ArgEnd, Name);
+    {
+        llvm::CallInst* call = ir->CreateCall(Callee, ArgBegin, ArgEnd, Name);
+        if (LLFunction* fn = llvm::dyn_cast<LLFunction>(Callee))
+            call->setAttributes(fn->getAttributes());
+        return call;
+    }
 }
 
 #endif // LDC_GEN_IRSTATE_H