From evan.cheng at apple.com Mon Apr 26 02:38:56 2010
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 26 Apr 2010 07:38:56 -0000
Subject: [llvm-commits] [llvm] r102323 - in /llvm/trunk:
include/llvm/Target/TargetInstrInfo.h include/llvm/Target/TargetLowering.h
lib/CodeGen/LiveIntervalAnalysis.cpp
lib/CodeGen/SelectionDAG/InstrEmitter.cpp
lib/CodeGen/SelectionDAG/InstrEmitter.h
lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h
lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h
Message-ID: <20100426073856.60001312800A@llvm.org>
Author: evancheng
Date: Mon Apr 26 02:38:55 2010
New Revision: 102323
URL: http://llvm.org/viewvc/llvm-project?rev=102323&view=rev
Log:
- Move TargetLowering::EmitTargetCodeForFrameDebugValue to TargetInstrInfo and rename it to emitFrameIndexDebugValue.
- Teach spiller to modify DBG_VALUE instructions to reference spill slots.
Modified:
llvm/trunk/include/llvm/Target/TargetInstrInfo.h
llvm/trunk/include/llvm/Target/TargetLowering.h
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h
llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.h
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.h
Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=102323&r1=102322&r2=102323&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Mon Apr 26 02:38:55 2010
@@ -23,6 +23,7 @@
class LiveVariables;
class MCAsmInfo;
class MachineMemOperand;
+class MDNode;
class SDNode;
class SelectionDAG;
class TargetRegisterClass;
@@ -361,6 +362,19 @@
return false;
}
+ /// emitFrameIndexDebugValue - Emit a target-dependent form of
+ /// DBG_VALUE encoding the address of a frame index. Addresses would
+ /// normally be lowered the same way as other addresses on the target,
+ /// e.g. in load instructions. For targets that do not support this
+ /// the debug info is simply lost.
+ virtual MachineInstr *emitFrameIndexDebugValue(MachineFunction &MF,
+ unsigned FrameIx,
+ uint64_t Offset,
+ const MDNode *MDPtr,
+ DebugLoc dl) const {
+ return 0;
+ }
+
/// foldMemoryOperand - Attempt to fold a load or store of the specified stack
/// slot into the specified machine instruction for the specified operand(s).
/// If this is possible, a new instruction is returned with the specified
Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=102323&r1=102322&r2=102323&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Mon Apr 26 02:38:55 2010
@@ -1255,16 +1255,6 @@
return SDValue();
}
- /// EmitTargetCodeForFrameDebugValue - Emit a target-dependent form of
- /// DBG_VALUE encoding the address of a frame index. Addresses would
- /// normally be lowered the same way as other addresses on the target,
- /// e.g. in load instructions. For targets that do not support this
- /// the debug info is simply lost.
- virtual void
- EmitTargetCodeForFrameDebugValue(MachineBasicBlock* BB, unsigned FrameIx,
- uint64_t Offset, MDNode *MDPtr,
- DebugLoc dl) const {}
-
/// LowerOperationWrapper - This callback is invoked by the type legalizer
/// to legalize nodes with an illegal operand type but legal result types.
/// It replaces the LowerOperation callback in the type Legalizer.
Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=102323&r1=102322&r2=102323&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Apr 26 02:38:55 2010
@@ -1296,9 +1296,23 @@
MachineOperand &O = ri.getOperand();
++ri;
if (MI->isDebugValue()) {
- // Remove debug info for now.
- O.setReg(0U);
- DEBUG(dbgs() << "Removing debug info due to spill:" << "\t" << *MI);
+ // Modify DBG_VALUE now that the value is in a spill slot.
+ uint64_t Offset = MI->getOperand(1).getImm();
+ const MDNode *MDPtr = MI->getOperand(2).getMetadata();
+ DebugLoc DL = MI->getDebugLoc();
+ MachineInstr *NewDV = tii_->emitFrameIndexDebugValue(*mf_, Slot, Offset,
+ MDPtr, DL);
+ if (NewDV) {
+ DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" << *MI);
+ ReplaceMachineInstrInMaps(MI, NewDV);
+ MachineBasicBlock *MBB = MI->getParent();
+ MBB->insert(MBB->erase(MI), NewDV);
+ } else {
+ DEBUG(dbgs() << "Removing debug info due to spill:" << "\t" << *MI);
+ RemoveMachineInstrFromMaps(MI);
+ vrm.RemoveMachineInstrFromMaps(MI);
+ MI->eraseFromParent();
+ }
continue;
}
assert(!O.isImplicit() && "Spilling register that's used as implicit use?");
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=102323&r1=102322&r2=102323&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Mon Apr 26 02:38:55 2010
@@ -507,7 +507,6 @@
/// EmitDbgValue - Generate machine instruction for a dbg_value node.
///
MachineInstr *InstrEmitter::EmitDbgValue(SDDbgValue *SD,
- MachineBasicBlock *InsertBB,
DenseMap
+GHC is an open source, +state-of-the-art programming suite for Haskell, a standard lazy +functional programming language. It includes an optimizing static +compiler generating good code for a variety of platforms, together +with an interactive system for convenient, quick development.
+ +In addition to the existing C and native code generators, GHC now +supports an LLVM +code generator. GHC supports LLVM 2.7.
+ +Clang is an LLVM front end for the C, C++, and Objective-C languages. Clang aims to provide a better user experience through expressive diagnostics, a high level of conformance to language standards, fast compilation, and low memory use. Like LLVM, Clang provides a modular, library-based architecture that makes it suitable for creating or integrating with other development tools. Clang is considered a production-quality compiler for C and Objective-C on x86 (32- and 64-bit).
+Clang is an LLVM front end for the C, +C++, and Objective-C languages. Clang aims to provide a better user experience +through expressive diagnostics, a high level of conformance to language +standards, fast compilation, and low memory use. Like LLVM, Clang provides a +modular, library-based architecture that makes it suitable for creating or +integrating with other development tools. Clang is considered a +production-quality compiler for C and Objective-C on x86 (32- and 64-bit).
In the LLVM 2.7 time-frame, the Clang team has made many improvements:
void function, etc.), sign-comparison warnings, and improved format-string warnings.void function, etc.), sign-comparison warnings, and improved
+format-string warnings.Trap values are similar to undef values, however +
Trap values are similar to undef values, however instead of representing an unspecified bit pattern, they represent the fact that an instruction or constant expression which cannot evoke side effects has nevertheless detected a condition which results in undefined - behavior.
+ behavior.
Any non-void instruction or constant expression other than a non-intrinsic
call, invoke, or phi with a trap operand has trap as its result value.
From Micah.Villmow at amd.com Mon Apr 26 15:37:46 2010
From: Micah.Villmow at amd.com (Villmow, Micah)
Date: Mon, 26 Apr 2010 15:37:46 -0500
Subject: [llvm-commits] Fix for assertion in DAGCombiner
In-Reply-To: <277854.61965.qm@web55602.mail.re4.yahoo.com>
References: <623530.48513.qm@web55607.mail.re4.yahoo.com>
<805706E5-D6DB-41BE-B6F7-B985B60AD9AA@apple.com>
<277854.61965.qm@web55602.mail.re4.yahoo.com>
Message-ID:
If a br or + switch instruction has a trap value + operand, all non-phi non-void instructions which control-depend on it + have trap as their result value. If any instruction which + control-depends on the br or switch invokes externally + visible side effects, the behavior of the program is undefined.
+ + +For example, an and of a trap value with zero still has a trap value result. Using that value as an index in a getelementptr yields a trap From gohman at apple.com Mon Apr 26 16:15:19 2010 From: gohman at apple.com (gohman at apple.com) Date: Mon, 26 Apr 2010 21:15:19 +0000 Subject: [llvm-commits] [PATCH] Consolidate the description of volatile operations (issue986042) Message-ID: <0016e68ee4b0342a2f04852a46e9@google.com> This looks good to me. There are some tricky issues with volatile not covered here, but they weren't covered by the original text either :-). http://codereview.appspot.com/986042/show From jyasskin at google.com Mon Apr 26 16:21:24 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 26 Apr 2010 21:21:24 -0000 Subject: [llvm-commits] [llvm] r102384 - /llvm/trunk/docs/LangRef.html Message-ID: <20100426212125.4A00A312800A@llvm.org> Author: jyasskin Date: Mon Apr 26 16:21:24 2010 New Revision: 102384 URL: http://llvm.org/viewvc/llvm-project?rev=102384&view=rev Log: Consolidate the description of volatile operations, now that some of the intrinsics have volatile semantics in addition to the load and store instructions. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=102384&r1=102383&r2=102384&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Apr 26 16:21:24 2010 @@ -50,6 +50,7 @@
Certain memory accesses, such as loads, stores, and llvm.memcpys may be marked volatile. +The optimizers must not change the number of volatile operations or change their +order of execution relative to other volatile operations. The optimizers +may change the order of volatile operations relative to non-volatile +operations. This is not Java's "volatile" and has no cross-thread +synchronization behavior.
+ +The optional constant align argument specifies the alignment of the operation (that is, the alignment of the memory address). A value of 0 or an @@ -4257,11 +4275,10 @@ and an address at which to store it. The type of the '<pointer>' operand must be a pointer to the first class type of the - '<value>' operand. If the store is marked - as volatile, then the optimizer is not allowed to modify the number - or order of execution of this store with other - volatile load and store - instructions.
+ '<value>' operand. If the store is marked as + volatile, then the optimizer is not allowed to modify the number or + order of execution of this store with other volatile operations.The optional constant "align" argument specifies the alignment of the operation (that is, the alignment of the memory address). A value of 0 or an @@ -5962,8 +5979,10 @@ then the caller guarantees that both the source and destination pointers are aligned to that boundary.
-Volatile accesses should not be deleted if dead, but the access behavior is - not very cleanly specified and it is unwise to depend on it.
+If the isvolatile parameter is true, the + llvm.memcpy call is a volatile operation. + The detailed access behavior is not very cleanly specified and it is unwise + to depend on it.
Volatile accesses should not be deleted if dead, but the access behavior is - not very cleanly specified and it is unwise to depend on it.
+If the isvolatile parameter is true, the + llvm.memmove call is a volatile operation. + The detailed access behavior is not very cleanly specified and it is unwise + to depend on it.
Volatile accesses should not be deleted if dead, but the access behavior is - not very cleanly specified and it is unwise to depend on it.
+If the isvolatile parameter is true, the + llvm.memset call is a volatile operation. + The detailed access behavior is not very cleanly specified and it is unwise + to depend on it.
The 'llvm.memset.*' intrinsics fill "len" bytes of memory starting
From jyasskin at google.com Mon Apr 26 16:22:47 2010
From: jyasskin at google.com (Jeffrey Yasskin)
Date: Mon, 26 Apr 2010 14:22:47 -0700
Subject: [llvm-commits] [PATCH] Consolidate the description of volatile
operations (issue986042)
In-Reply-To: <0016e68ee4b0342a2f04852a46e9@google.com>
References: <0016e68ee4b0342a2f04852a46e9@google.com>
Message-ID:
Any non-void instruction or constant expression other than a non-intrinsic - call, invoke, or phi with a trap operand has trap as its result value. - Any instruction with a trap operand which may have side effects emits - those side effects as if it had an undef operand instead.
+Any value other than a non-intrinsic call, invoke, or phi with a trap + operand has trap as its result value. Any instruction with + a trap operand which may have side effects emits those side effects as + if it had an undef operand instead. If the side effects are externally + visible, the behavior is undefined.
+ +Trap values may be stored to memory; a load from memory including any + part of a trap value results in a (full) trap value.
+ +For example:
+ + + ++%trap = sub nuw i32 0, 1 ; Results in a trap value. +%still_trap = and i32 %trap, 0 ; Whereas (and i32 undef, 0) would return 0. +%trap_yet_again = getelementptr i32* @h, i32 %still_trap +store i32 0, i32* %trap_yet_again ; undefined behavior + +volatile store i32 %trap, i32* @g ; External observation; undefined behavior. +%trap2 = load i32* @g ; Returns a trap value, not just undef. +%narrowaddr = bitcast i32* @g to i16* +%wideaddr = bitcast i32* @g to i64* +%trap3 = load 16* %narrowaddr ; Returns a trap value +%trap4 = load i64* %widaddr ; Returns a trap value, not partial trap. ++
If a br or switch instruction has a trap value operand, all non-phi non-void instructions which control-depend on it - have trap as their result value. If any instruction which - control-depends on the br or switch invokes externally - visible side effects, the behavior of the program is undefined.
+ have trap as their result value. A phi + node with an incoming value associated with a control edge which is + control-dependent on it has trap as its result value when control is + transferred from that block. If any instruction which control-depends + on the br or switch invokes externally visible side + effects, the behavior of the program is undefined. For example: -For example, an and of a trap value with - zero still has a trap value result. Using that value as an index in a - getelementptr yields a trap - result. Using that result as the address of a - store produces undefined behavior.
++entry: + %trap = sub nuw i32 0, 1 ; Results in a trap value. + %cmp = icmp i32 slt %trap, 0 ; Still trap. + %br i1 %cmp, %true, %end ; Branch to either destination. + +true: + volatile store i32 0, i32* @g ; Externally visible side effects + ; control-dependent on %cmp. + ; Undefined behavior. + br label %end + +end: + %p = phi i32 [ 0, %entry ], [ 1, %true ] + ; Both edges into this PHI are + ; control-dependent on %cmp, so this + ; results in a trap value. + + volatile store i32 0, i32* @g ; %end is control-equivalent to %entry + ; so this is defined (ignoring earlier + ; undefined behavior in this example). + ++
There is currently no way of representing a trap constant in the IR; they
only exist when produced by certain instructions, such as an
From sabre at nondot.org Mon Apr 26 18:37:21 2010
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 26 Apr 2010 23:37:21 -0000
Subject: [llvm-commits] [llvm] r102400 - in /llvm/trunk:
include/llvm/Target/TargetInstrInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h
test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll
test/CodeGen/X86/2008-01-25-EmptyFunction.ll
Message-ID: <20100426233721.D61E1312800A@llvm.org>
Author: lattner
Date: Mon Apr 26 18:37:21 2010
New Revision: 102400
URL: http://llvm.org/viewvc/llvm-project?rev=102400&view=rev
Log:
on darwin empty functions need to codegen into something of non-zero length,
otherwise labels get incorrectly merged. We handled this by emitting a
".byte 0", but this isn't correct on thumb/arm targets where the text segment
needs to be a multiple of 2/4 bytes. Handle this by emitting a noop. This
is more gross than it should be because arm/ppc are not fully mc'ized yet.
This fixes rdar://7908505
Modified:
llvm/trunk/include/llvm/Target/TargetInstrInfo.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.h
llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll
llvm/trunk/test/CodeGen/X86/2008-01-25-EmptyFunction.ll
Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=102400&r1=102399&r2=102400&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Mon Apr 26 18:37:21 2010
@@ -24,6 +24,7 @@
class MCAsmInfo;
class MachineMemOperand;
class MDNode;
+class MCInst;
class SDNode;
class SelectionDAG;
class TargetRegisterClass;
@@ -490,6 +491,13 @@
virtual void insertNoop(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI) const;
+
+ /// getNoopForMachoTarget - Return the noop instruction to use for a noop.
+ virtual void getNoopForMachoTarget(MCInst &NopInst) const {
+ // Default to just using 'nop' string.
+ }
+
+
/// isPredicated - Returns true if the instruction is already predicated.
///
virtual bool isPredicated(const MachineInstr *MI) const {
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=102400&r1=102399&r2=102400&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Apr 26 18:37:21 2010
@@ -585,9 +585,15 @@
// If the function is empty and the object file uses .subsections_via_symbols,
// then we need to emit *something* to the function body to prevent the
- // labels from collapsing together. Just emit a 0 byte.
- if (MAI->hasSubsectionsViaSymbols() && !HasAnyRealCode)
- OutStreamer.EmitIntValue(0, 1, 0/*addrspace*/);
+ // labels from collapsing together. Just emit a noop.
+ if (MAI->hasSubsectionsViaSymbols() && !HasAnyRealCode) {
+ MCInst Noop;
+ TM.getInstrInfo()->getNoopForMachoTarget(Noop);
+ if (Noop.getOpcode())
+ OutStreamer.EmitInstruction(Noop);
+ else // Target not mc-ized yet.
+ OutStreamer.EmitRawText(StringRef("\tnop\n"));
+ }
// Emit target-specific gunk after the function body.
EmitFunctionBodyEnd();
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=102400&r1=102399&r2=102400&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Apr 26 18:37:21 2010
@@ -27,6 +27,7 @@
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/LiveVariables.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/MC/MCInst.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -3766,3 +3767,9 @@
assert(table && "Cannot change domain");
MI->setDesc(get(table[Domain-1]));
}
+
+/// getNoopForMachoTarget - Return the noop instruction to use for a noop.
+void X86InstrInfo::getNoopForMachoTarget(MCInst &NopInst) const {
+ NopInst.setOpcode(X86::NOOP);
+}
+
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=102400&r1=102399&r2=102400&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Mon Apr 26 18:37:21 2010
@@ -693,6 +693,8 @@
int64_t Offset1, int64_t Offset2,
unsigned NumLoads) const;
+ virtual void getNoopForMachoTarget(MCInst &NopInst) const;
+
virtual
bool ReverseBranchCondition(SmallVectorImpl Alias Analysis (aka Pointer Analysis) is a class of techniques which attempt
+to determine whether or not two pointers ever can point to the same object in
+memory. There are many different algorithms for alias analysis and many
+different ways of classifying them: flow-sensitive vs flow-insensitive,
+context-sensitive vs context-insensitive, field-sensitive vs field-insensitive,
+unification-based vs subset-based, etc. Traditionally, alias analyses respond
+to a query with a Must, May, or No alias response,
+indicating that two pointers always point to the same object, might point to the
+same object, or are known to never point to the same object. The LLVM AliasAnalysis
+class is the primary interface used by clients and implementations of alias
+analyses in the LLVM system. This class is the common interface between clients
+of alias analysis information and the implementations providing it, and is
+designed to support a wide range of implementations and clients (but currently
+all clients are assumed to be flow-insensitive). In addition to simple alias
+analysis information, this class exposes Mod/Ref information from those
+implementations which can provide it, allowing for powerful analyses and
+transformations to work well together. This document contains information necessary to successfully implement this
+interface, use it, and to test both sides. It also explains some of the finer
+points about what exactly results mean. If you feel that something is unclear
+or should be added, please let me
+know. The AliasAnalysis
+class defines the interface that the various alias analysis implementations
+should support. This class exports two important enums: AliasResult
+and ModRefResult which represent the result of an alias query or a
+mod/ref query, respectively. The AliasAnalysis interface exposes information about memory,
+represented in several different ways. In particular, memory objects are
+represented as a starting address and size, and function calls are represented
+as the actual call or invoke instructions that performs the
+call. The AliasAnalysis interface also exposes some helper methods
+which allow you to get mod/ref information for arbitrary instructions. Most importantly, the AliasAnalysis class provides several methods
+which are used to query whether or not two memory objects alias, whether
+function calls can modify or read a memory object, etc. For all of these
+queries, memory objects are represented as a pair of their starting address (a
+symbolic LLVM Value*) and a static size. Representing memory objects as a starting address and a size is critically
+important for correct Alias Analyses. For example, consider this (silly, but
+possible) C code: In this case, the basicaa pass will disambiguate the stores to
+C[0] and C[1] because they are accesses to two distinct
+locations one byte apart, and the accesses are each one byte. In this case, the
+LICM pass can use store motion to remove the stores from the loop. In
+constrast, the following code: In this case, the two stores to C do alias each other, because the access to
+the &C[0] element is a two byte access. If size information wasn't
+available in the query, even the first case would have to conservatively assume
+that the accesses alias. The NoAlias response is used when the two pointers refer to distinct objects,
+regardless of whether the pointers compare equal. For example, freed pointers
+don't alias any pointers that were allocated afterwards. As a degenerate case,
+pointers returned by malloc(0) have no bytes for an object, and are considered
+NoAlias even when malloc returns the same pointer. The same rule applies to
+NULL pointers. The MayAlias response is used whenever the two pointers might refer to the
+same object. If the two memory objects overlap, but do not start at the same
+location, return MayAlias. The MustAlias response may only be returned if the two memory objects are
+guaranteed to always start at exactly the same location. A MustAlias response
+implies that the pointers compare equal. The getModRefInfo methods return information about whether the
+execution of an instruction can read or modify a memory location. Mod/Ref
+information is always conservative: if an instruction might read or write
+a location, ModRef is returned. The AliasAnalysis class also provides a getModRefInfo
+method for testing dependencies between function calls. This method takes two
+call sites (CS1 & CS2), returns NoModRef if the two calls refer to disjoint
+memory locations, Ref if CS1 reads memory written by CS2, Mod if CS1 writes to
+memory read or written by CS2, or ModRef if CS1 might read or write memory
+accessed by CS2. Note that this relation is not commutative.
+Several other tidbits of information are often collected by various alias
+analysis implementations and can be put to good use by various clients.
+ The pointsToConstantMemory method returns true if and only if the
+analysis can prove that the pointer only points to unchanging memory locations
+(functions, constant global variables, and the null pointer). This information
+can be used to refine mod/ref information: it is impossible for an unchanging
+memory location to be modified. These methods are used to provide very simple mod/ref information for
+function calls. The doesNotAccessMemory method returns true for a
+function if the analysis can prove that the function never reads or writes to
+memory, or if the function only reads from constant memory. Functions with this
+property are side-effect free and only depend on their input arguments, allowing
+them to be eliminated if they form common subexpressions or be hoisted out of
+loops. Many common functions behave this way (e.g., sin and
+cos) but many others do not (e.g., acos, which modifies the
+errno variable). The onlyReadsMemory method returns true for a function if analysis
+can prove that (at most) the function only reads from non-volatile memory.
+Functions with this property are side-effect free, only depending on their input
+arguments and the state of memory when they are called. This property allows
+calls to these functions to be eliminated and moved around, as long as there is
+no store instruction that changes the contents of memory. Note that all
+functions that satisfy the doesNotAccessMemory method also satisfies
+onlyReadsMemory. Writing a new alias analysis implementation for LLVM is quite
+straight-forward. There are already several implementations that you can use
+for examples, and the following information should help fill in any details.
+For a examples, take a look at the various alias analysis
+implementations included with LLVM. The first step to determining what type of LLVM pass you need to use for your Alias
+Analysis. As is the case with most other analyses and transformations, the
+answer should be fairly obvious from what type of problem you are trying to
+solve: In addition to the pass that you subclass, you should also inherit from the
+AliasAnalysis interface, of course, and use the
+RegisterAnalysisGroup template to register as an implementation of
+AliasAnalysis. Your subclass of AliasAnalysis is required to invoke two methods on
+the AliasAnalysis base class: getAnalysisUsage and
+InitializeAliasAnalysis. In particular, your implementation of
+getAnalysisUsage should explicitly call into the
+AliasAnalysis::getAnalysisUsage method in addition to doing any
+declaring any pass dependencies your pass has. Thus you should have something
+like this: Additionally, your must invoke the InitializeAliasAnalysis method
+from your analysis run method (run for a Pass,
+runOnFunction for a FunctionPass, or InitializePass
+for an ImmutablePass). For example (as part of a Pass): All of the AliasAnalysis
+virtual methods default to providing chaining to another
+alias analysis implementation, which ends up returning conservatively correct
+information (returning "May" Alias and "Mod/Ref" for alias and mod/ref queries
+respectively). Depending on the capabilities of the analysis you are
+implementing, you just override the interfaces you can improve. With only two special exceptions (the basicaa and no-aa
+passes) every alias analysis pass chains to another alias analysis
+implementation (for example, the user can specify "-basicaa -ds-aa
+-licm" to get the maximum benefit from both alias
+analyses). The alias analysis class automatically takes care of most of this
+for methods that you don't override. For methods that you do override, in code
+paths that return a conservative MayAlias or Mod/Ref result, simply return
+whatever the superclass computes. For example: In addition to analysis queries, you must make sure to unconditionally pass
+LLVM update notification methods to the superclass as
+well if you override them, which allows all alias analyses in a change to be
+updated.
+Alias analysis information is initially computed for a static snapshot of the
+program, but clients will use this information to make transformations to the
+code. All but the most trivial forms of alias analysis will need to have their
+analysis results updated to reflect the changes made by these transformations.
+
+The AliasAnalysis interface exposes two methods which are used to
+communicate program changes from the clients to the analysis implementations.
+Various alias analysis implementations should use these methods to ensure that
+their internal data structures are kept up-to-date as the program changes (for
+example, when an instruction is deleted), and clients of alias analysis must be
+sure to call these interfaces appropriately.
+ From the LLVM perspective, the only thing you need to do to provide an
+efficient alias analysis is to make sure that alias analysis queries are
+serviced quickly. The actual calculation of the alias analysis results (the
+"run" method) is only performed once, but many (perhaps duplicate) queries may
+be performed. Because of this, try to move as much computation to the run
+method as possible (within reason). There are several different ways to use alias analysis results. In order of
+preference, these are... The memdep pass uses alias analysis to provide high-level dependence
+information about memory-using instructions. This will tell you which store
+feeds into a load, for example. It uses caching and other techniques to be
+efficient, and is used by Dead Store Elimination, GVN, and memcpy optimizations.
+ Many transformations need information about alias sets that are active
+in some scope, rather than information about pairwise aliasing. The AliasSetTracker class
+is used to efficiently build these Alias Sets from the pairwise alias analysis
+information provided by the AliasAnalysis interface. First you initialize the AliasSetTracker by using the "add" methods
+to add information about various potentially aliasing instructions in the scope
+you are interested in. Once all of the alias sets are completed, your pass
+should simply iterate through the constructed alias sets, using the
+AliasSetTracker begin()/end() methods. The AliasSets formed by the AliasSetTracker are guaranteed
+to be disjoint, calculate mod/ref information and volatility for the set, and
+keep track of whether or not all of the pointers in the set are Must aliases.
+The AliasSetTracker also makes sure that sets are properly folded due to call
+instructions, and can provide a list of pointers in each set. As an example user of this, the Loop
+Invariant Code Motion pass uses AliasSetTrackers to calculate alias
+sets for each loop nest. If an AliasSet in a loop is not modified,
+then all load instructions from that set may be hoisted out of the loop. If any
+alias sets are stored to and are must alias sets, then the stores may be
+sunk to outside of the loop, promoting the memory location to a register for the
+duration of the loop nest. Both of these transformations only apply if the
+pointer argument is loop-invariant. The AliasSetTracker class is implemented to be as efficient as possible. It
+uses the union-find algorithm to efficiently merge AliasSets when a pointer is
+inserted into the AliasSetTracker that aliases multiple sets. The primary data
+structure is a hash table mapping pointers to the AliasSet they are in. The AliasSetTracker class must maintain a list of all of the LLVM Value*'s
+that are in each AliasSet. Since the hash table already has entries for each
+LLVM Value* of interest, the AliasesSets thread the linked list through these
+hash-table nodes to avoid having to allocate memory unnecessarily, and to make
+merging alias sets extremely efficient (the linked list merge is constant time).
+ You shouldn't need to understand these details if you are just a client of
+the AliasSetTracker, but if you look at the code, hopefully this brief
+description will help make sense of why things are designed the way they
+are. If neither of these utility class are what your pass needs, you should use
+the interfaces exposed by the AliasAnalysis class directly. Try to use
+the higher-level methods when possible (e.g., use mod/ref information instead of
+the alias method directly if possible) to get the
+best precision and efficiency. If you're going to be working with the LLVM alias analysis infrastructure,
+you should know what clients and implementations of alias analysis are
+available. In particular, if you are implementing an alias analysis, you should
+be aware of the the clients that are useful
+for monitoring and evaluating different implementations. This section lists the various implementations of the AliasAnalysis
+interface. With the exception of the -no-aa and
+-basicaa implementations, all of these chain to other alias analysis implementations. The -no-aa pass is just like what it sounds: an alias analysis that
+never returns any useful information. This pass can be useful if you think that
+alias analysis is doing something wrong and are trying to narrow down a
+problem. The -basicaa pass is the default LLVM alias analysis. It is an
+aggressive local analysis that "knows" many important facts: This pass implements a simple context-sensitive mod/ref and alias analysis
+for internal global variables that don't "have their address taken". If a
+global does not have its address taken, the pass knows that no pointers alias
+the global. This pass also keeps track of functions that it knows never access
+memory or never read memory. This allows certain optimizations (e.g. GVN) to
+eliminate call instructions entirely.
+ The real power of this pass is that it provides context-sensitive mod/ref
+information for call instructions. This allows the optimizer to know that
+calls to a function do not clobber or read the value of the global, allowing
+loads and stores to be eliminated. Note that this pass is somewhat limited in its scope (only support
+non-address taken globals), but is very quick analysis. The -steens-aa pass implements a variation on the well-known
+"Steensgaard's algorithm" for interprocedural alias analysis. Steensgaard's
+algorithm is a unification-based, flow-insensitive, context-insensitive, and
+field-insensitive alias analysis that is also very scalable (effectively linear
+time). The LLVM -steens-aa pass implements a "speculatively
+field-sensitive" version of Steensgaard's algorithm using the Data
+Structure Analysis framework. This gives it substantially more precision than
+the standard algorithm while maintaining excellent analysis scalability. Note that -steens-aa is available in the optional "poolalloc"
+module, it is not part of the LLVM core. The -ds-aa pass implements the full Data Structure Analysis
+algorithm. Data Structure Analysis is a modular unification-based,
+flow-insensitive, context-sensitive, and speculatively
+field-sensitive alias analysis that is also quite scalable, usually at
+O(n*log(n)). This algorithm is capable of responding to a full variety of alias analysis
+queries, and can provide context-sensitive mod/ref information as well. The
+only major facility not implemented so far is support for must-alias
+information. Note that -ds-aa is available in the optional "poolalloc"
+module, it is not part of the LLVM core. The -adce pass, which implements Aggressive Dead Code Elimination
+uses the AliasAnalysis interface to delete calls to functions that do
+not have side-effects and are not used. The -licm pass implements various Loop Invariant Code Motion related
+transformations. It uses the AliasAnalysis interface for several
+different transformations:
+The -argpromotion pass promotes by-reference arguments to be passed in
+by-value instead. In particular, if pointer arguments are only loaded from it
+passes in the value loaded instead of the address to the function. This pass
+uses alias information to make sure that the value loaded from the argument
+pointer is not modified between the entry of the function and any load of the
+pointer. These passes use AliasAnalysis information to reason about loads and stores.
+ These passes are useful for evaluating the various alias analysis
+implementations. You can use them with commands like 'opt -ds-aa
+-aa-eval foo.bc -disable-output -stats'. The -print-alias-sets pass is exposed as part of the
+opt tool to print out the Alias Sets formed by the AliasSetTracker class. This is useful if you're using
+the AliasSetTracker class. To use it, use something like: The -count-aa pass is useful to see how many queries a particular
+pass is making and what responses are returned by the alias analysis. As an
+example, will print out how many queries (and what responses are returned) by the
+-licm pass (of the -ds-aa pass) and how many queries are made
+of the -basicaa pass by the -ds-aa pass. This can be useful
+when debugging a transformation or an alias analysis implementation. The -aa-eval pass simply iterates through all pairs of pointers in a
+function and asks an alias analysis whether or not the pointers alias. This
+gives an indication of the precision of the alias analysis. Statistics are
+printed indicating the percent of no/may/must aliases found (a more precise
+algorithm will have a lower number of may aliases). If you're just looking to be a client of alias analysis information, consider
+using the Memory Dependence Analysis interface instead. MemDep is a lazy,
+caching layer on top of alias analysis that is able to answer the question of
+what preceding memory operations a given instruction depends on, either at an
+intra- or inter-block level. Because of its laziness and caching
+policy, using MemDep can be a significant performance win over accessing alias
+analysis directly. This document describes the LLVM bitstream file format and the encoding of
+the LLVM IR into it.
+What is commonly known as the LLVM bitcode file format (also, sometimes
+anachronistically known as bytecode) is actually two things: a bitstream container format
+and an encoding of LLVM IR into the container format.
+The bitstream format is an abstract encoding of structured data, very
+similar to XML in some ways. Like XML, bitstream files contain tags, and nested
+structures, and you can parse the file without having to understand the tags.
+Unlike XML, the bitstream format is a binary encoding, and unlike XML it
+provides a mechanism for the file to self-describe "abbreviations", which are
+effectively size optimizations for the content. LLVM IR files may be optionally embedded into a wrapper structure that makes it easy to embed extra data
+along with LLVM IR files. This document first describes the LLVM bitstream format, describes the
+wrapper format, then describes the record structure used by LLVM IR files.
+
+The bitstream format is literally a stream of bits, with a very simple
+structure. This structure consists of the following concepts:
+ Note that the llvm-bcanalyzer tool can be
+used to dump and inspect arbitrary bitstreams, which is very useful for
+understanding the encoding. The first two bytes of a bitcode file are 'BC' (0x42, 0x43).
+The second two bytes are an application-specific magic number. Generic
+bitcode tools can look at only the first two bytes to verify the file is
+bitcode, while application-specific programs will want to look at all four.
+A bitstream literally consists of a stream of bits, which are read in order
+starting with the least significant bit of each byte. The stream is made up of a
+number of primitive values that encode a stream of unsigned integer values.
+These integers are encoded in two ways: either as Fixed
+Width Integers or as Variable Width
+Integers.
+ Fixed-width integer values have their low bits emitted directly to the file.
+ For example, a 3-bit integer value encodes 1 as 001. Fixed width integers
+ are used when there are a well-known number of options for a field. For
+ example, boolean values are usually encoded with a 1-bit wide integer.
+ Variable-width integer (VBR) values encode values of arbitrary size,
+optimizing for the case where the values are small. Given a 4-bit VBR field,
+any 3-bit value (0 through 7) is encoded directly, with the high bit set to
+zero. Values larger than N-1 bits emit their bits in a series of N-1 bit
+chunks, where all but the last set the high bit. For example, the value 27 (0x1B) is encoded as 1011 0011 when emitted as a
+vbr4 value. The first set of four bits indicates the value 3 (011) with a
+continuation piece (indicated by a high bit of 1). The next word indicates a
+value of 24 (011 << 3) with no continuation. The sum (3+24) yields the value
+27.
+ 6-bit characters encode common characters into a fixed 6-bit field. They
+represent the following characters with the following 6-bit values: This encoding is only suitable for encoding characters and strings that
+consist only of the above characters. It is completely incapable of encoding
+characters not in the set. Occasionally, it is useful to emit zero bits until the bitstream is a
+multiple of 32 bits. This ensures that the bit position in the stream can be
+represented as a multiple of 32-bit words.
+A bitstream is a sequential series of Blocks and
+Data Records. Both of these start with an
+abbreviation ID encoded as a fixed-bitwidth field. The width is specified by
+the current block, as described below. The value of the abbreviation ID
+specifies either a builtin ID (which have special meanings, defined below) or
+one of the abbreviation IDs defined for the current block by the stream itself.
+
+The set of builtin abbrev IDs is:
+ Abbreviation IDs 4 and above are defined by the stream itself, and specify
+an abbreviated record encoding.
+Blocks in a bitstream denote nested regions of the stream, and are identified by
+a content-specific id number (for example, LLVM IR uses an ID of 12 to represent
+function bodies). Block IDs 0-7 are reserved for standard blocks
+whose meaning is defined by Bitcode; block IDs 8 and greater are
+application specific. Nested blocks capture the hierarchical structure of the data
+encoded in it, and various properties are associated with blocks as the file is
+parsed. Block definitions allow the reader to efficiently skip blocks
+in constant time if the reader wants a summary of blocks, or if it wants to
+efficiently skip data it does not understand. The LLVM IR reader uses this
+mechanism to skip function bodies, lazily reading them on demand.
+
+When reading and encoding the stream, several properties are maintained for the
+block. In particular, each block maintains:
+
+As sub blocks are entered, these properties are saved and the new sub-block has
+its own set of abbreviations, and its own abbrev id width. When a sub-block is
+popped, the saved values are restored.
+ [ENTER_SUBBLOCK, blockidvbr8, newabbrevlenvbr4,
+ <align32bits>, blocklen32]
+The ENTER_SUBBLOCK abbreviation ID specifies the start of a new block
+record. The blockid value is encoded as an 8-bit VBR identifier, and
+indicates the type of block being entered, which can be
+a standard block or an application-specific block.
+The newabbrevlen value is a 4-bit VBR, which specifies the abbrev id
+width for the sub-block. The blocklen value is a 32-bit aligned value
+that specifies the size of the subblock in 32-bit words. This value allows the
+reader to skip over the entire block in one jump.
+ [END_BLOCK, <align32bits>]
+The END_BLOCK abbreviation ID specifies the end of the current block
+record. Its end is aligned to 32-bits to ensure that the size of the block is
+an even multiple of 32-bits.
+
+Data records consist of a record code and a number of (up to) 64-bit
+integer values. The interpretation of the code and values is
+application specific and may vary between different block types.
+Records can be encoded either using an unabbrev record, or with an
+abbreviation. In the LLVM IR format, for example, there is a record
+which encodes the target triple of a module. The code is
+MODULE_CODE_TRIPLE, and the values of the record are the
+ASCII codes for the characters in the string.
+ [UNABBREV_RECORD, codevbr6, numopsvbr6,
+ op0vbr6, op1vbr6, ...]
+An UNABBREV_RECORD provides a default fallback encoding, which is both
+completely general and extremely inefficient. It can describe an arbitrary
+record by emitting the code and operands as VBRs.
+
+For example, emitting an LLVM IR target triple as an unabbreviated record
+requires emitting the UNABBREV_RECORD abbrevid, a vbr6 for the
+MODULE_CODE_TRIPLE code, a vbr6 for the length of the string, which is
+equal to the number of operands, and a vbr6 for each character. Because there
+are no letters with values less than 32, each letter would need to be emitted as
+at least a two-part VBR, which means that each letter would require at least 12
+bits. This is not an efficient encoding, but it is fully general.
+ [<abbrevid>, fields...]
+An abbreviated record is a abbreviation id followed by a set of fields that are
+encoded according to the abbreviation definition.
+This allows records to be encoded significantly more densely than records
+encoded with the UNABBREV_RECORD type,
+and allows the abbreviation types to be specified in the stream itself, which
+allows the files to be completely self describing. The actual encoding of
+abbreviations is defined below.
+ The record code, which is the first field of an abbreviated record,
+may be encoded in the abbreviation definition (as a literal
+operand) or supplied in the abbreviated record (as a Fixed or VBR
+operand value).
+Abbreviations are an important form of compression for bitstreams. The idea is
+to specify a dense encoding for a class of records once, then use that encoding
+to emit many records. It takes space to emit the encoding into the file, but
+the space is recouped (hopefully plus some) when the records that use it are
+emitted.
+
+Abbreviations can be determined dynamically per client, per file. Because the
+abbreviations are stored in the bitstream itself, different streams of the same
+format can contain different sets of abbreviations according to the needs
+of the specific stream.
+As a concrete example, LLVM IR files usually emit an abbreviation
+for binary operators. If a specific LLVM module contained no or few binary
+operators, the abbreviation does not need to be emitted.
+ [DEFINE_ABBREV, numabbrevopsvbr5, abbrevop0, abbrevop1,
+ ...]
+A DEFINE_ABBREV record adds an abbreviation to the list of currently
+defined abbreviations in the scope of this block. This definition only exists
+inside this immediate block — it is not visible in subblocks or enclosing
+blocks. Abbreviations are implicitly assigned IDs sequentially starting from 4
+(the first application-defined abbreviation ID). Any abbreviations defined in a
+BLOCKINFO record for the particular block type
+receive IDs first, in order, followed by any
+abbreviations defined within the block itself. Abbreviated data records
+reference this ID to indicate what abbreviation they are invoking.
+
+An abbreviation definition consists of the DEFINE_ABBREV abbrevid
+followed by a VBR that specifies the number of abbrev operands, then the abbrev
+operands themselves. Abbreviation operands come in three forms. They all start
+with a single bit that indicates whether the abbrev operand is a literal operand
+(when the bit is 1) or an encoding operand (when the bit is 0).
+ The possible operand encodings are:
+For example, target triples in LLVM modules are encoded as a record of the
+form [TRIPLE, 'a', 'b', 'c', 'd']. Consider if the bitstream emitted
+the following abbrev entry:
+
+When emitting a record with this abbreviation, the above entry would be emitted
+as:
+
+[4abbrevwidth, 24, 4vbr6, 06,
+16, 26, 36]
+ These values are:
+With this abbreviation, the triple is emitted with only 37 bits (assuming a
+abbrev id width of 3). Without the abbreviation, significantly more space would
+be required to emit the target triple. Also, because the TRIPLE value
+is not emitted as a literal in the abbreviation, the abbreviation can also be
+used for any other string value.
+
+In addition to the basic block structure and record encodings, the bitstream
+also defines specific built-in block types. These block types specify how the
+stream is to be decoded or other metadata. In the future, new standard blocks
+may be added. Block IDs 0-7 are reserved for standard blocks.
+
+The BLOCKINFO block allows the description of metadata for other
+blocks. The currently specified records are:
+
+The SETBID record (code 1) indicates which block ID is being
+described. SETBID records can occur multiple times throughout the
+block to change which block ID is being described. There must be
+a SETBID record prior to any other records.
+
+Standard DEFINE_ABBREV records can occur inside BLOCKINFO
+blocks, but unlike their occurrence in normal blocks, the abbreviation is
+defined for blocks matching the block ID we are describing, not the
+BLOCKINFO block itself. The abbreviations defined
+in BLOCKINFO blocks receive abbreviation IDs as described
+in DEFINE_ABBREV.
+ The BLOCKNAME record (code 2) can optionally occur in this block. The elements of
+the record are the bytes of the string name of the block. llvm-bcanalyzer can use
+this to dump out bitcode files symbolically. The SETRECORDNAME record (code 3) can also optionally occur in this block. The
+first operand value is a record ID number, and the rest of the elements of the record are
+the bytes for the string name of the record. llvm-bcanalyzer can use
+this to dump out bitcode files symbolically.
+Note that although the data in BLOCKINFO blocks is described as
+"metadata," the abbreviations they contain are essential for parsing records
+from the corresponding blocks. It is not safe to skip them.
+
+Bitcode files for LLVM IR may optionally be wrapped in a simple wrapper
+structure. This structure contains a simple header that indicates the offset
+and size of the embedded BC file. This allows additional information to be
+stored alongside the BC file. The structure of this file header is:
+
+[Magic32, Version32, Offset32,
+Size32, CPUType32]
+
+Each of the fields are 32-bit fields stored in little endian form (as with
+the rest of the bitcode file fields). The Magic number is always
+0x0B17C0DE and the version is currently always 0. The Offset
+field is the offset in bytes to the start of the bitcode stream in the file, and
+the Size field is the size in bytes of the stream. CPUType is a target-specific
+value that can be used to encode the CPU of the target.
+
+LLVM IR is encoded into a bitstream by defining blocks and records. It uses
+blocks for things like constant pools, functions, symbol tables, etc. It uses
+records for things like instructions, global variable descriptors, type
+descriptions, etc. This document does not describe the set of abbreviations
+that the writer uses, as these are fully self-described in the file, and the
+reader is not allowed to build in any knowledge of this.
+
+The magic number for LLVM IR files is:
+
+[0x04, 0xC4, 0xE4, 0xD4]
+
+When combined with the bitcode magic number and viewed as bytes, this is
+"BC 0xC0DE".
+
+Variable Width Integer encoding is an efficient way to
+encode arbitrary sized unsigned values, but is an extremely inefficient for
+encoding signed values, as signed values are otherwise treated as maximally large
+unsigned values.
+
+As such, signed VBR values of a specific width are emitted as follows:
+
+With this encoding, small positive and small negative values can both
+be emitted efficiently. Signed VBR encoding is used in
+CST_CODE_INTEGER and CST_CODE_WIDE_INTEGER records
+within CONSTANTS_BLOCK blocks.
+
+LLVM IR is defined with the following blocks:
+ The MODULE_BLOCK block (id 8) is the top-level block for LLVM
+bitcode files, and each bitcode file must contain exactly one. In
+addition to records (described below) containing information
+about the module, a MODULE_BLOCK block may contain the
+following sub-blocks:
+ [VERSION, version#] The VERSION record (code 1) contains a single value
+indicating the format version. Only version 0 is supported at this
+time. [TRIPLE, ...string...] The TRIPLE record (code 2) contains a variable number of
+values representing the bytes of the target triple
+specification string. [DATALAYOUT, ...string...] The DATALAYOUT record (code 3) contains a variable number of
+values representing the bytes of the target datalayout
+specification string. [ASM, ...string...] The ASM record (code 4) contains a variable number of
+values representing the bytes of module asm strings, with
+individual assembly blocks separated by newline (ASCII 10) characters. [SECTIONNAME, ...string...] The SECTIONNAME record (code 5) contains a variable number
+of values representing the bytes of a single section name
+string. There should be one SECTIONNAME record for each
+section name referenced (e.g., in global variable or function
+section attributes) within the module. These records can be
+referenced by the 1-based index in the section fields of
+GLOBALVAR or FUNCTION records. [DEPLIB, ...string...] The DEPLIB record (code 6) contains a variable number of
+values representing the bytes of a single dependent library name
+string, one of the libraries mentioned in a deplibs
+declaration. There should be one DEPLIB record for each
+library name referenced. [GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal] The GLOBALVAR record (code 7) marks the declaration or
+definition of a global variable. The operand fields are: [FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc] The FUNCTION record (code 8) marks the declaration or
+definition of a function. The operand fields are: [ALIAS, alias type, aliasee val#, linkage, visibility] The ALIAS record (code 9) marks the definition of an
+alias. The operand fields are [PURGEVALS, numvals] The PURGEVALS record (code 10) resets the module-level
+value list to the size given by the single operand value. Module-level
+value list items are added by GLOBALVAR, FUNCTION,
+and ALIAS records. After a PURGEVALS record is seen,
+new value indices will start from the given numvals value. [GCNAME, ...string...] The GCNAME record (code 11) contains a variable number of
+values representing the bytes of a single garbage collector name
+string. There should be one GCNAME record for each garbage
+collector name referenced in function gc attributes within
+the module. These records can be referenced by 1-based index in the gc
+fields of FUNCTION records. The PARAMATTR_BLOCK block (id 9) ...
+ [ENTRY, paramidx0, attr0, paramidx1, attr1...] The ENTRY record (code 1) ...
+ The TYPE_BLOCK block (id 10) ...
+ The CONSTANTS_BLOCK block (id 11) ...
+ The FUNCTION_BLOCK block (id 12) ...
+ In addition to the record types described below, a
+FUNCTION_BLOCK block may contain the following sub-blocks:
+ The TYPE_SYMTAB_BLOCK block (id 13) ...
+ The VALUE_SYMTAB_BLOCK block (id 14) ...
+ The METADATA_BLOCK block (id 15) ...
+ The METADATA_ATTACHMENT block (id 16) ...
+ bugpoint narrows down the source of problems in LLVM tools and
+passes. It can be used to debug three types of failures: optimizer crashes,
+miscompilations by optimizers, or bad native code generation (including problems
+in the static and JIT compilers). It aims to reduce large test cases to small,
+useful ones. For example, if opt crashes while optimizing a
+file, it will identify the optimization (or combination of optimizations) that
+causes the crash, and reduce the file down to a small example which triggers the
+crash. For detailed case scenarios, such as debugging opt,
+llvm-ld, or one of the LLVM code generators, see How To Submit a Bug Report document. bugpoint is designed to be a useful tool without requiring any
+hooks into the LLVM infrastructure at all. It works with any and all LLVM
+passes and code generators, and does not need to "know" how they work. Because
+of this, it may appear to do stupid things or miss obvious
+simplifications. bugpoint is also designed to trade off programmer
+time for computer time in the compiler-debugging process; consequently, it may
+take a long period of (unattended) time to reduce a test case, but we feel it
+is still worth it. Note that bugpoint is generally very quick unless
+debugging a miscompilation where each test of the program (which requires
+executing it) takes a long time. bugpoint reads each .bc or .ll file specified on
+the command line and links them together into a single module, called the test
+program. If any LLVM passes are specified on the command line, it runs these
+passes on the test program. If any of the passes crash, or if they produce
+malformed output (which causes the verifier to abort), bugpoint starts
+the crash debugger. Otherwise, if the -output option was not specified,
+bugpoint runs the test program with the C backend (which is assumed to
+generate good code) to generate a reference output. Once bugpoint has
+a reference output for the test program, it tries executing it with the
+selected code generator. If the selected code generator crashes,
+bugpoint starts the crash debugger on the
+code generator. Otherwise, if the resulting output differs from the reference
+output, it assumes the difference resulted from a code generator failure, and
+starts the code generator debugger. Finally, if the output of the selected code generator matches the reference
+output, bugpoint runs the test program after all of the LLVM passes
+have been applied to it. If its output differs from the reference output, it
+assumes the difference resulted from a failure in one of the LLVM passes, and
+enters the miscompilation debugger.
+Otherwise, there is no problem bugpoint can debug. If an optimizer or code generator crashes, bugpoint will try as hard
+as it can to reduce the list of passes (for optimizer crashes) and the size of
+the test program. First, bugpoint figures out which combination of
+optimizer passes triggers the bug. This is useful when debugging a problem
+exposed by opt, for example, because it runs over 38 passes. Next, bugpoint tries removing functions from the test program, to
+reduce its size. Usually it is able to reduce a test program to a single
+function, when debugging intraprocedural optimizations. Once the number of
+functions has been reduced, it attempts to delete various edges in the control
+flow graph, to reduce the size of the function as much as possible. Finally,
+bugpoint deletes any individual LLVM instructions whose absence does
+not eliminate the failure. At the end, bugpoint should tell you what
+passes crash, give you a bitcode file, and give you instructions on how to
+reproduce the failure with opt or llc. The code generator debugger attempts to narrow down the amount of code that
+is being miscompiled by the selected code generator. To do this, it takes the
+test program and partitions it into two pieces: one piece which it compiles
+with the C backend (into a shared object), and one piece which it runs with
+either the JIT or the static LLC compiler. It uses several techniques to
+reduce the amount of code pushed through the LLVM code generator, to reduce the
+potential scope of the problem. After it is finished, it emits two bitcode
+files (called "test" [to be compiled with the code generator] and "safe" [to be
+compiled with the C backend], respectively), and instructions for reproducing
+the problem. The code generator debugger assumes that the C backend produces
+good code. The miscompilation debugger works similarly to the code generator debugger.
+It works by splitting the test program into two pieces, running the
+optimizations specified on one piece, linking the two pieces back together, and
+then executing the result. It attempts to narrow down the list of passes to
+the one (or few) which are causing the miscompilation, then reduce the portion
+of the test program which is being miscompiled. The miscompilation debugger
+assumes that the selected code generator is working properly.
+
+ bugpoint can generate a lot of output and run for a long period
+ of time. It is often useful to capture the output of the program to file.
+ For example, in the C shell, you can run: bugpoint ... |& tee bugpoint.log to get a copy of bugpoint's output in the file
+ bugpoint.log, as well as on your terminal. bugpoint does not understand the -O option
+ that is used to specify optimization level to opt. You
+ can use e.g. opt -O2 -debug-pass=Arguments foo.bc -disable-output to get a list of passes that are used with -O2 and
+ then pass this list to bugpoint.
-
+
+
+
+
+
+
+int i;
+char C[2];
+char A[10];
+/* ... */
+for (i = 0; i != 10; ++i) {
+ C[0] = A[i]; /* One byte store */
+ C[1] = A[9-i]; /* One byte store */
+}
+
+
+int i;
+char C[2];
+char A[10];
+/* ... */
+for (i = 0; i != 10; ++i) {
+ ((short*)C)[0] = A[i]; /* Two byte store! */
+ C[1] = A[9-i]; /* One byte store */
+}
+
+
+
+
+
+void getAnalysisUsage(AnalysisUsage &AU) const {
+ AliasAnalysis::getAnalysisUsage(AU);
+ // declare your dependencies here.
+}
+
+
+bool run(Module &M) {
+ InitializeAliasAnalysis(this);
+ // Perform analysis here...
+ return false;
+}
+
+
+AliasAnalysis::AliasResult alias(const Value *V1, unsigned V1Size,
+ const Value *V2, unsigned V2Size) {
+ if (...)
+ return NoAlias;
+ ...
+
+ // Couldn't determine a must or no-alias result.
+ return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
+}
+
+
+
+
+
+
+
+
+% opt -ds-aa -print-alias-sets -disable-output
+
+
+% opt -basicaa -count-aa -ds-aa -count-aa -licm
+
+
+
+
+
+
+ Chris Lattner
+ LLVM Compiler Infrastructure
+ Last modified: $Date: 2010-03-01 13:24:17 -0600 (Mon, 01 Mar 2010) $
+
+
+
+
Added: www-releases/trunk/2.7/docs/BitCodeFormat.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/2.7/docs/BitCodeFormat.html?rev=102419&view=auto
==============================================================================
--- www-releases/trunk/2.7/docs/BitCodeFormat.html (added)
+++ www-releases/trunk/2.7/docs/BitCodeFormat.html Tue Apr 27 02:30:52 2010
@@ -0,0 +1,1163 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+'a' .. 'z' — 0 .. 25
+'A' .. 'Z' — 26 .. 51
+'0' .. '9' — 52 .. 61
+ '.' — 62
+ '_' — 63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[0, Fixed, 4]
+[0, Array]
+[0, Char6]
+
+
+
+
+
+[SETBID (#1), blockid]
+[DEFINE_ABBREV, ...]
+[BLOCKNAME, ...name...]
+[SETRECORDNAME, RecordID, ...name...]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Chris Lattner
+The LLVM Compiler Infrastructure
+Last modified: $Date: 2010-01-20 11:53:51 -0600 (Wed, 20 Jan 2010) $
+
+
+
Added: www-releases/trunk/2.7/docs/Bugpoint.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/2.7/docs/Bugpoint.html?rev=102419&view=auto
==============================================================================
--- www-releases/trunk/2.7/docs/Bugpoint.html (added)
+++ www-releases/trunk/2.7/docs/Bugpoint.html Tue Apr 27 02:30:52 2010
@@ -0,0 +1,250 @@
+
+
+
+
+
+
+
+
+
+
+
+ Chris Lattner
+ LLVM Compiler Infrastructure
+ Last modified: $Date: 2009-10-12 13:12:47 -0500 (Mon, 12 Oct 2009) $
+
+
+
+