[llvm] r267342 - ModuleSummaryIndex: Avoid enum bitfields for MSVC portability

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 24 12:38:50 PDT 2016


> On 2016-Apr-24, at 11:42, David Majnemer <david.majnemer at gmail.com> wrote:
> 
> I think this could have been fixed by making the LinkageTypes have an underlying type of `unsigned`.

That was Takumi's idea, but r267335 broke the build.  E.g.:
  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/23489/

Besides, establishing an underlying type hides warnings about complete
switch statements, etc.

I reverted in r267341 and made this fix instead.

Those logs don't stay around forever, so here's the error for posterity:
--
FAILED: /usr/bin/c++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -std=c++11 -fcolor-diagnostics -O3  -Ilib/Bitcode/Writer -I/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer -Iinclude -I/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/include    -UNDEBUG  -fno-exceptions -fno-rtti -MMD -MT lib/Bitcode/Writer/CMakeFiles/LLVMBitWriter.dir/BitcodeWriter.cpp.o -MF lib/Bitcode/Writer/CMakeFiles/LLVMBitWriter.dir/BitcodeWriter.cpp.o.d -o lib/Bitcode/Writer/CMakeFiles/LLVMBitWriter.dir/BitcodeWriter.cpp.o -c '/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp'

/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: error: use of overloaded operator '|' is ambiguous (with operand types 'uint64_t' (aka 'unsigned long long') and 'GlobalValue::LinkageTypes')

  RawFlags = (RawFlags << 4) | Flags.Linkage; // 4 bits
             ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long long, unsigned int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long long, int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned int, int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned __int128, unsigned int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(int, unsigned int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned __int128, int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long long, unsigned __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long long, unsigned long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long, int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long long, unsigned long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(int, int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long long, __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long, unsigned int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long long, long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long long, long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long, unsigned int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long long, int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long, int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned int, unsigned int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(__int128, unsigned int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long long, unsigned int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(__int128, int)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long long, unsigned long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long long, unsigned __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long long, unsigned long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(__int128, long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(__int128, long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(__int128, __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long long, __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(__int128, unsigned long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(__int128, unsigned long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(__int128, unsigned __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(int, long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned int, long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned int, long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned int, __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long long, long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned int, unsigned long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned int, unsigned long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned int, unsigned __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long long, long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long, long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long, long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long, __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long, unsigned __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long, unsigned long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long, unsigned long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned long, unsigned __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(int, long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long, unsigned long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long, unsigned long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long, __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long, long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(long, long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(int, unsigned __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(int, unsigned long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(int, unsigned long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned __int128, long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned __int128, long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned __int128, __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(int, __int128)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned __int128, unsigned long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned __int128, unsigned long long)
/Users/buildslave/jenkins/sharedspace/incremental at 2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:798:30: note: built-in candidate operator|(unsigned __int128, unsigned __int128)
1 error generated.
ninja: build stopped: subcommand failed.
--

> On Sun, Apr 24, 2016 at 2:10 PM, Mehdi Amini via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> Thanks Duncan!
> I was puzzled by this failure...
> 
> --
> Mehdi
> 
> 
> > On Apr 24, 2016, at 7:25 AM, Duncan P. N. Exon Smith via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> >
> > Author: dexonsmith
> > Date: Sun Apr 24 09:25:37 2016
> > New Revision: 267342
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=267342&view=rev
> > Log:
> > ModuleSummaryIndex: Avoid enum bitfields for MSVC portability
> >
> > Enum bitfields have crazy portability issues with MSVC.  Use unsigned
> > instead of LinkageTypes here in the ModuleSummaryIndex to address
> > Takumi's concerns from r267335.
> >
> > Modified:
> >    llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
> >
> > Modified: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h?rev=267342&r1=267341&r2=267342&view=diff
> > ==============================================================================
> > --- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h (original)
> > +++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h Sun Apr 24 09:25:37 2016
> > @@ -101,7 +101,7 @@ public:
> >     /// index, to disambiguate from other values with the same name.
> >     /// In the future this will be used to update and optimize linkage
> >     /// types based on global summary-based analysis.
> > -    GlobalValue::LinkageTypes Linkage : 4;
> > +    unsigned Linkage : 4;
> >
> >     /// Indicate if the global value is located in a specific section.
> >     unsigned HasSection : 1;
> > @@ -167,7 +167,9 @@ public:
> >   GVFlags flags() { return Flags; }
> >
> >   /// Return linkage type recorded for this global value.
> > -  GlobalValue::LinkageTypes linkage() const { return Flags.Linkage; }
> > +  GlobalValue::LinkageTypes linkage() const {
> > +    return static_cast<GlobalValue::LinkageTypes>(Flags.Linkage);
> > +  }
> >
> >   /// Return true if this global value is located in a specific section.
> >   bool hasSection() const { return Flags.HasSection; }
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 



More information about the llvm-commits mailing list