[llvm-commits] [llvm] r62956 - in /llvm/trunk: lib/Transforms/IPO/IndMemRemoval.cpp test/Transforms/IndMemRem/ test/Transforms/IndMemRem/2009-01-24-Noalias.ll
Nick Lewycky
nicholas at mxc.ca
Sat Jan 24 23:59:57 PST 2009
Author: nicholas
Date: Sun Jan 25 01:59:57 2009
New Revision: 62956
URL: http://llvm.org/viewvc/llvm-project?rev=62956&view=rev
Log:
The function that does nothing but call malloc is noalias return.
Added:
llvm/trunk/test/Transforms/IndMemRem/
llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll
Modified:
llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp
Modified: llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp?rev=62956&r1=62955&r2=62956&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp Sun Jan 25 01:59:57 2009
@@ -44,11 +44,11 @@
X("indmemrem","Indirect Malloc and Free Removal");
bool IndMemRemPass::runOnModule(Module &M) {
- //in Theory, all direct calls of malloc and free should be promoted
- //to intrinsics. Therefor, this goes through and finds where the
- //address of free or malloc are taken and replaces those with bounce
- //functions, ensuring that all malloc and free that might happen
- //happen through intrinsics.
+ // In theory, all direct calls of malloc and free should be promoted
+ // to intrinsics. Therefore, this goes through and finds where the
+ // address of free or malloc are taken and replaces those with bounce
+ // functions, ensuring that all malloc and free that might happen
+ // happen through intrinsics.
bool changed = false;
if (Function* F = M.getFunction("free")) {
if (F->isDeclaration() && F->arg_size() == 1 && !F->use_empty()) {
@@ -69,6 +69,7 @@
Function* FN = Function::Create(F->getFunctionType(),
GlobalValue::LinkOnceLinkage,
"malloc_llvm_bounce", &M);
+ FN->setDoesNotAlias(0);
BasicBlock* bb = BasicBlock::Create("entry",FN);
Instruction* c = CastInst::CreateIntegerCast(
FN->arg_begin(), Type::Int32Ty, false, "c", bb);
Added: llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll?rev=62956&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll (added)
+++ llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll Sun Jan 25 01:59:57 2009
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | opt -indmemrem | llvm-dis | grep bounce | grep noalias
+
+declare i8* @malloc(i32)
+
+ at g = external global i8*
+
+define void @test() {
+ %A = bitcast i8* (i32) * @malloc to i8*
+ store i8* %A, i8** @g
+ ret void
+}
More information about the llvm-commits
mailing list