[PATCH] D15996: Avoid undefined behavior in LinkAllPasses.h

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 13:22:18 PST 2016


grosser added a subscriber: Meinersbur.
grosser added a comment.

adding Michael, who should be able to test this change with Polly on Windows.


================
Comment at: include/llvm/LinkAllPasses.h:198
@@ -192,1 +197,3 @@
+      } BRP(0);
+      (void) BRP.createPrinterPass(os, "");
       llvm::AliasSetTracker X(*(llvm::AliasAnalysis*)nullptr);
----------------
dim wrote:
> joker.eph wrote:
> > Isn't instantiating a `RGPassManager` enough to force link `RegionPass.cpp`?
> Well, this was already done in the original code, but then they tried to pass it as an argument to a call to `runOnRegion`.  I am unsure what this gained, and why the RGPassManager appears to be a little different than the other pass managers...
> 
> That said, I think such a local object cannot be optimized out, certainly because the constructor is not inlined.  The assembly shows:
> 
>         leal    72(%esp), %esi
>         movl    %esi, (%esp)
>         calll   llvm::RGPassManager::RGPassManager()@PLT
> 
> so it's indeed definitely being called.
I looked at this again and I think instantiation RGPassManager is likely to be enough. runOnRegion should already be transitively preserved through llvm::createStructurizeCFGPass()
(StructurizeCFG has not been available when the original code was added)

In the unlikely case we remove too much, the linker error should allow us to understand without too much hassle what else needs to be preserved. 




http://reviews.llvm.org/D15996





More information about the llvm-commits mailing list