aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2013-06-20 18:45:16 -0700
committerStephen Hines <srhines@google.com>2013-08-13 14:48:38 -0700
commit80dd15464ebcff64f4eb58df5af0d3fc4723bbec (patch)
tree0a9ada777f6bc8109465cb69bad16168c7e3b885
parent9d234b6c83c9d6baab71433fdecab6bfde34a956 (diff)
downloadandroid_frameworks_compile_slang-80dd15464ebcff64f4eb58df5af0d3fc4723bbec.tar.gz
android_frameworks_compile_slang-80dd15464ebcff64f4eb58df5af0d3fc4723bbec.tar.bz2
android_frameworks_compile_slang-80dd15464ebcff64f4eb58df5af0d3fc4723bbec.zip
DO NOT MERGE - Write legacy function attributes properly.
Bug: 9503142 A prior LLVM rebase accidentally overwrote the various bitcode writer implementations with respect to function attributes. They were writing a new style section, which would not be able to be parsed/used on older devices. This change restores the generation of the legacy function attribute bitcode format. Change-Id: Ib6afc5ae405303881605c51c34b6966e4754c29d
-rw-r--r--BitWriter_2_9/Android.mk5
-rw-r--r--BitWriter_2_9/BitcodeWriter.cpp10
-rw-r--r--BitWriter_2_9_func/Android.mk5
-rw-r--r--BitWriter_2_9_func/BitcodeWriter.cpp10
-rw-r--r--BitWriter_3_2/Android.mk5
-rw-r--r--BitWriter_3_2/BitcodeWriter.cpp10
-rw-r--r--legacy_bitcode.h32
7 files changed, 62 insertions, 15 deletions
diff --git a/BitWriter_2_9/Android.mk b/BitWriter_2_9/Android.mk
index 28d3133..9df336e 100644
--- a/BitWriter_2_9/Android.mk
+++ b/BitWriter_2_9/Android.mk
@@ -3,8 +3,6 @@ LOCAL_PATH:= $(call my-dir)
LLVM_ROOT_PATH := $(LOCAL_PATH)/../../../../external/llvm
include $(LLVM_ROOT_PATH)/llvm.mk
-LOCAL_CFLAGS += $(local_cflags_for_slang)
-
bitcode_writer_2_9_SRC_FILES := \
BitcodeWriter.cpp \
BitcodeWriterPass.cpp \
@@ -14,6 +12,9 @@ bitcode_writer_2_9_SRC_FILES := \
# =====================================================
include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(local_cflags_for_slang)
+LOCAL_C_INCLUDES += frameworks/compile/slang
+
LOCAL_SRC_FILES := $(bitcode_writer_2_9_SRC_FILES)
LOCAL_MODULE:= libLLVMBitWriter_2_9
diff --git a/BitWriter_2_9/BitcodeWriter.cpp b/BitWriter_2_9/BitcodeWriter.cpp
index e8a8aa5..0d45193 100644
--- a/BitWriter_2_9/BitcodeWriter.cpp
+++ b/BitWriter_2_9/BitcodeWriter.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "ReaderWriter_2_9.h"
+#include "legacy_bitcode.h"
#include "ValueEnumerator.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/BitstreamWriter.h"
@@ -142,10 +143,13 @@ static void WriteAttributeTable(const llvm_2_9::ValueEnumerator &VE,
SmallVector<uint64_t, 64> Record;
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
const AttributeSet &A = Attrs[i];
- for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i)
- Record.push_back(VE.getAttributeGroupID(A.getSlotAttributes(i)));
+ for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
+ Record.push_back(A.getSlotIndex(i));
+ Record.push_back(encodeLLVMAttributesForBitcode(A, A.getSlotIndex(i)));
+ }
- Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
+ // This needs to use the 3.2 entry type
+ Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY_OLD, Record);
Record.clear();
}
diff --git a/BitWriter_2_9_func/Android.mk b/BitWriter_2_9_func/Android.mk
index 638c817..07b77d9 100644
--- a/BitWriter_2_9_func/Android.mk
+++ b/BitWriter_2_9_func/Android.mk
@@ -3,8 +3,6 @@ LOCAL_PATH:= $(call my-dir)
LLVM_ROOT_PATH := $(LOCAL_PATH)/../../../../external/llvm
include $(LLVM_ROOT_PATH)/llvm.mk
-LOCAL_CFLAGS += $(local_cflags_for_slang)
-
bitcode_writer_2_9_func_SRC_FILES := \
BitcodeWriter.cpp \
BitcodeWriterPass.cpp \
@@ -14,6 +12,9 @@ bitcode_writer_2_9_func_SRC_FILES := \
# =====================================================
include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(local_cflags_for_slang)
+LOCAL_C_INCLUDES += frameworks/compile/slang
+
LOCAL_SRC_FILES := $(bitcode_writer_2_9_func_SRC_FILES)
LOCAL_MODULE:= libLLVMBitWriter_2_9_func
diff --git a/BitWriter_2_9_func/BitcodeWriter.cpp b/BitWriter_2_9_func/BitcodeWriter.cpp
index ac02fad..828d891 100644
--- a/BitWriter_2_9_func/BitcodeWriter.cpp
+++ b/BitWriter_2_9_func/BitcodeWriter.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "ReaderWriter_2_9_func.h"
+#include "legacy_bitcode.h"
#include "ValueEnumerator.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/BitstreamWriter.h"
@@ -165,10 +166,13 @@ static void WriteAttributeTable(const llvm_2_9_func::ValueEnumerator &VE,
SmallVector<uint64_t, 64> Record;
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
const AttributeSet &A = Attrs[i];
- for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i)
- Record.push_back(VE.getAttributeGroupID(A.getSlotAttributes(i)));
+ for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
+ Record.push_back(A.getSlotIndex(i));
+ Record.push_back(encodeLLVMAttributesForBitcode(A, A.getSlotIndex(i)));
+ }
- Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
+ // This needs to use the 3.2 entry type
+ Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY_OLD, Record);
Record.clear();
}
diff --git a/BitWriter_3_2/Android.mk b/BitWriter_3_2/Android.mk
index f9ce5aa..6860880 100644
--- a/BitWriter_3_2/Android.mk
+++ b/BitWriter_3_2/Android.mk
@@ -3,8 +3,6 @@ LOCAL_PATH:= $(call my-dir)
LLVM_ROOT_PATH := $(LOCAL_PATH)/../../../../external/llvm
include $(LLVM_ROOT_PATH)/llvm.mk
-LOCAL_CFLAGS += $(local_cflags_for_slang)
-
bitcode_writer_3_2_SRC_FILES := \
BitcodeWriter.cpp \
BitcodeWriterPass.cpp \
@@ -14,6 +12,9 @@ bitcode_writer_3_2_SRC_FILES := \
# =====================================================
include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(local_cflags_for_slang)
+LOCAL_C_INCLUDES += frameworks/compile/slang
+
LOCAL_SRC_FILES := $(bitcode_writer_3_2_SRC_FILES)
LOCAL_MODULE:= libLLVMBitWriter_3_2
diff --git a/BitWriter_3_2/BitcodeWriter.cpp b/BitWriter_3_2/BitcodeWriter.cpp
index 0e3f907..ebd4d13 100644
--- a/BitWriter_3_2/BitcodeWriter.cpp
+++ b/BitWriter_3_2/BitcodeWriter.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "ReaderWriter_3_2.h"
+#include "legacy_bitcode.h"
#include "ValueEnumerator.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/BitstreamWriter.h"
@@ -174,10 +175,13 @@ static void WriteAttributeTable(const llvm_3_2::ValueEnumerator &VE,
SmallVector<uint64_t, 64> Record;
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
const AttributeSet &A = Attrs[i];
- for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i)
- Record.push_back(VE.getAttributeGroupID(A.getSlotAttributes(i)));
+ for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
+ Record.push_back(A.getSlotIndex(i));
+ Record.push_back(encodeLLVMAttributesForBitcode(A, A.getSlotIndex(i)));
+ }
- Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
+ // This needs to use the 3.2 entry type
+ Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY_OLD, Record);
Record.clear();
}
diff --git a/legacy_bitcode.h b/legacy_bitcode.h
new file mode 100644
index 0000000..5d45a1b
--- /dev/null
+++ b/legacy_bitcode.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2013, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "llvm/IR/Attributes.h"
+
+// Shared functionality for legacy function attribute encoding.
+static inline uint64_t encodeLLVMAttributesForBitcode(llvm::AttributeSet A,
+ unsigned i) {
+ uint64_t EncodedAttrs = A.Raw(i) & 0xffff;
+ if (A.hasAttribute(i, llvm::Attribute::Alignment)) {
+ // The alignment is stored as an actual power of 2 value (instead of the
+ // compressed log2 form). It occupies bits 31-16 inclusive.
+ EncodedAttrs |= (A.getParamAlignment(i) << 16);
+ }
+ // There are only 12 remaining attributes (bits 21-32), hence our 0xfff mask.
+ EncodedAttrs |= (A.Raw(i) & (0xfffull << 21)) << 11;
+ return EncodedAttrs;
+}
+