Add noalias and nocapture attributes to pointer stg registers
authorDavid Terei <davidterei@gmail.com>
Mon, 28 Jun 2010 11:51:20 +0000 (11:51 +0000)
committerDavid Terei <davidterei@gmail.com>
Mon, 28 Jun 2010 11:51:20 +0000 (11:51 +0000)
At the moment this gives a very slight performance boost of around 1 - 2%.
Future changes to the generated code though so that pointers are kept as
pointers more often instead of being cast to integer types straight away
should hopefully improve the benefit this brings.

compiler/llvmGen/LlvmCodeGen/Base.hs

index 83469c8..ba74a7f 100644 (file)
@@ -89,11 +89,15 @@ llvmFunSig :: CLabel -> LlvmLinkageType -> LlvmFunctionDecl
 llvmFunSig lbl link = llvmFunSig' (strCLabel_llvm lbl) link
 
 llvmFunSig' :: LMString -> LlvmLinkageType -> LlvmFunctionDecl
-llvmFunSig' lbl link = LlvmFunctionDecl lbl link llvmGhcCC LMVoid FixedArgs
-                        (tysToParams $ map getVarType llvmFunArgs) llvmFunAlign
+llvmFunSig' lbl link
+  = let toParams x | isPointer x = (x, [NoAlias, NoCapture])
+                   | otherwise   = (x, [])
+    in LlvmFunctionDecl lbl link llvmGhcCC LMVoid FixedArgs
+                        (map (toParams . getVarType) llvmFunArgs) llvmFunAlign
 
 -- | Create a Haskell function in LLVM.
-mkLlvmFunc :: CLabel -> LlvmLinkageType -> LMSection -> LlvmBlocks -> LlvmFunction
+mkLlvmFunc :: CLabel -> LlvmLinkageType -> LMSection -> LlvmBlocks
+           -> LlvmFunction
 mkLlvmFunc lbl link sec blks
   = let funDec = llvmFunSig lbl link
         funArgs = map (fsLit . getPlainName) llvmFunArgs