<div dir="ltr"><div>Currently LLVM accepts arbitrary string attributes like the following LLVM IR.<br></div><div><div><div><div><font size="1">; ModuleID = 'test.hlsl'</font></div><div><font size="1">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"</font></div>
<div><font size="1">target triple = "i686-pc-win32"</font></div><div><font size="1"><br></font></div><div><font size="1">; Function Attrs: nounwind</font></div><div><font size="1">define i32 @_Z3fooi(i32 %r  ) <font color="#9900ff">"myAttribute"="myValue" </font> {</font></div>
<div><font size="1">entry:</font></div><div><font size="1">  %r.addr = alloca i32, align 4</font></div><div><font size="1">  store i32 %r, i32* %r.addr, align 4</font></div><div><font size="1">  %0 = load i32* %r.addr, align 4</font></div>
<div><font size="1">  ret i32 %0</font></div><div><font size="1">}</font></div><div><font size="1"><br></font></div><div><font size="1">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" }</font></div>
</div><div><br></div></div></div><div><br></div><div>Three questions for LLVM/Clang community.</div><div><br></div><div>Clang</div><div>Is there any way in clang to specify an arbitraty string attribute?</div><div>i.e. __attribute__((string("myAttribute"="myValue")))</div>
<div><br></div><div>LLVM</div><div>Is there any way to specify an arbitrary string attribute to parameters on function declarations?</div><div>like <span style="font-size:x-small">define i32 @_Z3fooi(i32 %r  </span><span style="color:rgb(153,0,255);font-size:x-small">"myAttribute"="myValue" </span><span style="font-size:x-small">) </span><font color="#9900ff" style="font-size:x-small"> </font><span style="font-size:x-small"> {</span></div>
<div>How about arbitrary attributes to instructions as well?</div><div><font size="1">for.cond:   <font color="#9900ff">"unroll"="true"  </font>          ; preds = %for.inc, %entry</font><br></div><div>
<font size="1"><br></font></div><div>LLVM</div><div>Is Metadata the way to proceed here? I understood here <a href="http://www.tuicool.com/articles/UfiMVf?jdfwkey=oatw1" style="font-family:Calibri,sans-serif;font-size:11pt">http://www.tuicool.com/articles/UfiMVf?jdfwkey=oatw1</a></div>
<div>That LLVM may destroy metadata when optimizing, is this still true?</div><div><br></div><div><br></div></div>