diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2016-04-15 22:55:38 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2016-04-15 22:55:38 +0000 |
commit | 40cd1514cfd0ef6b98aa0693244c751ee321b7c3 (patch) | |
tree | ef6dc5bd9a6280f0ed39383e0b610b676b74fe47 | |
parent | faac567e681142b5f3fb518db9d6e9021fef6684 (diff) | |
download | llvm-40cd1514cfd0ef6b98aa0693244c751ee321b7c3.zip llvm-40cd1514cfd0ef6b98aa0693244c751ee321b7c3.tar.gz llvm-40cd1514cfd0ef6b98aa0693244c751ee321b7c3.tar.bz2 |
[cfi] Support explicit sections for functions in cfi-icall.
Allow explicit section for indirectly called functions in cfi-icall.
Jumptables for functions in the same type class must be contiguous, so they
always go to the default text section.
Fixes PR25079.
llvm-svn: 266486
-rw-r--r-- | llvm/lib/Transforms/IPO/LowerBitSets.cpp | 5 | ||||
-rw-r--r-- | llvm/test/Transforms/LowerBitSets/section.ll | 26 |
2 files changed, 29 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/LowerBitSets.cpp b/llvm/lib/Transforms/IPO/LowerBitSets.cpp index 1798d83..db5bab0 100644 --- a/llvm/lib/Transforms/IPO/LowerBitSets.cpp +++ b/llvm/lib/Transforms/IPO/LowerBitSets.cpp @@ -639,8 +639,9 @@ void LowerBitSets::verifyBitSetMDNode(MDNode *Op) { if (OpGlobal->isThreadLocal()) report_fatal_error("Bit set element may not be thread-local"); - if (OpGlobal->hasSection()) - report_fatal_error("Bit set element may not have an explicit section"); + if (isa<GlobalVariable>(OpGlobal) && OpGlobal->hasSection()) + report_fatal_error( + "Bit set global var element may not have an explicit section"); if (isa<GlobalVariable>(OpGlobal) && OpGlobal->isDeclarationForLinker()) report_fatal_error("Bit set global var element must be a definition"); diff --git a/llvm/test/Transforms/LowerBitSets/section.ll b/llvm/test/Transforms/LowerBitSets/section.ll new file mode 100644 index 0000000..d5f9414 --- /dev/null +++ b/llvm/test/Transforms/LowerBitSets/section.ll @@ -0,0 +1,26 @@ +; Test that functions with "section" attribute are accepted, and jumptables are +; emitted in ".text". + +; RUN: opt -S -lowerbitsets < %s | FileCheck %s + +target triple = "x86_64-unknown-linux-gnu" + +; CHECK: @[[A:.*]] = private constant {{.*}} section ".text" +; CHECK: @f = alias void (), bitcast ({{.*}}* @[[A]] to void ()*) +; CHECK: define private void {{.*}} section "xxx" + +define void @f() section "xxx" { +entry: + ret void +} + +define i1 @g() { +entry: + %0 = call i1 @llvm.bitset.test(i8* bitcast (void ()* @f to i8*), metadata !"_ZTSFvE") + ret i1 %0 +} + +declare i1 @llvm.bitset.test(i8*, metadata) nounwind readnone + +!llvm.bitsets = !{!0} +!0 = !{!"_ZTSFvE", void ()* @f, i64 0} |