1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

34 Commits

Author SHA1 Message Date
Alexander Kornienko
f993659b8f Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)
Apparently, the style needs to be agreed upon first.

llvm-svn: 240390
2015-06-23 09:49:53 +00:00
Alexander Kornienko
40cb19d802 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
  -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
  llvm/lib/


Thanks to Eugene Kosov for the original patch!

llvm-svn: 240137
2015-06-19 15:57:42 +00:00
Peter Collingbourne
68aaa34960 Introduce bitset metadata format and bitset lowering pass.
This patch introduces a new mechanism that allows IR modules to co-operatively
build pointer sets corresponding to addresses within a given set of
globals. One particular use case for this is to allow a C++ program to
efficiently verify (at each call site) that a vtable pointer is in the set
of valid vtable pointers for the class or its derived classes. One way of
doing this is for a toolchain component to build, for each class, a bit set
that maps to the memory region allocated for the vtables, such that each 1
bit in the bit set maps to a valid vtable for that class, and lay out the
vtables next to each other, to minimize the total size of the bit sets.

The patch introduces a metadata format for representing pointer sets, an
'@llvm.bitset.test' intrinsic and an LTO lowering pass that lays out the globals
and builds the bitsets, and documents the new feature.

Differential Revision: http://reviews.llvm.org/D7288

llvm-svn: 230054
2015-02-20 20:30:47 +00:00
Aaron Ballman
0e19b5d670 Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition.
llvm-svn: 229335
2015-02-15 22:00:20 +00:00
Chandler Carruth
46cf170b93 [ADT] Teach PointerUnion to support assignment directly from nullptr to
clear it out.

llvm-svn: 207471
2014-04-29 00:14:27 +00:00
Nick Lewycky
938c4fcef0 Add a DenseMapInfo specialization for PointerUnion. In tree user to land shortly.
llvm-svn: 206253
2014-04-15 07:08:40 +00:00
Chandler Carruth
87f14b4eec Re-sort all of the includes with ./utils/sort_includes.py so that
subsequent changes are easier to review. About to fix some layering
issues, and wanted to separate out the necessary churn.

Also comment and sink the include of "Windows.h" in three .inc files to
match the usage in Memory.inc.

llvm-svn: 198685
2014-01-07 11:48:04 +00:00
David Blaikie
29dad430cd Basic unit tests for PointerUnion
llvm-svn: 188933
2013-08-21 21:30:23 +00:00
Chris Lattner
54e35eee92 I'm told that != is not ==
llvm-svn: 188583
2013-08-16 22:29:44 +00:00
Chris Lattner
e41f27b395 allow != to compare PointerUnion, we already support ==.
llvm-svn: 188582
2013-08-16 22:09:02 +00:00
Douglas Gregor
8fdda97cb6 Add missing #include
llvm-svn: 181900
2013-05-15 17:41:02 +00:00
David Blaikie
898763a097 Use only explicit bool conversion operators
BitVector/SmallBitVector::reference::operator bool remain implicit since
they model more exactly a bool, rather than something else that can be
boolean tested.

The most common (non-buggy) case are where such objects are used as
return expressions in bool-returning functions or as boolean function
arguments. In those cases I've used (& added if necessary) a named
function to provide the equivalent (or sometimes negative, depending on
convenient wording) test.

One behavior change (YAMLParser) was made, though no test case is
included as I'm not sure how to reach that code path. Essentially any
comparison of llvm::yaml::document_iterators would be invalid if neither
iterator was at the end.

This helped uncover a couple of bugs in Clang - test cases provided for
those in a separate commit along with similar changes to `operator bool`
instances in Clang.

llvm-svn: 181868
2013-05-15 07:36:59 +00:00
Argyrios Kyrtzidis
ef5e4688df Eliminate redundant bitwise operations when using a llvm/ADT/PointerUnion.
For comparison, with this code sample:

PointerUnion<int *, char *> Data;
PointerUnion<int *, char *> foo1() {
	Data = new int;
	return new int;
}
PointerUnion<int *, char *> foo2() {
	Data = new char;
	return new char;
}

Before this patch we would get:

define i64 @_Z4foo1v() uwtable ssp {
  %1 = tail call noalias i8* @_Znwm(i64 4)
  %2 = ptrtoint i8* %1 to i64
  %3 = load i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %4 = and i64 %3, 1
  %.masked.i = and i64 %2, -3
  %5 = or i64 %4, %.masked.i
  store i64 %5, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %6 = tail call noalias i8* @_Znwm(i64 4)
  %7 = ptrtoint i8* %6 to i64
  %8 = and i64 %7, -3
  ret i64 %8
}

define i64 @_Z4foo2v() uwtable ssp {
  %1 = tail call noalias i8* @_Znwm(i64 1)
  %2 = ptrtoint i8* %1 to i64
  %3 = load i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %4 = and i64 %3, 1
  %5 = or i64 %2, %4
  %6 = or i64 %5, 2
  store i64 %6, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %7 = tail call noalias i8* @_Znwm(i64 1)
  %8 = ptrtoint i8* %7 to i64
  %9 = or i64 %8, 2
  ret i64 %9
}

After the patch:

define i64 @_Z4foo1v() uwtable ssp {
  %1 = tail call noalias i8* @_Znwm(i64 4)
  %2 = ptrtoint i8* %1 to i64
  store i64 %2, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %3 = tail call noalias i8* @_Znwm(i64 4)
  %4 = ptrtoint i8* %3 to i64
  ret i64 %4
}

declare noalias i8* @_Znwm(i64)

define i64 @_Z4foo2v() uwtable ssp {
  %1 = tail call noalias i8* @_Znwm(i64 1)
  %2 = ptrtoint i8* %1 to i64
  %3 = or i64 %2, 2
  store i64 %3, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %4 = tail call noalias i8* @_Znwm(i64 1)
  %5 = ptrtoint i8* %4 to i64
  %6 = or i64 %5, 2
  ret i64 %6
}

llvm-svn: 169147
2012-12-03 19:59:23 +00:00
Galina Kistanova
77f96f54b4 Fixed few warnings.
llvm-svn: 160192
2012-07-13 21:06:54 +00:00
Douglas Gregor
bb5c9263b1 Add a few missing 'template' keywords
llvm-svn: 152525
2012-03-11 02:22:41 +00:00
Argyrios Kyrtzidis
267b14e42c PointerUnion::getAddrOf() does not need to be template since we can only
use the first pointer type for it. Rename it to getAddrOfPtr1().

llvm-svn: 152106
2012-03-06 07:14:54 +00:00
Chris Lattner
ec2b25406c Fix an obscure bug in PointerUnion that would bite PointerUnion3/4. Basically,
when checking isNull(), we'd pick off the sentinel bit for the outer 
PointerUnion, but would not recursively convert the inner pointerunion to bool,
so if *its* sentinel bit is set, isNull() would incorrectly return false.

No testcase, because someone hit this when they were trying to refactor code
to use PointerUnion3, but they since found a better solution.

llvm-svn: 137428
2011-08-12 04:31:38 +00:00
Argyrios Kyrtzidis
5a57c82f11 Try fixing mingw build.
llvm-svn: 127153
2011-03-07 05:35:01 +00:00
Argyrios Kyrtzidis
9cd53db2f9 Do a compiler check that we use one of the types from PointerUnion[N], instead of a runtime check.
llvm-svn: 127145
2011-03-07 01:30:20 +00:00
Argyrios Kyrtzidis
a3437f732e Allow getting the address of the value in a PointerUnion or PointerIntPair if one is
confident enough that he knows what he is doing.

llvm-svn: 126019
2011-02-19 03:55:58 +00:00
Ted Kremenek
59cdbd3cfc Change PointerUnionX::getFromOpaqueValue() to be declared 'static inline' instead of 'static'.
llvm-svn: 99892
2010-03-30 16:20:03 +00:00
Douglas Gregor
790089c6e6 Add a bunch of missing "template" keywords to disambiguate dependent template names. GCC eats this ill-formed code, Clang does not. I already filed PR5404 to improve recovery in this case
llvm-svn: 86204
2009-11-06 00:12:53 +00:00
Douglas Gregor
7bc7d66441 Fix a typo, and all of its copies
llvm-svn: 77489
2009-07-29 18:27:22 +00:00
Douglas Gregor
9072f2cd18 Implement PointerUnion4.
llvm-svn: 77487
2009-07-29 18:19:47 +00:00
Sebastian Redl
51473d2434 Fix three MSVC 2008 warnings that completely clutter the build output.
llvm-svn: 74430
2009-06-29 17:12:06 +00:00
Douglas Gregor
aaa9263fc6 Allow the use of pointers to const within PointerUnion.
llvm-svn: 68159
2009-03-31 23:19:54 +00:00
Douglas Gregor
50b29cfe51 Stop guessing, start thinking, and make PointerUnion3::is actually be correct.
llvm-svn: 68126
2009-03-31 18:31:03 +00:00
Douglas Gregor
41ab75e9ef Really, really fix PointerUnion3::is
llvm-svn: 68079
2009-03-31 00:34:31 +00:00
Douglas Gregor
0beaefea25 Make PointerUnion3::get work properly
llvm-svn: 68067
2009-03-30 21:44:13 +00:00
Chris Lattner
ccc73c9327 update comment.
llvm-svn: 68060
2009-03-30 20:44:04 +00:00
Chris Lattner
a172ae1d4f add a PointerUnion3 class and generalize PointerUnion to work with
anything pointer-like, which may or may not actually be a pointer.

llvm-svn: 68056
2009-03-30 20:29:27 +00:00
Chris Lattner
be9cd842ae add some comments, add a dyn_cast method.
llvm-svn: 67992
2009-03-29 07:03:30 +00:00
Chris Lattner
696742399a add helper method.
llvm-svn: 67989
2009-03-29 06:32:46 +00:00
Chris Lattner
2c6632d760 Add a simple type-safe bit-mangling pointer union class. This allows
you to do things like:

  ///    PointerUnion<int*, float*> P;
  ///    P = (int*)0;
  ///    printf("%d %d", P.is<int*>(), P.is<float*>()); // prints "1 0"
  ///    X = P.get<int*>();     // ok.
  ///    Y = P.get<float*>();   // runtime assertion failure.
  ///    Z = P.get<double*>();  // does not compile.
  ///    P = (float*)0;
  ///    Y = P.get<float*>();   // ok.
  ///    X = P.get<int*>();     // runtime assertion failure.

llvm-svn: 67987
2009-03-29 06:06:02 +00:00