// ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
// if possible.
//
-FunctionPass *createScalarReplAggregatesPass();
+FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1);
//===----------------------------------------------------------------------===//
//
namespace {
struct VISIBILITY_HIDDEN SROA : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
- SROA() : FunctionPass((intptr_t)&ID) {}
+ SROA(signed T = -1) : FunctionPass((intptr_t)&ID) {
+ if (T == -1)
+ SRThreshold = 128;
+ else
+ SRThreshold = T;
+ }
bool runOnFunction(Function &F);
isMemCpySrc(false), isMemCpyDst(false) {}
};
+ unsigned SRThreshold;
+
void MarkUnsafe(AllocaInfo &I) { I.isUnsafe = true; }
int isSafeAllocaToScalarRepl(AllocationInst *AI);
}
// Public interface to the ScalarReplAggregates pass
-FunctionPass *llvm::createScalarReplAggregatesPass() { return new SROA(); }
+FunctionPass *llvm::createScalarReplAggregatesPass(signed int Threshold) {
+ return new SROA(Threshold);
+}
bool SROA::runOnFunction(Function &F) {
(isa<StructType>(AI->getAllocatedType()) ||
isa<ArrayType>(AI->getAllocatedType())) &&
AI->getAllocatedType()->isSized() &&
- TD.getTypeSize(AI->getAllocatedType()) < 128) {
+ TD.getTypeSize(AI->getAllocatedType()) < SRThreshold) {
// Check that all of the users of the allocation are capable of being
// transformed.
switch (isSafeAllocaToScalarRepl(AI)) {