[llvm] r181978 - Respect the 'nobuiltin' attribute when determining if a call is to a memory builtin.

Richard Smith richard-llvm at metafoo.co.uk
Wed May 15 21:12:04 PDT 2013


Author: rsmith
Date: Wed May 15 23:12:04 2013
New Revision: 181978

URL: http://llvm.org/viewvc/llvm-project?rev=181978&view=rev
Log:
Respect the 'nobuiltin' attribute when determining if a call is to a memory builtin.

Added:
    llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll
Modified:
    llvm/trunk/lib/Analysis/MemoryBuiltins.cpp

Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=181978&r1=181977&r2=181978&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Wed May 15 23:12:04 2013
@@ -77,6 +77,9 @@ static Function *getCalledFunction(const
   if (!CS.getInstruction())
     return 0;
 
+  if (CS.hasFnAttr(Attribute::NoBuiltin))
+    return 0;
+
   Function *Callee = CS.getCalledFunction();
   if (!Callee || !Callee->isDeclaration())
     return 0;

Added: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll?rev=181978&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll (added)
+++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll Wed May 15 23:12:04 2013
@@ -0,0 +1,18 @@
+; RUN: opt < %s -globalopt -S | FileCheck %s
+target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
+
+ at G = internal global i32* null
+
+define void @t() {
+; CHECK: @t()
+; CHECK: call i8* @malloc
+  %malloccall = tail call i8* @malloc(i64 mul (i64 100, i64 4)) nobuiltin
+  %P = bitcast i8* %malloccall to i32*
+  store i32* %P, i32** @G
+  %GV = load i32** @G
+  %GVe = getelementptr i32* %GV, i32 40
+  store i32 20, i32* %GVe
+  ret void
+}
+
+declare noalias i8* @malloc(i64)





More information about the llvm-commits mailing list