[PATCH] Compile time reduction for small programs.

Eric Christopher echristo at gmail.com
Tue Feb 4 18:52:17 PST 2014


Hey cool,

+/// reinitPhysRegEntries - Initializes PhysRegEntries to new
+/// zeroed out memory of size NumPhysRegs. This is faster than using
+/// llvm::SmallVector::assign(N, 0). It's used in the below code to
+/// also supports when a pass manager could be reused for different
+/// but similar targets that could have varying numbers of PhysRegs.
+void InterferenceCache::reinitPhysRegEntries() {
+  if (PhysRegEntriesCount == TRI->getNumRegs()) return;
+  free(PhysRegEntries);
+  PhysRegEntriesCount = TRI->getNumRegs();
+  PhysRegEntries = (unsigned char*) calloc(PhysRegEntriesCount,
sizeof(unsigned char));
+}

Looks to be faster since we're not actually zeroing out the array if
it's the same size as the previous allocation?

+  PhysRegEntries = (unsigned char*) calloc(PhysRegEntriesCount,
sizeof(unsigned char));

80-col?

+  reinitPhysRegEntries();

Might be nice to get a comment of when we're reinitializing why we're
doing so there.

+    for (auto RegI = PhysRegs.begin(), E = PhysRegs.end(); RegI != E; ++RegI)
+      if (!MRI->reg_nodbg_empty(*RegI))
+        MRI->setPhysRegUsed(*RegI);

Can't use auto quite yet :)


-eric

On Tue, Feb 4, 2014 at 3:44 PM, Puyan Lotfi <plotfi at apple.com> wrote:
>
> On Feb 4, 2014, at 2:52 PM, Eric Christopher <echristo at gmail.com> wrote:
>
>> On Tue, Feb 4, 2014 at 2:47 PM, Andrew Trick <atrick at apple.com> wrote:
>>> On Feb 4, 2014, at 2:41 PM, Puyan Lotfi <plotfi at apple.com> wrote:
>>>
>>>> Here is a patch for reducing compile time on small programs, especially if the target has a large register file.
>>>> I've already done sanity checks to determine that it doesn't regress compile time on large programs.
>>>
>>> LGTM. (mainly I'm trusting Jakob's informal review earlier).
>>
>> Knowing this helps :)
>>
>> It'd be nice to get some comments in the code as to what's going on
>> where. There aren't a lot in there as it is, but getting some more
>> would be nice.
>>
>> -eric
>>
>
> Here's a better commented version, Eric:
>
>
>
>
> -Puyan
>
>
>>> -Andy
>>>
>>>>
>>>> -Puyan
>>>>
>>>> <CompileTimeReductionSmall.patch>_______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>>
>>> _______________________________________________
>>> 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