llvm.org GIT mirror llvm / ff36685
Expose struct size threhold to allow users to tweak their own setting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38472 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 12 years ago
2 changed file(s) with 13 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
7575 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
7676 // if possible.
7777 //
78 FunctionPass *createScalarReplAggregatesPass();
78 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1);
7979
8080 //===----------------------------------------------------------------------===//
8181 //
4747 namespace {
4848 struct VISIBILITY_HIDDEN SROA : public FunctionPass {
4949 static char ID; // Pass identification, replacement for typeid
50 SROA() : FunctionPass((intptr_t)&ID) {}
50 SROA(signed T = -1) : FunctionPass((intptr_t)&ID) {
51 if (T == -1)
52 SRThreshold = 128;
53 else
54 SRThreshold = T;
55 }
5156
5257 bool runOnFunction(Function &F);
5358
8691 isMemCpySrc(false), isMemCpyDst(false) {}
8792 };
8893
94 unsigned SRThreshold;
95
8996 void MarkUnsafe(AllocaInfo &I) { I.isUnsafe = true; }
9097
9198 int isSafeAllocaToScalarRepl(AllocationInst *AI);
118125 }
119126
120127 // Public interface to the ScalarReplAggregates pass
121 FunctionPass *llvm::createScalarReplAggregatesPass() { return new SROA(); }
128 FunctionPass *llvm::createScalarReplAggregatesPass(signed int Threshold) {
129 return new SROA(Threshold);
130 }
122131
123132
124133 bool SROA::runOnFunction(Function &F) {
210219 (isa(AI->getAllocatedType()) ||
211220 isa(AI->getAllocatedType())) &&
212221 AI->getAllocatedType()->isSized() &&
213 TD.getTypeSize(AI->getAllocatedType()) < 128) {
222 TD.getTypeSize(AI->getAllocatedType()) < SRThreshold) {
214223 // Check that all of the users of the allocation are capable of being
215224 // transformed.
216225 switch (isSafeAllocaToScalarRepl(AI)) {