[LLVMdev] How to get ELF section virtual starting address from MCSymbolRefExpr?

Carter, Jack jcarter at mips.com
Sun Nov 20 19:54:50 PST 2011


Yeh, I eventually figured that out.

Thanks for responding though.

Jack
________________________________________
From: llvmdev-bounces at cs.uiuc.edu [llvmdev-bounces at cs.uiuc.edu] on behalf of llvmdev-request at cs.uiuc.edu [llvmdev-request at cs.uiuc.edu]
Sent: Sunday, November 20, 2011 10:00 AM
To: llvmdev at cs.uiuc.edu
Subject: LLVMdev Digest, Vol 89, Issue 47

Send LLVMdev mailing list submissions to
        llvmdev at cs.uiuc.edu

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
or, via email, send a message with subject or body 'help' to
        llvmdev-request at cs.uiuc.edu

You can reach the person managing the list at
        llvmdev-owner at cs.uiuc.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of LLVMdev digest..."


Today's Topics:

   1. llvm_anyint_ty clarification (Alberto Magni)
   2. Re: How to make Polly ignore some non-affine memory       accesses
      (Bernhard Reutner-Fischer)
   3. Re: How to make Polly ignore some non-affine memory       accesses
      (Tobias Grosser)
   4. Re: How to make Polly ignore some non-affine memory       accesses
      (Bernhard Reutner-Fischer)
   5. Re: How to make Polly ignore some non-affine memory       accesses
      (Tobias Grosser)
   6. Re: How to get ELF section virtual starting address from
      MCSymbolRefExpr? (Rafael ?vila de Esp?ndola)
   7. Re: llvm_anyint_ty clarification (Eli Friedman)
   8. Automatic C++ Refactoring application. (Joe Abbey)
   9. Re: Automatic C++ Refactoring application. (Chandler Carruth)
  10. Re: GlobalsModRef (Jorge A. Navas)
  11. Re: How to make Polly ignore some non-affine memory       accesses
      (Marcello Maggioni)
  12. Re: Insert a function call in the code (=?GB2312?B?1dTPxA==?=)
  13. call different function while running (=?GB2312?B?1dTPxA==?=)
  14. Re: How to make Polly ignore some non-affine memory       accesses
      (Tobias Grosser)
  15. How can I output assembly comments from emitPrologue()?
      (Stephen McGruer)
  16. (no subject) (Sandra Johnson)
  17. Re: How can I output assembly comments from       emitPrologue()?
      (Stephen McGruer)
  18. Re: call different function while running (Duncan Sands)


----------------------------------------------------------------------

Message: 1
Date: Sat, 19 Nov 2011 18:13:08 +0000
From: Alberto Magni <alberto.magni86 at gmail.com>
Subject: [LLVMdev] llvm_anyint_ty clarification
To: llvmdev at cs.uiuc.edu
Message-ID:
        <CAJJyQPS33eaRtVfsAo0-sGdjtKUU4EzurCqCrfTdctEOwuzfFw at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello everyone,

I am trying to implement the max PTX builtin function.
This is defined in the following way:

"max.type   d, a, b;"

where .type can be:
.type = { .u16, .u32, .u64,
                .s16, .s32, .s64 };

The presence of multiple types requires llvm.ptx.max
to be overloaded for i16, i32 and i64.
So I think that the right way to define the intrinsic would be
(as in the attached max_not_working.patch file):

def int_ptx_max : Intrinsic<[llvm_anyint_ty],
                            [LLVMMatchType<0>, LLVMMatchType<0>],
                            [Commutative]>;

The problem is that the builtin is not recognised in the following test case:

define ptx_device i16 @max_16(i16 %a, i16 %b) {
entry:
  %d = call i16 @llvm.ptx.max(i16 %a, i16 %b)
  ret i16 %d
}
declare i16 @llvm.ptx.max(i16, i16)

Things change if I define explicitly the i16 intrinsic, like this:

def int_ptx_max : Intrinsic<[llvm_i16_ty],
                            [llvm_i16_ty, llvm_i16_ty],
                            [Commutative]>;
In this case all goes well. But this is obviously non-extensible.

Am I using the llvm_anyint_ty type in the right way ?
Is there another way to implement this kind of behaviour?

Thanks,

Alberto
-------------- next part --------------
A non-text attachment was scrubbed...
Name: max_not_working.patch
Type: text/x-patch
Size: 1346 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111119/c9cac7e2/attachment-0002.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: max_working.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111119/c9cac7e2/attachment-0003.bin

------------------------------

Message: 2
Date: Sat, 19 Nov 2011 19:43:47 +0100
From: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
Subject: Re: [LLVMdev] How to make Polly ignore some non-affine memory
        accesses
To: Tobias Grosser <tobias at grosser.es>
Cc: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu>
Message-ID:
        <CAC1BbcTkr3BwDjXUOsJ-OrPLp76JiJSY0mpdVCx-pNQ44fzSCg at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Nov 19, 2011 5:40 PM, "Tobias Grosser" <tobias at grosser.es> wrote:
>
> On 11/18/2011 01:34 PM, Marcello Maggioni wrote:

> > +    // Devide the access function by the size of the elements in the
array.

Decide,  with a 'c', please. Multiple other occurances below, too.

Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111119/a4d0fbc8/attachment-0001.html

------------------------------

Message: 3
Date: Sat, 19 Nov 2011 10:45:46 -0800
From: Tobias Grosser <tobias at grosser.es>
Subject: Re: [LLVMdev] How to make Polly ignore some non-affine memory
        accesses
To: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
Cc: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu>
Message-ID: <4EC7F95A.4010203 at grosser.es>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 11/19/2011 10:43 AM, Bernhard Reutner-Fischer wrote:
>
> On Nov 19, 2011 5:40 PM, "Tobias Grosser" <tobias at grosser.es
> <mailto:tobias at grosser.es>> wrote:
>  >
>  > On 11/18/2011 01:34 PM, Marcello Maggioni wrote:
>
>  > > +    // Devide the access function by the size of the elements in
> the array.
>
> Decide,  with a 'c', please. Multiple other occurances below, too.

I think the use of 'Devide' is correct here. It is the mathematical
operation '/' - to devide. Or do I miss something obvious?

Tobi


------------------------------

Message: 4
Date: Sat, 19 Nov 2011 19:48:41 +0100
From: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
Subject: Re: [LLVMdev] How to make Polly ignore some non-affine memory
        accesses
To: Tobias Grosser <tobias at grosser.es>
Cc: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu>
Message-ID:
        <CAC1BbcSDMZ4Z+hxD3PLiXOiEk_jPH0KJ2KU_7K_ygFsjguQypw at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Nov 19, 2011 7:45 PM, "Tobias Grosser" <tobias at grosser.es> wrote:
>
> On 11/19/2011 10:43 AM, Bernhard Reutner-Fischer wrote:
>>
>>
>> On Nov 19, 2011 5:40 PM, "Tobias Grosser" <tobias at grosser.es
>> <mailto:tobias at grosser.es>> wrote:
>>  >
>>  > On 11/18/2011 01:34 PM, Marcello Maggioni wrote:
>>
>>  > > +    // Devide the access function by the size of the elements in
>> the array.
>>
>> Decide,  with a 'c', please. Multiple other occurances below, too.
>
>
> I think the use of 'Devide' is correct here. It is the mathematical
operation '/' - to devide. Or do I miss something obvious?

Isn't / more "divide"?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111119/c127a401/attachment-0001.html

------------------------------

Message: 5
Date: Sat, 19 Nov 2011 10:50:12 -0800
From: Tobias Grosser <tobias at grosser.es>
Subject: Re: [LLVMdev] How to make Polly ignore some non-affine memory
        accesses
To: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
Cc: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu>
Message-ID: <4EC7FA64.1020905 at grosser.es>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 11/19/2011 10:48 AM, Bernhard Reutner-Fischer wrote:
>
> On Nov 19, 2011 7:45 PM, "Tobias Grosser" <tobias at grosser.es
> <mailto:tobias at grosser.es>> wrote:
>  >
>  > On 11/19/2011 10:43 AM, Bernhard Reutner-Fischer wrote:
>  >>
>  >>
>  >> On Nov 19, 2011 5:40 PM, "Tobias Grosser" <tobias at grosser.es
> <mailto:tobias at grosser.es>
>  >> <mailto:tobias at grosser.es <mailto:tobias at grosser.es>>> wrote:
>  >> >
>  >> > On 11/18/2011 01:34 PM, Marcello Maggioni wrote:
>  >>
>  >> > > +    // Devide the access function by the size of the elements in
>  >> the array.
>  >>
>  >> Decide,  with a 'c', please. Multiple other occurances below, too.
>  >
>  >
>  > I think the use of 'Devide' is correct here. It is the mathematical
> operation '/' - to devide. Or do I miss something obvious?
>
> Isn't / more "divide"?

True, it should be 'divide' instead of 'devide'.
Thanks for pointing out this typo.

Tobi



------------------------------

Message: 6
Date: Sat, 19 Nov 2011 11:07:01 -0800
From: Rafael ?vila de Esp?ndola         <rafael.espindola at gmail.com>
Subject: Re: [LLVMdev] How to get ELF section virtual starting address
        from MCSymbolRefExpr?
To: llvmdev at cs.uiuc.edu
Message-ID: <4EC7FE55.60207 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 11-11-17 12:32 PM, Carter, Jack wrote:
> I have a case where I the expression (MCSymbolRefExpr) is the offset
> from the beginning of the section.
>
> The need is to combine that offset to the virtual address of the section
> it belongs, in this case .text, but it could be any section.
>
> I can get a MCSectionELF class object from MCSymbol that I get from
> MCSymbolRefExpr:
>
> int Kind = Value->getKind();
> if (Kind == MCExpr::SymbolRef) {
> const MCSymbol &Sym = SRE->getSymbol();
> const MCSectionELF = dyn_cast_or_null<MCSectionELF>(Sym.getSection());
> }
>
> But can't see how to get the virtual address of the section. This is odd
> since I would have expected methods for accessing every part of the ELF
> section header entry.
>
> How does one get the virtual address (sh_addr in ELF) starting from a
> MCSymbolRefExpr?

The offset is not know until relaxation. You probably want an expression
that is (cur_label - label_at_section_start), no?

> Thanks,
>
> Jack
>

Cheers,
Rafael



------------------------------

Message: 7
Date: Sat, 19 Nov 2011 12:42:34 -0800
From: Eli Friedman <eli.friedman at gmail.com>
Subject: Re: [LLVMdev] llvm_anyint_ty clarification
To: Alberto Magni <alberto.magni86 at gmail.com>
Cc: llvmdev at cs.uiuc.edu
Message-ID:
        <CAJdarcF078jhDZxOZeLK4qkCfymXv7=MnTSn1eC7fFb8rraZXA at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Nov 19, 2011 at 10:13 AM, Alberto Magni
<alberto.magni86 at gmail.com> wrote:
> Hello everyone,
>
> I am trying to implement the max PTX builtin function.
> This is defined in the following way:
>
> "max.type ? d, a, b;"
>
> where .type can be:
> .type = { .u16, .u32, .u64,
> ? ? ? ? ? ? ? ?.s16, .s32, .s64 };
>
> The presence of multiple types requires llvm.ptx.max
> to be overloaded for i16, i32 and i64.
> So I think that the right way to define the intrinsic would be
> (as in the attached max_not_working.patch file):
>
> def int_ptx_max : Intrinsic<[llvm_anyint_ty],
> ? ? ? ? ? ? ? ? ? ? ? ? ? ?[LLVMMatchType<0>, LLVMMatchType<0>],
> ? ? ? ? ? ? ? ? ? ? ? ? ? ?[Commutative]>;
>
> The problem is that the builtin is not recognised in the following test case:
>
> define ptx_device i16 @max_16(i16 %a, i16 %b) {
> entry:
> ?%d = call i16 @llvm.ptx.max(i16 %a, i16 %b)
> ?ret i16 %d
> }
> declare i16 @llvm.ptx.max(i16, i16)

Try llvm.ptx.max.i16.

-Eli



------------------------------

Message: 8
Date: Sat, 19 Nov 2011 16:30:43 -0600
From: Joe Abbey <jabbey at arxan.com>
Subject: [LLVMdev] Automatic C++ Refactoring application.
To: "llvmdev at cs.uiuc.edu Mailing List" <llvmdev at cs.uiuc.edu>
Message-ID: <A6F3E4BF-4C14-47EC-ADE8-B9959C6FD4A6 at arxan.com>
Content-Type: text/plain; charset="us-ascii"

Our product is currently integrated with LLVM 2.8 (I know), and it sounded like many others at the conference were too.  It'd be really cool to use the clang auto refactoring language to upgrade from Path V1 to V2 for instance.

The sooner it can get open sourced the better.

Looking forward to it

Joe

Sent from my iPhone


------------------------------

Message: 9
Date: Sat, 19 Nov 2011 14:37:15 -0800
From: Chandler Carruth <chandlerc at google.com>
Subject: Re: [LLVMdev] Automatic C++ Refactoring application.
To: Joe Abbey <jabbey at arxan.com>
Cc: Manuel Klimek <klimek at google.com>,  clang-dev Developers
        <cfe-dev at cs.uiuc.edu>
Message-ID:
        <CAGCO0Khz2y2JKF7dgWMP231YCKR128dDqApXwea5xCwRSmKeqQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

(cfe-dev is probably the more appropriate mailing list)
(bcc:llvmdev in the hope of reducing their spam)

On Sat, Nov 19, 2011 at 2:30 PM, Joe Abbey <jabbey at arxan.com> wrote:

> Our product is currently integrated with LLVM 2.8 (I know), and it sounded
> like many others at the conference were too.  It'd be really cool to use
> the clang auto refactoring language to upgrade from Path V1 to V2 for
> instance.
>
> The sooner it can get open sourced the better.
>

Yep, we're working on it. =]

That said, the 2.8 -> 3.0 move is going to require a lot more than an API
upgrade for path...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111119/746c1cd1/attachment-0001.html

------------------------------

Message: 10
Date: Sun, 20 Nov 2011 10:54:35 +0100
From: "Jorge A. Navas" <jorge at clip.dia.fi.upm.es>
Subject: Re: [LLVMdev] GlobalsModRef
To: Duncan Sands <baldrick at free.fr>
Cc: llvmdev at cs.uiuc.edu
Message-ID: <20168.52827.844407.462483 at clip.dia.fi.upm.es>
Content-Type: text/plain; charset=iso-8859-1

Got it!

Thanks

Jorge

On Saturday, November 19, 2011 at 15:16:52 (+0100), Duncan Sands wrote:
>> Hi Jorge,
>>
>> > I'm implementing an intra-procedural analysis. For correctness, during
>> > the analysis of each function I need to know which global variables
>> > may be modified by other functions in order to avoid wrong assumptions
>> > about those variables.
>> >
>> > I looked at lib/Analysis/IPA/GlobalsModRef.cpp and it seems that it
>> > does what I want. My problem is that I don't know how to use it ;-(
>> >
>> > I wrote a pass:
>> >
>> >    struct MyPass : public FunctionPass {
>> >      ....
>> >      virtual void getAnalysisUsage(AnalysisUsage&  AU) const {
>> >         AU.addRequired<GlobalsModRef>();
>> >         ...
>> >      }
>> >      ...
>> >    }
>> >
>> > but then I don't know which header file should I include. Otherwise, I
>> > get the obvious error that "GlobalsModRef was not declared in this
>> > scope"
>> >
>> > Sorry because it's a basic question but I looked for any client of
>> > GlobalsModRef in the llvm tree but it seems nobody uses it.
>>
>> I think the reason for that is that you are supposed to use the generic
>> alias analysis interface.  This then queries any present alias analyses
>> (like GlobalsModRef) for you.
>>
>> Ciao, Duncan.
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


------------------------------

Message: 11
Date: Sun, 20 Nov 2011 12:01:07 +0100
From: Marcello Maggioni <hayarms at gmail.com>
Subject: Re: [LLVMdev] How to make Polly ignore some non-affine memory
        accesses
To: Tobias Grosser <tobias at grosser.es>, LLVM Developers Mailing List
        <llvmdev at cs.uiuc.edu>
Message-ID:
        <CA+5XV7bmkC1yNSR+xyEPansck6u=1g9G3dogbZYyXaEts_1tCQ at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

2011/11/19 Tobias Grosser <tobias at grosser.es>:
> On 11/18/2011 01:34 PM, Marcello Maggioni wrote:
>>
>> Ok , this is what I believe is the final patch that adds the
>> non-affine accept functionality to Polly, this should have no issues.
>>
>> I added three tests, two in ScopInfo (two simple tests, one expected
>> fail and one success based on the same source) and one in CodeGen that
>> verifies that the code is generated.
>>
>> The patch is attached.
>
> The patch includes only one test case. I also have some tiny last comments
> inline. Otherwise the patch looks good.
>
>> +++ test/ScopInfo/simple_nonaffine_loop_exfail.ll ? ? (revision 0)
>> @@ -0,0 +1,42 @@
>> +; RUN: opt %loadPolly %defaultOpts -polly-scops -analyze %s |
>> FileCheck %s
>> +; XFAIL: *
>
> Why is this one still XFAIL?

I wanted to add a test case that in case of a "missing the flag" at
command line confirmed the functionality was actually disabled (and
this is the reason of the XFAIL test).
Originally you said I had to add a minimal test case to the patch,
should I add some more tests now with more complex scops?

>> Index: lib/Analysis/ScopInfo.cpp
>> ===================================================================
>> --- lib/Analysis/ScopInfo.cpp ? (revision 144978)
>> +++ lib/Analysis/ScopInfo.cpp ? (working copy)
>> @@ -311,29 +311,38 @@
>> ? ?Type = Access.isRead() ? Read : Write;
>> ? ?statement = Statement;
>>
>> - ?isl_pw_aff *Affine = SCEVAffinator::getPwAff(Statement,
>> Access.getOffset());
>> ? ?BaseAddr = Access.getBase();
>>
>> - ?setBaseName();
>> + ?if (Access.isAffine()) {
>>
>> - ?// Devide the access function by the size of the elements in the array.
>> - ?//
>> - ?// A stride one array access in C expressed as A[i] is expressed in
>> LLVM-IR
>> - ?// as something like A[i * elementsize]. This hides the fact that two
>> - ?// subsequent values of 'i' index two values that are stored next to
>> each
>> - ?// other in memory. By this devision we make this characteristic
>> obvious
>> - ?// again.
>> - ?isl_int v;
>> - ?isl_int_init(v);
>> - ?isl_int_set_si(v, Access.getElemSizeInBytes());
>> - ?Affine = isl_pw_aff_scale_down(Affine, v);
>> - ?isl_int_clear(v);
>> + ? ?isl_pw_aff *Affine = SCEVAffinator::getPwAff(Statement,
>> Access.getOffset());
>>
>> - ?AccessRelation = isl_map_from_pw_aff(Affine);
>> - ?AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_in,
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Statement->getBaseName());
>> - ?AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_out,
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?getBaseName().c_str());
>> + ? ?setBaseName();
>> +
>> + ? ?// Devide the access function by the size of the elements in the
>> array.
>> + ? ?//
>> + ? ?// A stride one array access in C expressed as A[i] is expressed in
>> LLVM-IR
>> + ? ?// as something like A[i * elementsize]. This hides the fact that two
>> + ? ?// subsequent values of 'i' index two values that are stored next to
>> each
>> + ? ?// other in memory. By this devision we make this characteristic
>> obvious
>> + ? ?// again.
>> + ? ?isl_int v;
>> + ? ?isl_int_init(v);
>> + ? ?isl_int_set_si(v, Access.getElemSizeInBytes());
>> + ? ?Affine = isl_pw_aff_scale_down(Affine, v);
>> + ? ?isl_int_clear(v);
>> +
>> + ? ?AccessRelation = isl_map_from_pw_aff(Affine);
>> + ? ?AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_in,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Statement->getBaseName());
>> + ? ?AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_out,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?getBaseName().c_str());
>> + ?}
>> + ?else
>> + ?{
>
> Use '} else {' here.

Ouch!

>
>> Index: lib/Analysis/ScopDetection.cpp
>> ===================================================================
>> --- lib/Analysis/ScopDetection.cpp ? ? ?(revision 144978)
>> +++ lib/Analysis/ScopDetection.cpp ? ? ?(working copy)
>> @@ -79,6 +79,11 @@
>> ? ? ? ? ? ? ? ? cl::desc("Ignore possible aliasing of the array bases"),
>> ? ? ? ? ? ? ? ? cl::Hidden, cl::init(false));
>>
>> +static cl::opt<bool>
>> +AllowNonAffine("polly-allow-nonaffine",
>> + ? ? ? ? ? ? ? cl::desc("Allow non affine access functions for arrays"),
>> + ? ? ? ? ? ? ? cl::Hidden, cl::init(false));
>> +
>>
>> ?//===----------------------------------------------------------------------===//
>> ?// Statistics.
>>
>> @@ -236,7 +241,9 @@
>> ? ?BasePointer =
>> dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction));
>>
>> ? ?if (!BasePointer)
>> + ?{
>> ? ? ?INVALID(AffFunc, "No base pointer");
>> + ?}
>
> This change is unneeded and unrelated.
>
>>
>> ? ?BaseValue = BasePointer->getValue();
>>
>> @@ -245,8 +252,9 @@
>>
>> ? ?AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
>>
>> - ?if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE, BaseValue))
>> + ?if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE, BaseValue)&&
>> ?!AllowNonAffine)
>> ? ? ?INVALID(AffFunc, "Bad memory address "<< ?*AccessFunction);
>> +
>>
>> ? ?// FIXME: Alias Analysis thinks IntToPtrInst aliases with alloca
>> instructions
>> ? ?// created by IndependentBlocks Pass.
>> Index: lib/Analysis/TempScopInfo.cpp
>> ===================================================================
>> --- lib/Analysis/TempScopInfo.cpp ? ? ? (revision 144978)
>> +++ lib/Analysis/TempScopInfo.cpp ? ? ? (working copy)
>> @@ -98,12 +98,20 @@
>> ? ? ? ? ?dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction));
>>
>> ? ? ? ?assert(BasePointer&& ?"Could not find base pointer");
>> + ? ? ?AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
>> +
>> + ? ? ?if (isAffineExpr(&R, AccessFunction, *SE, BasePointer->getValue()))
>> {
>>
>> - ? ? ?AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
>> - ? ? ?Functions.push_back(std::make_pair(IRAccess(Type,
>> + ? ? ? ?Functions.push_back(std::make_pair(IRAccess(Type,
>>
>> ?BasePointer->getValue(),
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?AccessFunction, Size),
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?AccessFunction, Size,
>> true),
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &Inst));
>> + ? ? ?} else {
>> + ? ? ? ?Functions.push_back(std::make_pair(IRAccess(Type,
>> +
>> ?BasePointer->getValue(),
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?AccessFunction, Size,
>> false),
>> +&Inst));
>> + ? ? ?}
>
> You may want to simplify this to:
>
> AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
> bool IsAffine = isAffineExpr(&R, AccessFunction, *SE,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? BasePointer->getValue()));
> Functions.push_back(std::make_pair(IRAccess(Type,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?BasePointer->getValue(),
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?AccessFunction, Size,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?IsAffine);
>
> Cheers and thanks for you work
> Tobi
>

Ok, I'll simplify these parts, thanks.

Marcello



------------------------------

Message: 12
Date: Sun, 20 Nov 2011 19:14:21 +0800
From: =?GB2312?B?1dTPxA==?= <zhaoxiahust at gmail.com>
Subject: Re: [LLVMdev] Insert a function call in the code
To: Duncan Sands <baldrick at free.fr>
Cc: llvmdev at cs.uiuc.edu
Message-ID:
        <CAO0ZshLw6P9=N+Crbn0T3hcOTxYOXQ3kMJVZ1XeJTbFNKHz29g at mail.gmail.com>
Content-Type: text/plain; charset="gb2312"

Thank you for your help
I found the problem,
as hook() is a no paramter function,so

                            for(Function::arg_iterator i =
hook->arg_begin(), e = hook->arg_end(); i != e; ++i)
                            {
                                Args.push_back(i); /////////////Wong
                            }

we can add a call by
Instruction *newInst = CallInst::Create(hook, "");
BB->getInstList().insert((Instruction*)BI, newInst);


If you want to insert the function with a paramter, you should add a real
value to Args

?? 2011??11??20?? ????3:07??Duncan Sands <baldrick at free.fr>??????

> Hi ????, please don't send emails only to me: CC the mailing
> list too.  That way others can join in and the discussion is
> archived for the benefit of people with similar questions in
> the future.
>
> On 20/11/11 01:29, ???? wrote:
> > Thank you for your reply,
> > But after I remove the second Type::getVoidTy(M.getContext()),Another
> problem
> > occured
> >
> > opt: Value.cpp:175: void llvm::Value::setName(const llvm::Twine&):
> Assertion
> > `!getType()->isVoidTy() && "Cannot assign a name to void values!"'
> failed.
>
> Probably you are trying to give a name to the call to your function, i.e.
> to
> the value returned by it.  Since your function doesn't return a value
> (since it
> "returns" void), giving the returned value a name makes no sense, thus this
> assertion.
>
> > 0 opt 0x000000000082f5cf
> > 1 opt 0x000000000083181a
> > 2 libpthread.so.0 0x00000033f460f4c0
> > 3 libc.so.6 0x00000033f42329a5 gsignal + 53
> > 4 libc.so.6 0x00000033f4234185 abort + 373
> > 5 libc.so.6 0x00000033f422b935 __assert_fail + 245
> > 6 opt 0x00000000007d866b
> > 7 bishe_insert.so 0x00007f94c62a2b3f
> > 8 opt 0x00000000007c47d7 llvm::MPPassManager::runOnModule(llvm::Module&)
> + 503
> > 9 opt 0x00000000007c4957 llvm::PassManagerImpl::run(llvm::Module&) + 167
> > 10 opt 0x00000000004a43be main + 2734
> > 11 libc.so.6 0x00000033f421ec5d __libc_start_main + 253
> > 12 opt 0x0000000000499d19
> > Stack dump:
> > 0. Program arguments: opt -load
> > /home/kain/Documents/bishe/llvm-2.8/Release+Asserts/lib/bishe_insert.so
> > -bishe_insert
> > 1. Running pass 'test function exist' on module '<stdin>'.
> > Aborted (core dumped)
> >
> >
> > And If I want to insert a function such as void hook(int ),the first
> problem
> > occured
>
> I'm not sure what you mean by "the first problem".  If your function takes
> an integer parameter, you need to pass the appropriate integer type when
> you create the function.
>
> Ciao, Duncan.
>
> >
> >
> >
> > 2011/11/19 Duncan Sands <baldrick at free.fr <mailto:baldrick at free.fr>>
> >
> >     Hi ????,
> >
> >      > hookFunc = M.getOrInsertFunction("hook",
> >      > Type::getVoidTy(M.getContext()), Type::getVoidTy(M.getContext()),
> (Type*)0);
> >
> >     try removing the second Type::getVoidTy. Your function doesn't take
> any
> >     parameters, so you should simply pass an empty list of parameter
> types.
> >     Unlike in C++, a function foo(void) taking no parameters shouldn't be
> >     declared as taking one parameter of void type, it takes no
> parameters.
> >
> >     Ciao, Duncan.
> >     _______________________________________________
> >     LLVM Developers mailing list
> >     LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>
> http://llvm.cs.uiuc.edu
> >     http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111120/5551c75f/attachment-0001.html

------------------------------

Message: 13
Date: Sun, 20 Nov 2011 20:00:35 +0800
From: =?GB2312?B?1dTPxA==?= <zhaoxiahust at gmail.com>
Subject: [LLVMdev] call different function while running
To: llvmdev at cs.uiuc.edu
Message-ID:
        <CAO0ZshKnyHu_1xF42SZNVUO=DVZFwo9r1F1yWHJ5achPr7ZeNA at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello every, I am new to LLVM, using it to create a system
Now I have a problem
code below:

int main(int argc, char **argv)
{
      symbolic(2);//symbolic(int a)

      sleep(1,2);//sleep(int a, int b)
}

two definations of sleep
int sleep(int a, int b)
{
     return a+b;
}
int sleep(int a, int b)
{
    return a-b;
}

can I choose different sleep() by the result of symbolic(),
if symbolic(5)  calling the first sleep
if symbolic(2)  calling the second sleep

how to make it by using PASS, how to complete it by writing symbolic()
Do you have any ideas,
Thank you very much
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111120/abc1802f/attachment-0001.html

------------------------------

Message: 14
Date: Sun, 20 Nov 2011 04:06:14 -0800
From: Tobias Grosser <tobias at grosser.es>
Subject: Re: [LLVMdev] How to make Polly ignore some non-affine memory
        accesses
To: llvmdev at cs.uiuc.edu, Marcello Maggioni <hayarms at gmail.com>
Message-ID: <4EC8ED36.4010001 at grosser.es>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 11/20/2011 03:01 AM, Marcello Maggioni wrote:
> 2011/11/19 Tobias Grosser<tobias at grosser.es>:
>> On 11/18/2011 01:34 PM, Marcello Maggioni wrote:
>>>
>>> Ok , this is what I believe is the final patch that adds the
>>> non-affine accept functionality to Polly, this should have no issues.
>>>
>>> I added three tests, two in ScopInfo (two simple tests, one expected
>>> fail and one success based on the same source) and one in CodeGen that
>>> verifies that the code is generated.
>>>
>>> The patch is attached.
>>
>> The patch includes only one test case. I also have some tiny last comments
>> inline. Otherwise the patch looks good.
>>
>>> +++ test/ScopInfo/simple_nonaffine_loop_exfail.ll     (revision 0)
>>> @@ -0,0 +1,42 @@
>>> +; RUN: opt %loadPolly %defaultOpts -polly-scops -analyze %s |
>>> FileCheck %s
>>> +; XFAIL: *
>>
>> Why is this one still XFAIL?
>
> I wanted to add a test case that in case of a "missing the flag" at
> command line confirmed the functionality was actually disabled (and
> this is the reason of the XFAIL test).he
XFAIL it not the way to test this. You can just add another command line
to the passing test, remove the flag to enable non-affine access
functions and replace '| FileCheck' with '| not FileCheck'.

> Originally you said I had to add a minimst al test case to the patch,
> should I add some more tests now withore complex scops?

I do not see that a more complex scope would test more of the feature.
You could add a test case where the access subscript is not a valid
SCEV, but COULD_NOT_COMPUTE.

Cheers
Tobi


------------------------------

Message: 15
Date: Sun, 20 Nov 2011 12:47:30 +0000
From: Stephen McGruer <stephen.mcgruer at gmail.com>
Subject: [LLVMdev] How can I output assembly comments from
        emitPrologue()?
To: llvmdev at cs.uiuc.edu
Message-ID:
        <CANV974AFYdf7aukaRVXc5fdU=138Y8pkNhDzSsU3X8iD7PY3Jg at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Dear all,

I am looking to output assembly comments in my emitPrologue() function,
just for my own readability. Searching for a way to do this found me this
thread - http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-October/043722.html,
which says that the best way to output comments from somewhere like
emitPrologue() is to:

   1. Create an MDString for the comment.
   2. Attach it to an LLVM instruction using setMetadata().
   3. Add a new member to MachineInstr to hold the metadata, and attach it
   when converting LLVM instructions.
   4. Update AsmPrinter to read off the metadata and output it as an
   assembly comment.

Is this the only (and correct) way to do this?




If so, I am having trouble attaching the MDString to an instruction. I am
using BuildMI to create my instruction, which only seems to have an
"addMetadata()" function rather than "setMetadata()", and which takes an
MDNode instead of an MDString. I attempted to do this as follows:

void XXXFrameLowering::emitPrologue(MachineFunction &MF) const {
...
  Value* end_prologue_comment = MDString::get(getGlobalContext(), "end of
prologue");
  BuildMI(MBB, MBBI, dl, TII.get(Target::AnInstr),
Target::R1).addMetadata(cast<MDNode>(end_prologue_comment));
}

However, it seems an MDString cannot be case to an MDNode this way. How do
I go about turning that MDString into an MDNode, and once done how do I add
the new member to MachineInstr and attach the metadata to it?

Thanks,
Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111120/7f1b6fda/attachment-0001.html

------------------------------

Message: 16
Date: Sun, 20 Nov 2011 07:15:06 -0800 (PST)
From: Sandra Johnson <sandra_johnk at yahoo.com>
Subject: [LLVMdev] (no subject)
To: copyrights at athenaeservices.com,
        inderscienceproofs at athenaeservices.com,
        manuscripts at causalproductions.com, llvmdev at cs.uiuc.edu,
        llvmdev-request at cs.uiuc.edu, tulsi at cs.umanitoba.ca
Message-ID:
        <1321802106.72557.yint-ygo-j2me at web35703.mail.mud.yahoo.com>
Content-Type: text/plain; charset=utf-8

http://bawb.info/pdf/pozlvmd.htm



------------------------------

Message: 17
Date: Sun, 20 Nov 2011 16:13:15 +0000
From: Stephen McGruer <stephen.mcgruer at gmail.com>
Subject: Re: [LLVMdev] How can I output assembly comments from
        emitPrologue()?
To: llvmdev at cs.uiuc.edu
Message-ID:
        <CANV974CjD6ZxORtewge-GVqzJBWL8hNRqCoTf_Vm2iMqdzLiqg at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

So, an update. I have managed to generate comments, although it does create
a non-existent instruction. My method is as follows (and I would appreciate
any comments on how to do it "better", although note that this won't make
it into the final code :).)

1. I declared a "fake" instruction type to hold comments, ala:

class FakeInst<dag outs, dag ins, string asmstr, list<dag> pattern> :
Instruction {
  field bits<32> Inst;

  let Namespace = "XXX"
  let Inst{31-0} = 0;

  dag OutOperandList = outs;
  dag InOperandList = ins;
  let AsmString = asmstr;
  let Pattern = pattern;
}

2. I then defined a comment instruction, ala:

def COMMENT : FakeInst<(outs), (ins Reg:$fake), "; $fake", []>;

3. I added the following to printOperand(...) in XXXAsmPrinter.cpp:

switch (MO.getType()) {
  ...
  case MachineOperand::MO_Metadata:
    O << cast<MDString>(MO.getMetadata()->getOperand(0))->getString();
    break;
  ...
}

4. Finally, whenever I needed to emit comments I call the following:

MDNode* comment =
MDNode::get(getGlobalContext(),
ArrayRef<Value*>(MDString::get(getGlobalContext(),
"COMMENT HERE")));
BuildMI(MBB, MBBI, dl, TII.get(XXX::COMMENT)).addMetadata(comment);



So, this seems to work, although it will create an empty instruction (I
think). That could probably be cleaned up before MC emission, but I would
really just remove the comments anyway. Any suggestions on a better way to
do this (or a pointer to some obvious existing solution!) welcome :).

Stephen

On 20 November 2011 12:47, Stephen McGruer <stephen.mcgruer at gmail.com>wrote:

> Dear all,
>
> I am looking to output assembly comments in my emitPrologue() function,
> just for my own readability. Searching for a way to do this found me this
> thread -
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-October/043722.html,
> which says that the best way to output comments from somewhere like
> emitPrologue() is to:
>
>    1. Create an MDString for the comment.
>    2. Attach it to an LLVM instruction using setMetadata().
>    3. Add a new member to MachineInstr to hold the metadata, and attach
>    it when converting LLVM instructions.
>    4. Update AsmPrinter to read off the metadata and output it as an
>    assembly comment.
>
> Is this the only (and correct) way to do this?
>
>
>
>
> If so, I am having trouble attaching the MDString to an instruction. I am
> using BuildMI to create my instruction, which only seems to have an
> "addMetadata()" function rather than "setMetadata()", and which takes an
> MDNode instead of an MDString. I attempted to do this as follows:
>
> void XXXFrameLowering::emitPrologue(MachineFunction &MF) const {
> ...
>   Value* end_prologue_comment = MDString::get(getGlobalContext(), "end of
> prologue");
>   BuildMI(MBB, MBBI, dl, TII.get(Target::AnInstr),
> Target::R1).addMetadata(cast<MDNode>(end_prologue_comment));
> }
>
> However, it seems an MDString cannot be case to an MDNode this way. How do
> I go about turning that MDString into an MDNode, and once done how do I add
> the new member to MachineInstr and attach the metadata to it?
>
> Thanks,
> Stephen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20111120/aaf53841/attachment-0001.html

------------------------------

Message: 18
Date: Sun, 20 Nov 2011 17:54:04 +0100
From: Duncan Sands <baldrick at free.fr>
Subject: Re: [LLVMdev] call different function while running
To: llvmdev at cs.uiuc.edu
Message-ID: <4EC930AC.5030505 at free.fr>
Content-Type: text/plain; charset=UTF-8; format=flowed

Hi ??,

> Hello every, I am new to LLVM, using it to create a system
> Now I have a problem
> code below:
>
> int main(int argc, char **argv)
> {
>        symbolic(2);//symbolic(int a)
>
>        sleep(1,2);//sleep(int a, int b)
> }
>
> two definations of sleep
> int sleep(int a, int b)
> {
>       return a+b;
> }
> int sleep(int a, int b)
> {
>      return a-b;
> }
>
> can I choose different sleep() by the result of symbolic(),
> if symbolic(5)  calling the first sleep
> if symbolic(2)  calling the second sleep

I'm not sure exactly what you are asking.  If symbolic returns a boolean
value, and you want to call different sleep functions depending on the
result, then:
(1) make sure the different sleep functions have different names, say sleep1
and sleep2.
(2) create a CallInst (call this CI) which calls symbolic.
(3) create a conditional Branch instruction which uses CI as the condition,
and branches either to basic block B1 or B2 depending on the condition.
You will need to create B1 and B2 and insert them into your function.
(4) in B1, create a call to sleep1; in B2, create a call to sleep2.
(5) at the ends of B1 and B2, create unconditional branches to a basic block
B3.  You will need to create B3 and insert it in your function.
(6) the return statement goes in B3.

One way to understand how to do things is to write an example in C, and
paste it into http://llvm.org/demo/  That will output LLVM IR that implements
the C you pasted, showing one way of implementing it in LLVM IR.

Ciao, Duncan.
>
> how to make it by using PASS, how to complete it by writing symbolic()
> Do you have any ideas,
> Thank you very much
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



------------------------------

_______________________________________________
LLVMdev mailing list
LLVMdev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


End of LLVMdev Digest, Vol 89, Issue 47
***************************************




More information about the llvm-dev mailing list