[llvm] r266486 - [cfi] Support explicit sections for functions in cfi-icall.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 15 15:55:38 PDT 2016


Author: eugenis
Date: Fri Apr 15 17:55:38 2016
New Revision: 266486

URL: http://llvm.org/viewvc/llvm-project?rev=266486&view=rev
Log:
[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.

Added:
    llvm/trunk/test/Transforms/LowerBitSets/section.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp

Modified: llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp?rev=266486&r1=266485&r2=266486&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp Fri Apr 15 17:55:38 2016
@@ -639,8 +639,9 @@ void LowerBitSets::verifyBitSetMDNode(MD
 
   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");

Added: llvm/trunk/test/Transforms/LowerBitSets/section.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerBitSets/section.ll?rev=266486&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LowerBitSets/section.ll (added)
+++ llvm/trunk/test/Transforms/LowerBitSets/section.ll Fri Apr 15 17:55:38 2016
@@ -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}




More information about the llvm-commits mailing list