88cd94d5165bf8a266d3f3095946fc25bc4809af |
|
17-May-2017 |
David Gross <dgross@google.com> |
Refactor attribute stripping for libbcc and llvm-rs-as. There is an existing StripUnknownAttributes pass we use to remove attributes unknown to old versions of LLVM before writing out bitcode. This is needed to avoid errors when writing or reading the bitcode. This change does three things: - Refactors code so that we can strip unknown attributes without depending on the pass infrastructure, and so that we have a library to strip unknown attributes. This is needed so that we can use this functionality in places where we're not using the pass manager and so that we can use it outside of slang (specifically, in libbcc). - Strips unknown attributes in llvm-rs-as, in order to satisfy frameworks/compile/libbcc/tests/run-lit-tests.sh (test_reduce_general_metadata.ll). See details below. - Updates some stale comments. Why do we need to strip unknown attributes in llvm-rs-as, even if the input .ll does not contain those attributes? Because the LLVM parser calls llvm::UpgradeCallsToIntrinsic() to canonicalize the attributes of intrinsic functions. For example, test_reduce_general_metadata.ll contains a call to @llvm.memcpy.p0i8.p0i8.i64, which gets canonicalized to have the argmemonly attribute. Remember that we're writing an old fixed version of bitcode, older than the "native" LLVM IR we're using, so there may be attributes in that IR that are not representible in that old fixed version of bitcode. Furthermore, argmemonly is one of a set of attributes that seem to be designed as "transient" -- they can appear in the IR (possibly only on intrinsics, or as the result of some analysis?) but can never appear in bitcode. Bug: 37720701 Test: aosp_angler-eng FORCE_BUILD_LLVM_DISABLE_NDEBUG=true 1) slang/tests 2) slang/lit-tests 3) RsTest (32-bit, 64-bit) 4) RsTest_11 5) cts -m RenderscriptTest Change-Id: I481f9a9d9ea5a0bd164ac4eeb68dd479eba5a187
/frameworks/compile/slang/StripUnkAttr/strip_unknown_attributes_pass.h
|