summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bcinfo/Android.bp1
-rw-r--r--bcinfo/BitcodeTranslator.cpp9
2 files changed, 10 insertions, 0 deletions
diff --git a/bcinfo/Android.bp b/bcinfo/Android.bp
index bd4fee5..e35bbd0 100644
--- a/bcinfo/Android.bp
+++ b/bcinfo/Android.bp
@@ -56,6 +56,7 @@ cc_library_shared {
"libLLVMBitReader_2_7",
"libLLVMBitReader_3_0",
"libLLVMBitWriter_3_2",
+ "libStripUnkAttr",
],
target: {
diff --git a/bcinfo/BitcodeTranslator.cpp b/bcinfo/BitcodeTranslator.cpp
index 5335eba..b3bce31 100644
--- a/bcinfo/BitcodeTranslator.cpp
+++ b/bcinfo/BitcodeTranslator.cpp
@@ -23,6 +23,8 @@
#include "BitWriter_3_2/ReaderWriter_3_2.h"
+#include "StripUnkAttr/strip_unknown_attributes.h"
+
#define LOG_TAG "bcinfo"
#include <log/log.h>
@@ -68,6 +70,11 @@ static const unsigned int kMinimumCompatibleVersion_LLVM_3_0 = 14;
static const unsigned int kMinimumCompatibleVersion_LLVM_2_7 = 11;
+static void stripUnknownAttributes(llvm::Module *M) {
+ for (llvm::Function &F : *M)
+ slang::stripUnknownAttributes(F);
+}
+
BitcodeTranslator::BitcodeTranslator(const char *bitcode, size_t bitcodeSize,
unsigned int version)
: mBitcode(bitcode), mBitcodeSize(bitcodeSize), mTranslatedBitcode(nullptr),
@@ -145,6 +152,8 @@ bool BitcodeTranslator::translate() {
// Module ownership is handled by the context, so we don't need to free it.
llvm::Module *module = MOrErr.get();
+ stripUnknownAttributes(module);
+
std::string Buffer;
llvm::raw_string_ostream OS(Buffer);