[PATCH] Attach attribute "trap-func-name" to IR function

Akira Hatanaka ahatanak at gmail.com
Mon Jun 29 22:35:22 PDT 2015


Remove cc1 option and simplify patch.


http://reviews.llvm.org/D10831

Files:
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGCall.cpp
  test/CodeGen/fn-attr.c

Index: lib/CodeGen/BackendUtil.cpp
===================================================================
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -536,7 +536,6 @@
   Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
   Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath;
   Options.StackAlignmentOverride = CodeGenOpts.StackAlignment;
-  Options.TrapFuncName = CodeGenOpts.TrapFuncName;
   Options.PositionIndependentExecutable = LangOpts.PIELevel != 0;
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
Index: lib/CodeGen/CGCall.cpp
===================================================================
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1483,6 +1483,9 @@
     if (!CodeGenOpts.StackRealignment)
       FuncAttrs.addAttribute("no-realign-stack");
 
+    if (!CodeGenOpts.TrapFuncName.empty())
+      FuncAttrs.addAttribute("trap-func-name", CodeGenOpts.TrapFuncName);
+
     // Add target-cpu and target-features attributes to functions. If
     // we have a decl for the function and it has a target attribute then
     // parse that and add it to the feature set.
Index: test/CodeGen/fn-attr.c
===================================================================
--- /dev/null
+++ test/CodeGen/fn-attr.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-ios5 -function-attribute trap-func-name=trapfuncname1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: attributes #0 = { {{.*}} "trap-func-name"="trapfuncname1"
+
+int foo1(int a) { return a; }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10831.28752.patch
Type: text/x-patch
Size: 1569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150630/431e368b/attachment.bin>


More information about the cfe-commits mailing list