[llvm] r217662 - Fix an ODR violation consisting of two 'struct Query' in the global namespace.
Benjamin Kramer
benny.kra at googlemail.com
Fri Sep 12 01:56:54 PDT 2014
Author: d0k
Date: Fri Sep 12 03:56:53 2014
New Revision: 217662
URL: http://llvm.org/viewvc/llvm-project?rev=217662&view=rev
Log:
Fix an ODR violation consisting of two 'struct Query' in the global namespace.
Put them in their own anonymous namespaces. Found by GCC's new -Wodr (PR20915).
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/lib/Analysis/ValueTracking.cpp
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=217662&r1=217661&r2=217662&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Fri Sep 12 03:56:53 2014
@@ -41,6 +41,7 @@ enum { RecursionLimit = 3 };
STATISTIC(NumExpand, "Number of expansions");
STATISTIC(NumReassoc, "Number of reassociations");
+namespace {
struct Query {
const DataLayout *DL;
const TargetLibraryInfo *TLI;
@@ -53,6 +54,7 @@ struct Query {
const Instruction *cxti = nullptr)
: DL(DL), TLI(tli), DT(dt), AT(at), CxtI(cxti) {}
};
+} // end anonymous namespace
static Value *SimplifyAndInst(Value *, Value *, const Query &, unsigned);
static Value *SimplifyBinOp(unsigned, Value *, Value *, const Query &,
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=217662&r1=217661&r2=217662&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Fri Sep 12 03:56:53 2014
@@ -58,6 +58,7 @@ static unsigned getBitWidth(Type *Ty, co
// isKnownToBeAPowerOfTwo (all of which can call computeKnownBits), and so on.
typedef SmallPtrSet<const Value *, 8> ExclInvsSet;
+namespace {
// Simplifying using an assume can only be done in a particular control-flow
// context (the context instruction provides that context). If an assume and
// the context instruction are not in the same block then the DT helps in
@@ -77,6 +78,7 @@ struct Query {
ExclInvs.insert(NewExcl);
}
};
+} // end anonymous namespace
// Given the provided Value and, potentially, a context instruction, returned
// the preferred context instruction (if any).
More information about the llvm-commits
mailing list