Fix the g++ build.
It turns out that the g++ test build, initiated by "make presubmit", was
actually using clang++ for the build. This fixes the makefile, plus the
code that actually produces errors under the g++ build.
BUG= none
TBR=jpp
Review URL: https://codereview.chromium.org/1572863003 .
diff --git a/Makefile.standalone b/Makefile.standalone
index 64796c9..eb9a3aa 100644
--- a/Makefile.standalone
+++ b/Makefile.standalone
@@ -94,17 +94,6 @@
OBJDIR := $(OBJDIR)+Asserts
endif
-# Use g++ to compile, to check for errors/warnings that clang++ might have
-# missed. It's unlikely to link, unless LLVM was also built with g++, so the
-# compile_only target should be used.
-ifdef GPLUSPLUS
- CXX = CCACHE_CPP2=yes $(CCACHE) g++
- STDLIB_FLAGS =
- LLVM_EXTRA_WARNINGS="-Wno-unknown-pragmas -Wno-unused-parameter \
- -Wno-comment -Wno-enum-compare -Wno-strict-aliasing"
- OBJDIR := $(OBJDIR)+Gplusplus
-endif
-
ifdef UBSAN
OBJDIR := $(OBJDIR)+UBSan
CXX_EXTRA += -fsanitize=undefined -fno-sanitize=vptr \
@@ -192,6 +181,20 @@
# Extra warnings that LLVM's build system adds in addition to -Wall.
LLVM_EXTRA_WARNINGS := -Wcovered-switch-default
+# Use g++ to compile, to check for errors/warnings that clang++ might have
+# missed. It's unlikely to link, unless LLVM was also built with g++, so the
+# compile_only target should be used. Note: This ifdef section is deliberately
+# placed here instead of with the other ifdef sections, so that its redefinition
+# of CXX/STDLIB_FLAGS/LLVM_EXTRA_WARNINGS follows their normal definitions.
+ifdef GPLUSPLUS
+ CXX := CCACHE_CPP2=yes $(CCACHE) g++
+ STDLIB_FLAGS :=
+ LLVM_EXTRA_WARNINGS := -Wno-unknown-pragmas -Wno-unused-parameter \
+ -Wno-comment -Wno-enum-compare -Wno-strict-aliasing \
+ -Wno-return-type
+ OBJDIR := $(OBJDIR)+Gplusplus
+endif
+
BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -Werror -fno-rtti \
-fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g -pedantic \
$(LLVM_EXTRA_WARNINGS) $(CXX_EXTRA)
diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
index cb36e3d..611121a 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -330,7 +330,7 @@
case ROData: {
const IceString SectionName =
MangleSectionName(IsPIC ? ".data.rel.ro" : ".rodata", SectionSuffix);
- const Elf64_Xword ShFlags = SHF_ALLOC | (IsPIC ? SHF_WRITE : 0);
+ const Elf64_Xword ShFlags = IsPIC ? (SHF_ALLOC | SHF_WRITE) : SHF_ALLOC;
Section = createSection<ELFDataSection>(SectionName, SHT_PROGBITS, ShFlags,
ShAddralign, ShEntsize);
Section->setFileOffset(alignFileOffset(ShAddralign));
diff --git a/src/IceRegistersARM32.h b/src/IceRegistersARM32.h
index 8ea5b01..29e291b 100644
--- a/src/IceRegistersARM32.h
+++ b/src/IceRegistersARM32.h
@@ -117,18 +117,18 @@
static constexpr struct TableType {
const char *Name;
- int32_t Encoding : 10;
- int32_t CCArg : 6;
- int32_t Scratch : 1;
- int32_t Preserved : 1;
- int32_t StackPtr : 1;
- int32_t FramePtr : 1;
- int32_t IsGPR : 1;
- int32_t IsInt : 1;
- int32_t IsI64Pair : 1;
- int32_t IsFP32 : 1;
- int32_t IsFP64 : 1;
- int32_t IsVec128 : 1;
+ unsigned Encoding : 10;
+ unsigned CCArg : 6;
+ unsigned Scratch : 1;
+ unsigned Preserved : 1;
+ unsigned StackPtr : 1;
+ unsigned FramePtr : 1;
+ unsigned IsGPR : 1;
+ unsigned IsInt : 1;
+ unsigned IsI64Pair : 1;
+ unsigned IsFP32 : 1;
+ unsigned IsFP64 : 1;
+ unsigned IsVec128 : 1;
#define NUM_ALIASES_BITS 3
SizeT NumAliases : (NUM_ALIASES_BITS + 1);
uint16_t Aliases[1 << NUM_ALIASES_BITS];
diff --git a/src/IceTargetLoweringX8632Traits.h b/src/IceTargetLoweringX8632Traits.h
index 2010ee4..00ea2d9 100644
--- a/src/IceTargetLoweringX8632Traits.h
+++ b/src/IceTargetLoweringX8632Traits.h
@@ -449,17 +449,17 @@
static constexpr struct {
uint16_t Val;
- int Is64 : 1;
- int Is32 : 1;
- int Is16 : 1;
- int Is8 : 1;
- int IsXmm : 1;
- int Is64To8 : 1;
- int Is32To8 : 1;
- int Is16To8 : 1;
- int IsTrunc8Rcvr : 1;
- int IsAhRcvr : 1;
- int Scratch : 1;
+ unsigned Is64 : 1;
+ unsigned Is32 : 1;
+ unsigned Is16 : 1;
+ unsigned Is8 : 1;
+ unsigned IsXmm : 1;
+ unsigned Is64To8 : 1;
+ unsigned Is32To8 : 1;
+ unsigned Is16To8 : 1;
+ unsigned IsTrunc8Rcvr : 1;
+ unsigned IsAhRcvr : 1;
+ unsigned Scratch : 1;
#define NUM_ALIASES_BITS 2
SizeT NumAliases : (NUM_ALIASES_BITS + 1);
uint16_t Aliases[1 << NUM_ALIASES_BITS];
diff --git a/src/IceTargetLoweringX8664Traits.h b/src/IceTargetLoweringX8664Traits.h
index 314416c..bab08a1 100644
--- a/src/IceTargetLoweringX8664Traits.h
+++ b/src/IceTargetLoweringX8664Traits.h
@@ -501,17 +501,17 @@
static constexpr struct {
uint16_t Val;
- int Is64 : 1;
- int Is32 : 1;
- int Is16 : 1;
- int Is8 : 1;
- int IsXmm : 1;
- int Is64To8 : 1;
- int Is32To8 : 1;
- int Is16To8 : 1;
- int IsTrunc8Rcvr : 1;
- int IsAhRcvr : 1;
- int Scratch : 1;
+ unsigned Is64 : 1;
+ unsigned Is32 : 1;
+ unsigned Is16 : 1;
+ unsigned Is8 : 1;
+ unsigned IsXmm : 1;
+ unsigned Is64To8 : 1;
+ unsigned Is32To8 : 1;
+ unsigned Is16To8 : 1;
+ unsigned IsTrunc8Rcvr : 1;
+ unsigned IsAhRcvr : 1;
+ unsigned Scratch : 1;
#define NUM_ALIASES_BITS 2
SizeT NumAliases : (NUM_ALIASES_BITS + 1);
uint16_t Aliases[1 << NUM_ALIASES_BITS];
diff --git a/src/IceTargetLoweringX86Base.h b/src/IceTargetLoweringX86Base.h
index d39bda0..f8a0578 100644
--- a/src/IceTargetLoweringX86Base.h
+++ b/src/IceTargetLoweringX86Base.h
@@ -60,7 +60,6 @@
public:
using Traits = TraitsType;
- using BoolFolding = BoolFolding<Traits>;
using ConcreteTarget = typename Traits::ConcreteTarget;
using InstructionSetEnum = typename Traits::InstructionSet;
@@ -836,7 +835,7 @@
typename std::enable_if<!T::Is64Bit, void>::type
lowerIcmp64(const InstIcmp *Icmp, const Inst *Consumer);
- BoolFolding FoldingInfo;
+ BoolFolding<Traits> FoldingInfo;
static FixupKind PcRelFixup;
static FixupKind AbsFixup;
diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h
index 5127768..2b94df0 100644
--- a/src/IceTargetLoweringX86BaseImpl.h
+++ b/src/IceTargetLoweringX86BaseImpl.h
@@ -1974,19 +1974,19 @@
// Handle folding opportunities.
if (const Inst *Producer = FoldingInfo.getProducerFor(Cond)) {
assert(Producer->isDeleted());
- switch (BoolFolding::getProducerKind(Producer)) {
+ switch (BoolFolding<Traits>::getProducerKind(Producer)) {
default:
break;
- case BoolFolding::PK_Icmp32:
- case BoolFolding::PK_Icmp64: {
+ case BoolFolding<Traits>::PK_Icmp32:
+ case BoolFolding<Traits>::PK_Icmp64: {
lowerIcmpAndConsumer(llvm::dyn_cast<InstIcmp>(Producer), Br);
return;
}
- case BoolFolding::PK_Fcmp: {
+ case BoolFolding<Traits>::PK_Fcmp: {
lowerFcmpAndConsumer(llvm::dyn_cast<InstFcmp>(Producer), Br);
return;
}
- case BoolFolding::PK_Arith: {
+ case BoolFolding<Traits>::PK_Arith: {
lowerArithAndConsumer(llvm::dyn_cast<InstArithmetic>(Producer), Br);
return;
}
@@ -4810,15 +4810,15 @@
// Handle folding opportunities.
if (const Inst *Producer = FoldingInfo.getProducerFor(Condition)) {
assert(Producer->isDeleted());
- switch (BoolFolding::getProducerKind(Producer)) {
+ switch (BoolFolding<Traits>::getProducerKind(Producer)) {
default:
break;
- case BoolFolding::PK_Icmp32:
- case BoolFolding::PK_Icmp64: {
+ case BoolFolding<Traits>::PK_Icmp32:
+ case BoolFolding<Traits>::PK_Icmp64: {
lowerIcmpAndConsumer(llvm::dyn_cast<InstIcmp>(Producer), Select);
return;
}
- case BoolFolding::PK_Fcmp: {
+ case BoolFolding<Traits>::PK_Fcmp: {
lowerFcmpAndConsumer(llvm::dyn_cast<InstFcmp>(Producer), Select);
return;
}