[llvm] r292889 - Make VerifyDomInfo and VerifyLoopInfo global variables

Serge Pavlov via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 21:06:21 PST 2017


DominatorTree has a method 'verifyDomTree`, which can be called by
transformations that change dominator trees (in particular LoopUnroll).
These calls occur always when expensive checks are enabled. If we don't
want to call to call this expensive check always, we need some way to call
it conditionally depending on some command line option. The option
`-verify-dom-info` does this job but it can be used only in one source
file, because corresponding flag is a static variable. By making the flag a
global variable we can put the domtree checks into any file. Otherwise each
transformation had to introduce its own option as in
https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Utils/LoopUnroll.cpp#L54:L56
.

Thanks,
--Serge

2017-01-25 1:01 GMT+07:00 Philip Reames <listmail at philipreames.com>:

> Sorry, I'm confused by this change.  Doesn't the DominatorTree have an
> verifyAnalysis method which is invoked by the pass manager?  Why does any
> other pass need to directly interact with these variables?
>
> Philip
>
>
>
> On 01/23/2017 09:52 PM, Serge Pavlov via llvm-commits wrote:
>
>> Author: sepavloff
>> Date: Mon Jan 23 23:52:07 2017
>> New Revision: 292889
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=292889&view=rev
>> Log:
>> Make VerifyDomInfo and VerifyLoopInfo global variables
>>
>> Verifications of dominator tree and loop info are expensive operations
>> so they are disabled by default. They can be enabled by command line
>> options -verify-dom-info and -verify-loop-info. These options however
>> enable checks only in files Dominators.cpp and LoopInfo.cpp. If some
>> transformation changes dominaror tree and/or loop info, it would be
>> convenient to place similar checks to the files implementing the
>> transformation.
>>
>> This change makes corresponding flags global, so they can be used in
>> any file to optionally turn verification on.
>>
>> Modified:
>>      llvm/trunk/include/llvm/Support/Debug.h
>>      llvm/trunk/lib/Analysis/LoopInfo.cpp
>>      llvm/trunk/lib/IR/Dominators.cpp
>>
>> Modified: llvm/trunk/include/llvm/Support/Debug.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/
>> Support/Debug.h?rev=292889&r1=292888&r2=292889&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/include/llvm/Support/Debug.h (original)
>> +++ llvm/trunk/include/llvm/Support/Debug.h Mon Jan 23 23:52:07 2017
>> @@ -33,11 +33,6 @@ namespace llvm {
>>   class raw_ostream;
>>     #ifndef NDEBUG
>> -/// DebugFlag - This boolean is set to true if the '-debug' command line
>> option
>> -/// is specified.  This should probably not be referenced directly,
>> instead, use
>> -/// the DEBUG macro below.
>> -///
>> -extern bool DebugFlag;
>>     /// isCurrentDebugType - Return true if the specified string is the
>> debug type
>>   /// specified on the command line, or if none was specified on the
>> command line
>> @@ -77,6 +72,29 @@ void setCurrentDebugTypes(const char **T
>>   #define DEBUG_WITH_TYPE(TYPE, X) do { } while (false)
>>   #endif
>>   +/// This boolean is set to true if the '-debug' command line option
>> +/// is specified.  This should probably not be referenced directly,
>> instead, use
>> +/// the DEBUG macro below.
>> +///
>> +extern bool DebugFlag;
>> +
>> +/// \name Verification flags.
>> +///
>> +/// These flags turns on/off that are expensive and are turned off by
>> default,
>> +/// unless macro EXPENSIVE_CHECKS is defined. The flags allow selectively
>> +/// turning the checks on without need to recompile.
>> +/// \{
>> +
>> +/// Enables verification of dominator trees.
>> +///
>> +extern bool VerifyDomInfo;
>> +
>> +/// Enables verification of loop info.
>> +///
>> +extern bool VerifyLoopInfo;
>> +
>> +///\}
>> +
>>   /// EnableDebugBuffering - This defaults to false.  If true, the debug
>>   /// stream will install signal handlers to dump any buffered debug
>>   /// output.  It allows clients to selectively allow the debug stream
>>
>> Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/
>> LoopInfo.cpp?rev=292889&r1=292888&r2=292889&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)
>> +++ llvm/trunk/lib/Analysis/LoopInfo.cpp Mon Jan 23 23:52:07 2017
>> @@ -40,9 +40,9 @@ template class llvm::LoopInfoBase<BasicB
>>     // Always verify loopinfo if expensive checking is enabled.
>>   #ifdef EXPENSIVE_CHECKS
>> -static bool VerifyLoopInfo = true;
>> +bool llvm::VerifyLoopInfo = true;
>>   #else
>> -static bool VerifyLoopInfo = false;
>> +bool llvm::VerifyLoopInfo = false;
>>   #endif
>>   static cl::opt<bool,true>
>>   VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo),
>>
>> Modified: llvm/trunk/lib/IR/Dominators.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Domina
>> tors.cpp?rev=292889&r1=292888&r2=292889&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/IR/Dominators.cpp (original)
>> +++ llvm/trunk/lib/IR/Dominators.cpp Mon Jan 23 23:52:07 2017
>> @@ -29,9 +29,9 @@ using namespace llvm;
>>     // Always verify dominfo if expensive checking is enabled.
>>   #ifdef EXPENSIVE_CHECKS
>> -static bool VerifyDomInfo = true;
>> +bool llvm::VerifyDomInfo = true;
>>   #else
>> -static bool VerifyDomInfo = false;
>> +bool llvm::VerifyDomInfo = false;
>>   #endif
>>   static cl::opt<bool,true>
>>   VerifyDomInfoX("verify-dom-info", cl::location(VerifyDomInfo),
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170125/508cb02f/attachment.html>


More information about the llvm-commits mailing list