[llvm-commits] [PATCH] extend transform passes to treat malloc calls the same as MallocInst (patch #3)

Dan Gohman gohman at apple.com
Wed Sep 16 18:19:30 PDT 2009


Hi Victor,

I haven't finished reviewing this, but here are all the comments I
had time to come up with so far:

Please use spaces instead of tabs.

in FunctionAttributes.cpp:
@@ -247,8 +248,11 @@
      if (Instruction *RVI = dyn_cast<Instruction>(RetVal))
        switch (RVI->getOpcode()) {
          // Extend the analysis by looking upwards.
+        case Instruction::BitCast:
+          if (isMalloc(RVI))
+            break;
+          // fall through
          case Instruction::GetElementPtr:
-        case Instruction::BitCast:
            FlowsToReturn.insert(RVI->getOperand(0));
            continue;
          case Instruction::Select: {
@@ -267,6 +271,8 @@
          case Instruction::Malloc:
            break;
          case Instruction::Call:
+          if (isMalloc(RVI))
+            break;
          case Instruction::Invoke: {
            CallSite CS(RVI);
            if (CS.paramHasAttr(0, Attribute::NoAlias))

Those break statements are inside a switch, so they aren't
breaking to where they appear to be intended.

In InstructionCombining.cpp:

@@ -9459,6 +9488,7 @@
          Align = PrefAlign;
        }
      }
+    // No alignment changes needed for malloc calls

This should rather say that no alignment changes are possible
for malloc calls (short of calling a different function).

I assume that for those big regions of copied code in GlobalOpt.cpp
the original code for MallocInst will go away soon, right?

Dan


On Sep 15, 2009, at 1:44 PM, Victor Hernandez wrote:

> These are the changes to make all the transform passes apply the  
> same analysis to malloc calls as to MallocInst.
>
> <MallocTransforms.diff>
>
> Victor_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list