[llvm-commits] [llvm] r120498 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/PartialStore.ll

Duncan Sands baldrick at free.fr
Wed Dec 1 00:09:50 PST 2010


Hi Chris,

> --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Nov 30 17:43:23 2010
> @@ -19,6 +19,7 @@
>   #include "llvm/Transforms/Scalar.h"
>   #include "llvm/Constants.h"
>   #include "llvm/Function.h"
> +#include "llvm/GlobalVariable.h"
>   #include "llvm/Instructions.h"
>   #include "llvm/IntrinsicInst.h"
>   #include "llvm/Pass.h"
> @@ -255,6 +256,17 @@
>     return TD->getTypeAllocSize(PT->getElementType());
>   }
>
> +/// isObjectPointerWithTrustworthySize - Return true if the specified Value* is
> +/// pointing to an object with a pointer size we can trust.
> +static bool isObjectPointerWithTrustworthySize(const Value *V) {
> +  if (const AllocaInst *AI = dyn_cast<AllocaInst>(V))
> +    return !AI->isArrayAllocation();
> +  if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
> +    return !GV->isWeakForLinker();

this should be mayBeOverridden not isWeakForLinker.  That way globals with
weak ODR linkage will be considered to have a trustworthy size.  By the way
isWeakForLinker should really be moved somewhere where people can't get at
it, like the linker for example.

> +  if (const Argument *A = dyn_cast<Argument>(V))
> +    return A->hasByValAttr();
> +  return false;
> +}

Ciao,

Duncan.



More information about the llvm-commits mailing list