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

Victor Hernandez vhernandez at apple.com
Thu Sep 17 12:51:52 PDT 2009


On Sep 16, 2009, at 6:19 PM, Dan Gohman wrote:

> 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.

Damn FileMerge.  Will fix up my 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.

As we discussed, the breaks are correct.  They are supposed to break  
out of the switch statement.
>
> 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).

Comment fixed.

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

Yes, it all goes away once I delete MallocInst.

>
> 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