[cfe-dev] clang and LLVM string __attribute__

Alejandro Jimenez whilealex at gmail.com
Tue Oct 22 17:57:58 PDT 2013


Currently LLVM accepts arbitrary string attributes like the following LLVM
IR.
; ModuleID = 'test.hlsl'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32"
target triple = "i686-pc-win32"

; Function Attrs: nounwind
define i32 @_Z3fooi(i32 %r  ) "myAttribute"="myValue"  {
entry:
  %r.addr = alloca i32, align 4
  store i32 %r, i32* %r.addr, align 4
  %0 = load i32* %r.addr, align 4
  ret i32 %0
}

attributes #0 = { nounwind "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"unsafe-fp-math"="false" "use-soft-float"="false" }


Three questions for LLVM/Clang community.

Clang
Is there any way in clang to specify an arbitraty string attribute?
i.e. __attribute__((string("myAttribute"="myValue")))

LLVM
Is there any way to specify an arbitrary string attribute to parameters on
function declarations?
like define i32 @_Z3fooi(i32 %r  "myAttribute"="myValue" )   {
How about arbitrary attributes to instructions as well?
for.cond:   "unroll"="true"            ; preds = %for.inc, %entry

LLVM
Is Metadata the way to proceed here? I understood here
http://www.tuicool.com/articles/UfiMVf?jdfwkey=oatw1
That LLVM may destroy metadata when optimizing, is this still true?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131022/e75a5051/attachment.html>


More information about the cfe-dev mailing list