History log of /frameworks/compile/slang/slang_rs_object_ref_count.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
670ba1d5f33d0914e63732da0c9423f8069ac313 31-Mar-2016 Stephen Hines <srhines@google.com> Use empty list initializers to construct all zero-initialized variables.

Bug: http://b/24008889

In the past, we always tried to construct appropriate full
zero-initializers for uninitialized variables that contained any RS
object types (like rs_allocation) or any RS matrix types. For some
structures containing rs_matrix* types, we would insert an initializer
that uses just a single raw 0. While this is almost correct, it leads to
an invalid AST (that Clang is still happy to do the right thing with, for
now). Instead, we can rely on a supported extension that allows
zero-initialization with empty initializer lists (like in C++11, but for
older versions of C too). Switching to the empty list allows us to
remove a particularly tricky (and incomplete) section of code.

(cherry picked from commit d9ed6b51a3fe997aefdcd360f8bfc40b17c9ab91)

Change-Id: I241acdc3ce1740306c9f9d7fd37669c58909d582
f44e96036289beae53f6b3f345a723d990563f81 23-Mar-2016 Yang Ni <yangni@google.com> Initialize temp var for a return value

Bug: 27698337

This is the temporary variable introduced for the expression used in
a return statement.

We use rsSetObject() to set the value of the temporary variable to
the original expression from the return statement, and to bump up
the sysRefCount of the temp.

However, to have rsSetObject() work properly, the temp has to be zero

Change-Id: I0efb83fc7d54e95bb4d7a956f3f82b6d85188390
(cherry picked from commit 5767c359bac779b5d76d668ca5699fd5a0e3efc5)
8f093e05e28046b6fc74175b66a06152f72e0c66 04-Mar-2016 Pirama Arumuga Nainar <pirama@google.com> Update slang for LLVM rebase to r256229

Bug: http://b/26987366

(cherry picked from commit 98cfae456bb1831336bce2b21979a04e2e31fed4)

Change-Id: Ic7f67da3fee0da075f11e3125132af7ea9c96457
283a6cf32b808c703b219862ac491df3c9fc8b4b 16-Jan-2016 Yang Ni <yangni@google.com> Handle return values of rsObject type

Bug: 25570907
Bug: 25777125

This made further improvements over a previous fix on return
values of rsObject type.

1) The temp variable created for a return expression is now set using
rsSetObject() rather than directly put in the initializer of the temp.
This way, the returned rsObject would have a sys ref count of at least
1 and won't become invalid on the return for the caller.

2) On the caller side, introduced another temp variable .rs.tmpXXX for
the result of any function call that returns an rsObject. This temp
is set in the initializer upon declaration, without using rsSetObject().
A destructor is inserted at the end of the enclosing scope for the temp.

3) Both temp variables above are now named with a unique suffix (that is
a unique integer, which starts from 0 and increases monotonically within
the function currently being analyzed and transformed.)

4) Fixed an issue in the previous fix, when there are multiple rsObjects
defined in a block, we will only introduce one temp variable for a
return statement. The previous CL would introduce one temp for each
rsObject, mistakenly.

Change-Id: Id3604f93b166089e3aca896d1c6c509b3ea19bcf
(cherry picked from commit b478c3dd0a47dc4c0c884d911819c9cf53c46649)
65f23ed862e1a1e16477ba740f295ff4a83ac822 08-Jan-2016 David Gross <dgross@google.com> Add semantic analysis of "#pragma rs reduce" script functions.

- Make initializer() optional.
- Swap initializer and accumulator in metadata.
- Expose new slang::HasRSObjectType() interface from reference counting engine.

Bug: 23535724
Change-Id: If042e227a1af87c231c867ef20ed4c2082bb1871
2902ebb66a719485a06db264dc10d5d8a30f11ee 25-Nov-2015 Yang Ni <yangni@google.com> Fixed ref counting for returned rs objects

Bug: 25777125

As reported in the bug, currently an rs object referenced in a return
statement may be cleared at the end of a block, even before the
return expression is evaluated or any thing is actually returned.

This may cause a crash on the statment, when the return expression
references such objects, or cause the caller to crash on using a rs
object returned by such a function, when the return expression is a
single local variable reference.

This CL avoids such crashes by creating a local variable for the
returned value, and not calling rsClearObj on the new local variable.

Proper reclaiming of the returned objects would be in a seperate CL.

Change-Id: I49b683aa95aa1c600bf30e792bf830f762c2fe79
56916bec2734a6059e1d0f58959514c825c746f7 30-Nov-2015 Yang Ni <yangni@google.com> Cleaned up ref counting destructor visitor

Change-Id: Ib796dc6d6093b62b2420eeca21dbb80f35ed2c00
cd57c5447d831a237d0917a0d687749e6348a46d 25-Aug-2015 Stephen Hines <srhines@google.com> Fix invalid declaration of rsClearObject() iterator.

Bug: 23445219
Bug: 19545955

The erroneous code here triggered an assertion while building source
files that include an array destructor for RS object types (i.e.
rs_allocation a[4];). In the original case, the creation of the helper
iterator formed an invalid AST that caused the emission of its alloca
twice (because Clang would walk the outer scoped declaration first, and
then see another DeclRef to the creation within the loop). Moving the
iterator declaration into the loop (as an initialized variable) properly
scopes things, and makes the resulting AST a bit easier to read as well.
This never caused any harm without the assertion because the new (inner
scope) value would always overwrite the older (outer scope) value.

This change also fixes an improper use of the LValue for the iterator
when comparing it with the array bounds. The code now contains the
proper LValueToRValue cast. Relevant comments have been updated to show
the new AST that we have formed.

The final issue that this code defensively handles is the creation of
nested iterators (which isn't currently supported, but could be in the
future). In this case, we create a unique name for the iterator using a
static counter. The code should probably be refactored to use a proper
depth count (like other areas of Clang already do), but that can be part
of a separate cleanup CL, since it would be quite invasive.

The assertion fixed by this CL looks like:

llvm-rs-cc: external/clang/lib/CodeGen/CGDecl.cpp:1015: CodeGenFunction::AutoVarEmission clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(const clang::VarDecl &): Assertion `!DMEntry && "Decl already exists in localdeclmap!"' failed.

Change-Id: I4e8551de62112661d601d73104988e5adcfd6855
cc4d93488b344cbdb0d65c3af076f02dbf2ceb00 09-Jun-2015 Pirama Arumuga Nainar <pirama@google.com> Fix a few Clang assertions thrown by llvm-rs-cc

Bug: 19545955

- Mark global or local RS objects as 'Used' when inserting calls to
- Mark an integer variable created by ClearRSArrayObject for iteration
as 'used'.
- Pass a valid DeclarationNameInfo while creating a MemberExpr.

Change-Id: I591b98a7840f0d9117a751daef97df16aeba8206
8024ed54c23c08534434da14d3be99c3efcc5754 05-May-2015 Jean-Luc Brouillet <jeanluc@google.com> Merge Slang with SlangRS, Backend with RSBackend.

Change-Id: I4721f92c10ec14a886923778595289f96d3a8de5
0b7545898dcfe2979f2c13afd12d276fc736412d 07-Apr-2015 Stephen Hines <srhines@google.com> Update slang for LLVM rebase to r233350.

Change-Id: I1883757eb9987e45892ae6efde80f825fc9b5367
5abbe0e9ca2508260b627ffef2bf01e2554e8357 13-Aug-2014 Chris Wailes <chriswailes@google.com> Replace the NULL macro with nullptr literal.

Change-Id: I33609969cd0d7aa55eaa83fb2c65f5faa6d55fa0
9ae18b2bbee0b08afd400542e863dd665ff76059 11-Jun-2014 Stephen Hines <srhines@google.com> Add an option to emit 32-bit and 64-bit bitcode.

Bug: 16031597

Change-Id: Ifb3c4eca5e7ae16106260c2b5f5da6854c021a3a
796e7b1400d3f3f7c07496d88bb48129ea925bb9 27-May-2014 Jean-Luc Brouillet <jeanluc@google.com> Remove useless "return;" statements.

More cleanups to follow...

Change-Id: Ib8348255273771c1e9ff07e79bd7fbc8f2795a5b
cec9b65aa890dea58e39951900ae13efb8d11703 15-May-2014 Jean-Luc Brouillet <jeanluc@google.com> Move DataType enum out of RSExportPrimitiveDataType.

It applies to more than just Primitives and should not have been in there.

Change-Id: If2b6a9d2a87a05176a74bcf7212f65cf1cdf67fe
474655a402e70cb329e1bcd4ebbe00bdc5be4206 29-Apr-2014 Jean-Luc Brouillet <jeanluc@google.com> Remove rs_spec_gen and associated macros.

Also, enable new data types to be defined, out of order.
More CLs are coming to continue refactoring the code and removing

modified: Android.mk
deleted: RSSpec.mk
modified: slang_rs_export_element.cpp
modified: slang_rs_export_type.cpp
modified: slang_rs_export_type.h
modified: slang_rs_metadata_spec_encoder.cpp
modified: slang_rs_object_ref_count.cpp
modified: slang_rs_object_ref_count.h
deleted: slang_rs_spec_table.cpp
modified: slang_rs_type_spec.h

Change-Id: I3eb3e4357bbe9af26011df714795de8e495fec68
4b3f3bada7155de983e7d92fa8b20091629b3bb3 07-May-2013 Stephen Hines <srhines@google.com> Adapt llvm-rs-cc for LLVM/Clang update.

Change-Id: Ic38ebc1d824f6d3ae26c6b354336a01b52d46136
82d7288620fade361dd8f7408b5db54a55c2c794 19-Mar-2013 Stephen Hines <srhines@google.com> Update slang for LLVM/Clang rebase.

Change-Id: I80217ebbc4d5783afd34bd49b800dcc9cbff6427
23c4358f12bd9d0ba7166eceebd683db95a41b3f 10-Jan-2013 Stephen Hines <srhines@google.com> Updates for LLVM merge to r171906 on 20130108.

Change-Id: I4cf3718041d8876d4a23a412b6b4fa4226ec3b50
b0fabe574945bfa85e688e77e9dcb5341fe08840 08-Jan-2013 Stephen Hines <srhines@google.com> Fix rs_matrix destructor issue.

Bug: 7949301

This change fixes the destructor issue for rs_matrix types. We need to skip
creating a destructor if there are no reference-counted RS object types in
the struct. We still need to zero-init all RS object types (ref-counted or
not, as is the case for rs_matrix*). I also fix another issue where a missing
struct definition could cause an early parser crash (i.e. before the standard
clang errors kick in and notice that you are using an undefined struct).

Change-Id: If2009d96f35a8cb693431aaeae3cb4b5642695fa
1dfc415431ddd360354fecfcd9b12dcaf686355a 11-Sep-2012 Stephen Hines <srhines@google.com> Fix up slang for merge through LLVM r163557.

Adapt to use of ArrayRef instead of C array + length pairs for some
types of argument passing.

Change-Id: I133c059f32ae1b2e55ebb2473e642faa62d49714
e2597ac5a8ba7a45a1d5f342973cd43a3a1932cf 24-Mar-2012 Shih-wei Liao <sliao@google.com> Migrate to upstream-153220-20120321.

Change-Id: I877797e8cc284ef3147b52f40406559340ac1243
0444de0c0e7cfc8d8f8fed6f64cd97812bdd6a41 03-Mar-2012 Stephen Hines <srhines@google.com> Adapt to upstream Clang/LLVM changes.

Change-Id: Ib81ad97246dbee060341e2690fb7f27e9e0298f4
f6c0ca86dfd7959e1eada2fa09eb7f6b5dd2aa87 02-Mar-2012 Stephen Hines <srhines@google.com> am 47e7ca09: am c1024ba2: Merge "Xcode 4.3 compatibility checkin"

* commit '47e7ca09cf520f0a31ee8a72f91716ce4e764408':
Xcode 4.3 compatibility checkin
246fa17206bf78c59a64b2f7d98a6716d5345b81 23-Feb-2012 Al Sutton <al@funkyandroid.com> Xcode 4.3 compatibility checkin

The Xcode 4.3 compiler shows the method CreateArrayRSSetObject is unused and,
due to -Werror being specified as a compilation option, the compilation fails.

This patch comments out the method and has also been tested on an Ubuntu
10.04 build as well as Xcode 4.3 and neither generated compilation issues
which indicates the method isn't needed.

Signed-off-by: Al Sutton <al@funkyandroid.com>
c7234c1531e2623c0f23e29601a1bc17fbf76913 20-Dec-2011 Stephen Hines <srhines@google.com> am 9f1d0aa5: Update error diagnostic for struct/array copy.

* commit '9f1d0aa55669b75a718ad2e962fc8c3d8df1a5f4':
Update error diagnostic for struct/array copy.
9f1d0aa55669b75a718ad2e962fc8c3d8df1a5f4 19-Dec-2011 Stephen Hines <srhines@google.com> Update error diagnostic for struct/array copy.

An upstream Clang change caused F_struct_array_copy to start failing with the
latest downstreaming work. I noticed that the change makes the diagnostic more
clear, but can be confusing for the StartLoc (for the variable). This change
updates the test to use the new source location (for the actual assignment
operator), while making sure that StartLoc points to the LHS variable in the

Change-Id: Ie58b602ad4ce69d80b82fc03475fbd5d4beb17c7
d1123c29614eb9e0df7485f9e0775470db2f0384 15-Nov-2011 Stephen Hines <srhines@google.com> am 6a20005e: Merge "Adapt to upstream changes."

* commit '6a20005e9cf115b450ff344c5b13b2efaf8c4b75':
Adapt to upstream changes.
4c622e0953afe3dca4da0aee364a811f3ccb61d9 11-Nov-2011 Stephen Hines <srhines@google.com> Adapt to upstream changes.

Change-Id: I9ab7bad890eb78621c5fc6dd516dbcacdad88471
db6dfdfcb7e8183f1c796475e5098ee4be80b5b8 08-Nov-2011 Jason Sams <jsams@google.com> Add path object type.

Change-Id: I40f2323d2495d1754c910bd0161d59c0f2054eca
9207a2e495c8363606861e4f034504ec5c153dab 21-Oct-2011 Logan Chien <loganchien@google.com> Apply changes to migrate to LLVM upstream Oct 20th 2011.

- StructType::isAnonymous is renamed to StructType::isLiteral.

- PassManagerBuilder has been moved from
llvm/Support/PassManagerBuilder.h to

- Include llvm/Transforms/IPO.h for llvm::createInternalizePass.

- clang::DiagClient has be renamed to clang::DiagnosticConsumer.
Besides, we have to implement one additional pure virtual method
'clone' for create a clone of slang::DiagnosticBuffer.

- llvm::Linker::LinkModules comes with one additional parameter.
Passing llvm::Linker::DestroySource should be equivalent to
the old code we were using.

- slang::Slang is now derived from clang::ModuleLoader and implemented
loadModule pure virtual method (though we will always return NULL.)

- clang::Preprocessor is taking one additional parameter for

- clang::Diagnostic has been changed. A lot of the method has been
moved to clang::DiagnosticsEngine, and we can no longer 'Report' a
diagnostic from clang::Diagnostic. We have to use
clang::DiagnosticEngine instead.

- llvm::setCodeModel has been removed.

Change-Id: I1f2a4cbeaf61a8ed1d0d635a5a0e1baa90d99d07
3f175af8a0644fb5fc53aa90e01c24f75855c5f7 17-Sep-2011 Stephen Hines <srhines@google.com> Fix .rs.dtor scoping bug.


This change makes sure to scope any helper variables (like rsIntIter) to the
enclosing function (and not make them global). Prior to this change, if an
array iterator was created, it would be marked as a global symbol. The
libbcc library then sometimes removed this global as it was not able to
determine that it was actually used (.rs.dtor is not guaranteed to be called).
A fix should be made to libbcc as well, but the proper fix for llvm-rs-cc is
to scope any helper variable declarations to the calling function.

Change-Id: Ia46654cb0a114f6f5495e32ad1508d7d01e2084b
688e64b2d56e4218c680b9d6523c5de672f55757 24-Aug-2011 Stephen Hines <srhines@google.com> Generate .rs.dtor() to clean up globals.


Change-Id: I9d1996153fe774a5ce95646a8a2e07aa6e7fa85f
a883ce325281796dc7cc8fcf973a7ccd47a9a17e 12-Aug-2011 Stephen Hines <srhines@google.com> Fix refcount issue with locals declared in middle of compound statements.

Declaring a local variable in the middle of a compound statement is perfectly
legal in Renderscript (C99). Unfortunately, the refcount implementation was
mistakenly inserting destructors prior to the declaration, which is incorrect.
This change only allows destructors to be placed lexically after the local
variable has been declared.

Change-Id: Ieb8d5e2eac448719aa9266f7ba94437dad73ec0b
ab992e59a36a18df49bf4878968ef0598299afd3 20-Jul-2011 Logan Chien <loganchien@google.com> Apply changes to migrate to llvm upstream r135568.

- Remove the const qualifier of llvm::Type and
llvm::PointerType due to the API change.

- Update the relocation model setup code, since
llvm::TargetMachine changes the API.

- Qualify dyn_cast with llvm namespace.

Change-Id: I4820fb86effc3a62569e19a6a8753ba9e960f6b2
78e69cb06b9b0683b2ac9dcafde87b867690ef2f 23-Apr-2011 Stephen Hines <srhines@google.com> Forbid RS objects from being contained in unions.

This change also refactors variable validation in general for RS.

Change-Id: I4527986a07c9cf2babdc5b855cdb1f00e3535d5b
d0b5edd02be5f09c1d8d211f4a06b031a7b66510 19-Apr-2011 Stephen Hines <srhines@google.com> Disallow union copies that contain RS object types

This also cleans up RSObjectRefCount's usage of ASTContext a bit.


Change-Id: I9ca61e27fc5d6eb1befc2da4fe2d157f5936a56f
cc887ba8fe42cca706caae636932ae6a61a30ed2 20-Apr-2011 Shih-wei Liao <sliao@google.com> Apply changes to migrate to upstream as of March 18th, 2011 from logn.

- VarDecl requires StartLoc. We can get StartLoc by using

- FieldDecl and RecordDecl require StartLoc for Create function.
We can use clang::SourceLocation() in this case.

Change-Id: Ifc82678d10ad948484df1022df2bfc3e94e360cd
292e00a0259ac28cac1055cb6077cf6fc7c6743c 19-Mar-2011 Stephen Hines <srhines@google.com> Add support for RSASTReplace for ref-counting.


Change-Id: Ia17d40753952e4a021b39549a082cc4b3f20916c
9be9360d8e02b52ed669afbd69f9becb575c3f0d 18-Mar-2011 Alex Sakhartchouk <alexst@google.com> Re-enable warnings as errors in Slang.

Change-Id: Id926a089c6e8c4ae5d11ce692105bc6d383636a9
be27482cdeaf08576bc39b72a15d35d13014a636 16-Feb-2011 Logan <tzuhsiang.chien@gmail.com> Apply changes to migrate to LLVM Mar 6th 2011.

- API for name mangling. (Changing from non-public APIs to the
public one)

- API changes for clang::Diagnostic::getNumErrors ->

- API changes for clang::CharUnits and Quantity type.

- API changes libLLVMSystem -> libLLVMSupport.

- Change clang::Token::eom -> clang::Token::eod.

- Remove SourceRange parameter for DeclRefExpr::Create and

- Add const qualifier for several unsafe type cast.
832429f6bf4592cfc2ce58f2462f1e8ecdbaaf52 26-Feb-2011 Stephen Hines <srhines@google.com> Add proper line info to rsSetObject diagnostic.

Change-Id: Ib0281b66541f4c4fe3cd7d6e9a2490471481df1c
a0611e66bec148b176404cf6afe4c9ec9b960414 12-Feb-2011 Stephen Hines <srhines@google.com> Initialize structs.

Bug: 3092382
Change-Id: I4b9596c686205bbbc38505ed5dd33d1b968d2fd6
2bb67db8364162b30e6920baddf6c2e890b3ce79 11-Feb-2011 Stephen Hines <srhines@google.com> Replace struct assignments with rsSetObject calls.

Bug: 3092382
Change-Id: I63f16a7dac02eb348b87a6225944d48faa615899
f2174cfd6a556b51aadf2b8765e50df080e8f18e 10-Feb-2011 Stephen Hines <srhines@google.com> Handle struct reference counting.

Bug: 3092382

Change-Id: I215bd8245324ec2b7752a7c40817e3e5cd1c0e00
6e6578a360497f78a181e63d7783422a9c9bfb15 08-Feb-2011 Stephen Hines <srhines@google.com> Add support for assertions in llvm-rs-cc.

Bug: 3430674
Change-Id: I3400238652449cde84275cc2a770f405332d9544
feaca06fcb0772e9e972a0d61b17259fc5124d50 04-Feb-2011 Stephen Hines <srhines@google.com> Zero-initialize structs containing RS objects.

Bug: 3092382
Change-Id: I2fd80777db7ed52d8c0a1a598567399e08ce06a2
e79fb5ec220e20bd04cd6f6059cbc9748181ce21 02-Feb-2011 Stephen Hines <srhines@google.com> Handle local RS object initialization properly.

This change properly reference counts local RS object types when they are
statically initialized.

Change-Id: Ib21e8715cf63d2bcba01d332b592516262efb41e
Bug: 3092382
4cc67fce91f43215d61b2695746eab102a3db516 01-Feb-2011 Stephen Hines <srhines@google.com> Support for generating .java dependencies for RS.

This updates the -MD option to also emit .java targets to the dependency
information placed in our foo.d file.

Change-Id: I189cf6302bc1cbd6201487743a37dced87b5c5eb
c202d2d64fe0172bcc3999b515a14d3d88532420 26-Jan-2011 Stephen Hines <srhines@google.com> Replace RS object assignments with rsSetObject().

Reference counting works now for all scalar/array types. It still needs to be
modified slightly to support structs, initializers and break/continue.

Change-Id: I6e531df86508f261b784932fca930bc666cb0084
b: 3092382
a858cb6f3d9223d65bf73e1230c6324ded4095f6 17-Jan-2011 Stephen Hines <srhines@google.com> Fix variable names for Clang-based compilation.

Change-Id: I69b28110e9fda63abb3770da7a1127af4e1f2963
9d2c0fa6490e09b3ff5603796bce42d97788e5c8 05-Jan-2011 Stephen Hines <srhines@google.com> Fix style and a small typo.

Change-Id: I3525f400feecd11be9cd90a142434f6eb89d965a
03981a308201b9123512297c8b9562a0f29bdf31 15-Dec-2010 Stephen Hines <srhines@google.com> Support basic array destructors for RS types.

Bug: 3092382
Change-Id: I8f39672eb9ce4bae6aeb91f186f72def083aa6c1
d5f9d6c8b6944dfc30d4fea68479c2fcc250a62c 16-Dec-2010 Stephen Hines <srhines@google.com> Convert from use of Expr -> Stmt.

This will facilitate rs* array destructors (which use CompoundStmt).

Bug: 3092382
Change-Id: I17d86ccedfb6f40c49a491a80dbced55ed917c8f
2d095046682d9c372e8c4f102cd1b340ec14beba 13-Nov-2010 Stephen Hines <srhines@google.com> Properly zero-initialize local arrays of RS types.

Change-Id: I55b02f5d4e26a8b82dc96bcc2a524bb1380e0313
4464d825c11349068f2917f9ebee86b721423f3c 12-Nov-2010 Stephen Hines <srhines@google.com> Support local destructor for many return stmts.

This allows us to insert destructor calls to rsClearObject() for all local
variables at the end of their scope (closing curly brace), as well as before
any enclosed return statement. Note that proper support for a local destructor
with break/continue is still unimplemented.

Change-Id: I7c0633d2901b9bc7e1bac8e211b9eae2ac9f6e92
e639eb5caa2c386b4a60659a4929e8a6141a2cbe 09-Nov-2010 Stephen Hines <srhines@google.com> Improve code style.

Change-Id: I26e043849bce2a4b41ae132fbe0c882f4a6f112f
1bdd4978caabcdc9489bdcb7f1cd6087340699e8 09-Nov-2010 Stephen Hines <srhines@google.com> Add simple destructors to local RS objects.

Change-Id: Ie4aa964840b25c3aa8eed257d4ff0a1e4f6ef22a
4b32ffdfc1ac766f8932e7effbcdf7484e804a8e 06-Nov-2010 Stephen Hines <srhines@google.com> Factor out RSObjectRefCount for destructor work.

Change-Id: Ibdacc9e9f15401680bc54747664e187a05f62e25