Compare commits
10 Commits
llvmorg-8.
...
llvmorg-3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ee1a18837 | ||
|
|
6a22c4c854 | ||
|
|
fae92bda03 | ||
|
|
8a7f8bffd5 | ||
|
|
b15f39b1a7 | ||
|
|
c21780a296 | ||
|
|
5be7a7772f | ||
|
|
6ca80bece0 | ||
|
|
60a859b987 | ||
|
|
e8a1be67a3 |
@@ -1648,8 +1648,10 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(DeclStmt *DS) {
|
||||
|
||||
// If the type of VD is a VLA, then we must process its size expressions.
|
||||
for (const VariableArrayType* VA = FindVA(VD->getType().getTypePtr());
|
||||
VA != 0; VA = FindVA(VA->getElementType().getTypePtr()))
|
||||
Block = addStmt(VA->getSizeExpr());
|
||||
VA != 0; VA = FindVA(VA->getElementType().getTypePtr())) {
|
||||
if (CFGBlock *newBlock = addStmt(VA->getSizeExpr()))
|
||||
LastBlock = newBlock;
|
||||
}
|
||||
|
||||
// Remove variable from local scope.
|
||||
if (ScopePos && VD == *ScopePos)
|
||||
@@ -1767,7 +1769,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
|
||||
// Add the condition as the last statement in the new block. This may create
|
||||
// new blocks as the condition may contain control-flow. Any newly created
|
||||
// blocks will be pointed to be "Block".
|
||||
Block = addStmt(I->getCond());
|
||||
CFGBlock *LastBlock = addStmt(I->getCond());
|
||||
|
||||
// Finally, if the IfStmt contains a condition variable, add both the IfStmt
|
||||
// and the condition variable initialization to the CFG.
|
||||
@@ -1775,11 +1777,11 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
|
||||
if (Expr *Init = VD->getInit()) {
|
||||
autoCreateBlock();
|
||||
appendStmt(Block, I->getConditionVariableDeclStmt());
|
||||
addStmt(Init);
|
||||
LastBlock = addStmt(Init);
|
||||
}
|
||||
}
|
||||
|
||||
return Block;
|
||||
return LastBlock;
|
||||
}
|
||||
|
||||
|
||||
@@ -2611,7 +2613,7 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) {
|
||||
// Add the terminator and condition in the switch block.
|
||||
SwitchTerminatedBlock->setTerminator(Terminator);
|
||||
Block = SwitchTerminatedBlock;
|
||||
Block = addStmt(Terminator->getCond());
|
||||
CFGBlock *LastBlock = addStmt(Terminator->getCond());
|
||||
|
||||
// Finally, if the SwitchStmt contains a condition variable, add both the
|
||||
// SwitchStmt and the condition variable initialization to the CFG.
|
||||
@@ -2619,11 +2621,11 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) {
|
||||
if (Expr *Init = VD->getInit()) {
|
||||
autoCreateBlock();
|
||||
appendStmt(Block, Terminator->getConditionVariableDeclStmt());
|
||||
addStmt(Init);
|
||||
LastBlock = addStmt(Init);
|
||||
}
|
||||
}
|
||||
|
||||
return Block;
|
||||
return LastBlock;
|
||||
}
|
||||
|
||||
static bool shouldAddCase(bool &switchExclusivelyCovered,
|
||||
@@ -2807,8 +2809,7 @@ CFGBlock *CFGBuilder::VisitCXXTryStmt(CXXTryStmt *Terminator) {
|
||||
|
||||
assert(Terminator->getTryBlock() && "try must contain a non-NULL body");
|
||||
Block = NULL;
|
||||
Block = addStmt(Terminator->getTryBlock());
|
||||
return Block;
|
||||
return addStmt(Terminator->getTryBlock());
|
||||
}
|
||||
|
||||
CFGBlock *CFGBuilder::VisitCXXCatchStmt(CXXCatchStmt *CS) {
|
||||
@@ -2949,15 +2950,15 @@ CFGBlock *CFGBuilder::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
|
||||
addLocalScopeAndDtors(S->getLoopVarStmt());
|
||||
|
||||
// Populate a new block to contain the loop body and loop variable.
|
||||
Block = addStmt(S->getBody());
|
||||
addStmt(S->getBody());
|
||||
if (badCFG)
|
||||
return 0;
|
||||
Block = addStmt(S->getLoopVarStmt());
|
||||
CFGBlock *LoopVarStmtBlock = addStmt(S->getLoopVarStmt());
|
||||
if (badCFG)
|
||||
return 0;
|
||||
|
||||
// This new body block is a successor to our condition block.
|
||||
addSuccessor(ConditionBlock, KnownVal.isFalse() ? 0 : Block);
|
||||
addSuccessor(ConditionBlock, KnownVal.isFalse() ? 0 : LoopVarStmtBlock);
|
||||
}
|
||||
|
||||
// Link up the condition block with the code that follows the loop (the
|
||||
|
||||
@@ -818,6 +818,18 @@ namespace {
|
||||
|
||||
static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC,
|
||||
bool PerFunction) {
|
||||
// Only perform this analysis when using C++11. There is no good workflow
|
||||
// for this warning when not using C++11. There is no good way to silence
|
||||
// the warning (no attribute is available) unless we are using C++11's support
|
||||
// for generalized attributes. Once could use pragmas to silence the warning,
|
||||
// but as a general solution that is gross and not in the spirit of this
|
||||
// warning.
|
||||
//
|
||||
// NOTE: This an intermediate solution. There are on-going discussions on
|
||||
// how to properly support this warning outside of C++11 with an annotation.
|
||||
if (!AC.getASTContext().getLangOpts().CPlusPlus0x)
|
||||
return;
|
||||
|
||||
FallthroughMapper FM(S);
|
||||
FM.TraverseStmt(AC.getBody());
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class MallocChecker : public Checker<check::DeadSymbols,
|
||||
check::PreStmt<CallExpr>,
|
||||
check::PostStmt<CallExpr>,
|
||||
check::PostStmt<BlockExpr>,
|
||||
check::PreObjCMessage,
|
||||
check::PostObjCMessage,
|
||||
check::Location,
|
||||
check::Bind,
|
||||
eval::Assume,
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
|
||||
void checkPreStmt(const CallExpr *S, CheckerContext &C) const;
|
||||
void checkPostStmt(const CallExpr *CE, CheckerContext &C) const;
|
||||
void checkPreObjCMessage(const ObjCMethodCall &Call, CheckerContext &C) const;
|
||||
void checkPostObjCMessage(const ObjCMethodCall &Call, CheckerContext &C) const;
|
||||
void checkPostStmt(const BlockExpr *BE, CheckerContext &C) const;
|
||||
void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
|
||||
void checkEndPath(CheckerContext &C) const;
|
||||
@@ -193,12 +193,14 @@ private:
|
||||
ProgramStateRef FreeMemAux(CheckerContext &C, const CallExpr *CE,
|
||||
ProgramStateRef state, unsigned Num,
|
||||
bool Hold,
|
||||
bool &ReleasedAllocated) const;
|
||||
bool &ReleasedAllocated,
|
||||
bool ReturnsNullOnFailure = false) const;
|
||||
ProgramStateRef FreeMemAux(CheckerContext &C, const Expr *Arg,
|
||||
const Expr *ParentExpr,
|
||||
ProgramStateRef state,
|
||||
ProgramStateRef State,
|
||||
bool Hold,
|
||||
bool &ReleasedAllocated) const;
|
||||
bool &ReleasedAllocated,
|
||||
bool ReturnsNullOnFailure = false) const;
|
||||
|
||||
ProgramStateRef ReallocMem(CheckerContext &C, const CallExpr *CE,
|
||||
bool FreesMemOnFailure) const;
|
||||
@@ -341,6 +343,10 @@ private:
|
||||
REGISTER_MAP_WITH_PROGRAMSTATE(RegionState, SymbolRef, RefState)
|
||||
REGISTER_MAP_WITH_PROGRAMSTATE(ReallocPairs, SymbolRef, ReallocPair)
|
||||
|
||||
// A map from the freed symbol to the symbol representing the return value of
|
||||
// the free function.
|
||||
REGISTER_MAP_WITH_PROGRAMSTATE(FreeReturnValue, SymbolRef, SymbolRef)
|
||||
|
||||
namespace {
|
||||
class StopTrackingCallback : public SymbolVisitor {
|
||||
ProgramStateRef state;
|
||||
@@ -492,8 +498,8 @@ static bool isFreeWhenDoneSetToZero(const ObjCMethodCall &Call) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MallocChecker::checkPreObjCMessage(const ObjCMethodCall &Call,
|
||||
CheckerContext &C) const {
|
||||
void MallocChecker::checkPostObjCMessage(const ObjCMethodCall &Call,
|
||||
CheckerContext &C) const {
|
||||
// If the first selector is dataWithBytesNoCopy, assume that the memory will
|
||||
// be released with 'free' by the new object.
|
||||
// Ex: [NSData dataWithBytesNoCopy:bytes length:10];
|
||||
@@ -506,9 +512,12 @@ void MallocChecker::checkPreObjCMessage(const ObjCMethodCall &Call,
|
||||
S.getNameForSlot(0) == "initWithCharactersNoCopy") &&
|
||||
!isFreeWhenDoneSetToZero(Call)){
|
||||
unsigned int argIdx = 0;
|
||||
C.addTransition(FreeMemAux(C, Call.getArgExpr(argIdx),
|
||||
Call.getOriginExpr(), C.getState(), true,
|
||||
ReleasedAllocatedMemory));
|
||||
ProgramStateRef State = FreeMemAux(C, Call.getArgExpr(argIdx),
|
||||
Call.getOriginExpr(), C.getState(), true,
|
||||
ReleasedAllocatedMemory,
|
||||
/* RetNullOnFailure*/ true);
|
||||
|
||||
C.addTransition(State);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,21 +618,39 @@ ProgramStateRef MallocChecker::FreeMemAux(CheckerContext &C,
|
||||
ProgramStateRef state,
|
||||
unsigned Num,
|
||||
bool Hold,
|
||||
bool &ReleasedAllocated) const {
|
||||
bool &ReleasedAllocated,
|
||||
bool ReturnsNullOnFailure) const {
|
||||
if (CE->getNumArgs() < (Num + 1))
|
||||
return 0;
|
||||
|
||||
return FreeMemAux(C, CE->getArg(Num), CE, state, Hold, ReleasedAllocated);
|
||||
return FreeMemAux(C, CE->getArg(Num), CE, state, Hold,
|
||||
ReleasedAllocated, ReturnsNullOnFailure);
|
||||
}
|
||||
|
||||
/// Checks if the previous call to free on the given symbol failed - if free
|
||||
/// failed, returns true. Also, returns the corresponding return value symbol.
|
||||
bool didPreviousFreeFail(ProgramStateRef State,
|
||||
SymbolRef Sym, SymbolRef &RetStatusSymbol) {
|
||||
const SymbolRef *Ret = State->get<FreeReturnValue>(Sym);
|
||||
if (Ret) {
|
||||
assert(*Ret && "We should not store the null return symbol");
|
||||
ConstraintManager &CMgr = State->getConstraintManager();
|
||||
ConditionTruthVal FreeFailed = CMgr.isNull(State, *Ret);
|
||||
RetStatusSymbol = *Ret;
|
||||
return FreeFailed.isConstrainedTrue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ProgramStateRef MallocChecker::FreeMemAux(CheckerContext &C,
|
||||
const Expr *ArgExpr,
|
||||
const Expr *ParentExpr,
|
||||
ProgramStateRef state,
|
||||
ProgramStateRef State,
|
||||
bool Hold,
|
||||
bool &ReleasedAllocated) const {
|
||||
bool &ReleasedAllocated,
|
||||
bool ReturnsNullOnFailure) const {
|
||||
|
||||
SVal ArgVal = state->getSVal(ArgExpr, C.getLocationContext());
|
||||
SVal ArgVal = State->getSVal(ArgExpr, C.getLocationContext());
|
||||
if (!isa<DefinedOrUnknownSVal>(ArgVal))
|
||||
return 0;
|
||||
DefinedOrUnknownSVal location = cast<DefinedOrUnknownSVal>(ArgVal);
|
||||
@@ -634,7 +661,7 @@ ProgramStateRef MallocChecker::FreeMemAux(CheckerContext &C,
|
||||
|
||||
// The explicit NULL case, no operation is performed.
|
||||
ProgramStateRef notNullState, nullState;
|
||||
llvm::tie(notNullState, nullState) = state->assume(location);
|
||||
llvm::tie(notNullState, nullState) = State->assume(location);
|
||||
if (nullState && !notNullState)
|
||||
return 0;
|
||||
|
||||
@@ -683,10 +710,14 @@ ProgramStateRef MallocChecker::FreeMemAux(CheckerContext &C,
|
||||
return 0;
|
||||
|
||||
SymbolRef Sym = SR->getSymbol();
|
||||
const RefState *RS = state->get<RegionState>(Sym);
|
||||
const RefState *RS = State->get<RegionState>(Sym);
|
||||
SymbolRef PreviousRetStatusSymbol = 0;
|
||||
|
||||
// Check double free.
|
||||
if (RS && (RS->isReleased() || RS->isRelinquished())) {
|
||||
if (RS &&
|
||||
(RS->isReleased() || RS->isRelinquished()) &&
|
||||
!didPreviousFreeFail(State, Sym, PreviousRetStatusSymbol)) {
|
||||
|
||||
if (ExplodedNode *N = C.generateSink()) {
|
||||
if (!BT_DoubleFree)
|
||||
BT_DoubleFree.reset(
|
||||
@@ -696,6 +727,8 @@ ProgramStateRef MallocChecker::FreeMemAux(CheckerContext &C,
|
||||
"Attempt to free non-owned memory"), N);
|
||||
R->addRange(ArgExpr->getSourceRange());
|
||||
R->markInteresting(Sym);
|
||||
if (PreviousRetStatusSymbol)
|
||||
R->markInteresting(PreviousRetStatusSymbol);
|
||||
R->addVisitor(new MallocBugVisitor(Sym));
|
||||
C.emitReport(R);
|
||||
}
|
||||
@@ -704,10 +737,24 @@ ProgramStateRef MallocChecker::FreeMemAux(CheckerContext &C,
|
||||
|
||||
ReleasedAllocated = (RS != 0);
|
||||
|
||||
// Clean out the info on previous call to free return info.
|
||||
State = State->remove<FreeReturnValue>(Sym);
|
||||
|
||||
// Keep track of the return value. If it is NULL, we will know that free
|
||||
// failed.
|
||||
if (ReturnsNullOnFailure) {
|
||||
SVal RetVal = C.getSVal(ParentExpr);
|
||||
SymbolRef RetStatusSymbol = RetVal.getAsSymbol();
|
||||
if (RetStatusSymbol) {
|
||||
C.getSymbolManager().addSymbolDependency(Sym, RetStatusSymbol);
|
||||
State = State->set<FreeReturnValue>(Sym, RetStatusSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
// Normal free.
|
||||
if (Hold)
|
||||
return state->set<RegionState>(Sym, RefState::getRelinquished(ParentExpr));
|
||||
return state->set<RegionState>(Sym, RefState::getReleased(ParentExpr));
|
||||
return State->set<RegionState>(Sym, RefState::getRelinquished(ParentExpr));
|
||||
return State->set<RegionState>(Sym, RefState::getReleased(ParentExpr));
|
||||
}
|
||||
|
||||
bool MallocChecker::SummarizeValue(raw_ostream &os, SVal V) {
|
||||
@@ -1064,6 +1111,15 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper,
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup the FreeReturnValue Map.
|
||||
FreeReturnValueTy FR = state->get<FreeReturnValue>();
|
||||
for (FreeReturnValueTy::iterator I = FR.begin(), E = FR.end(); I != E; ++I) {
|
||||
if (SymReaper.isDead(I->first) ||
|
||||
SymReaper.isDead(I->second)) {
|
||||
state = state->remove<FreeReturnValue>(I->first);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate leak node.
|
||||
ExplodedNode *N = C.getPredecessor();
|
||||
if (!Errors.empty()) {
|
||||
|
||||
@@ -137,6 +137,8 @@ static SVal adjustReturnValue(SVal V, QualType ExpectedTy, QualType ActualTy,
|
||||
return V;
|
||||
|
||||
// If the types already match, don't do any unnecessary work.
|
||||
ExpectedTy = ExpectedTy.getCanonicalType();
|
||||
ActualTy = ActualTy.getCanonicalType();
|
||||
if (ExpectedTy == ActualTy)
|
||||
return V;
|
||||
|
||||
@@ -189,6 +191,16 @@ void ExprEngine::removeDeadOnEndOfFunction(NodeBuilderContext& BC,
|
||||
currBldrCtx = 0;
|
||||
}
|
||||
|
||||
static bool wasDifferentDeclUsedForInlining(CallEventRef<> Call,
|
||||
const StackFrameContext *calleeCtx) {
|
||||
const Decl *RuntimeCallee = calleeCtx->getDecl();
|
||||
const Decl *StaticDecl = Call->getDecl();
|
||||
assert(RuntimeCallee);
|
||||
if (!StaticDecl)
|
||||
return true;
|
||||
return RuntimeCallee->getCanonicalDecl() != StaticDecl->getCanonicalDecl();
|
||||
}
|
||||
|
||||
/// The call exit is simulated with a sequence of nodes, which occur between
|
||||
/// CallExitBegin and CallExitEnd. The following operations occur between the
|
||||
/// two program points:
|
||||
@@ -228,9 +240,10 @@ void ExprEngine::processCallExit(ExplodedNode *CEBNode) {
|
||||
const LocationContext *LCtx = CEBNode->getLocationContext();
|
||||
SVal V = state->getSVal(RS, LCtx);
|
||||
|
||||
const Decl *Callee = calleeCtx->getDecl();
|
||||
if (Callee != Call->getDecl()) {
|
||||
QualType ReturnedTy = CallEvent::getDeclaredResultType(Callee);
|
||||
// Ensure that the return type matches the type of the returned Expr.
|
||||
if (wasDifferentDeclUsedForInlining(Call, calleeCtx)) {
|
||||
QualType ReturnedTy =
|
||||
CallEvent::getDeclaredResultType(calleeCtx->getDecl());
|
||||
if (!ReturnedTy.isNull()) {
|
||||
if (const Expr *Ex = dyn_cast<Expr>(CE)) {
|
||||
V = adjustReturnValue(V, Ex->getType(), ReturnedTy,
|
||||
|
||||
@@ -126,3 +126,26 @@ int test_5() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int test_6_aux(unsigned x);
|
||||
|
||||
void test_6() {
|
||||
unsigned currDestLen = 0; // no-warning
|
||||
try {
|
||||
while (test_6_aux(currDestLen)) {
|
||||
currDestLen += 2; // no-warning
|
||||
}
|
||||
}
|
||||
catch (void *) {}
|
||||
}
|
||||
|
||||
void test_6b() {
|
||||
unsigned currDestLen = 0; // no-warning
|
||||
try {
|
||||
while (test_6_aux(currDestLen)) {
|
||||
currDestLen += 2; // expected-warning {{Value stored to 'currDestLen' is never read}}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (void *) {}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,32 @@
|
||||
// RUN: %clang --analyze -Xanalyzer -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -Xclang -verify %s
|
||||
// RUN: %clang --analyze -Xanalyzer -analyzer-checker=osx.cocoa.IncompatibleMethodTypes,osx.coreFoundation.CFRetainRelease -Xclang -verify %s
|
||||
|
||||
#include "InlineObjCInstanceMethod.h"
|
||||
|
||||
typedef const struct __CFString * CFStringRef;
|
||||
typedef const void * CFTypeRef;
|
||||
extern CFTypeRef CFRetain(CFTypeRef cf);
|
||||
extern void CFRelease(CFTypeRef cf);
|
||||
extern CFStringRef getString(void);
|
||||
|
||||
// Method is defined in the parent; called through self.
|
||||
@interface MyParent : NSObject
|
||||
- (int)getInt;
|
||||
- (const struct __CFString *) testCovariantReturnType __attribute__((cf_returns_retained));
|
||||
@end
|
||||
@implementation MyParent
|
||||
- (int)getInt {
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (CFStringRef) testCovariantReturnType __attribute__((cf_returns_retained)) {
|
||||
CFStringRef Str = ((void*)0);
|
||||
Str = getString();
|
||||
if (Str) {
|
||||
CFRetain(Str);
|
||||
}
|
||||
return Str;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface MyClass : MyParent
|
||||
@@ -88,12 +105,22 @@ void randomlyMessageAnObject(MyClass *arr[], int i) {
|
||||
|
||||
@interface EvilChild : MyParent
|
||||
- (id)getInt;
|
||||
- (const struct __CFString *) testCovariantReturnType __attribute__((cf_returns_retained));
|
||||
@end
|
||||
|
||||
@implementation EvilChild
|
||||
- (id)getInt { // expected-warning {{types are incompatible}}
|
||||
return self;
|
||||
}
|
||||
- (CFStringRef) testCovariantReturnType __attribute__((cf_returns_retained)) {
|
||||
CFStringRef Str = ((void*)0);
|
||||
Str = getString();
|
||||
if (Str) {
|
||||
CFRetain(Str);
|
||||
}
|
||||
return Str;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int testNonCovariantReturnType() {
|
||||
@@ -109,3 +136,13 @@ int testNonCovariantReturnType() {
|
||||
[obj release];
|
||||
return 5/(x-1); // no-warning
|
||||
}
|
||||
|
||||
int testCovariantReturnTypeNoErrorSinceTypesMatch() {
|
||||
MyParent *obj = [[EvilChild alloc] init];
|
||||
|
||||
CFStringRef S = ((void*)0);
|
||||
S = [obj testCovariantReturnType];
|
||||
if (S)
|
||||
CFRelease(S);
|
||||
CFRelease(obj);
|
||||
}
|
||||
|
||||
@@ -222,3 +222,59 @@ void noCrashOnVariableArgumentSelector() {
|
||||
NSMutableString *myString = [NSMutableString stringWithString:@"some text"];
|
||||
[myString appendFormat:@"some text = %d", 3];
|
||||
}
|
||||
|
||||
void test12365078_check() {
|
||||
unichar *characters = (unichar*)malloc(12);
|
||||
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (!string) free(characters); // no-warning
|
||||
}
|
||||
|
||||
void test12365078_nocheck() {
|
||||
unichar *characters = (unichar*)malloc(12);
|
||||
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
}
|
||||
|
||||
void test12365078_false_negative() {
|
||||
unichar *characters = (unichar*)malloc(12);
|
||||
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (!string) {;}
|
||||
}
|
||||
|
||||
void test12365078_no_malloc(unichar *characters) {
|
||||
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (!string) {free(characters);}
|
||||
}
|
||||
|
||||
NSString *test12365078_no_malloc_returnValue(unichar *characters) {
|
||||
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (!string) {
|
||||
return 0; // no-warning
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
void test12365078_nocheck_nomalloc(unichar *characters) {
|
||||
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
free(characters); // expected-warning {{Attempt to free non-owned memory}}
|
||||
}
|
||||
|
||||
void test12365078_nested(unichar *characters) {
|
||||
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (!string) {
|
||||
NSString *string2 = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (!string2) {
|
||||
NSString *string3 = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (!string3) {
|
||||
NSString *string4 = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (!string4)
|
||||
free(characters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test12365078_check_positive() {
|
||||
unichar *characters = (unichar*)malloc(12);
|
||||
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1];
|
||||
if (string) free(characters); // expected-warning{{Attempt to free non-owned memory}}
|
||||
}
|
||||
|
||||
@@ -343,5 +343,21 @@ void test_test_return_inline_2(char *bytes) {
|
||||
CFRelease(str);
|
||||
}
|
||||
|
||||
extern CFStringRef getString(void);
|
||||
CFStringRef testCovariantReturnType(void) __attribute__((cf_returns_retained));
|
||||
|
||||
void usetestCovariantReturnType() {
|
||||
CFStringRef S = ((void*)0);
|
||||
S = testCovariantReturnType();
|
||||
if (S)
|
||||
CFRelease(S);
|
||||
}
|
||||
|
||||
CFStringRef testCovariantReturnType() {
|
||||
CFStringRef Str = ((void*)0);
|
||||
Str = getString();
|
||||
if (Str) {
|
||||
CFRetain(Str);
|
||||
}
|
||||
return Str;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wimplicit-fallthrough %s
|
||||
// XFAIL: *
|
||||
|
||||
// NOTE: This test is marked XFAIL until we come up with a good language design
|
||||
// for a worfklow to use this warning outside of C++11.
|
||||
|
||||
int fallthrough(int n) {
|
||||
switch (n / 10) {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
This is a collection of tests to check debugging information generated by
|
||||
compiler. This test suite can be checked out inside clang/test folder. This
|
||||
will enable 'make test' for clang to pick up these tests. Typically, test
|
||||
cases included here includes debugger commands and intended debugger output
|
||||
as comments in source file using DEBUGGER: and CHECK: as prefixes respectively.
|
||||
|
||||
For exmaple,
|
||||
|
||||
define i32 @f1(i32 %i) nounwind ssp {
|
||||
; DEBUGGER: break f1
|
||||
; DEBUGGER: r
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $1 = 42
|
||||
entry:
|
||||
}
|
||||
|
||||
is a testcase where the debuger is asked to break at function 'f1' and
|
||||
print value of argument 'i'. The expected value of 'i' is 42 in this case.
|
||||
@@ -1,32 +0,0 @@
|
||||
// RUN: %clangxx -O0 -g %s -c -o %t.o
|
||||
// RUN: %clangxx %t.o -o %t.out
|
||||
// RUN: %test_debuginfo %s %t.out
|
||||
// Radar 8945514
|
||||
// DEBUGGER: break 22
|
||||
// DEBUGGER: r
|
||||
// DEBUGGER: p v
|
||||
// CHECK: $1 = (SVal &)
|
||||
// CHECK: Data = 0x0,
|
||||
// CHECK: Kind = 2142
|
||||
|
||||
class SVal {
|
||||
public:
|
||||
~SVal() {}
|
||||
const void* Data;
|
||||
unsigned Kind;
|
||||
};
|
||||
|
||||
void bar(SVal &v) {}
|
||||
class A {
|
||||
public:
|
||||
void foo(SVal v) { bar(v); }
|
||||
};
|
||||
|
||||
int main() {
|
||||
SVal v;
|
||||
v.Data = 0;
|
||||
v.Kind = 2142;
|
||||
A a;
|
||||
a.foo(v);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
// RUN: %clang -O0 -g %s -c -o %t.o
|
||||
// RUN: %clang %t.o -o %t.out -framework Foundation
|
||||
// RUN: %test_debuginfo %s %t.out
|
||||
|
||||
// REQUIRES: system-darwin
|
||||
|
||||
// DEBUGGER: break 24
|
||||
// DEBUGGER: r
|
||||
// DEBUGGER: p result
|
||||
// CHECK: $1 = 42
|
||||
|
||||
void doBlock(void (^block)(void))
|
||||
{
|
||||
block();
|
||||
}
|
||||
|
||||
int I(int n)
|
||||
{
|
||||
__block int result;
|
||||
int i = 2;
|
||||
doBlock(^{
|
||||
result = n;
|
||||
});
|
||||
return result + i; /* Check value of 'result' */
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, const char * argv[]) {
|
||||
return I(42);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
// RUN: %clang -O0 -g %s -c -o %t.o
|
||||
// RUN: %clang %t.o -o %t.out -framework Foundation
|
||||
// RUN: %test_debuginfo %s %t.out
|
||||
|
||||
// REQUIRES: system-darwin
|
||||
// Radar 9279956
|
||||
|
||||
// DEBUGGER: break 31
|
||||
// DEBUGGER: r
|
||||
// DEBUGGER: p m2
|
||||
// DEBUGGER: p dbTransaction
|
||||
// DEBUGGER: p master
|
||||
// CHECK: $1 = 1
|
||||
// CHECK: $2 = 0
|
||||
// CHECK: $3 = 0
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
extern void foo(void(^)(void));
|
||||
|
||||
@interface A:NSObject @end
|
||||
@implementation A
|
||||
- (void) helper {
|
||||
int master = 0;
|
||||
__block int m2 = 0;
|
||||
__block int dbTransaction = 0;
|
||||
int (^x)(void) = ^(void) { (void) self;
|
||||
(void) master;
|
||||
(void) dbTransaction;
|
||||
m2++;
|
||||
return m2;
|
||||
};
|
||||
master = x();
|
||||
}
|
||||
@end
|
||||
|
||||
void foo(void(^x)(void)) {}
|
||||
|
||||
int main() {
|
||||
A *a = [A alloc];
|
||||
[a helper];
|
||||
return 0;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// RUN: %clangxx -O0 -g %s -c -o %t.o
|
||||
// RUN: %clangxx %t.o -o %t.out
|
||||
// RUN: %test_debuginfo %s %t.out
|
||||
|
||||
|
||||
// DEBUGGER: break 14
|
||||
// DEBUGGER: r
|
||||
// DEBUGGER: p *this
|
||||
// CHECK-NEXT-NOT: Cannot access memory at address
|
||||
|
||||
class A {
|
||||
public:
|
||||
A() : zero(0), data(42)
|
||||
{
|
||||
}
|
||||
private:
|
||||
int zero;
|
||||
int data;
|
||||
};
|
||||
|
||||
int main() {
|
||||
A a;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
; This test case checks debug info during register moves for an argument.
|
||||
; RUN: %clang -arch x86_64 -mllvm -fast-isel=false %s -c -o %t.o
|
||||
; RUN: %clang -arch x86_64 %t.o -o %t.out
|
||||
; RUN: %test_debuginfo %s %t.out
|
||||
;
|
||||
; REQUIRES: system-darwin
|
||||
; Radar 8412415
|
||||
|
||||
target triple = "x86_64-apple-darwin10.0.0"
|
||||
|
||||
%struct._mtx = type { i64, i32, %struct.anon }
|
||||
%struct.anon = type { i32, i32 }
|
||||
|
||||
define i32 @foobar(%struct._mtx* nocapture %mutex) nounwind readonly noinline ssp {
|
||||
; DEBUGGER: break foobar
|
||||
; DEBUGGER: r
|
||||
; DEBUGGER: info address mutex
|
||||
; CHECK: Symbol "mutex" is
|
||||
; CHECK-NEXT:
|
||||
; CHECK-NEXT: in register
|
||||
entry:
|
||||
tail call void @llvm.dbg.value(metadata !{%struct._mtx* %mutex}, i64 0, metadata !8), !dbg !29
|
||||
tail call void @llvm.dbg.value(metadata !30, i64 0, metadata !21), !dbg !31
|
||||
tail call void @llvm.dbg.value(metadata !32, i64 0, metadata !23), !dbg !33
|
||||
tail call void @llvm.dbg.value(metadata !32, i64 0, metadata !24), !dbg !34
|
||||
br label %do.body1, !dbg !37
|
||||
|
||||
do.body1: ; preds = %entry, %do.body1
|
||||
%0 = phi i32 [ 0, %entry ], [ %inc, %do.body1 ]
|
||||
%r.1 = phi i32 [ 1, %entry ], [ %r.0, %do.body1 ]
|
||||
%inc = add i32 %0, 1
|
||||
%tmp2 = getelementptr inbounds %struct._mtx* %mutex, i64 0, i32 1, !dbg !35
|
||||
%tmp3 = load i32* %tmp2, align 4, !dbg !35
|
||||
%tobool = icmp eq i32 %tmp3, 0, !dbg !35
|
||||
%r.0 = select i1 %tobool, i32 %r.1, i32 2
|
||||
%call = tail call i32 @bar(i32 %r.0, i32 %0), !dbg !38
|
||||
%cmp = icmp slt i32 %inc, %call, !dbg !39
|
||||
br i1 %cmp, label %do.body1, label %do.end9, !dbg !39
|
||||
|
||||
do.end9: ; preds = %do.body1
|
||||
tail call void @llvm.dbg.value(metadata !40, i64 0, metadata !21), !dbg !41
|
||||
tail call void @llvm.dbg.value(metadata !{i32 %call}, i64 0, metadata !24), !dbg !38
|
||||
tail call void @llvm.dbg.value(metadata !{i32 %inc}, i64 0, metadata !23), !dbg !42
|
||||
%add = add nsw i32 %r.0, %call, !dbg !43
|
||||
ret i32 %add, !dbg !43
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
|
||||
|
||||
define i32 @bar(i32 %i, i32 %j) nounwind readnone noinline ssp {
|
||||
entry:
|
||||
tail call void @llvm.dbg.value(metadata !{i32 %i}, i64 0, metadata !25), !dbg !44
|
||||
tail call void @llvm.dbg.value(metadata !{i32 %j}, i64 0, metadata !26), !dbg !45
|
||||
%add = add nsw i32 %j, %i, !dbg !46
|
||||
ret i32 %add, !dbg !46
|
||||
}
|
||||
|
||||
define i32 @main() nounwind readonly ssp {
|
||||
entry:
|
||||
%m = alloca %struct._mtx, align 8
|
||||
call void @llvm.dbg.declare(metadata !{%struct._mtx* %m}, metadata !27), !dbg !48
|
||||
%tmp = getelementptr inbounds %struct._mtx* %m, i64 0, i32 1, !dbg !49
|
||||
store i32 0, i32* %tmp, align 8, !dbg !49
|
||||
%call = call i32 @foobar(%struct._mtx* %m), !dbg !50
|
||||
ret i32 %call, !dbg !50
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
|
||||
|
||||
!llvm.dbg.sp = !{!0, !6, !7}
|
||||
!llvm.dbg.lv.foobar = !{!8, !21, !23, !24}
|
||||
!llvm.dbg.lv.bar = !{!25, !26}
|
||||
!llvm.dbg.lv.main = !{!27}
|
||||
|
||||
!0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"foobar", metadata !"foobar", metadata !"foobar", metadata !1, i32 12, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true, i32 (%struct._mtx*)* @foobar} ; [ DW_TAG_subprogram ]
|
||||
!1 = metadata !{i32 524329, metadata !"mu.c", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ]
|
||||
!2 = metadata !{i32 524305, i32 0, i32 12, metadata !"mu.c", metadata !"/private/tmp", metadata !"clang version 2.9 (trunk 114183)", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
|
||||
!3 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!4 = metadata !{metadata !5}
|
||||
!5 = metadata !{i32 524324, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
||||
!6 = metadata !{i32 524334, i32 0, metadata !1, metadata !"bar", metadata !"bar", metadata !"bar", metadata !1, i32 26, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true, i32 (i32, i32)* @bar} ; [ DW_TAG_subprogram ]
|
||||
!7 = metadata !{i32 524334, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 30, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true, i32 ()* @main} ; [ DW_TAG_subprogram ]
|
||||
!8 = metadata !{i32 524545, metadata !0, metadata !"mutex", metadata !1, i32 12, metadata !9} ; [ DW_TAG_arg_variable ]
|
||||
!9 = metadata !{i32 524303, metadata !1, metadata !"", metadata !1, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ]
|
||||
!10 = metadata !{i32 524310, metadata !1, metadata !"mtx_t", metadata !1, i32 9, i64 0, i64 0, i64 0, i32 0, metadata !11} ; [ DW_TAG_typedef ]
|
||||
!11 = metadata !{i32 524307, metadata !1, metadata !"_mtx", metadata !1, i32 2, i64 192, i64 64, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_structure_type ]
|
||||
!12 = metadata !{metadata !13, metadata !15, metadata !16}
|
||||
!13 = metadata !{i32 524301, metadata !1, metadata !"ptr", metadata !1, i32 3, i64 64, i64 64, i64 0, i32 0, metadata !14} ; [ DW_TAG_member ]
|
||||
!14 = metadata !{i32 524324, metadata !1, metadata !"long unsigned int", metadata !1, i32 0, i64 64, i64 64, i64 0, i32 0, i32 7} ; [ DW_TAG_base_type ]
|
||||
!15 = metadata !{i32 524301, metadata !1, metadata !"waiters", metadata !1, i32 4, i64 32, i64 32, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!16 = metadata !{i32 524301, metadata !1, metadata !"mtxi", metadata !1, i32 8, i64 64, i64 32, i64 96, i32 0, metadata !17} ; [ DW_TAG_member ]
|
||||
!17 = metadata !{i32 524307, metadata !11, metadata !"", metadata !1, i32 5, i64 64, i64 32, i64 0, i32 0, null, metadata !18, i32 0, null} ; [ DW_TAG_structure_type ]
|
||||
!18 = metadata !{metadata !19, metadata !20}
|
||||
!19 = metadata !{i32 524301, metadata !1, metadata !"tag", metadata !1, i32 6, i64 32, i64 32, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!20 = metadata !{i32 524301, metadata !1, metadata !"pad", metadata !1, i32 7, i64 32, i64 32, i64 32, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!21 = metadata !{i32 524544, metadata !22, metadata !"r", metadata !1, i32 13, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!22 = metadata !{i32 524299, metadata !0, i32 12, i32 52, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
|
||||
!23 = metadata !{i32 524544, metadata !22, metadata !"l", metadata !1, i32 14, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!24 = metadata !{i32 524544, metadata !22, metadata !"j", metadata !1, i32 15, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!25 = metadata !{i32 524545, metadata !6, metadata !"i", metadata !1, i32 26, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!26 = metadata !{i32 524545, metadata !6, metadata !"j", metadata !1, i32 26, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!27 = metadata !{i32 524544, metadata !28, metadata !"m", metadata !1, i32 31, metadata !10} ; [ DW_TAG_auto_variable ]
|
||||
!28 = metadata !{i32 524299, metadata !7, i32 30, i32 12, metadata !1, i32 4} ; [ DW_TAG_lexical_block ]
|
||||
!29 = metadata !{i32 12, i32 45, metadata !0, null}
|
||||
!30 = metadata !{i32 1}
|
||||
!31 = metadata !{i32 13, i32 12, metadata !22, null}
|
||||
!32 = metadata !{i32 0}
|
||||
!33 = metadata !{i32 14, i32 12, metadata !22, null}
|
||||
!34 = metadata !{i32 15, i32 12, metadata !22, null}
|
||||
!35 = metadata !{i32 18, i32 5, metadata !36, null}
|
||||
!36 = metadata !{i32 524299, metadata !22, i32 17, i32 6, metadata !1, i32 2} ; [ DW_TAG_lexical_block ]
|
||||
!37 = metadata !{i32 16, i32 3, metadata !22, null}
|
||||
!38 = metadata !{i32 20, i32 5, metadata !36, null}
|
||||
!39 = metadata !{i32 22, i32 3, metadata !36, null}
|
||||
!40 = metadata !{i32 2}
|
||||
!41 = metadata !{i32 19, i32 7, metadata !36, null}
|
||||
!42 = metadata !{i32 21, i32 5, metadata !36, null}
|
||||
!43 = metadata !{i32 23, i32 3, metadata !22, null}
|
||||
!44 = metadata !{i32 26, i32 39, metadata !6, null}
|
||||
!45 = metadata !{i32 26, i32 46, metadata !6, null}
|
||||
!46 = metadata !{i32 27, i32 3, metadata !47, null}
|
||||
!47 = metadata !{i32 524299, metadata !6, i32 26, i32 49, metadata !1, i32 3} ; [ DW_TAG_lexical_block ]
|
||||
!48 = metadata !{i32 31, i32 9, metadata !28, null}
|
||||
!49 = metadata !{i32 32, i32 3, metadata !28, null}
|
||||
!50 = metadata !{i32 33, i32 3, metadata !28, null}
|
||||
|
||||
@@ -1,263 +0,0 @@
|
||||
; This test case checks handling of llvm.dbg.declare intrinsic during fast-isel.
|
||||
; RUN: %clang -arch x86_64 -O0 -g %s -c -o %t.o
|
||||
; RUN: %clang -arch x86_64 %t.o -o %t.out
|
||||
; RUN: %test_debuginfo %s %t.out
|
||||
;
|
||||
; REQUIRES: system-darwin
|
||||
|
||||
target triple = "x86_64-apple-darwin"
|
||||
%struct.XYZ = type { i32, i32, i32, i32, i32 }
|
||||
|
||||
; Check handling of llvm.dbg.declare for an argument referred through alloca, where
|
||||
; alloca dominates llvm.dbg.declare
|
||||
define i32 @f1(i32 %i) nounwind ssp {
|
||||
; DEBUGGER: break f1
|
||||
; DEBUGGER: r
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $1 = 42
|
||||
entry:
|
||||
%i.addr = alloca i32, align 4
|
||||
store i32 %i, i32* %i.addr, align 4
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i.addr}, metadata !16), !dbg !17
|
||||
%tmp = load i32* %i.addr, align 4, !dbg !18
|
||||
ret i32 %tmp, !dbg !18
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
|
||||
|
||||
; Check handling of llvm.dbg.declare for an argument referred through alloca, where
|
||||
; llvm.dbg.declare dominates alloca.
|
||||
define i32 @f2(i32 %i) nounwind ssp {
|
||||
; DEBUGGER: break f2
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $2 = 43
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i.addr}, metadata !20), !dbg !21
|
||||
%i.addr = alloca i32, align 4
|
||||
store i32 %i, i32* %i.addr, align 4
|
||||
%tmp = load i32* %i.addr, align 4, !dbg !22
|
||||
ret i32 %tmp, !dbg !22
|
||||
}
|
||||
|
||||
; If llvm.dbg.declare is using an argument after its last use then register
|
||||
; allocator may destroy debug info for the argument. This is expected and
|
||||
; it should be fixed before registers are allocated.
|
||||
define i32 @f3(i32 %i) nounwind ssp {
|
||||
entry:
|
||||
%i.addr = alloca i32, align 4
|
||||
store i32 %i, i32* %i.addr, align 4
|
||||
call void @llvm.dbg.declare(metadata !{i32 %i}, metadata !24), !dbg !25
|
||||
%tmp = load i32* %i.addr, align 4, !dbg !26
|
||||
ret i32 %tmp, !dbg !26
|
||||
}
|
||||
|
||||
; Check handling of an argument referred directly by llvm.dbg.declare where
|
||||
; llvm.dbg.declare dominates all uses of argument.
|
||||
define i32 @f4(i32 %i) nounwind ssp {
|
||||
; DEBUGGER: break f4
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $3 = 45
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32 %i}, metadata !28), !dbg !29
|
||||
ret i32 %i, !dbg !30
|
||||
}
|
||||
|
||||
; Check handling of an argument referred directly by llvm.dbg.declare where
|
||||
; llvm.dbg.declare dominates all uses of argument in separate basic block.
|
||||
define i32 @f5(i32 %i) nounwind ssp {
|
||||
; DEBUGGER: break f5
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $4 = 46
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32 %i}, metadata !32), !dbg !33
|
||||
br label %bbr
|
||||
bbr:
|
||||
ret i32 %i, !dbg !34
|
||||
}
|
||||
|
||||
; Check handling of an argument referred directly by llvm.dbg.declare where
|
||||
; argument is not used.
|
||||
define i32 @f6(i32 %i) nounwind ssp {
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32 %i}, metadata !36), !dbg !37
|
||||
ret i32 1, !dbg !38
|
||||
}
|
||||
|
||||
; Check handling of an byval argument referred directly by llvm.dbg.declare where
|
||||
; argument is not used.
|
||||
define i32 @f7(%struct.XYZ* byval %i) nounwind ssp {
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %i}, metadata !40), !dbg !48
|
||||
ret i32 1, !dbg !49
|
||||
}
|
||||
|
||||
; Check handling of an byval argument referred directly by llvm.dbg.declare where
|
||||
; argument use dominates llvm.dbg.declare.
|
||||
define i32 @f8(%struct.XYZ* byval %i) nounwind ssp {
|
||||
; DEBUGGER: break f8
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i.x
|
||||
; CHECK: $5 = 51
|
||||
entry:
|
||||
%tmp = getelementptr inbounds %struct.XYZ* %i, i32 0, i32 1, !dbg !53
|
||||
%tmp1 = load i32* %tmp, align 4, !dbg !53
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %i}, metadata !51), !dbg !52
|
||||
ret i32 %tmp1, !dbg !53
|
||||
}
|
||||
|
||||
; Check handling of an byval argument referred directly by llvm.dbg.declare where
|
||||
; llvm.dbg.declare dominates all uses of argument.
|
||||
define i32 @f9(%struct.XYZ* byval %i) nounwind ssp {
|
||||
; DEBUGGER: break f9
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i.x
|
||||
; CHECK: $6 = 51
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %i}, metadata !55), !dbg !56
|
||||
%tmp = getelementptr inbounds %struct.XYZ* %i, i32 0, i32 2, !dbg !57
|
||||
%tmp1 = load i32* %tmp, align 4, !dbg !57
|
||||
ret i32 %tmp1, !dbg !57
|
||||
}
|
||||
|
||||
; Check handling of an byval argument referred directly by llvm.dbg.declare where
|
||||
; llvm.dbg.declare dominates all uses of argument in separate basic block.
|
||||
define i32 @f10(%struct.XYZ* byval %i) nounwind ssp {
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %i}, metadata !59), !dbg !60
|
||||
br label %bbr
|
||||
bbr:
|
||||
%tmp = getelementptr inbounds %struct.XYZ* %i, i32 0, i32 3, !dbg !61
|
||||
%tmp1 = load i32* %tmp, align 4, !dbg !61
|
||||
ret i32 %tmp1, !dbg !61
|
||||
}
|
||||
|
||||
define i32 @main() nounwind ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%abc = alloca %struct.XYZ, align 4
|
||||
%agg.tmp = alloca %struct.XYZ, align 4
|
||||
%agg.tmp13 = alloca %struct.XYZ, align 4
|
||||
%agg.tmp17 = alloca %struct.XYZ, align 4
|
||||
%agg.tmp21 = alloca %struct.XYZ, align 4
|
||||
store i32 0, i32* %retval
|
||||
%call = call i32 @f1(i32 42), !dbg !63
|
||||
%call1 = call i32 @f2(i32 43), !dbg !65
|
||||
%call2 = call i32 @f3(i32 44), !dbg !66
|
||||
%call3 = call i32 @f4(i32 45), !dbg !67
|
||||
%call4 = call i32 @f5(i32 46), !dbg !68
|
||||
%call5 = call i32 @f6(i32 47), !dbg !69
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %abc}, metadata !70), !dbg !71
|
||||
%tmp = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 0, !dbg !72
|
||||
store i32 51, i32* %tmp, align 4, !dbg !72
|
||||
%tmp6 = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 1, !dbg !72
|
||||
store i32 52, i32* %tmp6, align 4, !dbg !72
|
||||
%tmp7 = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 2, !dbg !72
|
||||
store i32 53, i32* %tmp7, align 4, !dbg !72
|
||||
%tmp8 = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 3, !dbg !72
|
||||
store i32 54, i32* %tmp8, align 4, !dbg !72
|
||||
%tmp9 = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 4, !dbg !72
|
||||
store i32 55, i32* %tmp9, align 4, !dbg !72
|
||||
%tmp10 = bitcast %struct.XYZ* %agg.tmp to i8*, !dbg !73
|
||||
%tmp11 = bitcast %struct.XYZ* %abc to i8*, !dbg !73
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp10, i8* %tmp11, i64 20, i32 4, i1 false), !dbg !73
|
||||
%call12 = call i32 @f7(%struct.XYZ* byval %agg.tmp), !dbg !73
|
||||
%tmp14 = bitcast %struct.XYZ* %agg.tmp13 to i8*, !dbg !74
|
||||
%tmp15 = bitcast %struct.XYZ* %abc to i8*, !dbg !74
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp14, i8* %tmp15, i64 20, i32 4, i1 false), !dbg !74
|
||||
%call16 = call i32 @f8(%struct.XYZ* byval %agg.tmp13), !dbg !74
|
||||
%tmp18 = bitcast %struct.XYZ* %agg.tmp17 to i8*, !dbg !75
|
||||
%tmp19 = bitcast %struct.XYZ* %abc to i8*, !dbg !75
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp18, i8* %tmp19, i64 20, i32 4, i1 false), !dbg !75
|
||||
%call20 = call i32 @f9(%struct.XYZ* byval %agg.tmp17), !dbg !75
|
||||
%tmp22 = bitcast %struct.XYZ* %agg.tmp21 to i8*, !dbg !76
|
||||
%tmp23 = bitcast %struct.XYZ* %abc to i8*, !dbg !76
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp22, i8* %tmp23, i64 20, i32 4, i1 false), !dbg !76
|
||||
%call24 = call i32 @f10(%struct.XYZ* byval %agg.tmp21), !dbg !76
|
||||
ret i32 0, !dbg !77
|
||||
}
|
||||
|
||||
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
|
||||
|
||||
!llvm.dbg.sp = !{!0, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15}
|
||||
|
||||
!0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f1", metadata !"f1", metadata !"f1", metadata !1, i32 11, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f1} ; [ DW_TAG_subprogram ]
|
||||
!1 = metadata !{i32 524329, metadata !"fastisel_arg.c", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ]
|
||||
!2 = metadata !{i32 524305, i32 0, i32 12, metadata !"fastisel_arg.c", metadata !"/private/tmp", metadata !"clang version 2.8 (trunk 112967)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
|
||||
!3 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!4 = metadata !{metadata !5}
|
||||
!5 = metadata !{i32 524324, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
||||
!6 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f2", metadata !"f2", metadata !"f2", metadata !1, i32 12, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f2} ; [ DW_TAG_subprogram ]
|
||||
!7 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f3", metadata !"f3", metadata !"f3", metadata !1, i32 13, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f3} ; [ DW_TAG_subprogram ]
|
||||
!8 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f4", metadata !"f4", metadata !"f4", metadata !1, i32 14, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f4} ; [ DW_TAG_subprogram ]
|
||||
!9 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f5", metadata !"f5", metadata !"f5", metadata !1, i32 15, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f5} ; [ DW_TAG_subprogram ]
|
||||
!10 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f6", metadata !"f6", metadata !"f6", metadata !1, i32 16, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f6} ; [ DW_TAG_subprogram ]
|
||||
!11 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f7", metadata !"f7", metadata !"f7", metadata !1, i32 17, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (%struct.XYZ*)* @f7} ; [ DW_TAG_subprogram ]
|
||||
!12 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f8", metadata !"f8", metadata !"f8", metadata !1, i32 18, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (%struct.XYZ*)* @f8} ; [ DW_TAG_subprogram ]
|
||||
!13 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f9", metadata !"f9", metadata !"f9", metadata !1, i32 19, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (%struct.XYZ*)* @f9} ; [ DW_TAG_subprogram ]
|
||||
!14 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f10", metadata !"f10", metadata !"f10", metadata !1, i32 20, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (%struct.XYZ*)* @f10} ; [ DW_TAG_subprogram ]
|
||||
!15 = metadata !{i32 524334, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 23, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ]
|
||||
!16 = metadata !{i32 524545, metadata !0, metadata !"i", metadata !1, i32 11, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!17 = metadata !{i32 11, i32 12, metadata !0, null}
|
||||
!18 = metadata !{i32 11, i32 17, metadata !19, null}
|
||||
!19 = metadata !{i32 524299, metadata !0, i32 11, i32 15, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
|
||||
!20 = metadata !{i32 524545, metadata !6, metadata !"i", metadata !1, i32 12, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!21 = metadata !{i32 12, i32 12, metadata !6, null}
|
||||
!22 = metadata !{i32 12, i32 17, metadata !23, null}
|
||||
!23 = metadata !{i32 524299, metadata !6, i32 12, i32 15, metadata !1, i32 1} ; [ DW_TAG_lexical_block ]
|
||||
!24 = metadata !{i32 524545, metadata !7, metadata !"i", metadata !1, i32 13, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!25 = metadata !{i32 13, i32 12, metadata !7, null}
|
||||
!26 = metadata !{i32 13, i32 17, metadata !27, null}
|
||||
!27 = metadata !{i32 524299, metadata !7, i32 13, i32 15, metadata !1, i32 2} ; [ DW_TAG_lexical_block ]
|
||||
!28 = metadata !{i32 524545, metadata !8, metadata !"i", metadata !1, i32 14, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!29 = metadata !{i32 14, i32 12, metadata !8, null}
|
||||
!30 = metadata !{i32 14, i32 17, metadata !31, null}
|
||||
!31 = metadata !{i32 524299, metadata !8, i32 14, i32 15, metadata !1, i32 3} ; [ DW_TAG_lexical_block ]
|
||||
!32 = metadata !{i32 524545, metadata !9, metadata !"i", metadata !1, i32 15, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!33 = metadata !{i32 15, i32 12, metadata !9, null}
|
||||
!34 = metadata !{i32 15, i32 17, metadata !35, null}
|
||||
!35 = metadata !{i32 524299, metadata !9, i32 15, i32 15, metadata !1, i32 4} ; [ DW_TAG_lexical_block ]
|
||||
!36 = metadata !{i32 524545, metadata !10, metadata !"i", metadata !1, i32 16, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!37 = metadata !{i32 16, i32 12, metadata !10, null}
|
||||
!38 = metadata !{i32 16, i32 17, metadata !39, null}
|
||||
!39 = metadata !{i32 524299, metadata !10, i32 16, i32 15, metadata !1, i32 5} ; [ DW_TAG_lexical_block ]
|
||||
!40 = metadata !{i32 524545, metadata !11, metadata !"i", metadata !1, i32 17, metadata !41} ; [ DW_TAG_arg_variable ]
|
||||
!41 = metadata !{i32 524307, metadata !1, metadata !"XYZ", metadata !1, i32 2, i64 160, i64 32, i64 0, i32 0, null, metadata !42, i32 0, null} ; [ DW_TAG_structure_type ]
|
||||
!42 = metadata !{metadata !43, metadata !44, metadata !45, metadata !46, metadata !47}
|
||||
!43 = metadata !{i32 524301, metadata !1, metadata !"x", metadata !1, i32 3, i64 32, i64 32, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!44 = metadata !{i32 524301, metadata !1, metadata !"y", metadata !1, i32 4, i64 32, i64 32, i64 32, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!45 = metadata !{i32 524301, metadata !1, metadata !"z", metadata !1, i32 5, i64 32, i64 32, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!46 = metadata !{i32 524301, metadata !1, metadata !"a", metadata !1, i32 6, i64 32, i64 32, i64 96, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!47 = metadata !{i32 524301, metadata !1, metadata !"b", metadata !1, i32 7, i64 32, i64 32, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!48 = metadata !{i32 17, i32 19, metadata !11, null}
|
||||
!49 = metadata !{i32 17, i32 24, metadata !50, null}
|
||||
!50 = metadata !{i32 524299, metadata !11, i32 17, i32 22, metadata !1, i32 6} ; [ DW_TAG_lexical_block ]
|
||||
!51 = metadata !{i32 524545, metadata !12, metadata !"i", metadata !1, i32 18, metadata !41} ; [ DW_TAG_arg_variable ]
|
||||
!52 = metadata !{i32 18, i32 19, metadata !12, null}
|
||||
!53 = metadata !{i32 18, i32 24, metadata !54, null}
|
||||
!54 = metadata !{i32 524299, metadata !12, i32 18, i32 22, metadata !1, i32 7} ; [ DW_TAG_lexical_block ]
|
||||
!55 = metadata !{i32 524545, metadata !13, metadata !"i", metadata !1, i32 19, metadata !41} ; [ DW_TAG_arg_variable ]
|
||||
!56 = metadata !{i32 19, i32 19, metadata !13, null}
|
||||
!57 = metadata !{i32 19, i32 24, metadata !58, null}
|
||||
!58 = metadata !{i32 524299, metadata !13, i32 19, i32 22, metadata !1, i32 8} ; [ DW_TAG_lexical_block ]
|
||||
!59 = metadata !{i32 524545, metadata !14, metadata !"i", metadata !1, i32 20, metadata !41} ; [ DW_TAG_arg_variable ]
|
||||
!60 = metadata !{i32 20, i32 20, metadata !14, null}
|
||||
!61 = metadata !{i32 20, i32 25, metadata !62, null}
|
||||
!62 = metadata !{i32 524299, metadata !14, i32 20, i32 23, metadata !1, i32 9} ; [ DW_TAG_lexical_block ]
|
||||
!63 = metadata !{i32 24, i32 3, metadata !64, null}
|
||||
!64 = metadata !{i32 524299, metadata !15, i32 23, i32 12, metadata !1, i32 10} ; [ DW_TAG_lexical_block ]
|
||||
!65 = metadata !{i32 25, i32 3, metadata !64, null}
|
||||
!66 = metadata !{i32 26, i32 3, metadata !64, null}
|
||||
!67 = metadata !{i32 27, i32 3, metadata !64, null}
|
||||
!68 = metadata !{i32 28, i32 3, metadata !64, null}
|
||||
!69 = metadata !{i32 29, i32 3, metadata !64, null}
|
||||
!70 = metadata !{i32 524544, metadata !64, metadata !"abc", metadata !1, i32 30, metadata !41} ; [ DW_TAG_auto_variable ]
|
||||
!71 = metadata !{i32 30, i32 14, metadata !64, null}
|
||||
!72 = metadata !{i32 30, i32 17, metadata !64, null}
|
||||
!73 = metadata !{i32 31, i32 3, metadata !64, null}
|
||||
!74 = metadata !{i32 32, i32 3, metadata !64, null}
|
||||
!75 = metadata !{i32 33, i32 3, metadata !64, null}
|
||||
!76 = metadata !{i32 34, i32 3, metadata !64, null}
|
||||
!77 = metadata !{i32 36, i32 3, metadata !64, null}
|
||||
@@ -1,264 +0,0 @@
|
||||
; This test case checks handling of llvm.dbg.declare intrinsic during isel.
|
||||
; RUN: %clang -arch x86_64 -mllvm -fast-isel=false -mllvm -regalloc=default -g %s -c -o %t.o
|
||||
; RUN: %clang -arch x86_64 %t.o -o %t.out
|
||||
; RUN: %test_debuginfo %s %t.out
|
||||
;
|
||||
; REQUIRES: system-darwin
|
||||
|
||||
target triple = "x86_64-apple-darwin"
|
||||
%struct.XYZ = type { i32, i32, i32, i32, i32 }
|
||||
|
||||
; Check handling of llvm.dbg.declare for an argument referred through alloca, where
|
||||
; alloca dominates llvm.dbg.declare
|
||||
define i32 @f1(i32 %i) nounwind ssp {
|
||||
; DEBUGGER: break f1
|
||||
; DEBUGGER: r
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $1 = 42
|
||||
entry:
|
||||
%i.addr = alloca i32, align 4
|
||||
store i32 %i, i32* %i.addr, align 4
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i.addr}, metadata !16), !dbg !17
|
||||
%tmp = load i32* %i.addr, align 4, !dbg !18
|
||||
ret i32 %tmp, !dbg !18
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
|
||||
|
||||
; Check handling of llvm.dbg.declare for an argument referred through alloca, where
|
||||
; llvm.dbg.declare dominates alloca.
|
||||
define i32 @f2(i32 %i) nounwind ssp {
|
||||
; DEBUGGER: break f2
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $2 = 43
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i.addr}, metadata !20), !dbg !21
|
||||
%i.addr = alloca i32, align 4
|
||||
store i32 %i, i32* %i.addr, align 4
|
||||
%tmp = load i32* %i.addr, align 4, !dbg !22
|
||||
ret i32 %tmp, !dbg !22
|
||||
}
|
||||
|
||||
; Check handling of an argument referred directly by llvm.dbg.declare where at least
|
||||
; one argument use dominates llvm.dbg.declare.
|
||||
; This is expected to not work because registor allocator has freedom to kill 'i'
|
||||
; after its last use.
|
||||
define i32 @f3(i32 %i) nounwind ssp {
|
||||
entry:
|
||||
%i.addr = alloca i32, align 4
|
||||
store i32 %i, i32* %i.addr, align 4
|
||||
call void @llvm.dbg.declare(metadata !{i32 %i}, metadata !24), !dbg !25
|
||||
%tmp = load i32* %i.addr, align 4, !dbg !26
|
||||
ret i32 %tmp, !dbg !26
|
||||
}
|
||||
|
||||
; Check handling of an argument referred directly by llvm.dbg.declare where
|
||||
; llvm.dbg.declare dominates all uses of argument.
|
||||
define i32 @f4(i32 %i) nounwind ssp {
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32 %i}, metadata !28), !dbg !29
|
||||
ret i32 %i, !dbg !30
|
||||
}
|
||||
|
||||
; Check handling of an argument referred directly by llvm.dbg.declare where
|
||||
; llvm.dbg.declare dominates all uses of argument in separate basic block.
|
||||
define i32 @f5(i32 %i) nounwind ssp {
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32 %i}, metadata !32), !dbg !33
|
||||
br label %bbr
|
||||
bbr:
|
||||
ret i32 %i, !dbg !34
|
||||
}
|
||||
|
||||
; Check handling of an argument referred directly by llvm.dbg.declare where
|
||||
; argument is not used.
|
||||
define i32 @f6(i32 %i) nounwind ssp {
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32 %i}, metadata !36), !dbg !37
|
||||
ret i32 1, !dbg !38
|
||||
}
|
||||
|
||||
; Check handling of an byval argument referred directly by llvm.dbg.declare where
|
||||
; argument is not used.
|
||||
define i32 @f7(%struct.XYZ* byval %i) nounwind ssp {
|
||||
; DEBUGGER: break f7
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i.x
|
||||
; CHECK: $3 = 51
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %i}, metadata !40), !dbg !48
|
||||
ret i32 1, !dbg !49
|
||||
}
|
||||
|
||||
; Check handling of an byval argument referred directly by llvm.dbg.declare where
|
||||
; argument use dominates llvm.dbg.declare.
|
||||
define i32 @f8(%struct.XYZ* byval %i) nounwind ssp {
|
||||
; DEBUGGER: break f8
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i.x
|
||||
; CHECK: $4 = 51
|
||||
entry:
|
||||
%tmp = getelementptr inbounds %struct.XYZ* %i, i32 0, i32 1, !dbg !53
|
||||
%tmp1 = load i32* %tmp, align 4, !dbg !53
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %i}, metadata !51), !dbg !52
|
||||
ret i32 %tmp1, !dbg !53
|
||||
}
|
||||
|
||||
; Check handling of an byval argument referred directly by llvm.dbg.declare where
|
||||
; llvm.dbg.declare dominates all uses of argument.
|
||||
define i32 @f9(%struct.XYZ* byval %i) nounwind ssp {
|
||||
; DEBUGGER: break f9
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i.x
|
||||
; CHECK: $5 = 51
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %i}, metadata !55), !dbg !56
|
||||
%tmp = getelementptr inbounds %struct.XYZ* %i, i32 0, i32 2, !dbg !57
|
||||
%tmp1 = load i32* %tmp, align 4, !dbg !57
|
||||
ret i32 %tmp1, !dbg !57
|
||||
}
|
||||
|
||||
; Check handling of an byval argument referred directly by llvm.dbg.declare where
|
||||
; llvm.dbg.declare dominates all uses of argument in separate basic block.
|
||||
define i32 @f10(%struct.XYZ* byval %i) nounwind ssp {
|
||||
; DEBUGGER: break f10
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: p i.x
|
||||
; CHECK: $6 = 51
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %i}, metadata !59), !dbg !60
|
||||
br label %bbr
|
||||
bbr:
|
||||
%tmp = getelementptr inbounds %struct.XYZ* %i, i32 0, i32 3, !dbg !61
|
||||
%tmp1 = load i32* %tmp, align 4, !dbg !61
|
||||
ret i32 %tmp1, !dbg !61
|
||||
}
|
||||
|
||||
define i32 @main() nounwind ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%abc = alloca %struct.XYZ, align 4
|
||||
%agg.tmp = alloca %struct.XYZ, align 4
|
||||
%agg.tmp13 = alloca %struct.XYZ, align 4
|
||||
%agg.tmp17 = alloca %struct.XYZ, align 4
|
||||
%agg.tmp21 = alloca %struct.XYZ, align 4
|
||||
store i32 0, i32* %retval
|
||||
%call = call i32 @f1(i32 42), !dbg !63
|
||||
%call1 = call i32 @f2(i32 43), !dbg !65
|
||||
%call2 = call i32 @f3(i32 44), !dbg !66
|
||||
%call3 = call i32 @f4(i32 45), !dbg !67
|
||||
%call4 = call i32 @f5(i32 46), !dbg !68
|
||||
%call5 = call i32 @f6(i32 47), !dbg !69
|
||||
call void @llvm.dbg.declare(metadata !{%struct.XYZ* %abc}, metadata !70), !dbg !71
|
||||
%tmp = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 0, !dbg !72
|
||||
store i32 51, i32* %tmp, align 4, !dbg !72
|
||||
%tmp6 = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 1, !dbg !72
|
||||
store i32 52, i32* %tmp6, align 4, !dbg !72
|
||||
%tmp7 = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 2, !dbg !72
|
||||
store i32 53, i32* %tmp7, align 4, !dbg !72
|
||||
%tmp8 = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 3, !dbg !72
|
||||
store i32 54, i32* %tmp8, align 4, !dbg !72
|
||||
%tmp9 = getelementptr inbounds %struct.XYZ* %abc, i32 0, i32 4, !dbg !72
|
||||
store i32 55, i32* %tmp9, align 4, !dbg !72
|
||||
%tmp10 = bitcast %struct.XYZ* %agg.tmp to i8*, !dbg !73
|
||||
%tmp11 = bitcast %struct.XYZ* %abc to i8*, !dbg !73
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp10, i8* %tmp11, i64 20, i32 4, i1 false), !dbg !73
|
||||
%call12 = call i32 @f7(%struct.XYZ* byval %agg.tmp), !dbg !73
|
||||
%tmp14 = bitcast %struct.XYZ* %agg.tmp13 to i8*, !dbg !74
|
||||
%tmp15 = bitcast %struct.XYZ* %abc to i8*, !dbg !74
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp14, i8* %tmp15, i64 20, i32 4, i1 false), !dbg !74
|
||||
%call16 = call i32 @f8(%struct.XYZ* byval %agg.tmp13), !dbg !74
|
||||
%tmp18 = bitcast %struct.XYZ* %agg.tmp17 to i8*, !dbg !75
|
||||
%tmp19 = bitcast %struct.XYZ* %abc to i8*, !dbg !75
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp18, i8* %tmp19, i64 20, i32 4, i1 false), !dbg !75
|
||||
%call20 = call i32 @f9(%struct.XYZ* byval %agg.tmp17), !dbg !75
|
||||
%tmp22 = bitcast %struct.XYZ* %agg.tmp21 to i8*, !dbg !76
|
||||
%tmp23 = bitcast %struct.XYZ* %abc to i8*, !dbg !76
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp22, i8* %tmp23, i64 20, i32 4, i1 false), !dbg !76
|
||||
%call24 = call i32 @f10(%struct.XYZ* byval %agg.tmp21), !dbg !76
|
||||
ret i32 0, !dbg !77
|
||||
}
|
||||
|
||||
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
|
||||
|
||||
!llvm.dbg.sp = !{!0, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15}
|
||||
|
||||
!0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f1", metadata !"f1", metadata !"f1", metadata !1, i32 11, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f1} ; [ DW_TAG_subprogram ]
|
||||
!1 = metadata !{i32 524329, metadata !"fastisel_arg.c", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ]
|
||||
!2 = metadata !{i32 524305, i32 0, i32 12, metadata !"fastisel_arg.c", metadata !"/private/tmp", metadata !"clang version 2.8 (trunk 112967)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
|
||||
!3 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!4 = metadata !{metadata !5}
|
||||
!5 = metadata !{i32 524324, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
||||
!6 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f2", metadata !"f2", metadata !"f2", metadata !1, i32 12, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f2} ; [ DW_TAG_subprogram ]
|
||||
!7 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f3", metadata !"f3", metadata !"f3", metadata !1, i32 13, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f3} ; [ DW_TAG_subprogram ]
|
||||
!8 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f4", metadata !"f4", metadata !"f4", metadata !1, i32 14, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f4} ; [ DW_TAG_subprogram ]
|
||||
!9 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f5", metadata !"f5", metadata !"f5", metadata !1, i32 15, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f5} ; [ DW_TAG_subprogram ]
|
||||
!10 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f6", metadata !"f6", metadata !"f6", metadata !1, i32 16, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (i32)* @f6} ; [ DW_TAG_subprogram ]
|
||||
!11 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f7", metadata !"f7", metadata !"f7", metadata !1, i32 17, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (%struct.XYZ*)* @f7} ; [ DW_TAG_subprogram ]
|
||||
!12 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f8", metadata !"f8", metadata !"f8", metadata !1, i32 18, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (%struct.XYZ*)* @f8} ; [ DW_TAG_subprogram ]
|
||||
!13 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f9", metadata !"f9", metadata !"f9", metadata !1, i32 19, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (%struct.XYZ*)* @f9} ; [ DW_TAG_subprogram ]
|
||||
!14 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f10", metadata !"f10", metadata !"f10", metadata !1, i32 20, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 (%struct.XYZ*)* @f10} ; [ DW_TAG_subprogram ]
|
||||
!15 = metadata !{i32 524334, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 23, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ]
|
||||
!16 = metadata !{i32 524545, metadata !0, metadata !"i", metadata !1, i32 11, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!17 = metadata !{i32 11, i32 12, metadata !0, null}
|
||||
!18 = metadata !{i32 11, i32 17, metadata !19, null}
|
||||
!19 = metadata !{i32 524299, metadata !0, i32 11, i32 15, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
|
||||
!20 = metadata !{i32 524545, metadata !6, metadata !"i", metadata !1, i32 12, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!21 = metadata !{i32 12, i32 12, metadata !6, null}
|
||||
!22 = metadata !{i32 12, i32 17, metadata !23, null}
|
||||
!23 = metadata !{i32 524299, metadata !6, i32 12, i32 15, metadata !1, i32 1} ; [ DW_TAG_lexical_block ]
|
||||
!24 = metadata !{i32 524545, metadata !7, metadata !"i", metadata !1, i32 13, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!25 = metadata !{i32 13, i32 12, metadata !7, null}
|
||||
!26 = metadata !{i32 13, i32 17, metadata !27, null}
|
||||
!27 = metadata !{i32 524299, metadata !7, i32 13, i32 15, metadata !1, i32 2} ; [ DW_TAG_lexical_block ]
|
||||
!28 = metadata !{i32 524545, metadata !8, metadata !"i", metadata !1, i32 14, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!29 = metadata !{i32 14, i32 12, metadata !8, null}
|
||||
!30 = metadata !{i32 14, i32 17, metadata !31, null}
|
||||
!31 = metadata !{i32 524299, metadata !8, i32 14, i32 15, metadata !1, i32 3} ; [ DW_TAG_lexical_block ]
|
||||
!32 = metadata !{i32 524545, metadata !9, metadata !"i", metadata !1, i32 15, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!33 = metadata !{i32 15, i32 12, metadata !9, null}
|
||||
!34 = metadata !{i32 15, i32 17, metadata !35, null}
|
||||
!35 = metadata !{i32 524299, metadata !9, i32 15, i32 15, metadata !1, i32 4} ; [ DW_TAG_lexical_block ]
|
||||
!36 = metadata !{i32 524545, metadata !10, metadata !"i", metadata !1, i32 16, metadata !5} ; [ DW_TAG_arg_variable ]
|
||||
!37 = metadata !{i32 16, i32 12, metadata !10, null}
|
||||
!38 = metadata !{i32 16, i32 17, metadata !39, null}
|
||||
!39 = metadata !{i32 524299, metadata !10, i32 16, i32 15, metadata !1, i32 5} ; [ DW_TAG_lexical_block ]
|
||||
!40 = metadata !{i32 524545, metadata !11, metadata !"i", metadata !1, i32 17, metadata !41} ; [ DW_TAG_arg_variable ]
|
||||
!41 = metadata !{i32 524307, metadata !1, metadata !"XYZ", metadata !1, i32 2, i64 160, i64 32, i64 0, i32 0, null, metadata !42, i32 0, null} ; [ DW_TAG_structure_type ]
|
||||
!42 = metadata !{metadata !43, metadata !44, metadata !45, metadata !46, metadata !47}
|
||||
!43 = metadata !{i32 524301, metadata !1, metadata !"x", metadata !1, i32 3, i64 32, i64 32, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!44 = metadata !{i32 524301, metadata !1, metadata !"y", metadata !1, i32 4, i64 32, i64 32, i64 32, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!45 = metadata !{i32 524301, metadata !1, metadata !"z", metadata !1, i32 5, i64 32, i64 32, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!46 = metadata !{i32 524301, metadata !1, metadata !"a", metadata !1, i32 6, i64 32, i64 32, i64 96, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!47 = metadata !{i32 524301, metadata !1, metadata !"b", metadata !1, i32 7, i64 32, i64 32, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ]
|
||||
!48 = metadata !{i32 17, i32 19, metadata !11, null}
|
||||
!49 = metadata !{i32 17, i32 24, metadata !50, null}
|
||||
!50 = metadata !{i32 524299, metadata !11, i32 17, i32 22, metadata !1, i32 6} ; [ DW_TAG_lexical_block ]
|
||||
!51 = metadata !{i32 524545, metadata !12, metadata !"i", metadata !1, i32 18, metadata !41} ; [ DW_TAG_arg_variable ]
|
||||
!52 = metadata !{i32 18, i32 19, metadata !12, null}
|
||||
!53 = metadata !{i32 18, i32 24, metadata !54, null}
|
||||
!54 = metadata !{i32 524299, metadata !12, i32 18, i32 22, metadata !1, i32 7} ; [ DW_TAG_lexical_block ]
|
||||
!55 = metadata !{i32 524545, metadata !13, metadata !"i", metadata !1, i32 19, metadata !41} ; [ DW_TAG_arg_variable ]
|
||||
!56 = metadata !{i32 19, i32 19, metadata !13, null}
|
||||
!57 = metadata !{i32 19, i32 24, metadata !58, null}
|
||||
!58 = metadata !{i32 524299, metadata !13, i32 19, i32 22, metadata !1, i32 8} ; [ DW_TAG_lexical_block ]
|
||||
!59 = metadata !{i32 524545, metadata !14, metadata !"i", metadata !1, i32 20, metadata !41} ; [ DW_TAG_arg_variable ]
|
||||
!60 = metadata !{i32 20, i32 20, metadata !14, null}
|
||||
!61 = metadata !{i32 20, i32 25, metadata !62, null}
|
||||
!62 = metadata !{i32 524299, metadata !14, i32 20, i32 23, metadata !1, i32 9} ; [ DW_TAG_lexical_block ]
|
||||
!63 = metadata !{i32 24, i32 3, metadata !64, null}
|
||||
!64 = metadata !{i32 524299, metadata !15, i32 23, i32 12, metadata !1, i32 10} ; [ DW_TAG_lexical_block ]
|
||||
!65 = metadata !{i32 25, i32 3, metadata !64, null}
|
||||
!66 = metadata !{i32 26, i32 3, metadata !64, null}
|
||||
!67 = metadata !{i32 27, i32 3, metadata !64, null}
|
||||
!68 = metadata !{i32 28, i32 3, metadata !64, null}
|
||||
!69 = metadata !{i32 29, i32 3, metadata !64, null}
|
||||
!70 = metadata !{i32 524544, metadata !64, metadata !"abc", metadata !1, i32 30, metadata !41} ; [ DW_TAG_auto_variable ]
|
||||
!71 = metadata !{i32 30, i32 14, metadata !64, null}
|
||||
!72 = metadata !{i32 30, i32 17, metadata !64, null}
|
||||
!73 = metadata !{i32 31, i32 3, metadata !64, null}
|
||||
!74 = metadata !{i32 32, i32 3, metadata !64, null}
|
||||
!75 = metadata !{i32 33, i32 3, metadata !64, null}
|
||||
!76 = metadata !{i32 34, i32 3, metadata !64, null}
|
||||
!77 = metadata !{i32 36, i32 3, metadata !64, null}
|
||||
@@ -1,31 +0,0 @@
|
||||
// RUN: %clang -O0 -g %s -c -o %t.o
|
||||
// RUN: %clang %t.o -o %t.out -framework Foundation
|
||||
// RUN: %test_debuginfo %s %t.out
|
||||
//
|
||||
// REQUIRES: system-darwin
|
||||
// Radar 8757124
|
||||
|
||||
// DEBUGGER: break 25
|
||||
// DEBUGGER: r
|
||||
// DEBUGGER: po thing
|
||||
// CHECK: aaa
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
int main (int argc, const char * argv[]) {
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSArray *things = [NSArray arrayWithObjects:@"one", @"two", @"three" , nil];
|
||||
for (NSString *thing in things) {
|
||||
NSLog (@"%@", thing);
|
||||
}
|
||||
|
||||
things = [NSArray arrayWithObjects:@"aaa", @"bbb", @"ccc" , nil];
|
||||
for (NSString *thing in things) {
|
||||
NSLog (@"%@", thing);
|
||||
}
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// RUN: %clangxx -O0 -g %s -c -o %t.o
|
||||
// RUN: %test_debuginfo %s %t.o
|
||||
// Radar 9168773
|
||||
|
||||
// DEBUGGER: ptype A
|
||||
// Work around a gdb bug where it believes that a class is a
|
||||
// struct if there aren't any methods - even though it's tagged
|
||||
// as a class.
|
||||
// CHECK: type = {{struct|class}} A {
|
||||
// CHECK-NEXT: {{(public:){0,1}}}
|
||||
// CHECK-NEXT: int MyData;
|
||||
// CHECK-NEXT: }
|
||||
class A;
|
||||
class B {
|
||||
public:
|
||||
void foo(const A *p);
|
||||
};
|
||||
|
||||
B iEntry;
|
||||
|
||||
class A {
|
||||
public:
|
||||
int MyData;
|
||||
};
|
||||
|
||||
A irp;
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
; This test case checks handling of llvm.dbg.declare intrinsic during fast-isel.
|
||||
; RUN: %clang -arch x86_64 -O0 -g %s -c -o %t.o
|
||||
; RUN: %clang -arch x86_64 %t.o -o %t.out
|
||||
; RUN: %test_debuginfo %s %t.out
|
||||
;
|
||||
; REQUIRES: system-darwin
|
||||
|
||||
target triple = "x86_64-apple-darwin10.0.0"
|
||||
|
||||
define i32 @f1() nounwind ssp {
|
||||
; DEBUGGER: break f1
|
||||
; DEBUGGER: r
|
||||
; DEBUGGER: n
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $1 = 42
|
||||
entry:
|
||||
%i = alloca i32, align 4
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !10), !dbg !12
|
||||
store i32 42, i32* %i, align 4, !dbg !13
|
||||
%tmp = load i32* %i, align 4, !dbg !14
|
||||
ret i32 %tmp, !dbg !14
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
|
||||
|
||||
define i32 @f2() nounwind ssp {
|
||||
; DEBUGGER: break f2
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: n
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $2 = 42
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !15), !dbg !17
|
||||
%i = alloca i32, align 4
|
||||
store i32 42, i32* %i, align 4, !dbg !18
|
||||
%tmp = load i32* %i, align 4, !dbg !19
|
||||
ret i32 %tmp, !dbg !19
|
||||
}
|
||||
|
||||
; dbg.declare is dropped, as expected, by instruction selector.
|
||||
; THIS IS NOT EXPECTED TO WORK.
|
||||
define i32 @f3() nounwind ssp {
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !20), !dbg !22
|
||||
br label %bbr
|
||||
bbr:
|
||||
%i = alloca i32, align 4
|
||||
store i32 42, i32* %i, align 4, !dbg !23
|
||||
%tmp = load i32* %i, align 4, !dbg !24
|
||||
ret i32 %tmp, !dbg !24
|
||||
}
|
||||
|
||||
; dbg.declare is dropped, as expected, by instruction selector.
|
||||
; THIS IS NOT EXPECTED TO WORK.
|
||||
define i32 @f4() nounwind ssp {
|
||||
entry:
|
||||
%i = alloca i32, align 4
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !25), !dbg !27
|
||||
ret i32 42, !dbg !28
|
||||
}
|
||||
|
||||
define i32 @main() nounwind ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
store i32 0, i32* %retval
|
||||
%call = call i32 @f1(), !dbg !29
|
||||
%call1 = call i32 @f2(), !dbg !31
|
||||
%call2 = call i32 @f3(), !dbg !32
|
||||
%call3 = call i32 @f4(), !dbg !33
|
||||
ret i32 0, !dbg !34
|
||||
}
|
||||
|
||||
!llvm.dbg.sp = !{!0, !6, !7, !8, !9}
|
||||
|
||||
!0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f1", metadata !"f1", metadata !"f1", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @f1} ; [ DW_TAG_subprogram ]
|
||||
!1 = metadata !{i32 524329, metadata !"lv.c", metadata !"dbg_info_bugs", metadata !2} ; [ DW_TAG_file_type ]
|
||||
!2 = metadata !{i32 524305, i32 0, i32 12, metadata !"lv.c", metadata !"dbg_info_bugs", metadata !"clang version 2.9 (trunk 113428)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
|
||||
!3 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!4 = metadata !{metadata !5}
|
||||
!5 = metadata !{i32 524324, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
||||
!6 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f2", metadata !"f2", metadata !"f2", metadata !1, i32 8, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @f2} ; [ DW_TAG_subprogram ]
|
||||
!7 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f3", metadata !"f3", metadata !"f3", metadata !1, i32 14, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @f3} ; [ DW_TAG_subprogram ]
|
||||
!8 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f4", metadata !"f4", metadata !"f4", metadata !1, i32 20, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @f4} ; [ DW_TAG_subprogram ]
|
||||
!9 = metadata !{i32 524334, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 25, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ]
|
||||
!10 = metadata !{i32 524544, metadata !11, metadata !"i", metadata !1, i32 3, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!11 = metadata !{i32 524299, metadata !0, i32 2, i32 10, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
|
||||
!12 = metadata !{i32 3, i32 7, metadata !11, null}
|
||||
!13 = metadata !{i32 4, i32 3, metadata !11, null}
|
||||
!14 = metadata !{i32 5, i32 3, metadata !11, null}
|
||||
!15 = metadata !{i32 524544, metadata !16, metadata !"i", metadata !1, i32 9, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!16 = metadata !{i32 524299, metadata !6, i32 8, i32 10, metadata !1, i32 1} ; [ DW_TAG_lexical_block ]
|
||||
!17 = metadata !{i32 9, i32 7, metadata !16, null}
|
||||
!18 = metadata !{i32 10, i32 3, metadata !16, null}
|
||||
!19 = metadata !{i32 11, i32 3, metadata !16, null}
|
||||
!20 = metadata !{i32 524544, metadata !21, metadata !"i", metadata !1, i32 15, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!21 = metadata !{i32 524299, metadata !7, i32 14, i32 10, metadata !1, i32 2} ; [ DW_TAG_lexical_block ]
|
||||
!22 = metadata !{i32 15, i32 7, metadata !21, null}
|
||||
!23 = metadata !{i32 16, i32 3, metadata !21, null}
|
||||
!24 = metadata !{i32 17, i32 3, metadata !21, null}
|
||||
!25 = metadata !{i32 524544, metadata !26, metadata !"i", metadata !1, i32 21, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!26 = metadata !{i32 524299, metadata !8, i32 20, i32 10, metadata !1, i32 3} ; [ DW_TAG_lexical_block ]
|
||||
!27 = metadata !{i32 21, i32 7, metadata !26, null}
|
||||
!28 = metadata !{i32 22, i32 3, metadata !26, null}
|
||||
!29 = metadata !{i32 26, i32 3, metadata !30, null}
|
||||
!30 = metadata !{i32 524299, metadata !9, i32 25, i32 12, metadata !1, i32 4} ; [ DW_TAG_lexical_block ]
|
||||
!31 = metadata !{i32 27, i32 3, metadata !30, null}
|
||||
!32 = metadata !{i32 28, i32 3, metadata !30, null}
|
||||
!33 = metadata !{i32 29, i32 3, metadata !30, null}
|
||||
!34 = metadata !{i32 30, i32 3, metadata !30, null}
|
||||
@@ -1,109 +0,0 @@
|
||||
; This test case checks handling of llvm.dbg.declare intrinsic during isel.
|
||||
; RUN: %clang -arch x86_64 -O0 -mllvm -fast-isel=false -g %s -c -o %t.o
|
||||
; RUN: %clang -arch x86_64 %t.o -o %t.out
|
||||
; RUN: %test_debuginfo %s %t.out
|
||||
;
|
||||
; REQUIRES: system-darwin
|
||||
|
||||
target triple = "x86_64-apple-darwin10.0.0"
|
||||
|
||||
define i32 @f1() nounwind ssp {
|
||||
; DEBUGGER: break f1
|
||||
; DEBUGGER: r
|
||||
; DEBUGGER: n
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $1 = 42
|
||||
entry:
|
||||
%i = alloca i32, align 4
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !10), !dbg !12
|
||||
store i32 42, i32* %i, align 4, !dbg !13
|
||||
%tmp = load i32* %i, align 4, !dbg !14
|
||||
ret i32 %tmp, !dbg !14
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
|
||||
|
||||
define i32 @f2() nounwind ssp {
|
||||
; DEBUGGER: break f2
|
||||
; DEBUGGER: c
|
||||
; DEBUGGER: n
|
||||
; DEBUGGER: p i
|
||||
; CHECK: $2 = 42
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !15), !dbg !17
|
||||
%i = alloca i32, align 4
|
||||
store i32 42, i32* %i, align 4, !dbg !18
|
||||
%tmp = load i32* %i, align 4, !dbg !19
|
||||
ret i32 %tmp, !dbg !19
|
||||
}
|
||||
|
||||
; dbg.declare is dropped, as expected, by instruction selector.
|
||||
; THIS IS NOT EXPECTED TO WORK.
|
||||
define i32 @f3() nounwind ssp {
|
||||
entry:
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !20), !dbg !22
|
||||
br label %bbr
|
||||
bbr:
|
||||
%i = alloca i32, align 4
|
||||
store i32 42, i32* %i, align 4, !dbg !23
|
||||
%tmp = load i32* %i, align 4, !dbg !24
|
||||
ret i32 %tmp, !dbg !24
|
||||
}
|
||||
|
||||
; dbg.declare is dropped, as expected, by instruction selector.
|
||||
; THIS IS NOT EXPECTED TO WORK.
|
||||
define i32 @f4() nounwind ssp {
|
||||
entry:
|
||||
%i = alloca i32, align 4
|
||||
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !25), !dbg !27
|
||||
ret i32 42, !dbg !28
|
||||
}
|
||||
|
||||
define i32 @main() nounwind ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
store i32 0, i32* %retval
|
||||
%call = call i32 @f1(), !dbg !29
|
||||
%call1 = call i32 @f2(), !dbg !31
|
||||
%call2 = call i32 @f3(), !dbg !32
|
||||
%call3 = call i32 @f4(), !dbg !33
|
||||
ret i32 0, !dbg !34
|
||||
}
|
||||
|
||||
!llvm.dbg.sp = !{!0, !6, !7, !8, !9}
|
||||
|
||||
!0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f1", metadata !"f1", metadata !"f1", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @f1} ; [ DW_TAG_subprogram ]
|
||||
!1 = metadata !{i32 524329, metadata !"lv.c", metadata !"dbg_info_bugs", metadata !2} ; [ DW_TAG_file_type ]
|
||||
!2 = metadata !{i32 524305, i32 0, i32 12, metadata !"lv.c", metadata !"dbg_info_bugs", metadata !"clang version 2.9 (trunk 113428)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
|
||||
!3 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!4 = metadata !{metadata !5}
|
||||
!5 = metadata !{i32 524324, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
||||
!6 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f2", metadata !"f2", metadata !"f2", metadata !1, i32 8, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @f2} ; [ DW_TAG_subprogram ]
|
||||
!7 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f3", metadata !"f3", metadata !"f3", metadata !1, i32 14, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @f3} ; [ DW_TAG_subprogram ]
|
||||
!8 = metadata !{i32 524334, i32 0, metadata !1, metadata !"f4", metadata !"f4", metadata !"f4", metadata !1, i32 20, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @f4} ; [ DW_TAG_subprogram ]
|
||||
!9 = metadata !{i32 524334, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 25, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ]
|
||||
!10 = metadata !{i32 524544, metadata !11, metadata !"i", metadata !1, i32 3, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!11 = metadata !{i32 524299, metadata !0, i32 2, i32 10, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
|
||||
!12 = metadata !{i32 3, i32 7, metadata !11, null}
|
||||
!13 = metadata !{i32 4, i32 3, metadata !11, null}
|
||||
!14 = metadata !{i32 5, i32 3, metadata !11, null}
|
||||
!15 = metadata !{i32 524544, metadata !16, metadata !"i", metadata !1, i32 9, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!16 = metadata !{i32 524299, metadata !6, i32 8, i32 10, metadata !1, i32 1} ; [ DW_TAG_lexical_block ]
|
||||
!17 = metadata !{i32 9, i32 7, metadata !16, null}
|
||||
!18 = metadata !{i32 10, i32 3, metadata !16, null}
|
||||
!19 = metadata !{i32 11, i32 3, metadata !16, null}
|
||||
!20 = metadata !{i32 524544, metadata !21, metadata !"i", metadata !1, i32 15, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!21 = metadata !{i32 524299, metadata !7, i32 14, i32 10, metadata !1, i32 2} ; [ DW_TAG_lexical_block ]
|
||||
!22 = metadata !{i32 15, i32 7, metadata !21, null}
|
||||
!23 = metadata !{i32 16, i32 3, metadata !21, null}
|
||||
!24 = metadata !{i32 17, i32 3, metadata !21, null}
|
||||
!25 = metadata !{i32 524544, metadata !26, metadata !"i", metadata !1, i32 21, metadata !5} ; [ DW_TAG_auto_variable ]
|
||||
!26 = metadata !{i32 524299, metadata !8, i32 20, i32 10, metadata !1, i32 3} ; [ DW_TAG_lexical_block ]
|
||||
!27 = metadata !{i32 21, i32 7, metadata !26, null}
|
||||
!28 = metadata !{i32 22, i32 3, metadata !26, null}
|
||||
!29 = metadata !{i32 26, i32 3, metadata !30, null}
|
||||
!30 = metadata !{i32 524299, metadata !9, i32 25, i32 12, metadata !1, i32 4} ; [ DW_TAG_lexical_block ]
|
||||
!31 = metadata !{i32 27, i32 3, metadata !30, null}
|
||||
!32 = metadata !{i32 28, i32 3, metadata !30, null}
|
||||
!33 = metadata !{i32 29, i32 3, metadata !30, null}
|
||||
!34 = metadata !{i32 30, i32 3, metadata !30, null}
|
||||
@@ -1,21 +0,0 @@
|
||||
// RUN: %clangxx -O0 -g %s -c -o %t.o
|
||||
// RUN: %test_debuginfo %s %t.o
|
||||
// Radar 9440721
|
||||
// If debug info for my_number() is emitted outside function foo's scope
|
||||
// then a debugger may not be able to handle it. At least one version of
|
||||
// gdb crashes in such cases.
|
||||
|
||||
// DEBUGGER: ptype foo
|
||||
// CHECK: type = int (void)
|
||||
|
||||
int foo() {
|
||||
struct Local {
|
||||
static int my_number() {
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
|
||||
int i = 0;
|
||||
i = Local::my_number();
|
||||
return i + 1;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
// RUN: %clangxx -O0 -g %s -c -o %t.o
|
||||
// RUN: %clangxx %t.o -o %t.out
|
||||
// RUN: %test_debuginfo %s %t.out
|
||||
// Radar 8775834
|
||||
// DEBUGGER: break 61
|
||||
// DEBUGGER: r
|
||||
// DEBUGGER: p a
|
||||
// CHECK: $1 = (A &)
|
||||
// CHECK: _vptr$A =
|
||||
// CHECK: m_int = 12
|
||||
|
||||
class A
|
||||
{
|
||||
public:
|
||||
A (int i=0);
|
||||
A (const A& rhs);
|
||||
const A&
|
||||
operator= (const A& rhs);
|
||||
virtual ~A() {}
|
||||
|
||||
int get_int();
|
||||
|
||||
protected:
|
||||
int m_int;
|
||||
};
|
||||
|
||||
A::A (int i) :
|
||||
m_int(i)
|
||||
{
|
||||
}
|
||||
|
||||
A::A (const A& rhs) :
|
||||
m_int (rhs.m_int)
|
||||
{
|
||||
}
|
||||
|
||||
const A &
|
||||
A::operator =(const A& rhs)
|
||||
{
|
||||
m_int = rhs.m_int;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int A::get_int()
|
||||
{
|
||||
return m_int;
|
||||
}
|
||||
|
||||
class B
|
||||
{
|
||||
public:
|
||||
B () {}
|
||||
|
||||
A AInstance();
|
||||
};
|
||||
|
||||
A
|
||||
B::AInstance()
|
||||
{
|
||||
A a(12);
|
||||
return a;
|
||||
}
|
||||
|
||||
int main (int argc, char const *argv[])
|
||||
{
|
||||
B b;
|
||||
int return_val = b.AInstance().get_int();
|
||||
|
||||
A a(b.AInstance());
|
||||
return return_val;
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
; This test checks debug info of unused, zero extended argument.
|
||||
; RUN: %clang -arch x86_64 -mllvm -fast-isel=false %s -c -o %t.o
|
||||
; RUN: %clang -arch x86_64 %t.o -o %t.out
|
||||
; RUN: %test_debuginfo %s %t.out
|
||||
;
|
||||
; REQUIRES: system-darwin
|
||||
; Radar 9422775
|
||||
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
|
||||
target triple = "x86_64-apple-macosx10.6.7"
|
||||
|
||||
%class.aClass = type { float }
|
||||
|
||||
; DEBUGGER: break aClass::setValues
|
||||
; DEBUGGER: r
|
||||
; DEBUGGER: p Filter
|
||||
; CHECK: true
|
||||
|
||||
define void @_ZN6aClass9setValuesEibf(%class.aClass* nocapture %this, i32 %ch, i1 zeroext %Filter, float %a1) nounwind noinline ssp align 2 {
|
||||
entry:
|
||||
tail call void @llvm.dbg.value(metadata !{%class.aClass* %this}, i64 0, metadata !19), !dbg !25
|
||||
tail call void @llvm.dbg.value(metadata !{i32 %ch}, i64 0, metadata !20), !dbg !26
|
||||
tail call void @llvm.dbg.value(metadata !{i1 %Filter}, i64 0, metadata !21), !dbg !27
|
||||
tail call void @llvm.dbg.value(metadata !{float %a1}, i64 0, metadata !22), !dbg !28
|
||||
%m = getelementptr inbounds %class.aClass* %this, i64 0, i32 0, !dbg !29
|
||||
store float %a1, float* %m, align 4, !dbg !29, !tbaa !31
|
||||
ret void, !dbg !34
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
|
||||
|
||||
define i32 @main() nounwind ssp {
|
||||
entry:
|
||||
%a = alloca %class.aClass, align 4
|
||||
call void @llvm.dbg.declare(metadata !{%class.aClass* %a}, metadata !23), !dbg !35
|
||||
call void @_ZN6aClass9setValuesEibf(%class.aClass* %a, i32 undef, i1 zeroext 1, float 1.000000e+00), !dbg !36
|
||||
ret i32 0, !dbg !37
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
|
||||
|
||||
!llvm.dbg.cu = !{!0}
|
||||
!llvm.dbg.sp = !{!1, !12, !16}
|
||||
!llvm.dbg.lv._ZN6aClass9setValuesEibf = !{!19, !20, !21, !22}
|
||||
!llvm.dbg.lv.main = !{!23}
|
||||
|
||||
!0 = metadata !{i32 589841, i32 0, i32 4, metadata !"two.cpp", metadata !"/private/tmp/inc", metadata !"clang version 3.0 (trunk 131411)", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
|
||||
!1 = metadata !{i32 589870, i32 0, metadata !2, metadata !"setValues", metadata !"setValues", metadata !"_ZN6aClass9setValuesEibf", metadata !3, i32 6, metadata !7, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 true, null, null} ; [ DW_TAG_subprogram ]
|
||||
!2 = metadata !{i32 589826, metadata !0, metadata !"aClass", metadata !3, i32 2, i64 32, i64 32, i32 0, i32 0, null, metadata !4, i32 0, null, null} ; [ DW_TAG_class_type ]
|
||||
!3 = metadata !{i32 589865, metadata !"./one.h", metadata !"/private/tmp/inc", metadata !0} ; [ DW_TAG_file_type ]
|
||||
!4 = metadata !{metadata !5, metadata !1}
|
||||
!5 = metadata !{i32 589837, metadata !3, metadata !"m", metadata !3, i32 4, i64 32, i64 32, i64 0, i32 1, metadata !6} ; [ DW_TAG_member ]
|
||||
!6 = metadata !{i32 589860, metadata !0, metadata !"float", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ]
|
||||
!7 = metadata !{i32 589845, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
|
||||
!8 = metadata !{null, metadata !9, metadata !10, metadata !11, metadata !6}
|
||||
!9 = metadata !{i32 589839, metadata !0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !2} ; [ DW_TAG_pointer_type ]
|
||||
!10 = metadata !{i32 589860, metadata !0, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
||||
!11 = metadata !{i32 589860, metadata !0, metadata !"bool", null, i32 0, i64 8, i64 8, i64 0, i32 0, i32 2} ; [ DW_TAG_base_type ]
|
||||
!12 = metadata !{i32 589870, i32 0, metadata !13, metadata !"setValues", metadata !"setValues", metadata !"_ZN6aClass9setValuesEibf", metadata !13, i32 4, metadata !14, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, void (%class.aClass*, i32, i1, float)* @_ZN6aClass9setValuesEibf, null, metadata !1} ; [ DW_TAG_subprogram ]
|
||||
!13 = metadata !{i32 589865, metadata !"two.cpp", metadata !"/private/tmp/inc", metadata !0} ; [ DW_TAG_file_type ]
|
||||
!14 = metadata !{i32 589845, metadata !13, metadata !"", metadata !13, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !15, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
|
||||
!15 = metadata !{null}
|
||||
!16 = metadata !{i32 589870, i32 0, metadata !13, metadata !"main", metadata !"main", metadata !"", metadata !13, i32 9, metadata !17, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 ()* @main, null, null} ; [ DW_TAG_subprogram ]
|
||||
!17 = metadata !{i32 589845, metadata !13, metadata !"", metadata !13, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !18, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
|
||||
!18 = metadata !{metadata !10}
|
||||
!19 = metadata !{i32 590081, metadata !12, metadata !"this", metadata !13, i32 16777219, metadata !9, i32 64} ; [ DW_TAG_arg_variable ]
|
||||
!20 = metadata !{i32 590081, metadata !12, metadata !"ch", metadata !13, i32 33554435, metadata !10, i32 0} ; [ DW_TAG_arg_variable ]
|
||||
!21 = metadata !{i32 590081, metadata !12, metadata !"Filter", metadata !13, i32 50331651, metadata !11, i32 0} ; [ DW_TAG_arg_variable ]
|
||||
!22 = metadata !{i32 590081, metadata !12, metadata !"a1", metadata !13, i32 67108867, metadata !6, i32 0} ; [ DW_TAG_arg_variable ]
|
||||
!23 = metadata !{i32 590080, metadata !24, metadata !"a", metadata !13, i32 10, metadata !2, i32 0} ; [ DW_TAG_auto_variable ]
|
||||
!24 = metadata !{i32 589835, metadata !16, i32 9, i32 1, metadata !13, i32 1} ; [ DW_TAG_lexical_block ]
|
||||
!25 = metadata !{i32 3, i32 40, metadata !12, null}
|
||||
!26 = metadata !{i32 3, i32 54, metadata !12, null}
|
||||
!27 = metadata !{i32 3, i32 63, metadata !12, null}
|
||||
!28 = metadata !{i32 3, i32 77, metadata !12, null}
|
||||
!29 = metadata !{i32 5, i32 2, metadata !30, null}
|
||||
!30 = metadata !{i32 589835, metadata !12, i32 4, i32 1, metadata !13, i32 0} ; [ DW_TAG_lexical_block ]
|
||||
!31 = metadata !{metadata !"float", metadata !32}
|
||||
!32 = metadata !{metadata !"omnipotent char", metadata !33}
|
||||
!33 = metadata !{metadata !"Simple C/C++ TBAA", null}
|
||||
!34 = metadata !{i32 6, i32 1, metadata !30, null}
|
||||
!35 = metadata !{i32 10, i32 11, metadata !24, null}
|
||||
!36 = metadata !{i32 11, i32 4, metadata !24, null}
|
||||
!37 = metadata !{i32 12, i32 4, metadata !24, null}
|
||||
@@ -1,2 +0,0 @@
|
||||
N: Peter Collingbourne
|
||||
E: peter@pcc.me.uk
|
||||
@@ -1,37 +0,0 @@
|
||||
libclc
|
||||
------
|
||||
|
||||
libclc is an open source, BSD licensed implementation of the library
|
||||
requirements of the OpenCL C programming language, as specified by the
|
||||
OpenCL 1.1 Specification. The following sections of the specification
|
||||
impose library requirements:
|
||||
|
||||
* 6.1: Supported Data Types
|
||||
* 6.2.3: Explicit Conversions
|
||||
* 6.2.4.2: Reinterpreting Types Using as_type() and as_typen()
|
||||
* 6.9: Preprocessor Directives and Macros
|
||||
* 6.11: Built-in Functions
|
||||
* 9.3: Double Precision Floating-Point
|
||||
* 9.4: 64-bit Atomics
|
||||
* 9.5: Writing to 3D image memory objects
|
||||
* 9.6: Half Precision Floating-Point
|
||||
|
||||
libclc is intended to be used with the Clang compiler's OpenCL frontend.
|
||||
|
||||
libclc is designed to be portable and extensible. To this end, it provides
|
||||
generic implementations of most library requirements, allowing the target
|
||||
to override the generic implementation at the granularity of individual
|
||||
functions.
|
||||
|
||||
libclc currently only supports the PTX target, but support for more
|
||||
targets is welcome.
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
./configure.py --with-llvm-config=/path/to/llvm-config && make
|
||||
|
||||
Website
|
||||
-------
|
||||
|
||||
http://www.pcc.me.uk/~peter/libclc/
|
||||
@@ -1,95 +0,0 @@
|
||||
import ninja_syntax
|
||||
import os
|
||||
|
||||
# Simple meta-build system.
|
||||
|
||||
class Make(object):
|
||||
def __init__(self):
|
||||
self.output = open(self.output_filename(), 'w')
|
||||
self.rules = {}
|
||||
self.rule_text = ''
|
||||
self.all_targets = []
|
||||
self.default_targets = []
|
||||
self.clean_files = []
|
||||
self.distclean_files = []
|
||||
self.output.write("""all::
|
||||
|
||||
ifndef VERBOSE
|
||||
Verb = @
|
||||
endif
|
||||
|
||||
""")
|
||||
|
||||
def output_filename(self):
|
||||
return 'Makefile'
|
||||
|
||||
def rule(self, name, command, description=None, depfile=None,
|
||||
generator=False):
|
||||
self.rules[name] = {'command': command, 'description': description,
|
||||
'depfile': depfile, 'generator': generator}
|
||||
|
||||
def build(self, output, rule, inputs=[], implicit=[], order_only=[]):
|
||||
inputs = self._as_list(inputs)
|
||||
implicit = self._as_list(implicit)
|
||||
order_only = self._as_list(order_only)
|
||||
|
||||
output_dir = os.path.dirname(output)
|
||||
if output_dir != '' and not os.path.isdir(output_dir):
|
||||
os.makedirs(output_dir)
|
||||
|
||||
dollar_in = ' '.join(inputs)
|
||||
subst = lambda text: text.replace('$in', dollar_in).replace('$out', output)
|
||||
|
||||
deps = ' '.join(inputs + implicit)
|
||||
if order_only:
|
||||
deps += ' | '
|
||||
deps += ' '.join(order_only)
|
||||
self.output.write('%s: %s\n' % (output, deps))
|
||||
|
||||
r = self.rules[rule]
|
||||
command = subst(r['command'])
|
||||
if r['description']:
|
||||
desc = subst(r['description'])
|
||||
self.output.write('\t@echo %s\n\t$(Verb) %s\n' % (desc, command))
|
||||
else:
|
||||
self.output.write('\t%s\n' % command)
|
||||
if r['depfile']:
|
||||
depfile = subst(r['depfile'])
|
||||
self.output.write('-include '+depfile+'\n')
|
||||
self.output.write('\n')
|
||||
|
||||
self.all_targets.append(output)
|
||||
if r['generator']:
|
||||
self.distclean_files.append(output)
|
||||
else:
|
||||
self.clean_files.append(output)
|
||||
|
||||
def _as_list(self, input):
|
||||
if isinstance(input, list):
|
||||
return input
|
||||
return [input]
|
||||
|
||||
def default(self, paths):
|
||||
self.default_targets += self._as_list(paths)
|
||||
|
||||
def finish(self):
|
||||
self.output.write('all:: %s\n\n' % ' '.join(self.default_targets or self.all_targets))
|
||||
self.output.write('clean: \n\trm -f %s\n\n' % ' '.join(self.clean_files))
|
||||
self.output.write('distclean: clean\n\trm -f %s\n' % ' '.join(self.distclean_files))
|
||||
|
||||
class Ninja(ninja_syntax.Writer):
|
||||
def __init__(self):
|
||||
ninja_syntax.Writer.__init__(self, open(self.output_filename(), 'w'))
|
||||
|
||||
def output_filename(self):
|
||||
return 'build.ninja'
|
||||
|
||||
def finish(self):
|
||||
pass
|
||||
|
||||
def from_name(name):
|
||||
if name == 'make':
|
||||
return Make()
|
||||
if name == 'ninja':
|
||||
return Ninja()
|
||||
raise LookupError, 'unknown generator: %s; supported generators are make and ninja' % name
|
||||
@@ -1,110 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""Python module for generating .ninja files.
|
||||
|
||||
Note that this is emphatically not a required piece of Ninja; it's
|
||||
just a helpful utility for build-file-generation systems that already
|
||||
use Python.
|
||||
"""
|
||||
|
||||
import textwrap
|
||||
|
||||
class Writer(object):
|
||||
def __init__(self, output, width=78):
|
||||
self.output = output
|
||||
self.width = width
|
||||
|
||||
def newline(self):
|
||||
self.output.write('\n')
|
||||
|
||||
def comment(self, text):
|
||||
for line in textwrap.wrap(text, self.width - 2):
|
||||
self.output.write('# ' + line + '\n')
|
||||
|
||||
def variable(self, key, value, indent=0):
|
||||
if value is None:
|
||||
return
|
||||
if isinstance(value, list):
|
||||
value = ' '.join(value)
|
||||
self._line('%s = %s' % (key, value), indent)
|
||||
|
||||
def rule(self, name, command, description=None, depfile=None,
|
||||
generator=False):
|
||||
self._line('rule %s' % name)
|
||||
self.variable('command', command, indent=1)
|
||||
if description:
|
||||
self.variable('description', description, indent=1)
|
||||
if depfile:
|
||||
self.variable('depfile', depfile, indent=1)
|
||||
if generator:
|
||||
self.variable('generator', '1', indent=1)
|
||||
|
||||
def build(self, outputs, rule, inputs=None, implicit=None, order_only=None,
|
||||
variables=None):
|
||||
outputs = self._as_list(outputs)
|
||||
all_inputs = self._as_list(inputs)[:]
|
||||
|
||||
if implicit:
|
||||
all_inputs.append('|')
|
||||
all_inputs.extend(self._as_list(implicit))
|
||||
if order_only:
|
||||
all_inputs.append('||')
|
||||
all_inputs.extend(self._as_list(order_only))
|
||||
|
||||
self._line('build %s: %s %s' % (' '.join(outputs),
|
||||
rule,
|
||||
' '.join(all_inputs)))
|
||||
|
||||
if variables:
|
||||
for key, val in variables:
|
||||
self.variable(key, val, indent=1)
|
||||
|
||||
return outputs
|
||||
|
||||
def include(self, path):
|
||||
self._line('include %s' % path)
|
||||
|
||||
def subninja(self, path):
|
||||
self._line('subninja %s' % path)
|
||||
|
||||
def default(self, paths):
|
||||
self._line('default %s' % ' '.join(self._as_list(paths)))
|
||||
|
||||
def _line(self, text, indent=0):
|
||||
"""Write 'text' word-wrapped at self.width characters."""
|
||||
leading_space = ' ' * indent
|
||||
while len(text) > self.width:
|
||||
# The text is too wide; wrap if possible.
|
||||
|
||||
# Find the rightmost space that would obey our width constraint.
|
||||
available_space = self.width - len(leading_space) - len(' $')
|
||||
space = text.rfind(' ', 0, available_space)
|
||||
if space < 0:
|
||||
# No such space; just use the first space we can find.
|
||||
space = text.find(' ', available_space)
|
||||
if space < 0:
|
||||
# Give up on breaking.
|
||||
break
|
||||
|
||||
self.output.write(leading_space + text[0:space] + ' $\n')
|
||||
text = text[space+1:]
|
||||
|
||||
# Subsequent lines are continuations, so indent them.
|
||||
leading_space = ' ' * (indent+2)
|
||||
|
||||
self.output.write(leading_space + text + '\n')
|
||||
|
||||
def _as_list(self, input):
|
||||
if input is None:
|
||||
return []
|
||||
if isinstance(input, list):
|
||||
return input
|
||||
return [input]
|
||||
|
||||
|
||||
def escape(string):
|
||||
"""Escape a string such that it can be embedded into a Ninja file without
|
||||
further interpretation."""
|
||||
assert '\n' not in string, 'Ninja syntax does not allow newlines'
|
||||
# We only have one special metacharacter: '$'.
|
||||
return string.replace('$', '$$')
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
clang -ccc-host-triple nvptx--nvidiacl -Iptx-nvidiacl/include -Igeneric/include -Xclang -mlink-bitcode-file -Xclang nvptx--nvidiacl/lib/builtins.bc -include clc/clc.h -Dcl_clang_storage_class_specifiers -Dcl_khr_fp64 "$@"
|
||||
@@ -1,149 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
def c_compiler_rule(b, name, description, compiler, flags):
|
||||
command = "%s -MMD -MF $out.d %s -c -o $out $in" % (compiler, flags)
|
||||
b.rule(name, command, description + " $out", depfile="$out.d")
|
||||
|
||||
from optparse import OptionParser
|
||||
import os
|
||||
from subprocess import *
|
||||
import sys
|
||||
|
||||
srcdir = os.path.dirname(sys.argv[0])
|
||||
|
||||
sys.path.insert(0, os.path.join(srcdir, 'build'))
|
||||
import metabuild
|
||||
|
||||
p = OptionParser()
|
||||
p.add_option('--with-llvm-config', metavar='PATH',
|
||||
help='use given llvm-config script')
|
||||
p.add_option('--prefix', metavar='PATH',
|
||||
help='install to given prefix')
|
||||
p.add_option('-g', metavar='GENERATOR', default='make',
|
||||
help='use given generator (default: make)')
|
||||
(options, args) = p.parse_args()
|
||||
|
||||
llvm_config_exe = options.with_llvm_config or "llvm-config"
|
||||
|
||||
def llvm_config(args):
|
||||
try:
|
||||
proc = Popen([llvm_config_exe] + args, stdout=PIPE)
|
||||
return proc.communicate()[0].rstrip().replace('\n', ' ')
|
||||
except OSError:
|
||||
print "Error executing llvm-config."
|
||||
print "Please ensure that llvm-config is in your $PATH, or use --with-llvm-config."
|
||||
sys.exit(1)
|
||||
|
||||
llvm_bindir = llvm_config(['--bindir'])
|
||||
llvm_core_libs = llvm_config(['--ldflags', '--libs', 'core', 'bitreader', 'bitwriter'])
|
||||
llvm_cxxflags = llvm_config(['--cxxflags']) + ' -fno-exceptions -fno-rtti'
|
||||
|
||||
llvm_clang = os.path.join(llvm_bindir, 'clang')
|
||||
llvm_link = os.path.join(llvm_bindir, 'llvm-link')
|
||||
llvm_opt = os.path.join(llvm_bindir, 'opt')
|
||||
|
||||
default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl']
|
||||
|
||||
targets = args
|
||||
if not targets:
|
||||
targets = default_targets
|
||||
|
||||
b = metabuild.from_name(options.g)
|
||||
|
||||
b.rule("LLVM_AS", "%s -o $out $in" % os.path.join(llvm_bindir, "llvm-as"),
|
||||
'LLVM-AS $out')
|
||||
b.rule("LLVM_LINK", command = llvm_link + " -o $out $in",
|
||||
description = 'LLVM-LINK $out')
|
||||
b.rule("OPT", command = llvm_opt + " -O3 -o $out $in",
|
||||
description = 'OPT $out')
|
||||
|
||||
c_compiler_rule(b, "LLVM_TOOL_CXX", 'CXX', 'c++', llvm_cxxflags)
|
||||
b.rule("LLVM_TOOL_LINK", "c++ -o $out $in %s" % llvm_core_libs, 'LINK $out')
|
||||
|
||||
prepare_builtins = os.path.join('utils', 'prepare-builtins')
|
||||
b.build(os.path.join('utils', 'prepare-builtins.o'), "LLVM_TOOL_CXX",
|
||||
os.path.join(srcdir, 'utils', 'prepare-builtins.cpp'))
|
||||
b.build(prepare_builtins, "LLVM_TOOL_LINK",
|
||||
os.path.join('utils', 'prepare-builtins.o'))
|
||||
|
||||
b.rule("PREPARE_BUILTINS", "%s -o $out $in" % prepare_builtins,
|
||||
'PREPARE-BUILTINS $out')
|
||||
|
||||
manifest_deps = set([sys.argv[0], os.path.join(srcdir, 'build', 'metabuild.py'),
|
||||
os.path.join(srcdir, 'build', 'ninja_syntax.py')])
|
||||
|
||||
install_files = []
|
||||
install_deps = []
|
||||
|
||||
for target in targets:
|
||||
(t_arch, t_vendor, t_os) = target.split('-')
|
||||
archs = [t_arch]
|
||||
if t_arch == 'nvptx' or t_arch == 'nvptx64':
|
||||
archs.append('ptx')
|
||||
archs.append('generic')
|
||||
|
||||
subdirs = []
|
||||
for arch in archs:
|
||||
subdirs.append("%s-%s-%s" % (arch, t_vendor, t_os))
|
||||
subdirs.append("%s-%s" % (arch, t_os))
|
||||
subdirs.append(arch)
|
||||
|
||||
incdirs = filter(os.path.isdir,
|
||||
[os.path.join(srcdir, subdir, 'include') for subdir in subdirs])
|
||||
libdirs = filter(lambda d: os.path.isfile(os.path.join(d, 'SOURCES')),
|
||||
[os.path.join(srcdir, subdir, 'lib') for subdir in subdirs])
|
||||
|
||||
clang_cl_includes = ' '.join(["-I%s" % incdir for incdir in incdirs])
|
||||
install_files += [(incdir, incdir[len(srcdir)+1:]) for incdir in incdirs]
|
||||
|
||||
# The rule for building a .bc file for the specified architecture using clang.
|
||||
clang_bc_flags = "-ccc-host-triple %s -I`dirname $in` %s " \
|
||||
"-Dcl_clang_storage_class_specifiers " \
|
||||
"-Dcl_khr_fp64 " \
|
||||
"-emit-llvm" % (target, clang_cl_includes)
|
||||
clang_bc_rule = "CLANG_CL_BC_" + target
|
||||
c_compiler_rule(b, clang_bc_rule, "LLVM-CC", llvm_clang, clang_bc_flags)
|
||||
|
||||
objects = []
|
||||
sources_seen = set()
|
||||
|
||||
for libdir in libdirs:
|
||||
subdir_list_file = os.path.join(libdir, 'SOURCES')
|
||||
manifest_deps.add(subdir_list_file)
|
||||
for src in open(subdir_list_file).readlines():
|
||||
src = src.rstrip()
|
||||
if src not in sources_seen:
|
||||
sources_seen.add(src)
|
||||
obj = os.path.join(target, 'lib', src + '.bc')
|
||||
objects.append(obj)
|
||||
src_file = os.path.join(libdir, src)
|
||||
ext = os.path.splitext(src)[1]
|
||||
if ext == '.ll':
|
||||
b.build(obj, 'LLVM_AS', src_file)
|
||||
else:
|
||||
b.build(obj, clang_bc_rule, src_file)
|
||||
|
||||
builtins_link_bc = os.path.join(target, 'lib', 'builtins.link.bc')
|
||||
builtins_opt_bc = os.path.join(target, 'lib', 'builtins.opt.bc')
|
||||
builtins_bc = os.path.join(target, 'lib', 'builtins.bc')
|
||||
b.build(builtins_link_bc, "LLVM_LINK", objects)
|
||||
b.build(builtins_opt_bc, "OPT", builtins_link_bc)
|
||||
b.build(builtins_bc, "PREPARE_BUILTINS", builtins_opt_bc, prepare_builtins)
|
||||
install_files.append((builtins_bc, builtins_bc))
|
||||
install_deps.append(builtins_bc)
|
||||
b.default(builtins_bc)
|
||||
|
||||
if options.prefix:
|
||||
install_cmd = ' && '.join(['mkdir -p %(dst)s && cp -r %(src)s %(dst)s' %
|
||||
{'src': file,
|
||||
'dst': os.path.join(options.prefix,
|
||||
os.path.dirname(dest))}
|
||||
for (file, dest) in install_files])
|
||||
b.rule('install', command = install_cmd, description = 'INSTALL')
|
||||
b.build('install', 'install', install_deps)
|
||||
|
||||
b.rule("configure", command = ' '.join(sys.argv), description = 'CONFIGURE',
|
||||
generator = True)
|
||||
b.build(b.output_filename(), 'configure', list(manifest_deps))
|
||||
|
||||
b.finish()
|
||||
@@ -1,53 +0,0 @@
|
||||
#define as_char(x) __builtin_astype(x, char)
|
||||
#define as_uchar(x) __builtin_astype(x, uchar)
|
||||
#define as_short(x) __builtin_astype(x, short)
|
||||
#define as_ushort(x) __builtin_astype(x, ushort)
|
||||
#define as_int(x) __builtin_astype(x, int)
|
||||
#define as_uint(x) __builtin_astype(x, uint)
|
||||
#define as_long(x) __builtin_astype(x, long)
|
||||
#define as_ulong(x) __builtin_astype(x, ulong)
|
||||
|
||||
#define as_char2(x) __builtin_astype(x, char2)
|
||||
#define as_uchar2(x) __builtin_astype(x, uchar2)
|
||||
#define as_short2(x) __builtin_astype(x, short2)
|
||||
#define as_ushort2(x) __builtin_astype(x, ushort2)
|
||||
#define as_int2(x) __builtin_astype(x, int2)
|
||||
#define as_uint2(x) __builtin_astype(x, uint2)
|
||||
#define as_long2(x) __builtin_astype(x, long2)
|
||||
#define as_ulong2(x) __builtin_astype(x, ulong2)
|
||||
|
||||
#define as_char3(x) __builtin_astype(x, char3)
|
||||
#define as_uchar3(x) __builtin_astype(x, uchar3)
|
||||
#define as_short3(x) __builtin_astype(x, short3)
|
||||
#define as_ushort3(x) __builtin_astype(x, ushort3)
|
||||
#define as_int3(x) __builtin_astype(x, int3)
|
||||
#define as_uint3(x) __builtin_astype(x, uint3)
|
||||
#define as_long3(x) __builtin_astype(x, long3)
|
||||
#define as_ulong3(x) __builtin_astype(x, ulong3)
|
||||
|
||||
#define as_char4(x) __builtin_astype(x, char4)
|
||||
#define as_uchar4(x) __builtin_astype(x, uchar4)
|
||||
#define as_short4(x) __builtin_astype(x, short4)
|
||||
#define as_ushort4(x) __builtin_astype(x, ushort4)
|
||||
#define as_int4(x) __builtin_astype(x, int4)
|
||||
#define as_uint4(x) __builtin_astype(x, uint4)
|
||||
#define as_long4(x) __builtin_astype(x, long4)
|
||||
#define as_ulong4(x) __builtin_astype(x, ulong4)
|
||||
|
||||
#define as_char8(x) __builtin_astype(x, char8)
|
||||
#define as_uchar8(x) __builtin_astype(x, uchar8)
|
||||
#define as_short8(x) __builtin_astype(x, short8)
|
||||
#define as_ushort8(x) __builtin_astype(x, ushort8)
|
||||
#define as_int8(x) __builtin_astype(x, int8)
|
||||
#define as_uint8(x) __builtin_astype(x, uint8)
|
||||
#define as_long8(x) __builtin_astype(x, long8)
|
||||
#define as_ulong8(x) __builtin_astype(x, ulong8)
|
||||
|
||||
#define as_char16(x) __builtin_astype(x, char16)
|
||||
#define as_uchar16(x) __builtin_astype(x, uchar16)
|
||||
#define as_short16(x) __builtin_astype(x, short16)
|
||||
#define as_ushort16(x) __builtin_astype(x, ushort16)
|
||||
#define as_int16(x) __builtin_astype(x, int16)
|
||||
#define as_uint16(x) __builtin_astype(x, uint16)
|
||||
#define as_long16(x) __builtin_astype(x, long16)
|
||||
#define as_ulong16(x) __builtin_astype(x, ulong16)
|
||||
@@ -1,79 +0,0 @@
|
||||
#ifndef cl_clang_storage_class_specifiers
|
||||
#error Implementation requires cl_clang_storage_class_specifiers extension!
|
||||
#endif
|
||||
|
||||
#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
#endif
|
||||
|
||||
/* Function Attributes */
|
||||
#include <clc/clcfunc.h>
|
||||
|
||||
/* Pattern Macro Definitions */
|
||||
#include <clc/clcmacro.h>
|
||||
|
||||
/* 6.1 Supported Data Types */
|
||||
#include <clc/clctypes.h>
|
||||
|
||||
/* 6.2.3 Explicit Conversions */
|
||||
#include <clc/convert.h>
|
||||
|
||||
/* 6.2.4.2 Reinterpreting Types Using as_type() and as_typen() */
|
||||
#include <clc/as_type.h>
|
||||
|
||||
/* 6.11.1 Work-Item Functions */
|
||||
#include <clc/workitem/get_global_size.h>
|
||||
#include <clc/workitem/get_global_id.h>
|
||||
#include <clc/workitem/get_local_size.h>
|
||||
#include <clc/workitem/get_local_id.h>
|
||||
#include <clc/workitem/get_num_groups.h>
|
||||
#include <clc/workitem/get_group_id.h>
|
||||
|
||||
/* 6.11.2 Math Functions */
|
||||
#include <clc/math/cos.h>
|
||||
#include <clc/math/exp.h>
|
||||
#include <clc/math/exp2.h>
|
||||
#include <clc/math/fabs.h>
|
||||
#include <clc/math/floor.h>
|
||||
#include <clc/math/fma.h>
|
||||
#include <clc/math/hypot.h>
|
||||
#include <clc/math/log.h>
|
||||
#include <clc/math/log2.h>
|
||||
#include <clc/math/mad.h>
|
||||
#include <clc/math/pow.h>
|
||||
#include <clc/math/sin.h>
|
||||
#include <clc/math/sqrt.h>
|
||||
#include <clc/math/native_cos.h>
|
||||
#include <clc/math/native_divide.h>
|
||||
#include <clc/math/native_exp.h>
|
||||
#include <clc/math/native_exp2.h>
|
||||
#include <clc/math/native_log.h>
|
||||
#include <clc/math/native_log2.h>
|
||||
#include <clc/math/native_powr.h>
|
||||
#include <clc/math/native_sin.h>
|
||||
#include <clc/math/native_sqrt.h>
|
||||
#include <clc/math/rsqrt.h>
|
||||
|
||||
/* 6.11.3 Integer Functions */
|
||||
#include <clc/integer/abs.h>
|
||||
#include <clc/integer/abs_diff.h>
|
||||
#include <clc/integer/add_sat.h>
|
||||
#include <clc/integer/sub_sat.h>
|
||||
|
||||
/* 6.11.5 Geometric Functions */
|
||||
#include <clc/geometric/cross.h>
|
||||
#include <clc/geometric/dot.h>
|
||||
#include <clc/geometric/length.h>
|
||||
#include <clc/geometric/normalize.h>
|
||||
|
||||
/* 6.11.6 Relational Functions */
|
||||
#include <clc/relational/any.h>
|
||||
#include <clc/relational/select.h>
|
||||
|
||||
/* 6.11.8 Synchronization Functions */
|
||||
#include <clc/synchronization/cl_mem_fence_flags.h>
|
||||
#include <clc/synchronization/barrier.h>
|
||||
|
||||
#pragma OPENCL EXTENSION all : disable
|
||||
@@ -1,4 +0,0 @@
|
||||
#define _CLC_OVERLOAD __attribute__((overloadable))
|
||||
#define _CLC_DECL
|
||||
#define _CLC_DEF __attribute__((always_inline))
|
||||
#define _CLC_INLINE __attribute__((always_inline)) static inline
|
||||
@@ -1,42 +0,0 @@
|
||||
#define _CLC_UNARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE) \
|
||||
DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x) { \
|
||||
return (RET_TYPE##2)(FUNCTION(x.x), FUNCTION(x.y)); \
|
||||
} \
|
||||
\
|
||||
DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x) { \
|
||||
return (RET_TYPE##3)(FUNCTION(x.x), FUNCTION(x.y), FUNCTION(x.z)); \
|
||||
} \
|
||||
\
|
||||
DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x) { \
|
||||
return (RET_TYPE##4)(FUNCTION(x.lo), FUNCTION(x.hi)); \
|
||||
} \
|
||||
\
|
||||
DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x) { \
|
||||
return (RET_TYPE##8)(FUNCTION(x.lo), FUNCTION(x.hi)); \
|
||||
} \
|
||||
\
|
||||
DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x) { \
|
||||
return (RET_TYPE##16)(FUNCTION(x.lo), FUNCTION(x.hi)); \
|
||||
}
|
||||
|
||||
#define _CLC_BINARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \
|
||||
DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 y) { \
|
||||
return (RET_TYPE##2)(FUNCTION(x.x, y.x), FUNCTION(x.y, y.y)); \
|
||||
} \
|
||||
\
|
||||
DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ARG2_TYPE##3 y) { \
|
||||
return (RET_TYPE##3)(FUNCTION(x.x, y.x), FUNCTION(x.y, y.y), \
|
||||
FUNCTION(x.z, y.z)); \
|
||||
} \
|
||||
\
|
||||
DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ARG2_TYPE##4 y) { \
|
||||
return (RET_TYPE##4)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
|
||||
} \
|
||||
\
|
||||
DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ARG2_TYPE##8 y) { \
|
||||
return (RET_TYPE##8)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
|
||||
} \
|
||||
\
|
||||
DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, ARG2_TYPE##16 y) { \
|
||||
return (RET_TYPE##16)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/* 6.1.1 Built-in Scalar Data Types */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long ulong;
|
||||
|
||||
/* 6.1.2 Built-in Vector Data Types */
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) char char2;
|
||||
typedef __attribute__((ext_vector_type(3))) char char3;
|
||||
typedef __attribute__((ext_vector_type(4))) char char4;
|
||||
typedef __attribute__((ext_vector_type(8))) char char8;
|
||||
typedef __attribute__((ext_vector_type(16))) char char16;
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) uchar uchar2;
|
||||
typedef __attribute__((ext_vector_type(3))) uchar uchar3;
|
||||
typedef __attribute__((ext_vector_type(4))) uchar uchar4;
|
||||
typedef __attribute__((ext_vector_type(8))) uchar uchar8;
|
||||
typedef __attribute__((ext_vector_type(16))) uchar uchar16;
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) short short2;
|
||||
typedef __attribute__((ext_vector_type(3))) short short3;
|
||||
typedef __attribute__((ext_vector_type(4))) short short4;
|
||||
typedef __attribute__((ext_vector_type(8))) short short8;
|
||||
typedef __attribute__((ext_vector_type(16))) short short16;
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) ushort ushort2;
|
||||
typedef __attribute__((ext_vector_type(3))) ushort ushort3;
|
||||
typedef __attribute__((ext_vector_type(4))) ushort ushort4;
|
||||
typedef __attribute__((ext_vector_type(8))) ushort ushort8;
|
||||
typedef __attribute__((ext_vector_type(16))) ushort ushort16;
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) int int2;
|
||||
typedef __attribute__((ext_vector_type(3))) int int3;
|
||||
typedef __attribute__((ext_vector_type(4))) int int4;
|
||||
typedef __attribute__((ext_vector_type(8))) int int8;
|
||||
typedef __attribute__((ext_vector_type(16))) int int16;
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) uint uint2;
|
||||
typedef __attribute__((ext_vector_type(3))) uint uint3;
|
||||
typedef __attribute__((ext_vector_type(4))) uint uint4;
|
||||
typedef __attribute__((ext_vector_type(8))) uint uint8;
|
||||
typedef __attribute__((ext_vector_type(16))) uint uint16;
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) long long2;
|
||||
typedef __attribute__((ext_vector_type(3))) long long3;
|
||||
typedef __attribute__((ext_vector_type(4))) long long4;
|
||||
typedef __attribute__((ext_vector_type(8))) long long8;
|
||||
typedef __attribute__((ext_vector_type(16))) long long16;
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) ulong ulong2;
|
||||
typedef __attribute__((ext_vector_type(3))) ulong ulong3;
|
||||
typedef __attribute__((ext_vector_type(4))) ulong ulong4;
|
||||
typedef __attribute__((ext_vector_type(8))) ulong ulong8;
|
||||
typedef __attribute__((ext_vector_type(16))) ulong ulong16;
|
||||
|
||||
typedef __attribute__((ext_vector_type(2))) float float2;
|
||||
typedef __attribute__((ext_vector_type(3))) float float3;
|
||||
typedef __attribute__((ext_vector_type(4))) float float4;
|
||||
typedef __attribute__((ext_vector_type(8))) float float8;
|
||||
typedef __attribute__((ext_vector_type(16))) float float16;
|
||||
|
||||
/* 9.3 Double Precision Floating-Point */
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
typedef __attribute__((ext_vector_type(2))) double double2;
|
||||
typedef __attribute__((ext_vector_type(3))) double double3;
|
||||
typedef __attribute__((ext_vector_type(4))) double double4;
|
||||
typedef __attribute__((ext_vector_type(8))) double double8;
|
||||
typedef __attribute__((ext_vector_type(16))) double double16;
|
||||
#endif
|
||||
@@ -1,82 +0,0 @@
|
||||
#define _CLC_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \
|
||||
_CLC_OVERLOAD _CLC_DECL TO_TYPE convert_##TO_TYPE##SUFFIX(FROM_TYPE x);
|
||||
|
||||
_CLC_CONVERT_DECL(long, char, )
|
||||
_CLC_CONVERT_DECL(ulong, uchar, )
|
||||
_CLC_CONVERT_DECL(long, short, )
|
||||
_CLC_CONVERT_DECL(ulong, ushort, )
|
||||
_CLC_CONVERT_DECL(long, int, )
|
||||
_CLC_CONVERT_DECL(ulong, uint, )
|
||||
_CLC_CONVERT_DECL(long, long, )
|
||||
_CLC_CONVERT_DECL(ulong, ulong, )
|
||||
#ifdef cl_khr_fp64
|
||||
_CLC_CONVERT_DECL(double, float, )
|
||||
_CLC_CONVERT_DECL(double, double, )
|
||||
#else
|
||||
_CLC_CONVERT_DECL(float, float, )
|
||||
#endif
|
||||
|
||||
_CLC_CONVERT_DECL(long, char, _sat)
|
||||
_CLC_CONVERT_DECL(ulong, uchar, _sat)
|
||||
_CLC_CONVERT_DECL(long, short, _sat)
|
||||
_CLC_CONVERT_DECL(ulong, ushort, _sat)
|
||||
_CLC_CONVERT_DECL(long, int, _sat)
|
||||
_CLC_CONVERT_DECL(ulong, uint, _sat)
|
||||
_CLC_CONVERT_DECL(long, long, _sat)
|
||||
_CLC_CONVERT_DECL(ulong, ulong, _sat)
|
||||
#ifdef cl_khr_fp64
|
||||
_CLC_CONVERT_DECL(double, float, _sat)
|
||||
_CLC_CONVERT_DECL(double, double, _sat)
|
||||
#else
|
||||
_CLC_CONVERT_DECL(float, float, _sat)
|
||||
#endif
|
||||
|
||||
#define _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE##2, TO_TYPE##2, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE##3, TO_TYPE##3, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE##4, TO_TYPE##4, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE##8, TO_TYPE##8, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE##16, TO_TYPE##16, SUFFIX)
|
||||
|
||||
#define _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, char, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, uchar, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, int, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, uint, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, short, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, ushort, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, long, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, ulong, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, float, SUFFIX)
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, double, SUFFIX)
|
||||
#else
|
||||
#define _CLC_VECTOR_CONVERT_FROM(FROM_TYPE, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX)
|
||||
#endif
|
||||
|
||||
#define _CLC_VECTOR_CONVERT_TO1(SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(char, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(uchar, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(int, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(uint, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(short, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(ushort, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(long, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(ulong, SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(float, SUFFIX)
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#define _CLC_VECTOR_CONVERT_TO(SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_TO1(SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_FROM(double, SUFFIX)
|
||||
#else
|
||||
#define _CLC_VECTOR_CONVERT_TO(SUFFIX) \
|
||||
_CLC_VECTOR_CONVERT_TO1(SUFFIX)
|
||||
#endif
|
||||
|
||||
_CLC_VECTOR_CONVERT_TO()
|
||||
_CLC_VECTOR_CONVERT_TO(_sat)
|
||||
@@ -1,51 +0,0 @@
|
||||
#define GENTYPE float
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#define GENTYPE double
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#endif
|
||||
|
||||
#undef BODY
|
||||
@@ -1,2 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL float3 cross(float3 p0, float3 p1);
|
||||
_CLC_OVERLOAD _CLC_DECL float4 cross(float4 p0, float4 p1);
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/geometric/distance.inc>
|
||||
#include <clc/geometric/floatn.inc>
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/geometric/dot.inc>
|
||||
#include <clc/geometric/floatn.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL FLOAT dot(FLOATN p0, FLOATN p1);
|
||||
@@ -1,45 +0,0 @@
|
||||
#define FLOAT float
|
||||
|
||||
#define FLOATN float
|
||||
#include BODY
|
||||
#undef FLOATN
|
||||
|
||||
#define FLOATN float2
|
||||
#include BODY
|
||||
#undef FLOATN
|
||||
|
||||
#define FLOATN float3
|
||||
#include BODY
|
||||
#undef FLOATN
|
||||
|
||||
#define FLOATN float4
|
||||
#include BODY
|
||||
#undef FLOATN
|
||||
|
||||
#undef FLOAT
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
|
||||
#define FLOAT double
|
||||
|
||||
#define FLOATN double
|
||||
#include BODY
|
||||
#undef FLOATN
|
||||
|
||||
#define FLOATN double2
|
||||
#include BODY
|
||||
#undef FLOATN
|
||||
|
||||
#define FLOATN double3
|
||||
#include BODY
|
||||
#undef FLOATN
|
||||
|
||||
#define FLOATN double4
|
||||
#include BODY
|
||||
#undef FLOATN
|
||||
|
||||
#undef FLOAT
|
||||
|
||||
#endif
|
||||
|
||||
#undef BODY
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/geometric/length.inc>
|
||||
#include <clc/geometric/floatn.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL float length(FLOATN p0);
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/geometric/normalize.inc>
|
||||
#include <clc/geometric/floatn.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL FLOATN normalize(FLOATN p);
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/integer/abs.inc>
|
||||
#include <clc/integer/gentype.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL UGENTYPE abs(GENTYPE x);
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/integer/abs_diff.inc>
|
||||
#include <clc/integer/gentype.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL UGENTYPE abs_diff(GENTYPE x, GENTYPE y);
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/integer/add_sat.inc>
|
||||
#include <clc/integer/gentype.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL GENTYPE add_sat(GENTYPE x, GENTYPE y);
|
||||
@@ -1,385 +0,0 @@
|
||||
#define GENTYPE char
|
||||
#define UGENTYPE uchar
|
||||
#define SGENTYPE char
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE char2
|
||||
#define UGENTYPE uchar2
|
||||
#define SGENTYPE char2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE char3
|
||||
#define UGENTYPE uchar3
|
||||
#define SGENTYPE char3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE char4
|
||||
#define UGENTYPE uchar4
|
||||
#define SGENTYPE char4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE char8
|
||||
#define UGENTYPE uchar8
|
||||
#define SGENTYPE char8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE char16
|
||||
#define UGENTYPE uchar16
|
||||
#define SGENTYPE char16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uchar
|
||||
#define UGENTYPE uchar
|
||||
#define SGENTYPE char
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uchar2
|
||||
#define UGENTYPE uchar2
|
||||
#define SGENTYPE char2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uchar3
|
||||
#define UGENTYPE uchar3
|
||||
#define SGENTYPE char3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uchar4
|
||||
#define UGENTYPE uchar4
|
||||
#define SGENTYPE char4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uchar8
|
||||
#define UGENTYPE uchar8
|
||||
#define SGENTYPE char8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uchar16
|
||||
#define UGENTYPE uchar16
|
||||
#define SGENTYPE char16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE short
|
||||
#define UGENTYPE ushort
|
||||
#define SGENTYPE short
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE short2
|
||||
#define UGENTYPE ushort2
|
||||
#define SGENTYPE short2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE short3
|
||||
#define UGENTYPE ushort3
|
||||
#define SGENTYPE short3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE short4
|
||||
#define UGENTYPE ushort4
|
||||
#define SGENTYPE short4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE short8
|
||||
#define UGENTYPE ushort8
|
||||
#define SGENTYPE short8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE short16
|
||||
#define UGENTYPE ushort16
|
||||
#define SGENTYPE short16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ushort
|
||||
#define UGENTYPE ushort
|
||||
#define SGENTYPE short
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ushort2
|
||||
#define UGENTYPE ushort2
|
||||
#define SGENTYPE short2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ushort3
|
||||
#define UGENTYPE ushort3
|
||||
#define SGENTYPE short3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ushort4
|
||||
#define UGENTYPE ushort4
|
||||
#define SGENTYPE short4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ushort8
|
||||
#define UGENTYPE ushort8
|
||||
#define SGENTYPE short8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ushort16
|
||||
#define UGENTYPE ushort16
|
||||
#define SGENTYPE short16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE int
|
||||
#define UGENTYPE uint
|
||||
#define SGENTYPE int
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE int2
|
||||
#define UGENTYPE uint2
|
||||
#define SGENTYPE int2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE int3
|
||||
#define UGENTYPE uint3
|
||||
#define SGENTYPE int3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE int4
|
||||
#define UGENTYPE uint4
|
||||
#define SGENTYPE int4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE int8
|
||||
#define UGENTYPE uint8
|
||||
#define SGENTYPE int8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE int16
|
||||
#define UGENTYPE uint16
|
||||
#define SGENTYPE int16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uint
|
||||
#define UGENTYPE uint
|
||||
#define SGENTYPE int
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uint2
|
||||
#define UGENTYPE uint2
|
||||
#define SGENTYPE int2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uint3
|
||||
#define UGENTYPE uint3
|
||||
#define SGENTYPE int3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uint4
|
||||
#define UGENTYPE uint4
|
||||
#define SGENTYPE int4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uint8
|
||||
#define UGENTYPE uint8
|
||||
#define SGENTYPE int8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE uint16
|
||||
#define UGENTYPE uint16
|
||||
#define SGENTYPE int16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE long
|
||||
#define UGENTYPE ulong
|
||||
#define SGENTYPE long
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE long2
|
||||
#define UGENTYPE ulong2
|
||||
#define SGENTYPE long2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE long3
|
||||
#define UGENTYPE ulong3
|
||||
#define SGENTYPE long3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE long4
|
||||
#define UGENTYPE ulong4
|
||||
#define SGENTYPE long4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE long8
|
||||
#define UGENTYPE ulong8
|
||||
#define SGENTYPE long8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE long16
|
||||
#define UGENTYPE ulong16
|
||||
#define SGENTYPE long16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ulong
|
||||
#define UGENTYPE ulong
|
||||
#define SGENTYPE long
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ulong2
|
||||
#define UGENTYPE ulong2
|
||||
#define SGENTYPE long2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ulong3
|
||||
#define UGENTYPE ulong3
|
||||
#define SGENTYPE long3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ulong4
|
||||
#define UGENTYPE ulong4
|
||||
#define SGENTYPE long4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ulong8
|
||||
#define UGENTYPE ulong8
|
||||
#define SGENTYPE long8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#define GENTYPE ulong16
|
||||
#define UGENTYPE ulong16
|
||||
#define SGENTYPE long16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#undef UGENTYPE
|
||||
#undef SGENTYPE
|
||||
|
||||
#undef BODY
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/integer/sub_sat.inc>
|
||||
#include <clc/integer/gentype.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL GENTYPE sub_sat(GENTYPE x, GENTYPE y);
|
||||
@@ -1,18 +0,0 @@
|
||||
_CLC_OVERLOAD float FUNCTION(float, float) __asm(INTRINSIC ".f32");
|
||||
_CLC_OVERLOAD float2 FUNCTION(float2, float2) __asm(INTRINSIC ".v2f32");
|
||||
_CLC_OVERLOAD float3 FUNCTION(float3, float3) __asm(INTRINSIC ".v3f32");
|
||||
_CLC_OVERLOAD float4 FUNCTION(float4, float4) __asm(INTRINSIC ".v4f32");
|
||||
_CLC_OVERLOAD float8 FUNCTION(float8, float8) __asm(INTRINSIC ".v8f32");
|
||||
_CLC_OVERLOAD float16 FUNCTION(float16, float16) __asm(INTRINSIC ".v16f32");
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
_CLC_OVERLOAD double FUNCTION(double, double) __asm(INTRINSIC ".f64");
|
||||
_CLC_OVERLOAD double2 FUNCTION(double2, double2) __asm(INTRINSIC ".v2f64");
|
||||
_CLC_OVERLOAD double3 FUNCTION(double3, double3) __asm(INTRINSIC ".v3f64");
|
||||
_CLC_OVERLOAD double4 FUNCTION(double4, double4) __asm(INTRINSIC ".v4f64");
|
||||
_CLC_OVERLOAD double8 FUNCTION(double8, double8) __asm(INTRINSIC ".v8f64");
|
||||
_CLC_OVERLOAD double16 FUNCTION(double16, double16) __asm(INTRINSIC ".v16f64");
|
||||
#endif
|
||||
|
||||
#undef FUNCTION
|
||||
#undef INTRINSIC
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef cos
|
||||
#define cos __clc_cos
|
||||
|
||||
#define FUNCTION __clc_cos
|
||||
#define INTRINSIC "llvm.cos"
|
||||
#include <clc/math/unary_intrin.inc>
|
||||
@@ -1,4 +0,0 @@
|
||||
#undef exp
|
||||
|
||||
// exp(x) = exp2(x * log2(e)
|
||||
#define exp(val) (__clc_exp2((val) * 1.44269504f))
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef exp2
|
||||
#define exp2 __clc_exp2
|
||||
|
||||
#define FUNCTION __clc_exp2
|
||||
#define INTRINSIC "llvm.exp2"
|
||||
#include <clc/math/unary_intrin.inc>
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef fabs
|
||||
#define fabs __clc_fabs
|
||||
|
||||
#define FUNCTION __clc_fabs
|
||||
#define INTRINSIC "llvm.fabs"
|
||||
#include <clc/math/unary_intrin.inc>
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef floor
|
||||
#define floor __clc_floor
|
||||
|
||||
#define FUNCTION __clc_floor
|
||||
#define INTRINSIC "llvm.floor"
|
||||
#include <clc/math/unary_intrin.inc>
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef fma
|
||||
#define fma __clc_fma
|
||||
|
||||
#define FUNCTION __clc_fma
|
||||
#define INTRINSIC "llvm.fma"
|
||||
#include <clc/math/ternary_intrin.inc>
|
||||
@@ -1,51 +0,0 @@
|
||||
#define GENTYPE float
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE float16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#define GENTYPE double
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double2
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double3
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double4
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double8
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
|
||||
#define GENTYPE double16
|
||||
#include BODY
|
||||
#undef GENTYPE
|
||||
#endif
|
||||
|
||||
#undef BODY
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/math/hypot.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL GENTYPE hypot(GENTYPE x, GENTYPE y);
|
||||
@@ -1,4 +0,0 @@
|
||||
#undef log
|
||||
|
||||
// log(x) = log2(x) * (1/log2(e))
|
||||
#define log(val) (__clc_log2(val) * 0.693147181f)
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef log2
|
||||
#define log2 __clc_log2
|
||||
|
||||
#define FUNCTION __clc_log2
|
||||
#define INTRINSIC "llvm.log2"
|
||||
#include <clc/math/unary_intrin.inc>
|
||||
@@ -1,2 +0,0 @@
|
||||
#define BODY <clc/math/mad.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL GENTYPE mad(GENTYPE a, GENTYPE b, GENTYPE c);
|
||||
@@ -1 +0,0 @@
|
||||
#define native_cos cos
|
||||
@@ -1 +0,0 @@
|
||||
#define native_divide(x, y) ((x) / (y))
|
||||
@@ -1 +0,0 @@
|
||||
#define native_exp exp
|
||||
@@ -1 +0,0 @@
|
||||
#define native_exp2 exp2
|
||||
@@ -1 +0,0 @@
|
||||
#define native_log log
|
||||
@@ -1 +0,0 @@
|
||||
#define native_log2 log2
|
||||
@@ -1 +0,0 @@
|
||||
#define native_powr pow
|
||||
@@ -1 +0,0 @@
|
||||
#define native_sin sin
|
||||
@@ -1 +0,0 @@
|
||||
#define native_sqrt sqrt
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef pow
|
||||
#define pow __clc_pow
|
||||
|
||||
#define FUNCTION __clc_pow
|
||||
#define INTRINSIC "llvm.pow"
|
||||
#include <clc/math/binary_intrin.inc>
|
||||
@@ -1 +0,0 @@
|
||||
#define rsqrt(x) (1.f/sqrt(x))
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef sin
|
||||
#define sin __clc_sin
|
||||
|
||||
#define FUNCTION __clc_sin
|
||||
#define INTRINSIC "llvm.sin"
|
||||
#include <clc/math/unary_intrin.inc>
|
||||
@@ -1,6 +0,0 @@
|
||||
#undef sqrt
|
||||
#define sqrt __clc_sqrt
|
||||
|
||||
#define FUNCTION __clc_sqrt
|
||||
#define INTRINSIC "llvm.sqrt"
|
||||
#include <clc/math/unary_intrin.inc>
|
||||
@@ -1,18 +0,0 @@
|
||||
_CLC_OVERLOAD float FUNCTION(float, float, float) __asm(INTRINSIC ".f32");
|
||||
_CLC_OVERLOAD float2 FUNCTION(float2, float2, float2) __asm(INTRINSIC ".v2f32");
|
||||
_CLC_OVERLOAD float3 FUNCTION(float3, float3, float3) __asm(INTRINSIC ".v3f32");
|
||||
_CLC_OVERLOAD float4 FUNCTION(float4, float4, float4) __asm(INTRINSIC ".v4f32");
|
||||
_CLC_OVERLOAD float8 FUNCTION(float8, float8, float8) __asm(INTRINSIC ".v8f32");
|
||||
_CLC_OVERLOAD float16 FUNCTION(float16, float16, float16) __asm(INTRINSIC ".v16f32");
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
_CLC_OVERLOAD double FUNCTION(double, double, double) __asm(INTRINSIC ".f64");
|
||||
_CLC_OVERLOAD double2 FUNCTION(double2, double2, double2) __asm(INTRINSIC ".v2f64");
|
||||
_CLC_OVERLOAD double3 FUNCTION(double3, double3, double3) __asm(INTRINSIC ".v3f64");
|
||||
_CLC_OVERLOAD double4 FUNCTION(double4, double4, double4) __asm(INTRINSIC ".v4f64");
|
||||
_CLC_OVERLOAD double8 FUNCTION(double8, double8, double8) __asm(INTRINSIC ".v8f64");
|
||||
_CLC_OVERLOAD double16 FUNCTION(double16, double16, double16) __asm(INTRINSIC ".v16f64");
|
||||
#endif
|
||||
|
||||
#undef FUNCTION
|
||||
#undef INTRINSIC
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE x);
|
||||
@@ -1,18 +0,0 @@
|
||||
_CLC_OVERLOAD float FUNCTION(float f) __asm(INTRINSIC ".f32");
|
||||
_CLC_OVERLOAD float2 FUNCTION(float2 f) __asm(INTRINSIC ".v2f32");
|
||||
_CLC_OVERLOAD float3 FUNCTION(float3 f) __asm(INTRINSIC ".v3f32");
|
||||
_CLC_OVERLOAD float4 FUNCTION(float4 f) __asm(INTRINSIC ".v4f32");
|
||||
_CLC_OVERLOAD float8 FUNCTION(float8 f) __asm(INTRINSIC ".v8f32");
|
||||
_CLC_OVERLOAD float16 FUNCTION(float16 f) __asm(INTRINSIC ".v16f32");
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
_CLC_OVERLOAD double FUNCTION(double d) __asm(INTRINSIC ".f64");
|
||||
_CLC_OVERLOAD double2 FUNCTION(double2 d) __asm(INTRINSIC ".v2f64");
|
||||
_CLC_OVERLOAD double3 FUNCTION(double3 d) __asm(INTRINSIC ".v3f64");
|
||||
_CLC_OVERLOAD double4 FUNCTION(double4 d) __asm(INTRINSIC ".v4f64");
|
||||
_CLC_OVERLOAD double8 FUNCTION(double8 d) __asm(INTRINSIC ".v8f64");
|
||||
_CLC_OVERLOAD double16 FUNCTION(double16 d) __asm(INTRINSIC ".v16f64");
|
||||
#endif
|
||||
|
||||
#undef FUNCTION
|
||||
#undef INTRINSIC
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
#define _CLC_ANY_DECL(TYPE) \
|
||||
_CLC_OVERLOAD _CLC_DECL int any(TYPE v);
|
||||
|
||||
#define _CLC_VECTOR_ANY_DECL(TYPE) \
|
||||
_CLC_ANY_DECL(TYPE) \
|
||||
_CLC_ANY_DECL(TYPE##2) \
|
||||
_CLC_ANY_DECL(TYPE##3) \
|
||||
_CLC_ANY_DECL(TYPE##4) \
|
||||
_CLC_ANY_DECL(TYPE##8) \
|
||||
_CLC_ANY_DECL(TYPE##16)
|
||||
|
||||
_CLC_VECTOR_ANY_DECL(char)
|
||||
_CLC_VECTOR_ANY_DECL(short)
|
||||
_CLC_VECTOR_ANY_DECL(int)
|
||||
_CLC_VECTOR_ANY_DECL(long)
|
||||
@@ -1 +0,0 @@
|
||||
#define select(a, b, c) ((c) ? (b) : (a))
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_DECL void barrier(cl_mem_fence_flags flags);
|
||||
@@ -1,4 +0,0 @@
|
||||
typedef uint cl_mem_fence_flags;
|
||||
|
||||
#define CLK_LOCAL_MEM_FENCE 1
|
||||
#define CLK_GLOBAL_MEM_FENCE 2
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_DECL size_t get_global_id(uint dim);
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_DECL size_t get_global_size(uint dim);
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_DECL size_t get_group_id(uint dim);
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_DECL size_t get_local_id(uint dim);
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_DECL size_t get_local_size(uint dim);
|
||||
@@ -1 +0,0 @@
|
||||
_CLC_DECL size_t get_num_groups(uint dim);
|
||||
@@ -1,17 +0,0 @@
|
||||
convert.cl
|
||||
geometric/cross.cl
|
||||
geometric/dot.cl
|
||||
geometric/length.cl
|
||||
geometric/normalize.cl
|
||||
integer/abs.cl
|
||||
integer/add_sat.cl
|
||||
integer/add_sat.ll
|
||||
integer/add_sat_impl.ll
|
||||
integer/sub_sat.cl
|
||||
integer/sub_sat.ll
|
||||
integer/sub_sat_impl.ll
|
||||
math/hypot.cl
|
||||
math/mad.cl
|
||||
relational/any.cl
|
||||
workitem/get_global_id.cl
|
||||
workitem/get_global_size.cl
|
||||
@@ -1,122 +0,0 @@
|
||||
#include <clc/clc.h>
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
#endif
|
||||
|
||||
#define CONVERT_ID(FROM_TYPE, TO_TYPE, SUFFIX) \
|
||||
_CLC_OVERLOAD _CLC_DEF TO_TYPE convert_##TO_TYPE##SUFFIX(FROM_TYPE x) { \
|
||||
return x; \
|
||||
}
|
||||
|
||||
#define CONVERT_VECTORIZE(FROM_TYPE, TO_TYPE, SUFFIX) \
|
||||
_CLC_OVERLOAD _CLC_DEF TO_TYPE##2 convert_##TO_TYPE##2##SUFFIX(FROM_TYPE##2 x) { \
|
||||
return (TO_TYPE##2)(convert_##TO_TYPE##SUFFIX(x.x), convert_##TO_TYPE##SUFFIX(x.y)); \
|
||||
} \
|
||||
\
|
||||
_CLC_OVERLOAD _CLC_DEF TO_TYPE##3 convert_##TO_TYPE##3##SUFFIX(FROM_TYPE##3 x) { \
|
||||
return (TO_TYPE##3)(convert_##TO_TYPE##SUFFIX(x.x), convert_##TO_TYPE##SUFFIX(x.y), convert_##TO_TYPE##SUFFIX(x.z)); \
|
||||
} \
|
||||
\
|
||||
_CLC_OVERLOAD _CLC_DEF TO_TYPE##4 convert_##TO_TYPE##4##SUFFIX(FROM_TYPE##4 x) { \
|
||||
return (TO_TYPE##4)(convert_##TO_TYPE##2##SUFFIX(x.lo), convert_##TO_TYPE##2##SUFFIX(x.hi)); \
|
||||
} \
|
||||
\
|
||||
_CLC_OVERLOAD _CLC_DEF TO_TYPE##8 convert_##TO_TYPE##8##SUFFIX(FROM_TYPE##8 x) { \
|
||||
return (TO_TYPE##8)(convert_##TO_TYPE##4##SUFFIX(x.lo), convert_##TO_TYPE##4##SUFFIX(x.hi)); \
|
||||
} \
|
||||
\
|
||||
_CLC_OVERLOAD _CLC_DEF TO_TYPE##16 convert_##TO_TYPE##16##SUFFIX(FROM_TYPE##16 x) { \
|
||||
return (TO_TYPE##16)(convert_##TO_TYPE##8##SUFFIX(x.lo), convert_##TO_TYPE##8##SUFFIX(x.hi)); \
|
||||
}
|
||||
|
||||
CONVERT_ID(long, char, )
|
||||
CONVERT_ID(ulong, uchar, )
|
||||
CONVERT_ID(long, short, )
|
||||
CONVERT_ID(ulong, ushort, )
|
||||
CONVERT_ID(long, int, )
|
||||
CONVERT_ID(ulong, uint, )
|
||||
CONVERT_ID(long, long, )
|
||||
CONVERT_ID(ulong, ulong, )
|
||||
#ifdef cl_khr_fp64
|
||||
CONVERT_ID(double, float, )
|
||||
CONVERT_ID(double, double, )
|
||||
#else
|
||||
CONVERT_ID(float, float, )
|
||||
#endif
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF char convert_char_sat(long l) {
|
||||
return l > 127 ? 127 : l < -128 ? -128 : l;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF uchar convert_uchar_sat(ulong l) {
|
||||
return l > 255U ? 255U : l;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF short convert_short_sat(long l) {
|
||||
return l > 32767 ? 32767 : l < -32768 ? -32768 : l;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF ushort convert_ushort_sat(ulong l) {
|
||||
return l > 65535U ? 65535U : l;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF int convert_int_sat(long l) {
|
||||
return l > ((1L<<31)-1) ? ((1L<<31L)-1) : l < -(1L<<31) ? -(1L<<31) : l;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF uint convert_uint_sat(ulong l) {
|
||||
return l > ((1UL<<32)-1) ? ((1UL<<32)-1) : l;
|
||||
}
|
||||
|
||||
CONVERT_ID(long, long, _sat)
|
||||
CONVERT_ID(ulong, ulong, _sat)
|
||||
#ifdef cl_khr_fp64
|
||||
CONVERT_ID(double, float, _sat)
|
||||
CONVERT_ID(double, double, _sat)
|
||||
#else
|
||||
CONVERT_ID(float, float, _sat)
|
||||
#endif
|
||||
|
||||
#define CONVERT_VECTORIZE_FROM1(FROM_TYPE, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, char, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, uchar, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, int, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, uint, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, short, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, ushort, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, long, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, ulong, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, float, SUFFIX)
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#define CONVERT_VECTORIZE_FROM(FROM_TYPE, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM1(FROM_TYPE, SUFFIX) \
|
||||
CONVERT_VECTORIZE(FROM_TYPE, double, SUFFIX)
|
||||
#else
|
||||
#define CONVERT_VECTORIZE_FROM(FROM_TYPE, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM1(FROM_TYPE, SUFFIX)
|
||||
#endif
|
||||
|
||||
#define CONVERT_VECTORIZE_TO1(SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(char, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(uchar, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(int, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(uint, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(short, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(ushort, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(long, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(ulong, SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(float, SUFFIX)
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#define CONVERT_VECTORIZE_TO(SUFFIX) \
|
||||
CONVERT_VECTORIZE_TO1(SUFFIX) \
|
||||
CONVERT_VECTORIZE_FROM(double, SUFFIX)
|
||||
#else
|
||||
#define CONVERT_VECTORIZE_TO(SUFFIX) \
|
||||
CONVERT_VECTORIZE_TO1(SUFFIX)
|
||||
#endif
|
||||
|
||||
CONVERT_VECTORIZE_TO()
|
||||
CONVERT_VECTORIZE_TO(_sat)
|
||||
@@ -1,11 +0,0 @@
|
||||
#include <clc/clc.h>
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float3 cross(float3 p0, float3 p1) {
|
||||
return (float3)(p0.y*p1.z - p0.z*p1.y, p0.z*p1.x - p0.x*p1.z,
|
||||
p0.x*p1.y - p0.y*p1.x);
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float4 cross(float4 p0, float4 p1) {
|
||||
return (float4)(p0.y*p1.z - p0.z*p1.y, p0.z*p1.x - p0.x*p1.z,
|
||||
p0.x*p1.y - p0.y*p1.x, 0.f);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#include <clc/clc.h>
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float dot(float p0, float p1) {
|
||||
return p0*p1;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float dot(float2 p0, float2 p1) {
|
||||
return p0.x*p1.x + p0.y*p1.y;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float dot(float3 p0, float3 p1) {
|
||||
return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float dot(float4 p0, float4 p1) {
|
||||
return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z + p0.w*p1.w;
|
||||
}
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF double dot(double p0, double p1) {
|
||||
return p0*p1;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF double dot(double2 p0, double2 p1) {
|
||||
return p0.x*p1.x + p0.y*p1.y;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF double dot(double3 p0, double3 p1) {
|
||||
return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z;
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF double dot(double4 p0, double4 p1) {
|
||||
return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z + p0.w*p1.w;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,8 +0,0 @@
|
||||
#include <clc/clc.h>
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
#endif
|
||||
|
||||
#define BODY "length.inc"
|
||||
#include <clc/geometric/floatn.inc>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user